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