diff options
author | Gabriel Millaire <millaire.gabriel@gmail.com> | 2009-09-30 05:57:53 +0800 |
---|---|---|
committer | Gabriel Millaire <gabriel.millaire@collabora.co.uk> | 2009-10-01 02:14:10 +0800 |
commit | d7cd12a662172eca0276c8bbe13fc1257e0d0609 (patch) | |
tree | f0839dc666e7fb70ce9a1421243ae3d2990748ee | |
parent | 3f4adb1dc22d89c35b56ea5fa99a5976cfc101bb (diff) | |
download | gsoc2013-empathy-d7cd12a662172eca0276c8bbe13fc1257e0d0609.tar gsoc2013-empathy-d7cd12a662172eca0276c8bbe13fc1257e0d0609.tar.gz gsoc2013-empathy-d7cd12a662172eca0276c8bbe13fc1257e0d0609.tar.bz2 gsoc2013-empathy-d7cd12a662172eca0276c8bbe13fc1257e0d0609.tar.lz gsoc2013-empathy-d7cd12a662172eca0276c8bbe13fc1257e0d0609.tar.xz gsoc2013-empathy-d7cd12a662172eca0276c8bbe13fc1257e0d0609.tar.zst gsoc2013-empathy-d7cd12a662172eca0276c8bbe13fc1257e0d0609.zip |
Fix after review
- Early return if no selection
- Now uses a for-loop with gtk_text_iter_equal
- Renamed flag_return to ignore_newlines, same meaning
- Improvement to string_append
-rw-r--r-- | libempathy-gtk/empathy-chat-text-view.c | 59 | ||||
-rw-r--r-- | libempathy-gtk/empathy-theme-boxes.c | 8 |
2 files changed, 33 insertions, 34 deletions
diff --git a/libempathy-gtk/empathy-chat-text-view.c b/libempathy-gtk/empathy-chat-text-view.c index 2e83cdfb8..9df2e35d9 100644 --- a/libempathy-gtk/empathy-chat-text-view.c +++ b/libempathy-gtk/empathy-chat-text-view.c @@ -1166,7 +1166,7 @@ chat_text_view_copy_clipboard (EmpathyChatView *view) GtkTextChildAnchor *anchor = NULL; GString *str; GList *list; - gboolean flag_return = FALSE; + gboolean ignore_newlines = FALSE; str = g_string_new (""); @@ -1175,43 +1175,42 @@ chat_text_view_copy_clipboard (EmpathyChatView *view) buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); - if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end)) { - iter = start; - while ((c = gtk_text_iter_get_char (&iter)) != 0 && - !gtk_text_iter_equal (&iter, &end)) { - if (c == 0xFFFC) { - flag_return = FALSE; - if ((pixbuf = gtk_text_iter_get_pixbuf (&iter))) { - gchar *text; - text = g_object_get_data (G_OBJECT(pixbuf), - "smiley_str"); + if (!gtk_text_buffer_get_selection_bounds (buffer, &start, &end)) + return; + + for (iter = start; !gtk_text_iter_equal (&iter, &end); gtk_text_iter_forward_char (&iter)) { + c = gtk_text_iter_get_char (&iter); + if (c == 0xFFFC) { + ignore_newlines = FALSE; + if ((pixbuf = gtk_text_iter_get_pixbuf (&iter))) { + gchar *text; + text = g_object_get_data (G_OBJECT(pixbuf), + "smiley_str"); + if (text) + str = g_string_append (str, text); + } else if ((anchor = gtk_text_iter_get_child_anchor (&iter))) { + gchar *text; + list = gtk_text_child_anchor_get_widgets (anchor); + if (list) { + text = g_object_get_data (G_OBJECT(list->data), + "str_obj"); if (text) str = g_string_append (str, text); - } else if ((anchor = gtk_text_iter_get_child_anchor (&iter))) { - gchar *text; - list = gtk_text_child_anchor_get_widgets (anchor); - if (list) { - text = g_object_get_data (G_OBJECT(list->data), - "str_obj"); - if (text) - str = g_string_append (str, text); - } - g_list_free (list); - } - } else if (c == '\n') { - if (!flag_return) { - flag_return = TRUE; - str = g_string_append_unichar (str, c); } - } else { - flag_return = FALSE; + g_list_free (list); + } + } else if (c == '\n') { + if (!ignore_newlines) { + ignore_newlines = TRUE; str = g_string_append_unichar (str, c); } - gtk_text_iter_forward_char (&iter); + } else { + ignore_newlines = FALSE; + str = g_string_append_unichar (str, c); } } - gtk_clipboard_set_text (clipboard, g_string_free (str, FALSE), -1); + gtk_clipboard_set_text (clipboard, g_string_free (str, FALSE), str->len); } static void diff --git a/libempathy-gtk/empathy-theme-boxes.c b/libempathy-gtk/empathy-theme-boxes.c index 0c989ba11..3d8b8ae7d 100644 --- a/libempathy-gtk/empathy-theme-boxes.c +++ b/libempathy-gtk/empathy-theme-boxes.c @@ -270,10 +270,10 @@ theme_boxes_maybe_append_header (EmpathyThemeBoxes *theme, NULL); str_obj = g_string_new ("\n- "); - str_obj = g_string_append (str_obj, name); - str_obj = g_string_append (str_obj, ", "); - str_obj = g_string_append (str_obj, tmp); - str_obj = g_string_append (str_obj, " -"); + g_string_append (str_obj, name); + g_string_append (str_obj, ", "); + g_string_append (str_obj, tmp); + g_string_append (str_obj, " -"); g_free (tmp); g_free (str); |