Complete fix for #2093 "key 'C' mention harcoded in string"
authorRicardo Mones <ricardo@mones.org>
Sun, 21 Apr 2013 09:45:51 +0000 (11:45 +0200)
committerRicardo Mones <ricardo@mones.org>
Sun, 21 Apr 2013 09:45:51 +0000 (11:45 +0200)
Refactor code to obtain shortcut to a function and don't
mention the shortcut in the cases it doesn't exist.

src/mimeview.c

index 7a1a5ca6d22eed2fd9ef86f847ee58974cbf30bb..8c328d02496bccdc95f05fdee180d470d93f07ba 100644 (file)
@@ -1004,6 +1004,17 @@ void mimeview_clear(MimeView *mimeview)
        mimeview_change_view_type(mimeview, MIMEVIEW_TEXT);
 }
 
+gchar * get_message_check_signature_shortcut(MessageView *messageview) {
+       GtkUIManager *ui_manager;
+
+       if (messageview->window != NULL)
+                       ui_manager = messageview->ui_manager;
+               else
+                       ui_manager = messageview->mainwin->ui_manager;
+
+       return cm_menu_item_get_shortcut(ui_manager, "Menu/Message/CheckSignature");
+}
+
 static void check_signature_cb(GtkWidget *widget, gpointer user_data);
 static void display_full_info_cb(GtkWidget *widget, gpointer user_data);
 
@@ -1059,25 +1070,26 @@ static void update_signature_noticeview(MimeView *mimeview, MimeInfo *mimeinfo,
                break;
        }
        if (mycode == SIGNATURE_UNCHECKED) {
-               GtkUIManager *ui_manager;
                gchar *tmp = privacy_mimeinfo_sig_info_short(mimeinfo);
-               gchar *shortcut;
+               gchar *shortcut = get_message_check_signature_shortcut(mimeview->messageview);
 
-               if (mimeview->messageview->window != NULL)
-                       ui_manager = mimeview->messageview->ui_manager;
+               if (*shortcut == '\0')
+                       text = g_strdup_printf(_("%s Click the icon to check it."), tmp);
                else
-                       ui_manager = mimeview->messageview->mainwin->ui_manager;
-
-               shortcut = cm_menu_item_get_shortcut(ui_manager, "Menu/Message/CheckSignature");
-
-               text = g_strdup_printf(_("%s Click the icon or hit '%s' to check it."),
-                       tmp, shortcut);
+                       text = g_strdup_printf(_("%s Click the icon or hit '%s' to check it."),
+                               tmp, shortcut);
                g_free(tmp);
                g_free(shortcut);
        } else if (mycode != SIGNATURE_CHECK_TIMEOUT) {
                text = privacy_mimeinfo_sig_info_short(mimeinfo);
        } else if (mycode == SIGNATURE_CHECK_TIMEOUT) {
-               text = g_strdup(_("Timeout checking the signature. Click the icon or hit 'C' to try again."));
+               gchar *shortcut = get_message_check_signature_shortcut(mimeview->messageview);
+
+               if (*shortcut == '\0')
+                       text = g_strdup(_("Timeout checking the signature. Click the icon to try again."));
+               else
+                       text = g_strdup_printf(_("Timeout checking the signature. Click the icon or hit '%s' to try again."), shortcut);
+               g_free(shortcut);
        }
 
        noticeview_set_text(mimeview->siginfoview, text);