diff plugins/docklet/docklet-x11.c @ 10268:d082b2a71ee7

[gaim-migrate @ 11414] Added an optional docklet ui op for positioning the GtkMenu that we pop up on right-click. I haven't touched the Windows part of this, but the Linux part aligns it appropriately with the icon so that it drops down in a cleaner way, much like nearly every other polished applet. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Fri, 26 Nov 2004 05:21:58 +0000
parents 4a15962c344a
children ec140184437b
line wrap: on
line diff
--- a/plugins/docklet/docklet-x11.c	Fri Nov 26 03:52:00 2004 +0000
+++ b/plugins/docklet/docklet-x11.c	Fri Nov 26 05:21:58 2004 +0000
@@ -124,6 +124,31 @@
 }
 
 static void
+docklet_x11_position_menu(GtkMenu *menu, int *x, int *y, gboolean *push_in,
+						  gpointer user_data)
+{
+	GtkWidget *widget = GTK_WIDGET(docklet);
+	GtkRequisition req;
+	gint menu_xpos, menu_ypos;
+
+	gtk_widget_size_request(GTK_WIDGET(menu), &req);
+	gdk_window_get_origin(widget->window, &menu_xpos, &menu_ypos);
+
+	menu_xpos += widget->allocation.x;
+	menu_ypos += widget->allocation.y;
+
+	if (menu_ypos > gdk_screen_get_height(gtk_widget_get_screen(widget)) / 2)
+		menu_ypos -= req.height;
+	else
+		menu_ypos += widget->allocation.height;
+
+	*x = menu_xpos;
+	*y = menu_ypos;
+
+	*push_in = TRUE;
+}
+
+static void
 docklet_x11_destroy()
 {
 	docklet_remove(GTK_WIDGET_VISIBLE(docklet));
@@ -181,7 +206,8 @@
 	docklet_x11_create,
 	docklet_x11_destroy,
 	docklet_x11_update_icon,
-	docklet_x11_blank_icon
+	docklet_x11_blank_icon,
+	docklet_x11_position_menu
 };
 
 void