[gtk+] GtkLabel: Make context menus on links work
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GtkLabel: Make context menus on links work
- Date: Wed, 21 May 2014 14:31:09 +0000 (UTC)
commit 6b26410d389b50c7f4291b0ef8c1f52ea35c0822
Author: Matthias Clasen <mclasen redhat com>
Date: Wed May 21 10:29:17 2014 -0400
GtkLabel: Make context menus on links work
We see an active link when creating the menu, but by the time
the menuitem is activated, we've received a leave notify that
makes the label clear its active link. Instead, give the
menuitems a direct reference to the link that is active when
the menu is created.
Problem pointed out by Tim Baedert
gtk/gtklabel.c | 23 ++++++++++-------------
1 files changed, 10 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 9be8715..0e72265 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -6189,30 +6189,25 @@ popup_position_func (GtkMenu *menu,
}
static void
-open_link_activate_cb (GtkMenuItem *menu_item,
+open_link_activate_cb (GtkMenuItem *menuitem,
GtkLabel *label)
{
GtkLabelLink *link;
- link = gtk_label_get_current_link (label);
-
- if (link)
- emit_activate_link (label, link);
+ link = g_object_get_data (G_OBJECT (menuitem), "link");
+ emit_activate_link (label, link);
}
static void
-copy_link_activate_cb (GtkMenuItem *menu_item,
+copy_link_activate_cb (GtkMenuItem *menuitem,
GtkLabel *label)
{
+ GtkLabelLink *link;
GtkClipboard *clipboard;
- const gchar *uri;
- uri = gtk_label_get_current_uri (label);
- if (uri)
- {
- clipboard = gtk_widget_get_clipboard (GTK_WIDGET (label), GDK_SELECTION_CLIPBOARD);
- gtk_clipboard_set_text (clipboard, uri, -1);
- }
+ link = g_object_get_data (G_OBJECT (menuitem), "link");
+ clipboard = gtk_widget_get_clipboard (GTK_WIDGET (label), GDK_SELECTION_CLIPBOARD);
+ gtk_clipboard_set_text (clipboard, link->uri, -1);
}
static gboolean
@@ -6262,6 +6257,7 @@ gtk_label_do_popup (GtkLabel *label,
{
/* Open Link */
menuitem = gtk_menu_item_new_with_mnemonic (_("_Open Link"));
+ g_object_set_data (G_OBJECT (menuitem), "link", link);
gtk_widget_show (menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
@@ -6270,6 +6266,7 @@ gtk_label_do_popup (GtkLabel *label,
/* Copy Link Address */
menuitem = gtk_menu_item_new_with_mnemonic (_("Copy _Link Address"));
+ g_object_set_data (G_OBJECT (menuitem), "link", link);
gtk_widget_show (menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]