diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2009-04-24 20:46:51 +0800 |
---|---|---|
committer | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2009-04-24 20:51:57 +0800 |
commit | 93d1b6ead8b6bb92c5e6251f75dd7109b51036f5 (patch) | |
tree | 3cf8336b17b22c5965393fef687f17e4d37f5ee5 | |
parent | 7f6ef434116202d103024c41cf280c2d15b81862 (diff) | |
download | gsoc2013-empathy-93d1b6ead8b6bb92c5e6251f75dd7109b51036f5.tar gsoc2013-empathy-93d1b6ead8b6bb92c5e6251f75dd7109b51036f5.tar.gz gsoc2013-empathy-93d1b6ead8b6bb92c5e6251f75dd7109b51036f5.tar.bz2 gsoc2013-empathy-93d1b6ead8b6bb92c5e6251f75dd7109b51036f5.tar.lz gsoc2013-empathy-93d1b6ead8b6bb92c5e6251f75dd7109b51036f5.tar.xz gsoc2013-empathy-93d1b6ead8b6bb92c5e6251f75dd7109b51036f5.tar.zst gsoc2013-empathy-93d1b6ead8b6bb92c5e6251f75dd7109b51036f5.zip |
Add a "Copy" toolbar item to copy text to clipboard.
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r-- | 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 d0cbef9fc..ac88b6aca 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", |