# HG changeset patch # User Christian Hammond # Date 1101446518 0 # Node ID d082b2a71ee78e7bfbcdb8c035b813f4376d4805 # Parent 9cafe038c95ecdc6173a7616d94bd7b5b2a44902 [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 diff -r 9cafe038c95e -r d082b2a71ee7 plugins/docklet/docklet-win32.c --- 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 */ diff -r 9cafe038c95e -r d082b2a71ee7 plugins/docklet/docklet-x11.c --- 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 diff -r 9cafe038c95e -r d082b2a71ee7 plugins/docklet/docklet.c --- 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 diff -r 9cafe038c95e -r d082b2a71ee7 plugins/docklet/docklet.h --- 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 */