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

Proposed by Sebastian Geiger
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 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>

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
=== modified file 'src/applet-main.c'
--- src/applet-main.c 2016-11-22 11:00:11 +0000
+++ src/applet-main.c 2017-02-26 11:18:09 +0000
@@ -364,6 +364,22 @@
364 return;364 return;
365}365}
366366
367static void
368size_allocate (GtkWidget *widget, GtkAllocation *allocation) {
369 int height = 0;
370 if(GTK_IS_CONTAINER(widget)) {
371 GList *children = gtk_container_get_children(GTK_CONTAINER(widget));
372 GList *l;
373 for (l = children; l != NULL; l = l->next) {
374 GtkAllocation ca;
375 gtk_widget_get_allocation (l->data, &ca);
376 height += ca.height;
377 }
378 }
379 allocation->height = height;
380 gtk_widget_set_allocation(widget, allocation);
381}
382
367static GtkWidget*383static GtkWidget*
368create_menuitem (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)384create_menuitem (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
369{385{
@@ -387,6 +403,7 @@
387 g_signal_connect(G_OBJECT(menuitem), "enter-notify-event", G_CALLBACK(entry_secondary_activated), NULL);403 g_signal_connect(G_OBJECT(menuitem), "enter-notify-event", G_CALLBACK(entry_secondary_activated), NULL);
388 g_signal_connect(G_OBJECT(menuitem), "leave-notify-event", G_CALLBACK(entry_secondary_activated), NULL);404 g_signal_connect(G_OBJECT(menuitem), "leave-notify-event", G_CALLBACK(entry_secondary_activated), NULL);
389 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), NULL);405 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), NULL);
406 g_signal_connect(G_OBJECT(entry->menu), "size-allocate", G_CALLBACK(size_allocate), NULL);
390407
391 if (entry->image != NULL) {408 if (entry->image != NULL) {
392 gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->image), FALSE, FALSE, 1);409 gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->image), FALSE, FALSE, 1);

Subscribers

People subscribed via source and target branches