bug-buddy r2584 - in trunk: . src



Author: cosimoc
Date: Fri Aug  1 08:07:12 2008
New Revision: 2584
URL: http://svn.gnome.org/viewvc/bug-buddy?rev=2584&view=rev

Log:
2008-08-01  Cosimo Cecchi  <cosimoc gnome org>

	* src/bug-buddy.c: (copy_link_item_activated_cb),
	(build_link_menu), (link_button_press_event_cb), (bug_sent):
	Add a right click menu item "Copy Link Address" on the GtkLinkButton
	to allow copying of the bug URL (#540174).


Modified:
   trunk/ChangeLog
   trunk/src/bug-buddy.c

Modified: trunk/src/bug-buddy.c
==============================================================================
--- trunk/src/bug-buddy.c	(original)
+++ trunk/src/bug-buddy.c	Fri Aug  1 08:07:12 2008
@@ -342,6 +342,55 @@
 }
 
 static void
+copy_link_item_activated_cb (GtkMenuItem *menu_item,
+			     const gchar *link)
+{
+	GtkClipboard *clipboard;
+
+	clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+	gtk_clipboard_set_text (clipboard, link, -1);
+}
+
+static GtkWidget *
+build_link_menu (const gchar *link)
+{
+	GtkWidget *menu;
+	GtkWidget *item;
+	GtkWidget *image;
+
+	menu = gtk_menu_new ();
+	item = gtk_image_menu_item_new_with_mnemonic (_("Copy _Link Address"));
+	image = gtk_image_new_from_stock (GTK_STOCK_COPY, GTK_ICON_SIZE_MENU);
+	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+	gtk_widget_show_all (item);
+	g_signal_connect (item, "activate",
+			  G_CALLBACK (copy_link_item_activated_cb), (char *) link);
+	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+	return menu;
+}
+
+static gboolean
+link_button_press_event_cb (GtkWidget *widget,
+			    GdkEventButton *event,
+			    gpointer data)
+{
+	const gchar *link = gtk_link_button_get_uri (GTK_LINK_BUTTON (widget));
+
+	if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
+		GtkWidget *popup;
+
+		popup = build_link_menu (link);
+		gtk_menu_popup (GTK_MENU (popup), NULL, NULL, NULL, NULL,
+				event->button, event->time);
+
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+static void
 link_callback (GtkLinkButton *button, gpointer user_data)
 {
 	const gchar *link = gtk_link_button_get_uri (button);
@@ -526,6 +575,8 @@
 		/* create a clickable link to the bug report */
 		urlbutton = gtk_link_button_new (text);
 		g_signal_connect (G_OBJECT (urlbutton), "clicked", G_CALLBACK (link_callback), NULL);
+		g_signal_connect (G_OBJECT (urlbutton), "button-press-event",
+				  G_CALLBACK (link_button_press_event_cb), NULL);
 		gtk_box_pack_end (GTK_BOX (main_vbox), urlbutton, FALSE, FALSE, 0);
 
 		gtk_widget_show (urlbutton);



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