[epiphany/tmp-gnome-2-32: 17/31] ephy-embed: clean up confirm_action_from_mime



commit 57550be8b10adccf22ede3ea9f0fcab8b0a9bb1b
Author: Diego Escalante Urrelo <descalante igalia com>
Date:   Tue Jun 8 00:14:53 2010 -0500

    ephy-embed: clean up confirm_action_from_mime
    
    Avoid duplication of code.
    
    Bug #621050

 embed/ephy-embed.c |   71 ++++++++++++++++++++++++++-------------------------
 1 files changed, 36 insertions(+), 35 deletions(-)
---
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index 8f2c473..a6f4ff7 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -690,6 +690,9 @@ confirm_action_from_mime (WebKitWebView *web_view,
   int default_response;
   WebKitNetworkResponse *response;
   SoupMessage *message;
+  GtkMessageType mtype;
+  char *title;
+  char *secondary;
 
   parent_window = gtk_widget_get_toplevel (GTK_WIDGET(web_view));
   if (!gtk_widget_is_toplevel (parent_window))
@@ -732,46 +735,44 @@ confirm_action_from_mime (WebKitWebView *web_view,
   suggested_filename = webkit_download_get_suggested_filename (download);
 
   if (mime_permission != EPHY_MIME_PERMISSION_SAFE && helper_app) {
-    dialog = gtk_message_dialog_new (GTK_WINDOW (parent_window),
-                                     GTK_DIALOG_DESTROY_WITH_PARENT,
-                                     GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE,
-                                     _("Download this potentially unsafe file?"));
-
-    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                                              /* translators: First %s is the file type description,
-                                                 Second %s is the file name */
-                                              _("File Type: â??%sâ??.\n\nIt is unsafe to open â??%sâ?? as "
-                                                "it could potentially damage your documents or "
-                                                "invade your privacy. You can download it instead."),
-                                              mime_description, suggested_filename);
+    title = _("Download this potentially unsafe file?");
+    mtype = GTK_MESSAGE_WARNING;
+    /* translators: First %s is the file type description, second %s is the
+     * file name */
+    secondary = g_strdup_printf (_("File Type: â??%sâ??.\n\nIt is unsafe to open "
+                                   "â??%sâ?? as it could potentially damage your "
+                                   "documents or invade your privacy. "
+                                   "You can download it instead."),
+                                 mime_description, suggested_filename);
+
     action_label = STOCK_DOWNLOAD;
   } else if (action == DOWNLOAD_ACTION_OPEN && helper_app) {
-    dialog = gtk_message_dialog_new (GTK_WINDOW (parent_window),
-                                     GTK_DIALOG_DESTROY_WITH_PARENT,
-                                     GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
-                                     _("Open this file?"));
-
-    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                                              /* translators: First %s is the file type description,
-                                                 Second %s is the file name,
-                                                 Third %s is the application used to open the file */
-                                              _("File Type: â??%sâ??.\n\nYou can open â??%sâ?? using â??%sâ?? or save it."),
-                                              mime_description, suggested_filename,
-                                              g_app_info_get_name (helper_app));
+    title = _("Open this file?");
+    mtype = GTK_MESSAGE_QUESTION;
+    /* translators: First %s is the file type description, second %s is the
+     * file name, third %s is the application used to open the file */
+    secondary = g_strdup_printf (_("File Type: â??%sâ??.\n\nYou can open â??%sâ?? "
+                                   "using â??%sâ?? or save it."),
+                                 mime_description, suggested_filename,
+                                 g_app_info_get_name (helper_app));
   } else  {
-    dialog = gtk_message_dialog_new (GTK_WINDOW (parent_window),
-                                     GTK_DIALOG_DESTROY_WITH_PARENT,
-                                     GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
-                                     _("Download this file?"));
-
-    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                                              /* translators: First %s is the file type description,
-                                                 Second %s is the file name */
-                                              _("File Type: â??%sâ??.\n\nYou have no application able to open â??%sâ??. "
-                                                "You can download it instead."),
-                                              mime_description, suggested_filename);
+    title = _("Download this file?");
+    mtype = GTK_MESSAGE_QUESTION;
+    /* translators: First %s is the file type description, second %s is the
+     * file name */
+    secondary = g_strdup_printf (_("File Type: â??%sâ??.\n\nYou have no "
+                                   "application able to open â??%sâ??. "
+                                   "You can download it instead."),
+                                 mime_description, suggested_filename);
   }
 
+  dialog = gtk_message_dialog_new (GTK_WINDOW (parent_window),
+                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                   mtype, GTK_BUTTONS_NONE,
+                                   title);
+  gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+                                            secondary, NULL);
+
   g_free (mime_description);
 
   button = gtk_button_new_with_mnemonic (_("_Save As..."));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]