[empathy: 44/53] Add a "Copy" toolbar item to copy text to clipboard.
- From: Jonny Lamb <jonnylamb src gnome org>
- To: svn-commits-list gnome org
- Subject: [empathy: 44/53] Add a "Copy" toolbar item to copy text to clipboard.
- Date: Thu, 4 Jun 2009 12:18:45 -0400 (EDT)
commit 93d1b6ead8b6bb92c5e6251f75dd7109b51036f5
Author: Jonny Lamb <jonny lamb collabora co uk>
Date: Fri Apr 24 13:46:51 2009 +0100
Add a "Copy" toolbar item to copy text to clipboard.
Signed-off-by: Jonny Lamb <jonny lamb collabora co uk>
---
src/empathy-debug-dialog.c | 73 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 73 insertions(+), 0 deletions(-)
diff --git a/src/empathy-debug-dialog.c b/src/empathy-debug-dialog.c
index d0cbef9..ac88b6a 100644
--- a/src/empathy-debug-dialog.c
+++ b/src/empathy-debug-dialog.c
@@ -798,6 +798,71 @@ debug_dialog_save_clicked_cb (GtkToolButton *tool_button,
gtk_widget_show (file_chooser);
}
+static gboolean
+debug_dialog_copy_model_foreach (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer user_data)
+{
+ gchar **text = (gchar **) user_data;
+ gchar *tmp;
+ gchar *domain, *category, *message, *level_str, *level_upper;
+ gdouble timestamp;
+ gchar *line;
+
+ gtk_tree_model_get (model, iter,
+ COL_DEBUG_TIMESTAMP, ×tamp,
+ COL_DEBUG_DOMAIN, &domain,
+ COL_DEBUG_CATEGORY, &category,
+ COL_DEBUG_LEVEL_STRING, &level_str,
+ COL_DEBUG_MESSAGE, &message,
+ -1);
+
+ level_upper = g_ascii_strup (level_str, -1);
+
+ line = g_strdup_printf ("%s%s%s-%s: %e: %s\n",
+ domain, EMP_STR_EMPTY (category) ? "" : "/",
+ category, level_upper, timestamp, message);
+
+ tmp = g_strconcat (*text, line, NULL);
+
+ g_free (*text);
+ g_free (line);
+ g_free (level_upper);
+ g_free (level_str);
+ g_free (domain);
+ g_free (category);
+ g_free (message);
+
+ *text = tmp;
+
+ return FALSE;
+}
+
+static void
+debug_dialog_copy_clicked_cb (GtkToolButton *tool_button,
+ EmpathyDebugDialog *debug_dialog)
+{
+ EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
+ GtkClipboard *clipboard;
+ gchar *text;
+
+ text = g_strdup ("");
+
+ gtk_tree_model_foreach (priv->store_filter,
+ debug_dialog_copy_model_foreach, &text);
+
+ clipboard = gtk_clipboard_get_for_display (
+ gtk_widget_get_display (GTK_WIDGET (tool_button)),
+ GDK_SELECTION_CLIPBOARD);
+
+ DEBUG ("Copying text to clipboard (length: %u)", strlen (text));
+
+ gtk_clipboard_set_text (clipboard, text, -1);
+
+ g_free (text);
+}
+
static GObject *
debug_dialog_constructor (GType type,
guint n_construct_params,
@@ -861,6 +926,14 @@ debug_dialog_constructor (GType type,
gtk_tool_item_set_is_important (GTK_TOOL_ITEM (item), TRUE);
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+ /* Copy */
+ item = gtk_tool_button_new_from_stock (GTK_STOCK_COPY);
+ g_signal_connect (item, "clicked",
+ G_CALLBACK (debug_dialog_copy_clicked_cb), object);
+ gtk_widget_show (GTK_WIDGET (item));
+ gtk_tool_item_set_is_important (GTK_TOOL_ITEM (item), TRUE);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+
/* Clear */
item = gtk_tool_button_new_from_stock (GTK_STOCK_CLEAR);
g_signal_connect (item, "clicked",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]