SF.net SVN: geany: [2715] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Thu Jun 19 17:37:35 UTC 2008


Revision: 2715
          http://geany.svn.sourceforge.net/geany/?rev=2715&view=rev
Author:   eht16
Date:     2008-06-19 10:37:26 -0700 (Thu, 19 Jun 2008)

Log Message:
-----------
Add "Copy All" to the popup menu of the Status, Compiler and Messages treeviews to copy all items to the clipboard.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/msgwindow.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-06-19 17:25:40 UTC (rev 2714)
+++ trunk/ChangeLog	2008-06-19 17:37:26 UTC (rev 2715)
@@ -20,6 +20,9 @@
  * src/document.c, src/editor.c, src/editor.h:
    Allow scrolling page by page by holding down the Shift or Alt key
    (closes #1995405).
+ * src/msgwindow.c:
+   Add "Copy All" to the popup menu of the Status, Compiler and Messages
+   treeviews to copy all items to the clipboard.
 
 
 2008-06-18  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/src/msgwindow.c
===================================================================
--- trunk/src/msgwindow.c	2008-06-19 17:25:40 UTC (rev 2714)
+++ trunk/src/msgwindow.c	2008-06-19 17:37:26 UTC (rev 2715)
@@ -412,6 +412,60 @@
 }
 
 
+static void on_compiler_treeview_copy_all_activate(GtkMenuItem *menuitem, gpointer user_data)
+{
+	GtkListStore *store = msgwindow.store_compiler;
+	GtkTreeIter iter;
+	GString *str = g_string_new("");
+	gint str_idx = 1;
+	gboolean valid;
+
+	switch (GPOINTER_TO_INT(user_data))
+	{
+		case MSG_STATUS:
+		store = msgwindow.store_status;
+		str_idx = 0;
+		break;
+
+		case MSG_COMPILER:
+		/* default values */
+		break;
+
+		case MSG_MESSAGE:
+		store = msgwindow.store_msg;
+		str_idx = 3;
+		break;
+	}
+
+	/* walk through the list and copy every line into a string */
+	valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
+	while (valid)
+	{
+		gchar *line;
+
+		gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, str_idx, &line, -1);
+		if (NZV(line))
+		{
+			g_string_append(str, line);
+			g_string_append_c(str, '\n');
+		}
+		g_free(line);
+
+		valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter);
+	}
+
+	/* copy the string into the clipboard */
+	if (str->len > 0)
+	{
+		gtk_clipboard_set_text(
+			gtk_clipboard_get(gdk_atom_intern("CLIPBOARD", FALSE)),
+			str->str,
+			str->len);
+	}
+	g_string_free(str, TRUE);
+}
+
+
 static void
 on_hide_message_window                 (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
@@ -422,7 +476,7 @@
 
 static GtkWidget *create_message_popup_menu(gint type)
 {
-	GtkWidget *message_popup_menu, *clear, *copy;
+	GtkWidget *message_popup_menu, *clear, *copy, *image;
 
 	message_popup_menu = gtk_menu_new();
 
@@ -438,6 +492,15 @@
 	g_signal_connect((gpointer)copy, "activate",
 		G_CALLBACK(on_compiler_treeview_copy_activate), GINT_TO_POINTER(type));
 
+	copy = gtk_image_menu_item_new_with_mnemonic(_("Copy _All"));
+	gtk_widget_show(copy);
+	gtk_container_add(GTK_CONTAINER(message_popup_menu), copy);
+	image = gtk_image_new_from_stock("gtk-copy", GTK_ICON_SIZE_MENU);
+	gtk_widget_show(image);
+	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(copy), image);
+	g_signal_connect((gpointer)copy, "activate",
+		G_CALLBACK(on_compiler_treeview_copy_all_activate), GINT_TO_POINTER(type));
+
 	msgwin_menu_add_common_items(GTK_MENU(message_popup_menu));
 
 	return message_popup_menu;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list