817d11
This is a backport of https://github.com/emacs-mirror/emacs/commit/3f4c6d52d345999938bc2d4a53246af4c61ef176
817d11
with a part of https://github.com/emacs-mirror/emacs/commit/5a1d858bbc5410916d764e7f9c62b4e405fab592 (everything
817d11
related to (struct x_output).toolbar_is_packed).
817d11
817d11
Resolves: #1477745
817d11
817d11
diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el
817d11
index 4cbcf767c0..a7e695da2a 100644
817d11
--- a/lisp/term/x-win.el
817d11
+++ b/lisp/term/x-win.el
817d11
@@ -1484,47 +1484,47 @@ This returns an error if any Emacs frames are X frames."
817d11
   (mapcar (lambda (arg)
817d11
 	    (cons (purecopy (car arg)) (purecopy (cdr arg))))
817d11
   '(
817d11
-    ("etc/images/new" . "gtk-new")
817d11
-    ("etc/images/open" . "gtk-open")
817d11
+    ("etc/images/new" . ("document-new" "gtk-new"))
817d11
+    ("etc/images/open" . ("document-open" "gtk-open"))
817d11
     ("etc/images/diropen" . "n:system-file-manager")
817d11
-    ("etc/images/close" . "gtk-close")
817d11
-    ("etc/images/save" . "gtk-save")
817d11
-    ("etc/images/saveas" . "gtk-save-as")
817d11
-    ("etc/images/undo" . "gtk-undo")
817d11
-    ("etc/images/cut" . "gtk-cut")
817d11
-    ("etc/images/copy" . "gtk-copy")
817d11
-    ("etc/images/paste" . "gtk-paste")
817d11
-    ("etc/images/search" . "gtk-find")
817d11
-    ("etc/images/print" . "gtk-print")
817d11
-    ("etc/images/preferences" . "gtk-preferences")
817d11
-    ("etc/images/help" . "gtk-help")
817d11
-    ("etc/images/left-arrow" . "gtk-go-back")
817d11
-    ("etc/images/right-arrow" . "gtk-go-forward")
817d11
-    ("etc/images/home" . "gtk-home")
817d11
-    ("etc/images/jump-to" . "gtk-jump-to")
817d11
+    ("etc/images/close" . ("window-close" "gtk-close"))
817d11
+    ("etc/images/save" . ("document-save" "gtk-save"))
817d11
+    ("etc/images/saveas" . ("document-save-as" "gtk-save-as"))
817d11
+    ("etc/images/undo" . ("edit-undo" "gtk-undo"))
817d11
+    ("etc/images/cut" . ("edit-cut" "gtk-cut"))
817d11
+    ("etc/images/copy" . ("edit-copy" "gtk-copy"))
817d11
+    ("etc/images/paste" . ("edit-paste" "gtk-paste"))
817d11
+    ("etc/images/search" . ("edit-find" "gtk-find"))
817d11
+    ("etc/images/print" . ("document-print" "gtk-print"))
817d11
+    ("etc/images/preferences" . ("preferences-system" "gtk-preferences"))
817d11
+    ("etc/images/help" . ("help-browser" "gtk-help"))
817d11
+    ("etc/images/left-arrow" . ("go-previous" "gtk-go-back"))
817d11
+    ("etc/images/right-arrow" . ("go-next" "gtk-go-forward"))
817d11
+    ("etc/images/home" . ("go-home" "gtk-home"))
817d11
+    ("etc/images/jump-to" . ("go-jump" "gtk-jump-to"))
817d11
     ("etc/images/index" . "gtk-index")
817d11
-    ("etc/images/search" . "gtk-find")
817d11
-    ("etc/images/exit" . "gtk-quit")
817d11
+    ("etc/images/exit" . ("application-exit" "gtk-quit"))
817d11
     ("etc/images/cancel" . "gtk-cancel")
817d11
-    ("etc/images/info" . "gtk-info")
817d11
+    ("etc/images/info" . ("dialog-information" "gtk-info"))
817d11
     ("etc/images/bookmark_add" . "n:bookmark_add")
817d11
     ;; Used in Gnus and/or MH-E:
817d11
     ("etc/images/attach" . "gtk-attach")
817d11
     ("etc/images/connect" . "gtk-connect")
817d11
     ("etc/images/contact" . "gtk-contact")
817d11
-    ("etc/images/delete" . "gtk-delete")
817d11
-    ("etc/images/describe" . "gtk-properties")
817d11
+    ("etc/images/delete" . ("edit-delete" "gtk-delete"))
817d11
+    ("etc/images/describe" . ("document-properties" "gtk-properties"))
817d11
     ("etc/images/disconnect" . "gtk-disconnect")
817d11
     ;; ("etc/images/exit" . "gtk-exit")
817d11
     ("etc/images/lock-broken" . "gtk-lock_broken")
817d11
     ("etc/images/lock-ok" . "gtk-lock_ok")
817d11
     ("etc/images/lock" . "gtk-lock")
817d11
     ("etc/images/next-page" . "gtk-next-page")
817d11
-    ("etc/images/refresh" . "gtk-refresh")
817d11
-    ("etc/images/sort-ascending" . "gtk-sort-ascending")
817d11
+    ("etc/images/refresh" . ("view-refresh" "gtk-refresh"))
817d11
+    ("etc/images/sort-ascending" . ("view-sort-ascending" "gtk-sort-ascending"))
817d11
     ("etc/images/sort-column-ascending" . "gtk-sort-column-ascending")
817d11
     ("etc/images/sort-criteria" . "gtk-sort-criteria")
817d11
-    ("etc/images/sort-descending" . "gtk-sort-descending")
817d11
+    ("etc/images/sort-descending" . ("view-sort-descending"
817d11
+				     "gtk-sort-descending"))
817d11
     ("etc/images/sort-row-ascending" . "gtk-sort-row-ascending")
817d11
     ("images/gnus/toggle-subscription" . "gtk-task-recurring")
817d11
     ("images/mail/compose" . "gtk-mail-compose")
817d11
@@ -1541,8 +1541,8 @@ This returns an error if any Emacs frames are X frames."
817d11
     ("images/mail/spam" . "gtk-spam")
817d11
     ;; Used for GDB Graphical Interface
817d11
     ("images/gud/break" . "gtk-no")
817d11
-    ("images/gud/recstart" . "gtk-media-record")
817d11
-    ("images/gud/recstop" . "gtk-media-stop")
817d11
+    ("images/gud/recstart" . ("media-record" "gtk-media-record"))
817d11
+    ("images/gud/recstop" . ("media-playback-stop" "gtk-media-stop"))
817d11
     ;; No themed versions available:
817d11
     ;; mail/preview (combining stock_mail and stock_zoom)
817d11
     ;; mail/save    (combining stock_mail, stock_save and stock_convert)
817d11
@@ -1551,9 +1551,12 @@ This returns an error if any Emacs frames are X frames."
817d11
 Emacs must be compiled with the Gtk+ toolkit for this to have any effect.
817d11
 A value that begins with n: denotes a named icon instead of a stock icon."
817d11
   :version "22.2"
817d11
-  :type '(choice (repeat (choice symbol
817d11
-				 (cons (string :tag "Emacs icon")
817d11
-				       (string :tag "Stock/named")))))
817d11
+  :type '(choice (repeat
817d11
+		  (choice symbol
817d11
+			  (cons (string :tag "Emacs icon")
817d11
+				(choice (group (string :tag "Named")
817d11
+					       (string :tag "Stock"))
817d11
+					(string :tag "Stock/named"))))))
817d11
   :group 'x)
817d11
 
817d11
 (defcustom icon-map-list '(x-gtk-stock-map)
817d11
diff --git a/src/xmenu.c b/src/xmenu.c
817d11
index e3f1a17fbc..eb783fe507 100644
817d11
--- a/src/xmenu.c
817d11
+++ b/src/xmenu.c
817d11
@@ -733,12 +733,6 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
817d11
       f->output_data.x->saved_menu_event->type = 0;
817d11
     }
817d11
 
817d11
-#ifdef USE_GTK
817d11
-  /* If we have detached menus, we must update deep so detached menus
817d11
-     also gets updated.  */
817d11
-  deep_p = deep_p || xg_have_tear_offs ();
817d11
-#endif
817d11
-
817d11
   if (deep_p)
817d11
     {
817d11
       /* Make a widget-value tree representing the entire menu trees.  */
817d11
diff --git a/src/xterm.h b/src/xterm.h
817d11
index ed611f1d19..0842195f33 100644
817d11
--- a/src/xterm.h
817d11
+++ b/src/xterm.h
817d11
@@ -474,12 +474,11 @@ struct x_output
817d11
   GtkWidget *menubar_widget;
817d11
   /* The tool bar in this frame  */
817d11
   GtkWidget *toolbar_widget;
817d11
-  /* The handle box that makes the tool bar detachable.  */
817d11
-  GtkWidget *handlebox_widget;
817d11
   /* Non-zero if the tool bar is detached.  */
817d11
   int toolbar_detached;
817d11
   /* Non-zero if tool bar is packed into the hbox widget (i.e. vertical).  */
817d11
   int toolbar_in_hbox;
817d11
+  int toolbar_is_packed;
817d11
 
817d11
   /* The last size hints set.  */
817d11
   GdkGeometry size_hints;
817d11
diff --git a/src/gtkutil.c b/src/gtkutil.c
817d11
--- a/src/gtkutil.c
817d11
+++ b/src/gtkutil.c
817d11
@@ -2428,45 +2428,6 @@ make_menu_item (const char *utf8_label,
817d11
   return w;
817d11
 }
817d11
 
817d11
-static int xg_detached_menus;
817d11
-
817d11
-/* Return true if there are detached menus.  */
817d11
-
817d11
-bool
817d11
-xg_have_tear_offs (void)
817d11
-{
817d11
-  return xg_detached_menus > 0;
817d11
-}
817d11
-
817d11
-/* Callback invoked when a detached menu window is removed.  Here we
817d11
-   decrease the xg_detached_menus count.
817d11
-   WIDGET is the top level window that is removed (the parent of the menu).
817d11
-   CLIENT_DATA is not used.  */
817d11
-
817d11
-static void
817d11
-tearoff_remove (GtkWidget *widget, gpointer client_data)
817d11
-{
817d11
-  if (xg_detached_menus > 0) --xg_detached_menus;
817d11
-}
817d11
-
817d11
-/* Callback invoked when a menu is detached.  It increases the
817d11
-   xg_detached_menus count.
817d11
-   WIDGET is the GtkTearoffMenuItem.
817d11
-   CLIENT_DATA is not used.  */
817d11
-
817d11
-static void
817d11
-tearoff_activate (GtkWidget *widget, gpointer client_data)
817d11
-{
817d11
-  GtkWidget *menu = gtk_widget_get_parent (widget);
817d11
-  if (gtk_menu_get_tearoff_state (GTK_MENU (menu)))
817d11
-    {
817d11
-      ++xg_detached_menus;
817d11
-      g_signal_connect (G_OBJECT (gtk_widget_get_toplevel (widget)),
817d11
-                        "destroy",
817d11
-                        G_CALLBACK (tearoff_remove), 0);
817d11
-    }
817d11
-}
817d11
-
817d11
 
817d11
 /* Create a menu item widget, and connect the callbacks.
817d11
    ITEM describes the menu item.
817d11
@@ -2538,8 +2499,6 @@ xg_create_one_menuitem (widget_value *it
817d11
    HIGHLIGHT_CB is the callback to call when entering/leaving menu items.
817d11
    If POP_UP_P, create a popup menu.
817d11
    If MENU_BAR_P, create a menu bar.
817d11
-   If ADD_TEAROFF_P, add a tearoff menu item.  Ignored if MENU_BAR_P.
817d11
-   TOPMENU is the topmost GtkWidget that others shall be placed under.
817d11
    It may be NULL, in that case we create the appropriate widget
817d11
    (menu bar or menu item depending on POP_UP_P and MENU_BAR_P)
817d11
    CL_DATA is the callback data we shall use for this menu, or NULL
817d11
@@ -2560,7 +2519,6 @@ create_menus (widget_value *data,
817d11
               GCallback highlight_cb,
817d11
               bool pop_up_p,
817d11
               bool menu_bar_p,
817d11
-              bool add_tearoff_p,
817d11
               GtkWidget *topmenu,
817d11
               xg_menu_cb_data *cl_data,
817d11
               const char *name)
817d11
@@ -2611,15 +2569,6 @@ create_menus (widget_value *data,
817d11
                           "selection-done", deactivate_cb, 0);
817d11
     }
817d11
 
817d11
-  if (! menu_bar_p && add_tearoff_p)
817d11
-    {
817d11
-      GtkWidget *tearoff = gtk_tearoff_menu_item_new ();
817d11
-      gtk_menu_shell_append (GTK_MENU_SHELL (wmenu), tearoff);
817d11
-
817d11
-      g_signal_connect (G_OBJECT (tearoff), "activate",
817d11
-                        G_CALLBACK (tearoff_activate), 0);
817d11
-    }
817d11
-
817d11
   for (item = data; item; item = item->next)
817d11
     {
817d11
       GtkWidget *w;
817d11
@@ -2633,7 +2582,6 @@ create_menus (widget_value *data,
817d11
           group = NULL;
817d11
           utf8_label = get_utf8_string (item->name);
817d11
 
817d11
-          gtk_menu_set_title (GTK_MENU (wmenu), utf8_label);
817d11
           w = gtk_menu_item_new_with_label (utf8_label);
817d11
           gtk_widget_set_sensitive (w, FALSE);
817d11
           if (utf8_label) g_free (utf8_label);
817d11
@@ -2664,7 +2612,6 @@ create_menus (widget_value *data,
817d11
                                                  highlight_cb,
817d11
                                                  0,
817d11
                                                  0,
817d11
-                                                 add_tearoff_p,
817d11
                                                  0,
817d11
                                                  cl_data,
817d11
                                                  0);
817d11
@@ -2722,7 +2669,6 @@ xg_create_widget (const char *type, cons
817d11
                         highlight_cb,
817d11
                         pop_up_p,
817d11
                         menu_bar_p,
817d11
-                        menu_bar_p,
817d11
                         0,
817d11
                         0,
817d11
                         name);
817d11
@@ -2832,7 +2778,7 @@ xg_update_menubar (GtkWidget *menubar,
817d11
     {
817d11
       /* Item(s) added.  Add all new items in one call.  */
817d11
       create_menus (val, f, select_cb, deactivate_cb, highlight_cb,
817d11
-                    0, 1, 0, menubar, cl_data, 0);
817d11
+                    0, 1, menubar, cl_data, 0);
817d11
 
817d11
       /* All updated.  */
817d11
       val = 0;
817d11
@@ -2909,12 +2855,6 @@ xg_update_menubar (GtkWidget *menubar,
817d11
 
817d11
           gtk_label_set_text (wlabel, utf8_label);
817d11
 
817d11
-          /* If this item has a submenu that has been detached, change
817d11
-             the title in the WM decorations also.  */
817d11
-          if (submenu && gtk_menu_get_tearoff_state (GTK_MENU (submenu)))
817d11
-            /* Set the title of the detached window.  */
817d11
-            gtk_menu_set_title (GTK_MENU (submenu), utf8_label);
817d11
-
817d11
           if (utf8_label) g_free (utf8_label);
817d11
           iter = g_list_next (iter);
817d11
           val = val->next;
817d11
@@ -2941,7 +2881,7 @@ xg_update_menubar (GtkWidget *menubar,
817d11
           GtkWidget *submenu = create_menus (NULL, f,
817d11
                                              select_cb, deactivate_cb,
817d11
                                              highlight_cb,
817d11
-                                             0, 0, 0, 0, cl_data, 0);
817d11
+                                             0, 0, 0, cl_data, 0);
817d11
           gtk_widget_set_name (w, MENU_ITEM_NAME);
817d11
           gtk_menu_shell_insert (GTK_MENU_SHELL (menubar), w, pos);
817d11
           gtk_menu_item_set_submenu (GTK_MENU_ITEM (w), submenu);
817d11
@@ -3141,15 +3081,6 @@ xg_update_submenu (GtkWidget *submenu,
817d11
   {
817d11
     GtkWidget *w = GTK_WIDGET (iter->data);
817d11
 
817d11
-    /* Skip tearoff items, they have no counterpart in val.  */
817d11
-    if (GTK_IS_TEAROFF_MENU_ITEM (w))
817d11
-      {
817d11
-        has_tearoff_p = 1;
817d11
-        iter = g_list_next (iter);
817d11
-        if (iter) w = GTK_WIDGET (iter->data);
817d11
-        else break;
817d11
-      }
817d11
-
817d11
     /* Remember first radio button in a group.  If we get a mismatch in
817d11
        a radio group we must rebuild the whole group so that the connections
817d11
        in GTK becomes correct.  */
817d11
@@ -3237,7 +3168,6 @@ xg_update_submenu (GtkWidget *submenu,
817d11
                              highlight_cb,
817d11
                              0,
817d11
                              0,
817d11
-                             ! has_tearoff_p,
817d11
                              submenu,
817d11
                              cl_data,
817d11
                              0);
817d11
@@ -4026,186 +3956,6 @@ xg_get_tool_bar_widgets (GtkWidget *vb,
817d11
 }
817d11
 
817d11
 
817d11
-/* This callback is called when a tool item should create a proxy item,
817d11
-   such as for the overflow menu.  Also called when the tool bar is detached.
817d11
-   If we don't create a proxy menu item, the detached tool bar will be
817d11
-   blank.  */
817d11
-
817d11
-static gboolean
817d11
-xg_tool_bar_menu_proxy (GtkToolItem *toolitem, gpointer user_data)
817d11
-{
817d11
-  GtkButton *wbutton = GTK_BUTTON (XG_BIN_CHILD (XG_BIN_CHILD (toolitem)));
817d11
-  GtkWidget *vb = XG_BIN_CHILD (wbutton);
817d11
-  GtkWidget *c1;
817d11
-  GtkLabel *wlbl = GTK_LABEL (xg_get_tool_bar_widgets (vb, &c1));
817d11
-  GtkImage *wimage = GTK_IMAGE (c1);
817d11
-  GtkWidget *wmenuitem = gtk_image_menu_item_new_with_label
817d11
-    (wlbl ? gtk_label_get_text (wlbl) : "");
817d11
-  GtkWidget *wmenuimage;
817d11
-
817d11
-
817d11
-  if (gtk_button_get_use_stock (wbutton))
817d11
-    wmenuimage = gtk_image_new_from_stock (gtk_button_get_label (wbutton),
817d11
-                                           GTK_ICON_SIZE_MENU);
817d11
-  else
817d11
-    {
817d11
-      GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (wbutton));
817d11
-      GtkImageType store_type = gtk_image_get_storage_type (wimage);
817d11
-
817d11
-      g_object_set (G_OBJECT (settings), "gtk-menu-images", TRUE, NULL);
817d11
-
817d11
-      if (store_type == GTK_IMAGE_STOCK)
817d11
-        {
817d11
-          gchar *stock_id;
817d11
-          gtk_image_get_stock (wimage, &stock_id, NULL);
817d11
-          wmenuimage = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
817d11
-        }
817d11
-      else if (store_type == GTK_IMAGE_ICON_SET)
817d11
-        {
817d11
-          GtkIconSet *icon_set;
817d11
-          gtk_image_get_icon_set (wimage, &icon_set, NULL);
817d11
-          wmenuimage = gtk_image_new_from_icon_set (icon_set,
817d11
-                                                    GTK_ICON_SIZE_MENU);
817d11
-        }
817d11
-      else if (store_type == GTK_IMAGE_PIXBUF)
817d11
-        {
817d11
-          gint width, height;
817d11
-
817d11
-          if (settings &&
817d11
-              gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU,
817d11
-                                                 &width, &height))
817d11
-            {
817d11
-              GdkPixbuf *src_pixbuf, *dest_pixbuf;
817d11
-
817d11
-              src_pixbuf = gtk_image_get_pixbuf (wimage);
817d11
-              dest_pixbuf = gdk_pixbuf_scale_simple (src_pixbuf, width, height,
817d11
-                                                     GDK_INTERP_BILINEAR);
817d11
-
817d11
-              wmenuimage = gtk_image_new_from_pixbuf (dest_pixbuf);
817d11
-            }
817d11
-          else
817d11
-            {
817d11
-              fprintf (stderr, "internal error: GTK_IMAGE_PIXBUF failed\n");
817d11
-              emacs_abort ();
817d11
-            }
817d11
-        }
817d11
-      else if (store_type == GTK_IMAGE_ICON_NAME)
817d11
-        {
817d11
-          const gchar *icon_name;
817d11
-          GtkIconSize icon_size;
817d11
-
817d11
-          gtk_image_get_icon_name (wimage, &icon_name, &icon_size);
817d11
-          wmenuimage = gtk_image_new_from_icon_name (icon_name,
817d11
-                                                     GTK_ICON_SIZE_MENU);
817d11
-        }
817d11
-      else
817d11
-        {
817d11
-          fprintf (stderr, "internal error: store_type is %d\n", store_type);
817d11
-          emacs_abort ();
817d11
-        }
817d11
-    }
817d11
-  if (wmenuimage)
817d11
-    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (wmenuitem), wmenuimage);
817d11
-
817d11
-  g_signal_connect (G_OBJECT (wmenuitem),
817d11
-                    "activate",
817d11
-                    G_CALLBACK (xg_tool_bar_proxy_callback),
817d11
-                    user_data);
817d11
-
817d11
-
817d11
-  g_object_set_data (G_OBJECT (wmenuitem), XG_TOOL_BAR_PROXY_BUTTON,
817d11
-                     (gpointer) wbutton);
817d11
-  gtk_tool_item_set_proxy_menu_item (toolitem, "Emacs toolbar item", wmenuitem);
817d11
-  gtk_widget_set_sensitive (wmenuitem,
817d11
-                            gtk_widget_get_sensitive (GTK_WIDGET (wbutton)));
817d11
-
817d11
-  /* Use enter/leave notify to show help.  We use the events
817d11
-     rather than the GtkButton specific signals "enter" and
817d11
-     "leave", so we can have only one callback.  The event
817d11
-     will tell us what kind of event it is.  */
817d11
-  g_signal_connect (G_OBJECT (wmenuitem),
817d11
-                    "enter-notify-event",
817d11
-                    G_CALLBACK (xg_tool_bar_proxy_help_callback),
817d11
-                    user_data);
817d11
-  g_signal_connect (G_OBJECT (wmenuitem),
817d11
-                    "leave-notify-event",
817d11
-                    G_CALLBACK (xg_tool_bar_proxy_help_callback),
817d11
-                    user_data);
817d11
-
817d11
-  return TRUE;
817d11
-}
817d11
-
817d11
-/* This callback is called when a tool bar is detached.  We must set
817d11
-   the height of the tool bar to zero when this happens so frame sizes
817d11
-   are correctly calculated.
817d11
-   WBOX is the handle box widget that enables detach/attach of the tool bar.
817d11
-   W is the tool bar widget.
817d11
-   CLIENT_DATA is a pointer to the frame the tool bar belongs to.  */
817d11
-
817d11
-static void
817d11
-xg_tool_bar_detach_callback (GtkHandleBox *wbox,
817d11
-                             GtkWidget *w,
817d11
-                             gpointer client_data)
817d11
-{
817d11
-  FRAME_PTR f = (FRAME_PTR) client_data;
817d11
-
817d11
-  g_object_set (G_OBJECT (w), "show-arrow", !x_gtk_whole_detached_tool_bar,
817d11
-		NULL);
817d11
-
817d11
-  if (f)
817d11
-    {
817d11
-      GtkRequisition req, req2;
817d11
-      FRAME_X_OUTPUT (f)->toolbar_detached = 1;
817d11
-      gtk_widget_get_preferred_size (GTK_WIDGET (wbox), NULL, &req;;
817d11
-      gtk_widget_get_preferred_size (w, NULL, &req2);
817d11
-      req.width -= req2.width;
817d11
-      req.height -= req2.height;
817d11
-      if (FRAME_TOOLBAR_TOP_HEIGHT (f) != 0)
817d11
-        FRAME_TOOLBAR_TOP_HEIGHT (f) = req.height;
817d11
-      else if (FRAME_TOOLBAR_BOTTOM_HEIGHT (f) != 0)
817d11
-        FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = req.height;
817d11
-      else if (FRAME_TOOLBAR_RIGHT_WIDTH (f) != 0)
817d11
-        FRAME_TOOLBAR_RIGHT_WIDTH (f) = req.width;
817d11
-      else if (FRAME_TOOLBAR_LEFT_WIDTH (f) != 0)
817d11
-        FRAME_TOOLBAR_LEFT_WIDTH (f) = req.width;
817d11
-      xg_height_or_width_changed (f);
817d11
-    }
817d11
-}
817d11
-
817d11
-/* This callback is called when a tool bar is reattached.  We must set
817d11
-   the height of the tool bar when this happens so frame sizes
817d11
-   are correctly calculated.
817d11
-   WBOX is the handle box widget that enables detach/attach of the tool bar.
817d11
-   W is the tool bar widget.
817d11
-   CLIENT_DATA is a pointer to the frame the tool bar belongs to.  */
817d11
-
817d11
-static void
817d11
-xg_tool_bar_attach_callback (GtkHandleBox *wbox,
817d11
-                             GtkWidget *w,
817d11
-                             gpointer client_data)
817d11
-{
817d11
-  FRAME_PTR f = (FRAME_PTR) client_data;
817d11
-  g_object_set (G_OBJECT (w), "show-arrow", TRUE, NULL);
817d11
-
817d11
-  if (f)
817d11
-    {
817d11
-      GtkRequisition req, req2;
817d11
-      FRAME_X_OUTPUT (f)->toolbar_detached = 0;
817d11
-      gtk_widget_get_preferred_size (GTK_WIDGET (wbox), NULL, &req;;
817d11
-      gtk_widget_get_preferred_size (w, NULL, &req2);
817d11
-      req.width += req2.width;
817d11
-      req.height += req2.height;
817d11
-      if (FRAME_TOOLBAR_TOP_HEIGHT (f) != 0)
817d11
-        FRAME_TOOLBAR_TOP_HEIGHT (f) = req.height;
817d11
-      else if (FRAME_TOOLBAR_BOTTOM_HEIGHT (f) != 0)
817d11
-        FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = req.height;
817d11
-      else if (FRAME_TOOLBAR_RIGHT_WIDTH (f) != 0)
817d11
-        FRAME_TOOLBAR_RIGHT_WIDTH (f) = req.width;
817d11
-      else if (FRAME_TOOLBAR_LEFT_WIDTH (f) != 0)
817d11
-        FRAME_TOOLBAR_LEFT_WIDTH (f) = req.width;
817d11
-      xg_height_or_width_changed (f);
817d11
-    }
817d11
-}
817d11
 
817d11
 /* This callback is called when the mouse enters or leaves a tool bar item.
817d11
    It is used for displaying and hiding the help text.
817d11
@@ -4298,44 +4048,30 @@ xg_pack_tool_bar (FRAME_PTR f, Lisp_Obje
817d11
                            into_hbox
817d11
                            ? GTK_ORIENTATION_VERTICAL
817d11
                            : GTK_ORIENTATION_HORIZONTAL);
817d11
-  if (!x->handlebox_widget)
817d11
-    {
817d11
-      x->handlebox_widget = gtk_handle_box_new ();
817d11
-      g_signal_connect (G_OBJECT (x->handlebox_widget), "child-detached",
817d11
-                        G_CALLBACK (xg_tool_bar_detach_callback), f);
817d11
-      g_signal_connect (G_OBJECT (x->handlebox_widget), "child-attached",
817d11
-                        G_CALLBACK (xg_tool_bar_attach_callback), f);
817d11
-      gtk_container_add (GTK_CONTAINER (x->handlebox_widget),
817d11
-                         x->toolbar_widget);
817d11
-    }
817d11
-
817d11
   if (into_hbox)
817d11
     {
817d11
-      gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (x->handlebox_widget),
817d11
-                                          GTK_POS_TOP);
817d11
-      gtk_box_pack_start (GTK_BOX (x->hbox_widget), x->handlebox_widget,
817d11
+      gtk_box_pack_start (GTK_BOX (x->hbox_widget), x->toolbar_widget,
817d11
                           FALSE, FALSE, 0);
817d11
 
817d11
       if (EQ (pos, Qleft))
817d11
         gtk_box_reorder_child (GTK_BOX (x->hbox_widget),
817d11
-                               x->handlebox_widget,
817d11
+                               x->toolbar_widget,
817d11
                                0);
817d11
       x->toolbar_in_hbox = 1;
817d11
     }
817d11
   else
817d11
     {
817d11
       bool vbox_pos = x->menubar_widget != 0;
817d11
-      gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (x->handlebox_widget),
817d11
-                                          GTK_POS_LEFT);
817d11
-      gtk_box_pack_start (GTK_BOX (x->vbox_widget), x->handlebox_widget,
817d11
+      gtk_box_pack_start (GTK_BOX (x->vbox_widget), x->toolbar_widget,
817d11
                           FALSE, FALSE, 0);
817d11
 
817d11
       if (EQ (pos, Qtop))
817d11
         gtk_box_reorder_child (GTK_BOX (x->vbox_widget),
817d11
-                               x->handlebox_widget,
817d11
+                               x->toolbar_widget,
817d11
                                vbox_pos);
817d11
       x->toolbar_in_hbox = 0;
817d11
     }
817d11
+  x->toolbar_is_packed = 1;
817d11
 }
817d11
 
817d11
 /* Create a tool bar for frame F.  */
817d11
@@ -4462,10 +4198,6 @@ xg_make_tool_item (FRAME_PTR f,
817d11
       intptr_t ii = i;
817d11
       gpointer gi = (gpointer) ii;
817d11
 
817d11
-      g_signal_connect (G_OBJECT (ti), "create-menu-proxy",
817d11
-                        G_CALLBACK (xg_tool_bar_menu_proxy),
817d11
-                        gi);
817d11
-
817d11
       g_signal_connect (G_OBJECT (wb), "clicked",
817d11
                         G_CALLBACK (xg_tool_bar_callback),
817d11
                         gi);
817d11
@@ -4580,12 +4312,12 @@ xg_update_tool_bar_sizes (FRAME_PTR f)
817d11
   GtkRequisition req;
817d11
   int nl = 0, nr = 0, nt = 0, nb = 0;
817d11
 
817d11
-  gtk_widget_get_preferred_size (GTK_WIDGET (x->handlebox_widget), NULL, &req;;
817d11
+  gtk_widget_get_preferred_size (GTK_WIDGET (x->toolbar_widget), NULL, &req;;
817d11
   if (x->toolbar_in_hbox)
817d11
     {
817d11
       int pos;
817d11
       gtk_container_child_get (GTK_CONTAINER (x->hbox_widget),
817d11
-                               x->handlebox_widget,
817d11
+                               x->toolbar_widget,
817d11
                                "position", &pos, NULL);
817d11
       if (pos == 0) nl = req.width;
817d11
       else nr = req.width;
817d11
@@ -4594,7 +4326,7 @@ xg_update_tool_bar_sizes (FRAME_PTR f)
817d11
     {
817d11
       int pos;
817d11
       gtk_container_child_get (GTK_CONTAINER (x->vbox_widget),
817d11
-                               x->handlebox_widget,
817d11
+                               x->toolbar_widget,
817d11
                                "position", &pos, NULL);
817d11
       if (pos == 0 || (pos == 1 && x->menubar_widget)) nt = req.height;
817d11
       else nb = req.height;
817d11
@@ -4665,7 +4397,6 @@ update_frame_tool_bar (FRAME_PTR f)
817d11
   GtkToolbar *wtoolbar;
817d11
   GtkToolItem *ti;
817d11
   GtkTextDirection dir;
817d11
-  bool pack_tool_bar = x->handlebox_widget == NULL;
817d11
   Lisp_Object style;
817d11
   bool text_image, horiz;
817d11
   struct xg_frame_tb_info *tbinfo;
817d11
@@ -4924,9 +4655,9 @@ update_frame_tool_bar (FRAME_PTR f)
817d11
 
817d11
   if (f->n_tool_bar_items != 0)
817d11
     {
817d11
-      if (pack_tool_bar)
817d11
+      if (! x->toolbar_is_packed)
817d11
         xg_pack_tool_bar (f, f->tool_bar_position);
817d11
-      gtk_widget_show_all (GTK_WIDGET (x->handlebox_widget));
817d11
+      gtk_widget_show_all (GTK_WIDGET (x->toolbar_widget));
817d11
       if (xg_update_tool_bar_sizes (f))
817d11
         xg_height_or_width_changed (f);
817d11
     }
817d11
@@ -4945,24 +4676,21 @@ free_frame_tool_bar (FRAME_PTR f)
817d11
   if (x->toolbar_widget)
817d11
     {
817d11
       struct xg_frame_tb_info *tbinfo;
817d11
-      bool is_packed = x->handlebox_widget != 0;
817d11
       block_input ();
817d11
-      /* We may have created the toolbar_widget in xg_create_tool_bar, but
817d11
-         not the x->handlebox_widget which is created in xg_pack_tool_bar.  */
817d11
-      if (is_packed)
817d11
+      if (x->toolbar_is_packed)
817d11
         {
817d11
           if (x->toolbar_in_hbox)
817d11
             gtk_container_remove (GTK_CONTAINER (x->hbox_widget),
817d11
-                                  x->handlebox_widget);
817d11
+                                  x->toolbar_widget);
817d11
           else
817d11
             gtk_container_remove (GTK_CONTAINER (x->vbox_widget),
817d11
-                                  x->handlebox_widget);
817d11
+                                  x->toolbar_widget);
817d11
         }
817d11
       else
817d11
         gtk_widget_destroy (x->toolbar_widget);
817d11
 
817d11
       x->toolbar_widget = 0;
817d11
-      x->handlebox_widget = 0;
817d11
+      x->toolbar_is_packed = 0;
817d11
       FRAME_TOOLBAR_TOP_HEIGHT (f) = FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = 0;
817d11
       FRAME_TOOLBAR_LEFT_WIDTH (f) = FRAME_TOOLBAR_RIGHT_WIDTH (f) = 0;
817d11
 
817d11
@@ -4987,19 +4715,22 @@ xg_change_toolbar_position (FRAME_PTR f,
817d11
 {
817d11
   struct x_output *x = f->output_data.x;
817d11
 
817d11
-  if (! x->toolbar_widget || ! x->handlebox_widget)
817d11
+  if (! x->toolbar_widget)
817d11
     return;
817d11
 
817d11
   block_input ();
817d11
-  g_object_ref (x->handlebox_widget);
817d11
-  if (x->toolbar_in_hbox)
817d11
-    gtk_container_remove (GTK_CONTAINER (x->hbox_widget),
817d11
-                          x->handlebox_widget);
817d11
-  else
817d11
-    gtk_container_remove (GTK_CONTAINER (x->vbox_widget),
817d11
-                          x->handlebox_widget);
817d11
+  g_object_ref (x->toolbar_widget);
817d11
+  if (x->toolbar_is_packed)
817d11
+    {
817d11
+      if (x->toolbar_in_hbox)
817d11
+        gtk_container_remove (GTK_CONTAINER (x->hbox_widget),
817d11
+                              x->toolbar_widget);
817d11
+      else
817d11
+        gtk_container_remove (GTK_CONTAINER (x->vbox_widget),
817d11
+                              x->toolbar_widget);
817d11
+    }
817d11
   xg_pack_tool_bar (f, pos);
817d11
-  g_object_unref (x->handlebox_widget);
817d11
+  g_object_unref (x->toolbar_widget);
817d11
   if (xg_update_tool_bar_sizes (f))
817d11
     xg_height_or_width_changed (f);
817d11
 
817d11
@@ -5025,7 +4756,6 @@ xg_initialize (void)
817d11
 
817d11
   gdpy_def = NULL;
817d11
   xg_ignore_gtk_scrollbar = 0;
817d11
-  xg_detached_menus = 0;
817d11
   xg_menu_cb_list.prev = xg_menu_cb_list.next =
817d11
     xg_menu_item_cb_list.prev = xg_menu_item_cb_list.next = 0;
817d11