[Xfce4-commits] <xfce4-taskmanager:master> Add a menu position function

Mike Massonnet noreply at xfce.org
Sat Jun 19 19:36:04 CEST 2010


Updating branch refs/heads/master
         to 75cc0da25499845a2e76b57c90ceff5c4ae928d6 (commit)
       from d70a49561878f49bb14c020fc2613191aefae486 (commit)

commit 75cc0da25499845a2e76b57c90ceff5c4ae928d6
Author: Mike Massonnet <mmassonnet at xfce.org>
Date:   Fri Jun 18 16:06:44 2010 +0200

    Add a menu position function

 src/process-window.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/process-window.c b/src/process-window.c
index 3d7a258..266a401 100644
--- a/src/process-window.c
+++ b/src/process-window.c
@@ -64,8 +64,8 @@ static void	xtm_process_window_hide				(GtkWidget *widget);
 static void	emit_destroy_signal				(XtmProcessWindow *window);
 static gboolean	emit_delete_event_signal			(XtmProcessWindow *window, GdkEvent *event);
 static void	monitor_update_step_size			(XtmProcessWindow *window);
-static void	show_menu_execute_task				(XtmProcessWindow *window);
-static void	show_menu_preferences				(XtmProcessWindow *window);
+static void	show_menu_execute_task				(XtmProcessWindow *window, GtkButton *button);
+static void	show_menu_preferences				(XtmProcessWindow *window, GtkButton *button);
 static void	show_about_dialog				(XtmProcessWindow *window);
 
 
@@ -214,6 +214,15 @@ monitor_update_step_size (XtmProcessWindow *window)
 	g_object_set (window->priv->mem_monitor, "step-size", refresh_rate / 1000.0, NULL);
 }
 
+static void
+menu_position_func (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, GtkWidget *widget)
+{
+	gdk_window_get_origin (widget->window, x, y);
+	*x += widget->allocation.x;
+	*y += widget->allocation.height;
+	*push_in = TRUE;
+}
+
 #ifdef HAVE_GKSU
 static void
 run_as_root (XtmProcessWindow *window)
@@ -263,7 +272,7 @@ program_exists (gchar *program)
 }
 
 static void
-show_menu_execute_task (XtmProcessWindow *window)
+show_menu_execute_task (XtmProcessWindow *window, GtkButton *button)
 {
 	static GtkWidget *menu = NULL;
 
@@ -304,7 +313,7 @@ show_menu_execute_task (XtmProcessWindow *window)
 		gtk_widget_show_all (menu);
 	}
 
-	gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time ());
+	gtk_menu_popup (GTK_MENU (menu), NULL, NULL, (GtkMenuPositionFunc)menu_position_func, button, 0, gtk_get_current_event_time ());
 }
 
 static void
@@ -378,7 +387,7 @@ menu_preferences_append_item (GtkMenu *menu, gchar *title, gchar *setting_name,
 }
 
 static void
-show_menu_preferences (XtmProcessWindow *window)
+show_menu_preferences (XtmProcessWindow *window, GtkButton *button)
 {
 	static GtkWidget *menu = NULL;
 	GtkWidget *refresh_rate_menu;
@@ -413,7 +422,7 @@ show_menu_preferences (XtmProcessWindow *window)
 	menu_preferences_append_item (GTK_MENU (menu), _("Priority"), "column-priority", window->priv->settings);
 
 	gtk_widget_show_all (menu);
-	gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time ());
+	gtk_menu_popup (GTK_MENU (menu), NULL, NULL, (GtkMenuPositionFunc)menu_position_func, button, 0, gtk_get_current_event_time ());
 }
 
 #if !GTK_CHECK_VERSION(2,18,0)



More information about the Xfce4-commits mailing list