changeset 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 9cafe038c95e
children 59b1fce24f60
files plugins/docklet/docklet-win32.c plugins/docklet/docklet-x11.c plugins/docklet/docklet.c plugins/docklet/docklet.h
diffstat 4 files changed, 33 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/docklet/docklet-win32.c	Fri Nov 26 03:52:00 2004 +0000
+++ b/plugins/docklet/docklet-win32.c	Fri Nov 26 05:21:58 2004 +0000
@@ -219,7 +219,8 @@
 	wgaim_tray_create,
 	wgaim_tray_destroy,
 	wgaim_tray_update_icon,
-        wgaim_tray_blank_icon
+	wgaim_tray_blank_icon,
+	NULL
 };
 
 /* Used by docklet's plugin load func */
--- 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
--- a/plugins/docklet/docklet.c	Fri Nov 26 03:52:00 2004 +0000
+++ b/plugins/docklet/docklet.c	Fri Nov 26 05:21:58 2004 +0000
@@ -231,7 +231,9 @@
 	g_signal_connect(menu, "leave-notify-event", G_CALLBACK(docklet_menu_leave), NULL);
 #endif
 	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,
+				   ui_ops->position_menu,
+				   NULL, 0, gtk_get_current_event_time());
 }
 
 static gboolean
--- a/plugins/docklet/docklet.h	Fri Nov 26 03:52:00 2004 +0000
+++ b/plugins/docklet/docklet.h	Fri Nov 26 05:21:58 2004 +0000
@@ -42,6 +42,7 @@
 	void (*destroy)();
 	void (*update_icon)(enum docklet_status);
 	void (*blank_icon)();
+	GtkMenuPositionFunc position_menu;
 };
 
 /* useful for setting idle callbacks that will be cleaned up */