[gtk/wip/baedert/for-master: 8/29] mountoperation: Stop using radio buttons




commit d6e1276fe1fe3cb2e26d12c5221d83aef9d92a9f
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Aug 30 17:51:21 2020 -0400

    mountoperation: Stop using radio buttons
    
    Use grouped check buttons instead.

 gtk/gtkmountoperation.c | 51 ++++++++++++++++++++++++-------------------------
 1 file changed, 25 insertions(+), 26 deletions(-)
---
diff --git a/gtk/gtkmountoperation.c b/gtk/gtkmountoperation.c
index 395f3eeea4..29d2f288dd 100644
--- a/gtk/gtkmountoperation.c
+++ b/gtk/gtkmountoperation.c
@@ -38,7 +38,7 @@
 #include "gtkmessagedialog.h"
 #include "gtkmountoperation.h"
 #include "gtkprivate.h"
-#include "gtkradiobutton.h"
+#include "gtkcheckbutton.h"
 #include "gtkgrid.h"
 #include "gtkwindow.h"
 #include "gtktreeview.h"
@@ -322,12 +322,12 @@ gtk_mount_operation_proxy_finish (GtkMountOperation     *op,
 }
 
 static void
-remember_button_toggled (GtkToggleButton   *button,
+remember_button_toggled (GtkCheckButton    *button,
                          GtkMountOperation *operation)
 {
   GtkMountOperationPrivate *priv = operation->priv;
 
-  if (gtk_toggle_button_get_active (button))
+  if (gtk_check_button_get_active (button))
     {
       gpointer data;
 
@@ -384,10 +384,10 @@ pw_dialog_got_response (GtkDialog         *dialog,
             }
         }
 
-      if (priv->tcrypt_hidden_toggle && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(priv->tcrypt_hidden_toggle)))
+      if (priv->tcrypt_hidden_toggle && gtk_check_button_get_active (GTK_CHECK_BUTTON 
(priv->tcrypt_hidden_toggle)))
         g_mount_operation_set_is_tcrypt_hidden_volume (op, TRUE);
 
-      if (priv->tcrypt_system_toggle && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(priv->tcrypt_system_toggle)))
+      if (priv->tcrypt_system_toggle && gtk_check_button_get_active (GTK_CHECK_BUTTON 
(priv->tcrypt_system_toggle)))
         g_mount_operation_set_is_tcrypt_system_volume (op, TRUE);
 
       if (priv->ask_flags & G_ASK_PASSWORD_SAVING_SUPPORTED)
@@ -668,7 +668,6 @@ gtk_mount_operation_ask_password_do_gtk (GtkMountOperation *operation,
     {
       GtkWidget *anon_box;
       GtkWidget *choice;
-      GSList    *group;
 
       label = gtk_label_new (_("Connect As"));
       gtk_widget_set_halign (label, GTK_ALIGN_END);
@@ -679,17 +678,15 @@ gtk_mount_operation_ask_password_do_gtk (GtkMountOperation *operation,
       anon_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
       gtk_grid_attach (GTK_GRID (grid), anon_box, 1, rows++, 1, 1);
 
-      choice = gtk_radio_button_new_with_mnemonic (NULL, _("_Anonymous"));
-      gtk_box_append (GTK_BOX (anon_box),
-                          choice);
+      choice = gtk_check_button_new_with_mnemonic (_("_Anonymous"));
+      gtk_box_append (GTK_BOX (anon_box), choice);
       g_signal_connect (choice, "toggled",
                         G_CALLBACK (pw_dialog_anonymous_toggled), operation);
       priv->anonymous_toggle = choice;
 
-      group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (choice));
-      choice = gtk_radio_button_new_with_mnemonic (group, _("Registered U_ser"));
-      gtk_box_append (GTK_BOX (anon_box),
-                          choice);
+      choice = gtk_check_button_new_with_mnemonic (_("Registered U_ser"));
+      gtk_check_button_set_group (GTK_CHECK_BUTTON (choice), GTK_CHECK_BUTTON (priv->anonymous_toggle));
+      gtk_box_append (GTK_BOX (anon_box), choice);
       g_signal_connect (choice, "toggled",
                         G_CALLBACK (pw_dialog_anonymous_toggled), operation);
     }
@@ -742,7 +739,7 @@ gtk_mount_operation_ask_password_do_gtk (GtkMountOperation *operation,
     {
       GtkWidget    *remember_box;
       GtkWidget    *choice;
-      GSList       *group;
+      GtkWidget    *group;
       GPasswordSave password_save;
 
       remember_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
@@ -755,29 +752,31 @@ gtk_mount_operation_ask_password_do_gtk (GtkMountOperation *operation,
       password_save = g_mount_operation_get_password_save (G_MOUNT_OPERATION (operation));
       priv->password_save = password_save;
 
-      choice = gtk_radio_button_new_with_mnemonic (NULL, _("Forget password _immediately"));
-      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (choice),
-                                    password_save == G_PASSWORD_SAVE_NEVER);
+      choice = gtk_check_button_new_with_mnemonic (_("Forget password _immediately"));
+      gtk_check_button_set_active (GTK_CHECK_BUTTON (choice),
+                                   password_save == G_PASSWORD_SAVE_NEVER);
       g_object_set_data (G_OBJECT (choice), "password-save",
                          GINT_TO_POINTER (G_PASSWORD_SAVE_NEVER));
       g_signal_connect (choice, "toggled",
                         G_CALLBACK (remember_button_toggled), operation);
       gtk_box_append (GTK_BOX (remember_box), choice);
+      group = choice;
 
-      group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (choice));
-      choice = gtk_radio_button_new_with_mnemonic (group, _("Remember password until you _logout"));
-      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (choice),
-                                    password_save == G_PASSWORD_SAVE_FOR_SESSION);
+      choice = gtk_check_button_new_with_mnemonic (_("Remember password until you _logout"));
+      gtk_check_button_set_group (GTK_CHECK_BUTTON (choice), GTK_CHECK_BUTTON (group));
+      gtk_check_button_set_active (GTK_CHECK_BUTTON (choice),
+                                   password_save == G_PASSWORD_SAVE_FOR_SESSION);
       g_object_set_data (G_OBJECT (choice), "password-save",
                          GINT_TO_POINTER (G_PASSWORD_SAVE_FOR_SESSION));
       g_signal_connect (choice, "toggled",
                         G_CALLBACK (remember_button_toggled), operation);
       gtk_box_append (GTK_BOX (remember_box), choice);
+      group = choice;
 
-      group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (choice));
-      choice = gtk_radio_button_new_with_mnemonic (group, _("Remember _forever"));
-      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (choice),
-                                    password_save == G_PASSWORD_SAVE_PERMANENTLY);
+      choice = gtk_check_button_new_with_mnemonic (_("Remember _forever"));
+      gtk_check_button_set_group (GTK_CHECK_BUTTON (choice), GTK_CHECK_BUTTON (group));
+      gtk_check_button_set_active (GTK_CHECK_BUTTON (choice),
+                                   password_save == G_PASSWORD_SAVE_PERMANENTLY);
       g_object_set_data (G_OBJECT (choice), "password-save",
                          GINT_TO_POINTER (G_PASSWORD_SAVE_PERMANENTLY));
       g_signal_connect (choice, "toggled",
@@ -793,7 +792,7 @@ gtk_mount_operation_ask_password_do_gtk (GtkMountOperation *operation,
       /* The anonymous option will be active by default,
        * ensure the toggled signal is emitted for it.
        */
-      gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (priv->anonymous_toggle));
+      g_signal_emit_by_name (priv->anonymous_toggle, "toggled");
     }
   else if (! pw_dialog_input_is_valid (operation))
     gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_OK, FALSE);


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