Popup menus in the right position
This commit is contained in:
parent
6b21b02658
commit
f03bfa021f
|
@ -52,6 +52,7 @@ typedef struct _PanelApplet
|
||||||
guint idle;
|
guint idle;
|
||||||
gboolean refresh;
|
gboolean refresh;
|
||||||
time_t refresh_mti;
|
time_t refresh_mti;
|
||||||
|
GtkWidget * widget;
|
||||||
} Main;
|
} Main;
|
||||||
|
|
||||||
typedef struct _MainMenu
|
typedef struct _MainMenu
|
||||||
|
@ -171,7 +172,8 @@ static Main * _main_init(PanelAppletHelper * helper, GtkWidget ** widget)
|
||||||
main);
|
main);
|
||||||
gtk_container_add(GTK_CONTAINER(ret), hbox);
|
gtk_container_add(GTK_CONTAINER(ret), hbox);
|
||||||
gtk_widget_show_all(ret);
|
gtk_widget_show_all(ret);
|
||||||
*widget = ret;
|
main->widget = ret;
|
||||||
|
*widget = main->widget;
|
||||||
return main;
|
return main;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,7 +581,15 @@ static void _clicked_position_menu(GtkMenu * menu, gint * x, gint * y,
|
||||||
gboolean * push_in, gpointer data)
|
gboolean * push_in, gpointer data)
|
||||||
{
|
{
|
||||||
Main * main = data;
|
Main * main = data;
|
||||||
|
GtkAllocation a;
|
||||||
|
|
||||||
|
#if GTK_CHECK_VERSION(2, 18, 0)
|
||||||
|
gtk_widget_get_allocation(main->widget, &a);
|
||||||
|
#else
|
||||||
|
a = main->widget->allocation;
|
||||||
|
#endif
|
||||||
|
*x = a.x;
|
||||||
|
*y = a.y;
|
||||||
main->helper->position_menu(main->helper->panel, menu, x, y, push_in);
|
main->helper->position_menu(main->helper->panel, menu, x, y, push_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,6 +103,7 @@ typedef struct _PanelApplet
|
||||||
ssize_t networks_cur;
|
ssize_t networks_cur;
|
||||||
|
|
||||||
/* widgets */
|
/* widgets */
|
||||||
|
GtkWidget * widget;
|
||||||
GtkWidget * image;
|
GtkWidget * image;
|
||||||
#ifndef EMBEDDED
|
#ifndef EMBEDDED
|
||||||
GtkWidget * label;
|
GtkWidget * label;
|
||||||
|
@ -199,6 +200,7 @@ static WPA * _wpa_init(PanelAppletHelper * helper, GtkWidget ** widget)
|
||||||
gtk_container_add(GTK_CONTAINER(ret), hbox);
|
gtk_container_add(GTK_CONTAINER(ret), hbox);
|
||||||
*widget = ret;
|
*widget = ret;
|
||||||
}
|
}
|
||||||
|
wpa->widget = *widget;
|
||||||
return wpa;
|
return wpa;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -699,7 +701,15 @@ static void _clicked_position_menu(GtkMenu * menu, gint * x, gint * y,
|
||||||
gboolean * push_in, gpointer data)
|
gboolean * push_in, gpointer data)
|
||||||
{
|
{
|
||||||
WPA * wpa = data;
|
WPA * wpa = data;
|
||||||
|
GtkAllocation a;
|
||||||
|
|
||||||
|
#if GTK_CHECK_VERSION(2, 18, 0)
|
||||||
|
gtk_widget_get_allocation(wpa->widget, &a);
|
||||||
|
#else
|
||||||
|
a = wpa->widget->allocation;
|
||||||
|
#endif
|
||||||
|
*x = a.x;
|
||||||
|
*y = a.y;
|
||||||
wpa->helper->position_menu(wpa->helper->panel, menu, x, y, push_in);
|
wpa->helper->position_menu(wpa->helper->panel, menu, x, y, push_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -248,15 +248,16 @@ static void _panel_helper_position_menu(Panel * panel, GtkMenu * menu, gint * x,
|
||||||
#endif
|
#endif
|
||||||
if(req.height <= 0)
|
if(req.height <= 0)
|
||||||
return;
|
return;
|
||||||
*x = (req.width < panel->root_width - PANEL_BORDER_WIDTH)
|
|
||||||
? PANEL_BORDER_WIDTH : 0;
|
|
||||||
if(position == PANEL_POSITION_TOP)
|
if(position == PANEL_POSITION_TOP)
|
||||||
*y = panel_window_get_height(panel->top);
|
*y = panel_window_get_height(panel->top);
|
||||||
else if(position == PANEL_POSITION_BOTTOM)
|
else if(position == PANEL_POSITION_BOTTOM)
|
||||||
*y = panel->root_height
|
*y = panel->root_height
|
||||||
- panel_window_get_height(panel->bottom) - req.height;
|
- panel_window_get_height(panel->bottom) - req.height;
|
||||||
else /* XXX generic */
|
else if(position == PANEL_POSITION_LEFT)
|
||||||
*y = panel->root_height - req.height;
|
*x = panel_window_get_width(panel->left);
|
||||||
|
else if(position == PANEL_POSITION_RIGHT)
|
||||||
|
*x = panel->root_width
|
||||||
|
- panel_window_get_width(panel->right) - req.width;
|
||||||
*push_in = TRUE;
|
*push_in = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
src/panel.c
14
src/panel.c
|
@ -69,6 +69,8 @@ struct _Panel
|
||||||
PanelWindow * top;
|
PanelWindow * top;
|
||||||
PanelAppletHelper bottom_helper;
|
PanelAppletHelper bottom_helper;
|
||||||
PanelWindow * bottom;
|
PanelWindow * bottom;
|
||||||
|
PanelWindow * left;
|
||||||
|
PanelWindow * right;
|
||||||
|
|
||||||
GdkScreen * screen;
|
GdkScreen * screen;
|
||||||
GdkWindow * root;
|
GdkWindow * root;
|
||||||
|
@ -192,6 +194,8 @@ Panel * panel_new(PanelPrefs const * prefs)
|
||||||
panel->bottom_helper = panel->top_helper;
|
panel->bottom_helper = panel->top_helper;
|
||||||
panel->bottom_helper.position_menu = _panel_helper_position_menu_bottom;
|
panel->bottom_helper.position_menu = _panel_helper_position_menu_bottom;
|
||||||
panel->bottom = NULL;
|
panel->bottom = NULL;
|
||||||
|
panel->left = NULL;
|
||||||
|
panel->right = NULL;
|
||||||
iconsize = GTK_ICON_SIZE_INVALID;
|
iconsize = GTK_ICON_SIZE_INVALID;
|
||||||
if(panel->prefs.iconsize != NULL)
|
if(panel->prefs.iconsize != NULL)
|
||||||
iconsize = gtk_icon_size_from_name(panel->prefs.iconsize);
|
iconsize = gtk_icon_size_from_name(panel->prefs.iconsize);
|
||||||
|
@ -321,6 +325,12 @@ static GtkIconSize _new_size(Panel * panel, PanelPosition position)
|
||||||
case PANEL_POSITION_TOP:
|
case PANEL_POSITION_TOP:
|
||||||
variable = "top_size";
|
variable = "top_size";
|
||||||
break;
|
break;
|
||||||
|
case PANEL_POSITION_LEFT:
|
||||||
|
variable = "left_size";
|
||||||
|
break;
|
||||||
|
case PANEL_POSITION_RIGHT:
|
||||||
|
variable = "right_size";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if(variable != NULL)
|
if(variable != NULL)
|
||||||
p = config_get(panel->config, NULL, variable);
|
p = config_get(panel->config, NULL, variable);
|
||||||
|
@ -446,6 +456,10 @@ void panel_delete(Panel * panel)
|
||||||
panel_window_delete(panel->top);
|
panel_window_delete(panel->top);
|
||||||
if(panel->bottom != NULL)
|
if(panel->bottom != NULL)
|
||||||
panel_window_delete(panel->bottom);
|
panel_window_delete(panel->bottom);
|
||||||
|
if(panel->left != NULL)
|
||||||
|
panel_window_delete(panel->left);
|
||||||
|
if(panel->right != NULL)
|
||||||
|
panel_window_delete(panel->right);
|
||||||
if(panel->config != NULL)
|
if(panel->config != NULL)
|
||||||
config_delete(panel->config);
|
config_delete(panel->config);
|
||||||
object_delete(panel);
|
object_delete(panel);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
/* Copyright (c) 2009-2012 Pierre Pronchery <khorben@defora.org> */
|
/* Copyright (c) 2009-2013 Pierre Pronchery <khorben@defora.org> */
|
||||||
/* This file is part of DeforaOS Desktop Panel */
|
/* This file is part of DeforaOS Desktop Panel */
|
||||||
/* This program is free software: you can redistribute it and/or modify
|
/* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -27,7 +27,9 @@
|
||||||
typedef enum _PanelPosition
|
typedef enum _PanelPosition
|
||||||
{
|
{
|
||||||
PANEL_POSITION_BOTTOM = 0x1,
|
PANEL_POSITION_BOTTOM = 0x1,
|
||||||
PANEL_POSITION_TOP = 0x2
|
PANEL_POSITION_TOP = 0x2,
|
||||||
|
PANEL_POSITION_LEFT = 0x4,
|
||||||
|
PANEL_POSITION_RIGHT = 0x8
|
||||||
} PanelPosition;
|
} PanelPosition;
|
||||||
# define PANEL_POSITION_DEFAULT PANEL_POSITION_BOTTOM
|
# define PANEL_POSITION_DEFAULT PANEL_POSITION_BOTTOM
|
||||||
|
|
||||||
|
|
10
src/window.c
10
src/window.c
|
@ -199,6 +199,16 @@ void panel_window_get_size(PanelWindow * panel, gint * width, gint * height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* panel_window_get_width */
|
||||||
|
int panel_window_get_width(PanelWindow * panel)
|
||||||
|
{
|
||||||
|
gint width;
|
||||||
|
|
||||||
|
gtk_window_get_size(panel, &width, NULL);
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* panel_window_set_accept_focus */
|
/* panel_window_set_accept_focus */
|
||||||
void panel_window_set_accept_focus(PanelWindow * panel, gboolean accept)
|
void panel_window_set_accept_focus(PanelWindow * panel, gboolean accept)
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,6 +47,7 @@ void panel_window_delete(PanelWindow * panel);
|
||||||
int panel_window_get_height(PanelWindow * panel);
|
int panel_window_get_height(PanelWindow * panel);
|
||||||
void panel_window_get_position(PanelWindow * panel, gint * x, gint * y);
|
void panel_window_get_position(PanelWindow * panel, gint * x, gint * y);
|
||||||
void panel_window_get_size(PanelWindow * panel, gint * width, gint * height);
|
void panel_window_get_size(PanelWindow * panel, gint * width, gint * height);
|
||||||
|
int panel_window_get_width(PanelWindow * panel);
|
||||||
|
|
||||||
void panel_window_set_accept_focus(PanelWindow * panel, gboolean accept);
|
void panel_window_set_accept_focus(PanelWindow * panel, gboolean accept);
|
||||||
void panel_window_set_keep_above(PanelWindow * panel, gboolean keep);
|
void panel_window_set_keep_above(PanelWindow * panel, gboolean keep);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user