summaryrefslogtreecommitdiff
path: root/gtk/gtkentry.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2013-08-18 10:45:24 -0400
committerMatthias Clasen <mclasen@redhat.com>2013-08-18 13:46:48 -0400
commit624ec0fb7d5329261dd0c4a991c7889a70c61535 (patch)
tree4d4e31aaf825e5c9965c5f92b3c9a3b8327ba2c0 /gtk/gtkentry.c
parent8d7bab7d7b902e54f27d7dbe26bca9e21eb45787 (diff)
downloadgtk+-624ec0fb7d5329261dd0c4a991c7889a70c61535.tar.gz
Add a style class for context menus
Attached widgets inherit from the style of the widget they are attached to. This can sometimes have unintended consequences, like a context menu in the main view of gedit inheriting the font that is configured for documents, or the context menu of the preview in the font chooser coming up with humongous font size. To fix this problem, we introduce a context menu style class and use it for all menus that are used like that. The theme can then set a font for this style class. https://bugzilla.gnome.org/show_bug.cgi?id=697127
Diffstat (limited to 'gtk/gtkentry.c')
-rw-r--r--gtk/gtkentry.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 7df6538976..76bb87409d 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -9225,60 +9225,61 @@ popup_targets_received (GtkClipboard *clipboard,
{
DisplayMode mode;
gboolean clipboard_contains_text;
+ GtkWidget *menu;
GtkWidget *menuitem;
clipboard_contains_text = gtk_selection_data_targets_include_text (data);
if (info_entry_priv->popup_menu)
gtk_widget_destroy (info_entry_priv->popup_menu);
- info_entry_priv->popup_menu = gtk_menu_new ();
+ info_entry_priv->popup_menu = menu = gtk_menu_new ();
+ gtk_style_context_add_class (gtk_widget_get_style_context (menu),
+ GTK_STYLE_CLASS_CONTEXT_MENU);
- gtk_menu_attach_to_widget (GTK_MENU (info_entry_priv->popup_menu),
- GTK_WIDGET (entry),
- popup_menu_detach);
+ gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (entry), popup_menu_detach);
mode = gtk_entry_get_display_mode (entry);
- append_action_signal (entry, info_entry_priv->popup_menu, _("Cu_t"), "cut-clipboard",
+ append_action_signal (entry, menu, _("Cu_t"), "cut-clipboard",
info_entry_priv->editable && mode == DISPLAY_NORMAL &&
info_entry_priv->current_pos != info_entry_priv->selection_bound);
- append_action_signal (entry, info_entry_priv->popup_menu, _("_Copy"), "copy-clipboard",
+ append_action_signal (entry, menu, _("_Copy"), "copy-clipboard",
mode == DISPLAY_NORMAL &&
info_entry_priv->current_pos != info_entry_priv->selection_bound);
- append_action_signal (entry, info_entry_priv->popup_menu, _("_Paste"), "paste-clipboard",
+ append_action_signal (entry, menu, _("_Paste"), "paste-clipboard",
info_entry_priv->editable && clipboard_contains_text);
menuitem = gtk_menu_item_new_with_mnemonic (_("_Delete"));
gtk_widget_set_sensitive (menuitem, info_entry_priv->editable && info_entry_priv->current_pos != info_entry_priv->selection_bound);
g_signal_connect_swapped (menuitem, "activate",
- G_CALLBACK (gtk_entry_delete_cb), entry);
+ G_CALLBACK (gtk_entry_delete_cb), entry);
gtk_widget_show (menuitem);
- gtk_menu_shell_append (GTK_MENU_SHELL (info_entry_priv->popup_menu), menuitem);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
menuitem = gtk_separator_menu_item_new ();
gtk_widget_show (menuitem);
- gtk_menu_shell_append (GTK_MENU_SHELL (info_entry_priv->popup_menu), menuitem);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
menuitem = gtk_menu_item_new_with_mnemonic (_("Select _All"));
gtk_widget_set_sensitive (menuitem, gtk_entry_buffer_get_length (info_entry_priv->buffer) > 0);
g_signal_connect_swapped (menuitem, "activate",
- G_CALLBACK (gtk_entry_select_all), entry);
+ G_CALLBACK (gtk_entry_select_all), entry);
gtk_widget_show (menuitem);
- gtk_menu_shell_append (GTK_MENU_SHELL (info_entry_priv->popup_menu), menuitem);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- g_signal_emit (entry, signals[POPULATE_POPUP], 0, info_entry_priv->popup_menu);
+ g_signal_emit (entry, signals[POPULATE_POPUP], 0, menu);
if (info->device)
- gtk_menu_popup_for_device (GTK_MENU (info_entry_priv->popup_menu),
- info->device, NULL, NULL, NULL, NULL, NULL,
- info->button, info->time);
+ gtk_menu_popup_for_device (GTK_MENU (menu),
+ info->device, NULL, NULL, NULL, NULL, NULL,
+ info->button, info->time);
else
{
- gtk_menu_popup (GTK_MENU (info_entry_priv->popup_menu), NULL, NULL,
- popup_position_func, entry,
- 0, gtk_get_current_event_time ());
- gtk_menu_shell_select_first (GTK_MENU_SHELL (info_entry_priv->popup_menu), FALSE);
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
+ popup_position_func, entry,
+ 0, gtk_get_current_event_time ());
+ gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
}
}