emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r116002: Make GTK+ menus work correctly with the Uni


From: Daniel Colascione
Subject: [Emacs-diffs] trunk r116002: Make GTK+ menus work correctly with the Unity global menu
Date: Mon, 13 Jan 2014 01:56:59 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 116002 [merge]
revision-id: address@hidden
parent: address@hidden
parent: address@hidden
committer: Daniel Colascione <address@hidden>
branch nick: trunk
timestamp: Sun 2014-01-12 17:50:46 -0800
message:
  Make GTK+ menus work correctly with the Unity global menu
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/gtkutil.c                  gtkutil.c-20091113204419-o5vbwnq5f7feedwu-2527
  src/gtkutil.h                  gtkutil.h-20091113204419-o5vbwnq5f7feedwu-2528
  src/xmenu.c                    xmenu.c-20091113204419-o5vbwnq5f7feedwu-161
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2014-01-12 23:23:55 +0000
+++ b/src/ChangeLog     2014-01-13 01:50:46 +0000
@@ -1,3 +1,19 @@
+2014-01-13  Daniel Colascione  <address@hidden>
+
+       Fix menu item updating in the presence of the Unity global menu
+       GTK+ module.
+
+       * gtkutil.h (xg_have_tear_offs): Add frame parameter
+       * gtkutil.c (xg_have_tear_offs): Count the global menu as a
+       tear-off.
+       (xg_update_menubar,xg_update_menu_item): Call g_object_notify when
+       updating menus; explain why.
+       (xg_update_frame_menubar): Remove the 23px hack: I can't repro the
+       problem it's supposed to solve and it interferes with detecting
+       the presence of a global menu.
+       * xmenu.c (set_frame_menubar): Call xg_have_tear_offs with new
+       parameter.
+
 2014-01-11  K. Handa  <address@hidden>
 
        * composite.c (composition_update_it): Fix indexing of

=== modified file 'src/gtkutil.c'
--- a/src/gtkutil.c     2014-01-01 07:43:34 +0000
+++ b/src/gtkutil.c     2014-01-13 01:40:35 +0000
@@ -2414,9 +2414,12 @@
 /* Return true if there are detached menus.  */
 
 bool
-xg_have_tear_offs (void)
+xg_have_tear_offs (struct frame *f)
 {
-  return xg_detached_menus > 0;
+  /* If the frame's menubar height is zero, the menu bar is probably
+     being redirected outside the window to some kind of global menu;
+     this situation is the moral equivalent of a tear-off.  */
+  return FRAME_MENUBAR_HEIGHT (f) == 0 || xg_detached_menus > 0;
 }
 
 /* Callback invoked when a detached menu window is removed.  Here we
@@ -2449,9 +2452,9 @@
 }
 #else /* ! HAVE_GTK_TEAROFF_MENU_ITEM_NEW */
 bool
-xg_have_tear_offs (void)
+xg_have_tear_offs (struct frame *f)
 {
-  return false;
+  return FRAME_MENUBAR_HEIGHT (f) == 0;
 }
 #endif /* ! HAVE_GTK_TEAROFF_MENU_ITEM_NEW */
 
@@ -2897,7 +2900,13 @@
           char *utf8_label = get_utf8_string (val->name);
           GtkWidget *submenu = gtk_menu_item_get_submenu (witem);
 
+          /* GTK menu items don't notice when their labels have been
+             changed from underneath them, so we have to explicitly
+             use g_object_notify to tell listeners (e.g., a GMenuModel
+             bridge that might be loaded) that the item's label has
+             changed.  */
           gtk_label_set_text (wlabel, utf8_label);
+          g_object_notify (G_OBJECT (witem), "label");
 
 #ifdef HAVE_GTK_TEAROFF_MENU_ITEM_NEW
           /* If this item has a submenu that has been detached, change
@@ -2934,6 +2943,7 @@
                                              select_cb, deactivate_cb,
                                              highlight_cb,
                                              0, 0, 0, 0, cl_data, 0);
+
           gtk_widget_set_name (w, MENU_ITEM_NAME);
           gtk_menu_shell_insert (GTK_MENU_SHELL (menubar), w, pos);
           gtk_menu_item_set_submenu (GTK_MENU_ITEM (w), submenu);
@@ -2993,6 +3003,7 @@
   const char *old_label = 0;
   const char *old_key = 0;
   xg_menu_item_cb_data *cb_data;
+  bool label_changed = false;
 
   wchild = XG_BIN_CHILD (w);
   utf8_label = get_utf8_string (val->name);
@@ -3037,15 +3048,20 @@
         }
     }
 
-
   if (wkey) old_key = gtk_label_get_label (wkey);
   if (wlbl) old_label = gtk_label_get_label (wlbl);
 
   if (wkey && utf8_key && (! old_key || strcmp (utf8_key, old_key) != 0))
-    gtk_label_set_text (wkey, utf8_key);
+    {
+      label_changed = true;
+      gtk_label_set_text (wkey, utf8_key);
+    }
 
   if (! old_label || strcmp (utf8_label, old_label) != 0)
-    gtk_label_set_text (wlbl, utf8_label);
+    {
+      label_changed = true;
+      gtk_label_set_text (wlbl, utf8_label);
+    }
 
   if (utf8_key) g_free (utf8_key);
   if (utf8_label) g_free (utf8_label);
@@ -3077,6 +3093,9 @@
           cb_data->select_id = 0;
         }
     }
+
+  if (label_changed) /* See comment in xg_update_menubar.  */
+    g_object_notify (G_OBJECT (w), "label");
 }
 
 /* Update the toggle menu item W so it corresponds to VAL.  */
@@ -3359,11 +3378,6 @@
   gtk_widget_show_all (x->menubar_widget);
   gtk_widget_get_preferred_size (x->menubar_widget, NULL, &req);
 
-  /* If menu bar doesn't know its height yet, cheat a little so the frame
-     doesn't jump so much when resized later in menubar_map_cb.  */
-  if (req.height == 0)
-    req.height = 23;
-
   if (FRAME_MENUBAR_HEIGHT (f) != req.height)
     {
       FRAME_MENUBAR_HEIGHT (f) = req.height;

=== modified file 'src/gtkutil.h'
--- a/src/gtkutil.h     2014-01-01 07:43:34 +0000
+++ b/src/gtkutil.h     2014-01-13 01:40:35 +0000
@@ -107,7 +107,7 @@
 
 extern bool xg_event_is_for_menubar (struct frame *, const XEvent *);
 
-extern bool xg_have_tear_offs (void);
+extern bool xg_have_tear_offs (struct frame *f);
 
 extern ptrdiff_t xg_get_scroll_id_for_window (Display *dpy, Window wid);
 

=== modified file 'src/xmenu.c'
--- a/src/xmenu.c       2014-01-01 07:43:34 +0000
+++ b/src/xmenu.c       2014-01-13 01:40:35 +0000
@@ -796,7 +796,7 @@
 #ifdef USE_GTK
   /* If we have detached menus, we must update deep so detached menus
      also gets updated.  */
-  deep_p = deep_p || xg_have_tear_offs ();
+  deep_p = deep_p || xg_have_tear_offs (f);
 #endif
 
   if (deep_p)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]