[file-roller] Make the message dialogs more modern



commit a86ef72c399330ed4466fa7553985d3773dec2f3
Author: Yosef Or Boczko <yoseforb src gnome org>
Date:   Tue Aug 26 13:27:33 2014 +0300

    Make the message dialogs more modern
    
    Make it a real GtkMessageDialog.
    
    Also, remove the icon, we not needs it anymore.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=735438

 po/POTFILES.in                |    1 -
 src/dlg-extract.c             |    2 -
 src/dlg-package-installer.c   |    1 -
 src/file-roller.gresource.xml |    1 -
 src/fr-new-archive-dialog.c   |    1 -
 src/fr-window.c               |    7 ---
 src/gtk-utils.c               |   54 +++---------------------
 src/gtk-utils.h               |    6 ---
 src/ui/Makefile.am            |    1 -
 src/ui/message-dialog.ui      |   91 -----------------------------------------
 10 files changed, 7 insertions(+), 158 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 95f346b..cba8443 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -135,7 +135,6 @@ src/typedefs.h
 [type: gettext/glade]src/ui/gears-menu.ui
 [type: gettext/glade]src/ui/menus-toolbars.ui
 [type: gettext/glade]src/ui/menus.ui
-[type: gettext/glade]src/ui/message-dialog.ui
 [type: gettext/glade]src/ui/new-archive-dialog.ui
 [type: gettext/glade]src/ui/password.ui
 [type: gettext/glade]src/ui/progress-dialog.ui
diff --git a/src/dlg-extract.c b/src/dlg-extract.c
index c4fbf00..94d2940 100644
--- a/src/dlg-extract.c
+++ b/src/dlg-extract.c
@@ -97,7 +97,6 @@ extract_cb (GtkWidget   *w,
 
                        d = _gtk_message_dialog_new (GTK_WINDOW (data->dialog),
                                                     GTK_DIALOG_MODAL,
-                                                    _GTK_ICON_NAME_DIALOG_QUESTION,
                                                     msg,
                                                     NULL,
                                                     _GTK_LABEL_CANCEL, GTK_RESPONSE_CANCEL,
@@ -137,7 +136,6 @@ extract_cb (GtkWidget   *w,
 
                d = _gtk_message_dialog_new (GTK_WINDOW (window),
                                             GTK_DIALOG_DESTROY_WITH_PARENT,
-                                            _GTK_ICON_NAME_DIALOG_WARNING,
                                             _("Extraction not performed"),
                                             NULL,
                                             _GTK_LABEL_CLOSE, GTK_RESPONSE_OK,
diff --git a/src/dlg-package-installer.c b/src/dlg-package-installer.c
index 70f1e94..1b9d8c7 100644
--- a/src/dlg-package-installer.c
+++ b/src/dlg-package-installer.c
@@ -314,7 +314,6 @@ file_buffer_ready_cb (GObject      *source_object,
                                                  g_content_type_get_description (mime_type));
                dialog = _gtk_message_dialog_new (GTK_WINDOW (idata->window),
                                                  GTK_DIALOG_MODAL,
-                                                 _GTK_ICON_NAME_DIALOG_ERROR,
                                                  _("Could not open this file type"),
                                                  secondary_text,
                                                  _GTK_LABEL_CANCEL, GTK_RESPONSE_NO,
diff --git a/src/file-roller.gresource.xml b/src/file-roller.gresource.xml
index 4c5a3b3..b99ea0b 100644
--- a/src/file-roller.gresource.xml
+++ b/src/file-roller.gresource.xml
@@ -13,7 +13,6 @@
     <file compressed="true">ui/gears-menu.ui</file>
     <file compressed="true">ui/menus.ui</file>
     <file compressed="true">ui/menus-toolbars.ui</file>
-    <file compressed="true">ui/message-dialog.ui</file>
     <file compressed="true">ui/new-archive-dialog.ui</file>
     <file compressed="true">ui/password.ui</file>
     <file compressed="true">ui/progress-dialog.ui</file>
diff --git a/src/fr-new-archive-dialog.c b/src/fr-new-archive-dialog.c
index 5e50022..5f73669 100644
--- a/src/fr-new-archive-dialog.c
+++ b/src/fr-new-archive-dialog.c
@@ -466,7 +466,6 @@ fr_new_archive_dialog_get_file (FrNewArchiveDialog  *self,
                secondary_message = g_strdup_printf (_("The file already exists in \"%s\".  Replacing it will 
overwrite its contents."), g_file_info_get_display_name (parent_info));
                dialog = _gtk_message_dialog_new (GTK_WINDOW (self),
                                                  GTK_DIALOG_MODAL,
-                                                 _GTK_ICON_NAME_DIALOG_QUESTION,
                                                  message,
                                                  secondary_message,
                                                  _GTK_LABEL_CANCEL, GTK_RESPONSE_CANCEL,
diff --git a/src/fr-window.c b/src/fr-window.c
index fd1beb0..de7a38e 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -4020,7 +4020,6 @@ fr_window_drag_data_received  (GtkWidget          *widget,
 
                        d = _gtk_message_dialog_new (GTK_WINDOW (window),
                                                     GTK_DIALOG_MODAL,
-                                                    _GTK_ICON_NAME_DIALOG_QUESTION,
                                                     _("Do you want to add this file to the current archive 
or open it as a new archive?"),
                                                     NULL,
                                                     _GTK_LABEL_CANCEL, GTK_RESPONSE_CANCEL,
@@ -4050,7 +4049,6 @@ fr_window_drag_data_received  (GtkWidget          *widget,
 
                        d = _gtk_message_dialog_new (GTK_WINDOW (window),
                                                     GTK_DIALOG_MODAL,
-                                                    _GTK_ICON_NAME_DIALOG_QUESTION,
                                                     _("Do you want to create a new archive with these 
files?"),
                                                     NULL,
                                                     _GTK_LABEL_CANCEL, GTK_RESPONSE_CANCEL,
@@ -6450,7 +6448,6 @@ query_info_ready_for_overwrite_dialog_cb (GObject      *source_object,
                details = g_strdup_printf (_("Another file with the same name already exists in \"%s\"."), 
parent_name);
                d = _gtk_message_dialog_new (GTK_WINDOW (odata->window),
                                             GTK_DIALOG_MODAL,
-                                            _GTK_ICON_NAME_DIALOG_QUESTION,
                                             msg,
                                             details,
                                             _GTK_LABEL_CANCEL, GTK_RESPONSE_CANCEL,
@@ -6529,7 +6526,6 @@ _fr_window_ask_overwrite_dialog (OverwriteData *odata)
 
                d = _gtk_message_dialog_new (GTK_WINDOW (odata->window),
                                             0,
-                                            _GTK_ICON_NAME_DIALOG_WARNING,
                                             _("Extraction not performed"),
                                             NULL,
                                             _GTK_LABEL_CLOSE, GTK_RESPONSE_OK,
@@ -6632,7 +6628,6 @@ fr_window_archive_extract (FrWindow    *window,
 
                        d = _gtk_message_dialog_new (GTK_WINDOW (window),
                                                     GTK_DIALOG_MODAL,
-                                                    _GTK_ICON_NAME_DIALOG_QUESTION,
                                                     msg,
                                                     NULL,
                                                     _GTK_LABEL_CANCEL, GTK_RESPONSE_CANCEL,
@@ -6676,7 +6671,6 @@ fr_window_archive_extract (FrWindow    *window,
 
                d = _gtk_message_dialog_new (GTK_WINDOW (window),
                                             0,
-                                            _GTK_ICON_NAME_DIALOG_WARNING,
                                             _("Extraction not performed"),
                                             NULL,
                                             _GTK_LABEL_CLOSE, GTK_RESPONSE_OK,
@@ -8086,7 +8080,6 @@ fr_window_rename_selection (FrWindow *window,
 
                        dlg = _gtk_message_dialog_new (GTK_WINDOW (window),
                                                       GTK_DIALOG_MODAL,
-                                                      _GTK_ICON_NAME_DIALOG_QUESTION,
                                                       (renaming_dir ? _("Could not rename the folder") : 
_("Could not rename the file")),
                                                       reason,
                                                       _GTK_LABEL_CLOSE, GTK_RESPONSE_OK,
diff --git a/src/gtk-utils.c b/src/gtk-utils.c
index 5c7f8cb..a20f268 100644
--- a/src/gtk-utils.c
+++ b/src/gtk-utils.c
@@ -54,65 +54,27 @@ _gtk_tree_selection_count_selected (GtkTreeSelection *selection)
 GtkWidget *
 _gtk_message_dialog_new (GtkWindow      *parent,
                         GtkDialogFlags  flags,
-                        const char     *icon_name,
                         const char     *message,
                         const char     *secondary_message,
                         const gchar    *first_button_text,
                         ...)
 {
-       GtkBuilder  *builder;
        GtkWidget   *dialog;
-       GtkWidget   *label;
        va_list      args;
        const gchar *text;
        int          response_id;
-       char        *markup_text;
 
-       builder = _gtk_builder_new_from_resource ("message-dialog.ui");
-       dialog = _gtk_builder_get_widget (builder, "message_dialog");
-       gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
-       gtk_window_set_modal (GTK_WINDOW (dialog), (flags & GTK_DIALOG_MODAL));
-       gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), (flags & GTK_DIALOG_DESTROY_WITH_PARENT));
-       g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, builder);
+       dialog = gtk_message_dialog_new (parent,
+                                        flags,
+                                        GTK_MESSAGE_OTHER,
+                                        GTK_BUTTONS_NONE,
+                                        "%s", message);
+
+       gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), secondary_message);
 
        if (flags & GTK_DIALOG_MODAL)
                _gtk_dialog_add_to_window_group (GTK_DIALOG (dialog));
 
-       /* set the icon */
-
-       gtk_image_set_from_icon_name (GTK_IMAGE (_gtk_builder_get_widget (builder, "icon_image")),
-                                     icon_name,
-                                     GTK_ICON_SIZE_DIALOG);
-
-       /* set the message */
-
-       label = _gtk_builder_get_widget (builder, "message_label");
-
-       if (message != NULL) {
-               char *escaped_message;
-
-               escaped_message = g_markup_escape_text (message, -1);
-               if (secondary_message != NULL) {
-                       char *escaped_secondary_message;
-
-                       escaped_secondary_message = g_markup_escape_text (secondary_message, -1);
-                       markup_text = g_strdup_printf ("<span weight=\"bold\" 
size=\"larger\">%s</span>\n\n%s",
-                                                      escaped_message,
-                                                      escaped_secondary_message);
-
-                       g_free (escaped_secondary_message);
-               }
-               else
-                       markup_text = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>", 
escaped_message);
-
-               g_free (escaped_message);
-       }
-       else
-               markup_text = g_markup_escape_text (secondary_message, -1);
-
-       gtk_label_set_markup (GTK_LABEL (label), markup_text);
-       g_free (markup_text);
-
        /* add the buttons */
 
        if (first_button_text == NULL)
@@ -314,7 +276,6 @@ _gtk_error_dialog_run (GtkWindow  *parent,
 
        d =  _gtk_message_dialog_new (parent,
                                      GTK_DIALOG_MODAL,
-                                     _GTK_ICON_NAME_DIALOG_ERROR,
                                      main_message,
                                      message,
                                      _GTK_LABEL_CLOSE, GTK_RESPONSE_CANCEL,
@@ -532,7 +493,6 @@ _gtk_show_help_dialog (GtkWindow  *parent,
 
                dialog = _gtk_message_dialog_new (parent,
                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                 _GTK_ICON_NAME_DIALOG_ERROR,
                                                  _("Could not display help"),
                                                  error->message,
                                                  _GTK_LABEL_CLOSE, GTK_RESPONSE_OK,
diff --git a/src/gtk-utils.h b/src/gtk-utils.h
index eee4085..12f2902 100644
--- a/src/gtk-utils.h
+++ b/src/gtk-utils.h
@@ -26,11 +26,6 @@
 #include <gio/gio.h>
 #include <gtk/gtk.h>
 
-#define _GTK_ICON_NAME_DIALOG_ERROR "dialog-error-symbolic"
-#define _GTK_ICON_NAME_DIALOG_INFO "dialog-information-symbolic"
-#define _GTK_ICON_NAME_DIALOG_QUESTION "dialog-question-symbolic"
-#define _GTK_ICON_NAME_DIALOG_WARNING "dialog-warning-symbolic"
-
 #define _GTK_LABEL_ADD _("_Add")
 #define _GTK_LABEL_CANCEL _("_Cancel")
 #define _GTK_LABEL_CLOSE _("_Close")
@@ -48,7 +43,6 @@ typedef struct {
 int           _gtk_tree_selection_count_selected   (GtkTreeSelection *selection);
 GtkWidget *   _gtk_message_dialog_new              (GtkWindow        *parent,
                                                    GtkDialogFlags    flags,
-                                                   const char       *icon_name,
                                                    const char       *message,
                                                    const char       *secondary_message,
                                                    const char       *first_button_text,
diff --git a/src/ui/Makefile.am b/src/ui/Makefile.am
index c32e04b..4e578dd 100644
--- a/src/ui/Makefile.am
+++ b/src/ui/Makefile.am
@@ -11,7 +11,6 @@ EXTRA_DIST =                          \
        gears-menu.ui                   \
        menus.ui                        \
        menus-toolbars.ui               \
-       message-dialog.ui               \
        new-archive-dialog.ui           \
        password.ui                     \
        progress-dialog.ui              \


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