/* Functions for creating and updating GTK widgets.
-Copyright (C) 2003-2013 Free Software Foundation, Inc.
+Copyright (C) 2003-2014 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#define remove_submenu(w) gtk_menu_item_remove_submenu ((w))
#endif
+#ifdef HAVE_FREETYPE
#if GTK_CHECK_VERSION (3, 2, 0)
#define USE_NEW_GTK_FONT_CHOOSER 1
#else
#define gtk_font_chooser_set_font(x, y) \
gtk_font_selection_dialog_set_font_name (x, y)
#endif
+#endif /* HAVE_FREETYPE */
#ifndef HAVE_GTK3
#ifdef USE_GTK_TOOLTIP
hint_flags = f->output_data.x->hint_flags;
hint_flags |= GDK_HINT_RESIZE_INC | GDK_HINT_MIN_SIZE;
- size_hints.width_inc = FRAME_COLUMN_WIDTH (f);
- size_hints.height_inc = FRAME_LINE_HEIGHT (f);
+ size_hints.width_inc = frame_resize_pixelwise ? 1 : FRAME_COLUMN_WIDTH (f);
+ size_hints.height_inc = frame_resize_pixelwise ? 1 : FRAME_LINE_HEIGHT (f);
hint_flags |= GDK_HINT_BASE_SIZE;
/* Use one row/col here so base_height/width does not become zero.
size_hints.base_width = base_width;
size_hints.base_height = base_height;
- size_hints.min_width = base_width + min_cols * size_hints.width_inc;
- size_hints.min_height = base_height + min_rows * size_hints.height_inc;
+ size_hints.min_width = base_width + min_cols * FRAME_COLUMN_WIDTH (f);;
+ size_hints.min_height = base_height + min_rows * FRAME_LINE_HEIGHT (f);
/* These currently have a one to one mapping with the X values, but I
don't think we should rely on that. */
font = Ffont_spec (8, args);
pango_font_description_free (desc);
- xfree (x_last_font_name);
- x_last_font_name = xstrdup (name);
+ dupstring (&x_last_font_name, name);
}
#else /* Use old font selector, which just returns the font name. */
/* 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
}
#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 */
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
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);
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);
}
}
-
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);
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. */
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;