Merge lp:~lanoxx/indicator-applet/menuitemfix into lp:indicator-applet

Proposed by Sebastian Geiger on 2017-02-26
Status: Needs review
Proposed branch: lp:~lanoxx/indicator-applet/menuitemfix
Merge into: lp:indicator-applet
Diff against target: 34 lines (+17/-0)
1 file modified
src/applet-main.c (+17/-0)
To merge this branch: bzr merge lp:~lanoxx/indicator-applet/menuitemfix
Reviewer Review Type Date Requested Status
Indicator Applet Developers 2017-02-26 Pending
Review via email: mp+318320@code.launchpad.net

Description of the change

This will make sure that indicator menus have the correct size.

To post a comment you must log in.

Unmerged revisions

430. By Sebastian Geiger <sebastiangeiger@mars> on 2014-05-13

Workaround: Fix menus having wrong size

 * This patch is needed when menus are
   in a panel that appears at the bottom
   of the screen. It recomputes the size
   of the menu each time a menu item
   is added to the menu.
 * If menu items are added or removed
   from the panel then it happens
   that the panel gets a wrong
   size allocated. This is caused by
   a bug in GTK+ see [1].
 * This patch is a workaround for the bug
   as its unlikely the bug will get fixed
   in Gtk in the near future.

[1] https://bugzilla.gnome.org/show_bug.cgi?id=726030

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/applet-main.c'
2--- src/applet-main.c 2016-11-22 11:00:11 +0000
3+++ src/applet-main.c 2017-02-26 11:18:09 +0000
4@@ -364,6 +364,22 @@
5 return;
6 }
7
8+static void
9+size_allocate (GtkWidget *widget, GtkAllocation *allocation) {
10+ int height = 0;
11+ if(GTK_IS_CONTAINER(widget)) {
12+ GList *children = gtk_container_get_children(GTK_CONTAINER(widget));
13+ GList *l;
14+ for (l = children; l != NULL; l = l->next) {
15+ GtkAllocation ca;
16+ gtk_widget_get_allocation (l->data, &ca);
17+ height += ca.height;
18+ }
19+ }
20+ allocation->height = height;
21+ gtk_widget_set_allocation(widget, allocation);
22+}
23+
24 static GtkWidget*
25 create_menuitem (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
26 {
27@@ -387,6 +403,7 @@
28 g_signal_connect(G_OBJECT(menuitem), "enter-notify-event", G_CALLBACK(entry_secondary_activated), NULL);
29 g_signal_connect(G_OBJECT(menuitem), "leave-notify-event", G_CALLBACK(entry_secondary_activated), NULL);
30 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), NULL);
31+ g_signal_connect(G_OBJECT(entry->menu), "size-allocate", G_CALLBACK(size_allocate), NULL);
32
33 if (entry->image != NULL) {
34 gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->image), FALSE, FALSE, 1);

Subscribers

People subscribed via source and target branches