[gnome-text-editor] preferences: make EditorPreferencesRadio look like a radio



commit 95d4f403d4b4a192813b03c57c66df93faa2189d
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jul 29 17:50:04 2021 -0700

    preferences: make EditorPreferencesRadio look like a radio

 src/editor-preferences-radio.c | 28 ++++++++++++----------------
 src/editor-preferences-radio.h |  3 +++
 2 files changed, 15 insertions(+), 16 deletions(-)
---
diff --git a/src/editor-preferences-radio.c b/src/editor-preferences-radio.c
index 7f05995..698d51a 100644
--- a/src/editor-preferences-radio.c
+++ b/src/editor-preferences-radio.c
@@ -62,7 +62,7 @@ editor_preferences_radio_changed_cb (EditorPreferencesRadio *self,
 
   value = g_settings_get_string (settings, key);
   active = g_strcmp0 (value, self->schema_value) == 0;
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->toggle), active);
+  gtk_check_button_set_active (self->toggle, active);
 }
 
 static void
@@ -103,14 +103,6 @@ editor_preferences_radio_activated (AdwActionRow *row)
   g_settings_set_string (self->settings, self->schema_key, self->schema_value);
 }
 
-static void
-editor_preferences_radio_clicked_cb (EditorPreferencesRadio *self,
-                                     GtkCheckButton         *button)
-{
-  editor_preferences_radio_activated (ADW_ACTION_ROW (self));
-  g_signal_stop_emission_by_name (button, "clicked");
-}
-
 static void
 editor_preferences_radio_finalize (GObject *object)
 {
@@ -220,13 +212,17 @@ editor_preferences_radio_init (EditorPreferencesRadio *self)
 {
   self->toggle = g_object_new (GTK_TYPE_CHECK_BUTTON,
                                "can-focus", FALSE,
-                                "valign", GTK_ALIGN_CENTER,
+                               "valign", GTK_ALIGN_CENTER,
                                NULL);
-  g_signal_connect_object (self->toggle,
-                           "clicked",
-                           G_CALLBACK (editor_preferences_radio_clicked_cb),
-                           self,
-                           G_CONNECT_SWAPPED);
+  adw_action_row_add_prefix (ADW_ACTION_ROW (self), GTK_WIDGET (self->toggle));
+}
+
+void
+editor_preferences_radio_set_group (EditorPreferencesRadio *self,
+                                    EditorPreferencesRadio *other)
+{
+  g_return_if_fail (EDITOR_IS_PREFERENCES_RADIO (self));
+  g_return_if_fail (EDITOR_IS_PREFERENCES_RADIO (other));
 
-  adw_action_row_add_suffix (ADW_ACTION_ROW (self), GTK_WIDGET (self->toggle));
+  gtk_check_button_set_group (self->toggle, other->toggle);
 }
diff --git a/src/editor-preferences-radio.h b/src/editor-preferences-radio.h
index d18f72a..2ee3533 100644
--- a/src/editor-preferences-radio.h
+++ b/src/editor-preferences-radio.h
@@ -28,4 +28,7 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (EditorPreferencesRadio, editor_preferences_radio, EDITOR, PREFERENCES_RADIO, 
AdwActionRow)
 
+void editor_preferences_radio_set_group (EditorPreferencesRadio *self,
+                                         EditorPreferencesRadio *other);
+
 G_END_DECLS


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