diff options
author | Diego Escalante Urrelo <descalante@igalia.com> | 2010-06-08 13:14:53 +0800 |
---|---|---|
committer | Diego Escalante Urrelo <descalante@igalia.com> | 2010-08-31 04:32:58 +0800 |
commit | aeb53c06241e56d779cbc849baf2abdd41b04999 (patch) | |
tree | f10d12b568c4847c4d5550b6a0d6fac99bc1caa7 | |
parent | 0d375c4d22ace65390274f6bdd1264d3d1af481f (diff) | |
download | gsoc2013-epiphany-aeb53c06241e56d779cbc849baf2abdd41b04999.tar gsoc2013-epiphany-aeb53c06241e56d779cbc849baf2abdd41b04999.tar.gz gsoc2013-epiphany-aeb53c06241e56d779cbc849baf2abdd41b04999.tar.bz2 gsoc2013-epiphany-aeb53c06241e56d779cbc849baf2abdd41b04999.tar.lz gsoc2013-epiphany-aeb53c06241e56d779cbc849baf2abdd41b04999.tar.xz gsoc2013-epiphany-aeb53c06241e56d779cbc849baf2abdd41b04999.tar.zst gsoc2013-epiphany-aeb53c06241e56d779cbc849baf2abdd41b04999.zip |
ephy-embed: clean up confirm_action_from_mime
Avoid duplication of code.
Bug #621050
-rw-r--r-- | 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 3f9084fbd..fa4f90d13 100644 --- a/embed/ephy-embed.c +++ b/embed/ephy-embed.c @@ -692,6 +692,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)) @@ -734,46 +737,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...")); |