[gedit] File choosers: remove GeditFileChooserFlags



commit 105ca1ded994284f84861592afcbe2c0a7b9bf2d
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Jun 11 16:40:44 2020 +0200

    File choosers: remove GeditFileChooserFlags

 gedit/gedit-commands-file.c           |  1 -
 gedit/gedit-file-chooser-dialog-gtk.c | 44 ++++++++++-------------------------
 gedit/gedit-file-chooser-dialog-gtk.h |  9 ++++---
 gedit/gedit-file-chooser-dialog.c     | 10 ++++----
 gedit/gedit-file-chooser-dialog.h     |  7 ------
 5 files changed, 20 insertions(+), 51 deletions(-)
---
diff --git a/gedit/gedit-commands-file.c b/gedit/gedit-commands-file.c
index e786327eb..47f162615 100644
--- a/gedit/gedit-commands-file.c
+++ b/gedit/gedit-commands-file.c
@@ -791,7 +791,6 @@ save_as_tab_async (GeditTab            *tab,
        /* Translators: "Save As" is the title of the file chooser window. */
        save_dialog = gedit_file_chooser_dialog_create (C_("window title", "Save As"),
                                                        GTK_WINDOW (window),
-                                                       GEDIT_FILE_CHOOSER_FLAG_SAVE,
                                                        _("_Save"),
                                                        _("_Cancel"));
 
diff --git a/gedit/gedit-file-chooser-dialog-gtk.c b/gedit/gedit-file-chooser-dialog-gtk.c
index 3af1add3a..8f2eb99b0 100644
--- a/gedit/gedit-file-chooser-dialog-gtk.c
+++ b/gedit/gedit-file-chooser-dialog-gtk.c
@@ -238,8 +238,7 @@ gedit_file_chooser_dialog_gtk_class_init (GeditFileChooserDialogGtkClass *klass)
 }
 
 static void
-create_option_menu (GeditFileChooserDialogGtk *dialog,
-                    GeditFileChooserFlags      flags)
+create_option_menu (GeditFileChooserDialogGtk *dialog)
 {
        GtkWidget *label;
        GtkWidget *menu;
@@ -248,7 +247,7 @@ create_option_menu (GeditFileChooserDialogGtk *dialog,
        label = gtk_label_new_with_mnemonic (_("C_haracter Encoding:"));
        gtk_widget_set_halign (label, GTK_ALIGN_START);
 
-       save_mode = (flags & GEDIT_FILE_CHOOSER_FLAG_SAVE) != 0;
+       save_mode = TRUE;
        menu = gedit_encodings_combo_box_new (save_mode);
 
        gtk_label_set_mnemonic_widget (GTK_LABEL (label), menu);
@@ -360,18 +359,13 @@ create_newline_combo (GeditFileChooserDialogGtk *dialog)
 }
 
 static void
-create_extra_widget (GeditFileChooserDialogGtk *dialog,
-                     GeditFileChooserFlags      flags)
+create_extra_widget (GeditFileChooserDialogGtk *dialog)
 {
        dialog->extra_widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
        gtk_widget_show (dialog->extra_widget);
 
-       create_option_menu (dialog, flags);
-
-       if ((flags & GEDIT_FILE_CHOOSER_FLAG_SAVE) != 0)
-       {
-               create_newline_combo (dialog);
-       }
+       create_option_menu (dialog);
+       create_newline_combo (dialog);
 
        gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), dialog->extra_widget);
 }
@@ -412,35 +406,21 @@ gedit_file_chooser_dialog_gtk_init (GeditFileChooserDialogGtk *dialog)
 }
 
 GeditFileChooserDialog *
-gedit_file_chooser_dialog_gtk_create (const gchar           *title,
-                                     GtkWindow             *parent,
-                                     GeditFileChooserFlags  flags,
-                                     const gchar           *accept_label,
-                                     const gchar           *cancel_label)
+gedit_file_chooser_dialog_gtk_create (const gchar *title,
+                                     GtkWindow   *parent,
+                                     const gchar *accept_label,
+                                     const gchar *cancel_label)
 {
        GeditFileChooserDialogGtk *result;
-       GtkFileChooserAction action;
-       gboolean select_multiple;
-
-       if ((flags & GEDIT_FILE_CHOOSER_FLAG_SAVE) != 0)
-       {
-               action = GTK_FILE_CHOOSER_ACTION_SAVE;
-               select_multiple = FALSE;
-       }
-       else
-       {
-               action = GTK_FILE_CHOOSER_ACTION_OPEN;
-               select_multiple = TRUE;
-       }
 
        result = g_object_new (GEDIT_TYPE_FILE_CHOOSER_DIALOG_GTK,
                               "title", title,
                               "local-only", FALSE,
-                              "action", action,
-                              "select-multiple", select_multiple,
+                              "action", GTK_FILE_CHOOSER_ACTION_SAVE,
+                              "select-multiple", FALSE,
                               NULL);
 
-       create_extra_widget (result, flags);
+       create_extra_widget (result);
 
        g_signal_connect (result,
                          "notify::action",
diff --git a/gedit/gedit-file-chooser-dialog-gtk.h b/gedit/gedit-file-chooser-dialog-gtk.h
index 40726af54..0bf6a0d41 100644
--- a/gedit/gedit-file-chooser-dialog-gtk.h
+++ b/gedit/gedit-file-chooser-dialog-gtk.h
@@ -33,11 +33,10 @@ G_DECLARE_FINAL_TYPE (GeditFileChooserDialogGtk, gedit_file_chooser_dialog_gtk,
                      GEDIT, FILE_CHOOSER_DIALOG_GTK,
                      GtkFileChooserDialog)
 
-GeditFileChooserDialog *       gedit_file_chooser_dialog_gtk_create    (const gchar           *title,
-                                                                        GtkWindow             *parent,
-                                                                        GeditFileChooserFlags  flags,
-                                                                        const gchar           *accept_label,
-                                                                        const gchar           *cancel_label);
+GeditFileChooserDialog *       gedit_file_chooser_dialog_gtk_create    (const gchar *title,
+                                                                        GtkWindow   *parent,
+                                                                        const gchar *accept_label,
+                                                                        const gchar *cancel_label);
 
 G_END_DECLS
 
diff --git a/gedit/gedit-file-chooser-dialog.c b/gedit/gedit-file-chooser-dialog.c
index af2454a9b..56edbae3b 100644
--- a/gedit/gedit-file-chooser-dialog.c
+++ b/gedit/gedit-file-chooser-dialog.c
@@ -62,15 +62,13 @@ gedit_file_chooser_dialog_default_init (GeditFileChooserDialogInterface *iface)
 }
 
 GeditFileChooserDialog *
-gedit_file_chooser_dialog_create (const gchar           *title,
-                                 GtkWindow             *parent,
-                                 GeditFileChooserFlags  flags,
-                                 const gchar           *accept_label,
-                                 const gchar           *cancel_label)
+gedit_file_chooser_dialog_create (const gchar *title,
+                                 GtkWindow   *parent,
+                                 const gchar *accept_label,
+                                 const gchar *cancel_label)
 {
        return gedit_file_chooser_dialog_gtk_create (title,
                                                     parent,
-                                                    flags,
                                                     accept_label,
                                                     cancel_label);
 }
diff --git a/gedit/gedit-file-chooser-dialog.h b/gedit/gedit-file-chooser-dialog.h
index af83e68f3..b759c6566 100644
--- a/gedit/gedit-file-chooser-dialog.h
+++ b/gedit/gedit-file-chooser-dialog.h
@@ -74,16 +74,9 @@ struct _GeditFileChooserDialogInterface
                (*get_window)           (GeditFileChooserDialog *dialog);
 };
 
-typedef enum
-{
-       GEDIT_FILE_CHOOSER_FLAG_SAVE = 1 << 0,
-       GEDIT_FILE_CHOOSER_FLAG_OPEN = 1 << 1
-} GeditFileChooserFlags;
-
 GeditFileChooserDialog *
                gedit_file_chooser_dialog_create                (const gchar              *title,
                                                                 GtkWindow                *parent,
-                                                                GeditFileChooserFlags     flags,
                                                                 const gchar              *accept_label,
                                                                 const gchar              *cancel_label);
 


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