* src/modest-ui-actions.c:
authorJose Dapena Paz <jdapena@igalia.com>
Mon, 21 Jul 2008 17:36:18 +0000 (17:36 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Mon, 21 Jul 2008 17:36:18 +0000 (17:36 +0000)
* Disable copying (even from keyboard shortcut) of gtkhtml
  buffer if it's empty (fixes NB#86618).

pmo-trunk-r5081

src/modest-ui-actions.c

index 82a7845..8bae8df 100644 (file)
@@ -3796,9 +3796,16 @@ modest_ui_actions_on_copy (GtkAction *action,
                gtk_clipboard_set_can_store (clipboard, NULL, 0);
                gtk_clipboard_store (clipboard);
        } else if (GTK_IS_HTML (focused_widget)) {
-               gtk_html_copy (GTK_HTML (focused_widget));
-               gtk_clipboard_set_can_store (clipboard, NULL, 0);
-               gtk_clipboard_store (clipboard);
+               const gchar *sel;
+               int len = -1;
+               sel = gtk_html_get_selection_html (GTK_HTML (focused_widget), &len);
+               if ((sel == NULL) || (sel[0] == '\0')) {
+                       copied = FALSE;
+               } else {
+                       gtk_html_copy (GTK_HTML (focused_widget));
+                       gtk_clipboard_set_can_store (clipboard, NULL, 0);
+                       gtk_clipboard_store (clipboard);
+               }
        } else if (GTK_IS_TEXT_VIEW (focused_widget)) {
                GtkTextBuffer *buffer;
                buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (focused_widget));