diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-04-16 17:56:45 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-05-10 15:48:07 +0800 |
commit | 60e7f9f68bbcb287e8df3aac35a0ee5b5cf01b94 (patch) | |
tree | 74fe16ba812001bac80c33904287403cd7f5984f | |
parent | bb58c649539336ca1081ffff0fef14f3b632be36 (diff) | |
download | gsoc2013-empathy-60e7f9f68bbcb287e8df3aac35a0ee5b5cf01b94.tar gsoc2013-empathy-60e7f9f68bbcb287e8df3aac35a0ee5b5cf01b94.tar.gz gsoc2013-empathy-60e7f9f68bbcb287e8df3aac35a0ee5b5cf01b94.tar.bz2 gsoc2013-empathy-60e7f9f68bbcb287e8df3aac35a0ee5b5cf01b94.tar.lz gsoc2013-empathy-60e7f9f68bbcb287e8df3aac35a0ee5b5cf01b94.tar.xz gsoc2013-empathy-60e7f9f68bbcb287e8df3aac35a0ee5b5cf01b94.tar.zst gsoc2013-empathy-60e7f9f68bbcb287e8df3aac35a0ee5b5cf01b94.zip |
merge store_filter_foreach () and copy_model_foreach ()
They were basically the same function. The only difference was that one was
assuming to receive an empty string during the first iteration while the other
was coping with it being NULL.
https://bugzilla.gnome.org/show_bug.cgi?id=674182
-rw-r--r-- | src/empathy-debug-window.c | 75 |
1 files changed, 14 insertions, 61 deletions
diff --git a/src/empathy-debug-window.c b/src/empathy-debug-window.c index f64ebabdd..677a9ed26 100644 --- a/src/empathy-debug-window.c +++ b/src/empathy-debug-window.c @@ -1494,15 +1494,19 @@ debug_window_time_formatter (GtkTreeViewColumn *tree_column, } static gboolean -debug_window_store_filter_foreach (GtkTreeModel *model, +debug_window_copy_model_foreach (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data) { - gchar **debug_data = (gchar **)user_data; + gchar **text = (gchar **) user_data; + gchar *tmp; gchar *domain, *category, *message, *level_str, *level_upper; gdouble timestamp; - gchar *line, *time_str, *tmp; + gchar *line, *time_str; + + if (*text == NULL) + *text = g_strdup (""); gtk_tree_model_get (model, iter, COL_DEBUG_TIMESTAMP, ×tamp, @@ -1522,15 +1526,9 @@ debug_window_store_filter_foreach (GtkTreeModel *model, g_free (time_str); - /* Compact all message lines in the out parameter debug_data */ - if (!tp_str_empty (*debug_data)) - tmp = g_strconcat (*debug_data, line, NULL); - else - tmp = g_strdup (line); - - g_free (*debug_data); - *debug_data = tmp; + tmp = g_strconcat (*text, line, NULL); + g_free (*text); g_free (line); g_free (level_upper); g_free (level_str); @@ -1538,6 +1536,8 @@ debug_window_store_filter_foreach (GtkTreeModel *model, g_free (category); g_free (message); + *text = tmp; + return FALSE; } @@ -1572,7 +1572,7 @@ debug_window_save_file_chooser_response_cb (GtkDialog *dialog, } gtk_tree_model_foreach (self->priv->store_filter, - debug_window_store_filter_foreach, &debug_data); + debug_window_copy_model_foreach, &debug_data); g_output_stream_write (G_OUTPUT_STREAM (output_stream), debug_data, strlen (debug_data), NULL, &file_write_error); @@ -1766,65 +1766,18 @@ debug_window_send_to_pastebin_cb (GtkToolButton *tool_button, DEBUG ("Preparing debug data for sending to pastebin."); gtk_tree_model_foreach (self->priv->store_filter, - debug_window_store_filter_foreach, &debug_data); + debug_window_copy_model_foreach, &debug_data); debug_window_send_to_pastebin (self, debug_data); g_free (debug_data); } -static gboolean -debug_window_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, *time_str; - - 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); - - time_str = debug_window_format_timestamp (timestamp); - - line = g_strdup_printf ("%s%s%s-%s: %s: %s\n", - domain, EMP_STR_EMPTY (category) ? "" : "/", - category, level_upper, time_str, message); - - g_free (time_str); - - 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_window_copy_clicked_cb (GtkToolButton *tool_button, EmpathyDebugWindow *self) { GtkClipboard *clipboard; - gchar *text; - - text = g_strdup (""); + gchar *text = NULL; gtk_tree_model_foreach (self->priv->store_filter, debug_window_copy_model_foreach, &text); |