[gnome-control-center/mwleeds/region-login-screen-toggle] region: replace the "Login Screen" button




commit 1d952d4ebdb5d6d565dd3c85b515ffbeab89c336
Author: Felipe Erias Morandeira <femorandeira igalia com>
Date:   Thu Apr 10 13:44:03 2014 +0200

    region: replace the "Login Screen" button
    
    ...on the title bar with joined toggles (like in Background panel) for a
    clearer UI.
    
    Note 2020-08-26: This patch has been in Endless OS since 2014. It seems
      like a good UX change, so I'm proposing it upstream with some minor
      changes. - mwleeds

 panels/region/cc-region-panel.c  | 33 +++++++-----------------------
 panels/region/cc-region-panel.ui | 44 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 26 deletions(-)
---
diff --git a/panels/region/cc-region-panel.c b/panels/region/cc-region-panel.c
index 3c8f03d34..375c34036 100644
--- a/panels/region/cc-region-panel.c
+++ b/panels/region/cc-region-panel.c
@@ -53,14 +53,15 @@ struct _CcRegionPanel {
         GtkListBox      *formats_list;
         GtkListBoxRow   *formats_row;
         GtkSizeGroup    *input_size_group;
-        GtkToggleButton *login_button;
         GtkLabel        *login_label;
         GtkLabel        *language_label;
         GtkListBox      *language_list;
         GtkListBoxRow   *language_row;
         GtkFrame        *language_section_frame;
+        GtkToggleButton *login_language_button;
         GtkButton       *restart_button;
         GtkRevealer     *restart_revealer;
+        GtkBox          *session_or_login_box;
 
         gboolean     login;
         gboolean     login_auto_apply;
@@ -114,19 +115,6 @@ cc_region_panel_finalize (GObject *object)
         G_OBJECT_CLASS (cc_region_panel_parent_class)->finalize (object);
 }
 
-static void
-cc_region_panel_constructed (GObject *object)
-{
-        CcRegionPanel *self = CC_REGION_PANEL (object);
-
-        G_OBJECT_CLASS (cc_region_panel_parent_class)->constructed (object);
-
-        if (self->permission)
-                cc_shell_embed_widget_in_header (cc_panel_get_shell (CC_PANEL (object)),
-                                                 GTK_WIDGET (self->login_button),
-                                                 GTK_POS_RIGHT);
-}
-
 static const char *
 cc_region_panel_get_help_uri (CcPanel *panel)
 {
@@ -670,8 +658,6 @@ localed_proxy_ready (GObject      *source,
 
         self->localed = proxy;
 
-        gtk_widget_set_sensitive (GTK_WIDGET (self->login_button), TRUE);
-
         g_signal_connect_object (self->localed, "g-properties-changed",
                                  G_CALLBACK (on_localed_properties_changed), self, G_CONNECT_SWAPPED);
         on_localed_properties_changed (self, NULL, NULL);
@@ -682,7 +668,7 @@ login_changed (CcRegionPanel *self)
 {
         gboolean can_acquire;
 
-        self->login = gtk_toggle_button_get_active (self->login_button);
+        self->login = gtk_toggle_button_get_active (self->login_language_button);
         gtk_widget_set_visible (GTK_WIDGET (self->login_label), self->login);
 
         can_acquire = self->permission &&
@@ -707,7 +693,7 @@ set_login_button_visibility (CcRegionPanel *self)
         g_object_get (self->user_manager, "has-multiple-users", &has_multiple_users, NULL);
 
         self->login_auto_apply = !has_multiple_users && g_permission_get_allowed (self->permission);
-        gtk_widget_set_visible (GTK_WIDGET (self->login_button), !self->login_auto_apply);
+        gtk_widget_set_visible (GTK_WIDGET (self->session_or_login_box), !self->login_auto_apply);
 
         g_signal_handlers_disconnect_by_func (self->user_manager, set_login_button_visibility, self);
 }
@@ -737,13 +723,7 @@ setup_login_button (CcRegionPanel *self)
                           (GAsyncReadyCallback) localed_proxy_ready,
                           self);
 
-        self->login_button = GTK_TOGGLE_BUTTON (gtk_toggle_button_new_with_mnemonic (_("Login _Screen")));
-        gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self->login_button)),
-                                     "text-button");
-        gtk_widget_set_valign (GTK_WIDGET (self->login_button), GTK_ALIGN_CENTER);
-        gtk_widget_set_visible (GTK_WIDGET (self->login_button), FALSE);
-        gtk_widget_set_sensitive (GTK_WIDGET (self->login_button), FALSE);
-        g_signal_connect_object (self->login_button, "notify::active",
+        g_signal_connect_object (self->login_language_button, "notify::active",
                                  G_CALLBACK (login_changed), self, G_CONNECT_SWAPPED);
 
         g_object_get (self->user_manager, "is-loaded", &loaded, NULL);
@@ -783,7 +763,6 @@ cc_region_panel_class_init (CcRegionPanelClass * klass)
 
         panel_class->get_help_uri = cc_region_panel_get_help_uri;
 
-        object_class->constructed = cc_region_panel_constructed;
         object_class->finalize = cc_region_panel_finalize;
 
         gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/control-center/region/cc-region-panel.ui");
@@ -796,8 +775,10 @@ cc_region_panel_class_init (CcRegionPanelClass * klass)
         gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, language_list);
         gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, language_row);
         gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, language_section_frame);
+        gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, login_language_button);
         gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, restart_button);
         gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, restart_revealer);
+        gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, session_or_login_box);
 
         gtk_widget_class_bind_template_callback (widget_class, restart_now);
 }
diff --git a/panels/region/cc-region-panel.ui b/panels/region/cc-region-panel.ui
index 9fb6ebdb2..fc698f0af 100644
--- a/panels/region/cc-region-panel.ui
+++ b/panels/region/cc-region-panel.ui
@@ -26,6 +26,50 @@
                 <property name="orientation">vertical</property>
                 <property name="spacing">12</property>
                 <property name="hexpand">True</property>
+               <child>
+                 <object class="GtkBox" id="session_or_login_box">
+                   <property name="visible">True</property>
+                   <property name="can_focus">False</property>
+                   <property name="orientation">horizontal</property>
+                   <property name="homogeneous">True</property>
+                   <property name="halign">center</property>
+                   <property name="hexpand">True</property>
+                   <style>
+                     <class name="linked"/>
+                   </style>
+                   <child>
+                     <object class="GtkRadioButton" id="session_language_button">
+                       <property name="label" translatable="yes">My Account</property>
+                       <property name="visible">True</property>
+                       <property name="can_focus">True</property>
+                       <property name="receives_default">False</property>
+                       <property name="xalign">0</property>
+                       <property name="active">True</property>
+                       <property name="draw_indicator">False</property>
+                     </object>
+                   </child>
+                   <child>
+                     <object class="GtkRadioButton" id="login_language_button">
+                       <property name="label" translatable="yes">Login Screen</property>
+                       <property name="visible">True</property>
+                       <property name="can_focus">True</property>
+                       <property name="receives_default">False</property>
+                       <property name="xalign">0</property>
+                       <property name="active">False</property>
+                       <property name="draw_indicator">False</property>
+                       <property name="group">session_language_button</property>
+                       <style>
+                         <class name="raised"/>
+                       </style>
+                     </object>
+                   </child>
+                 </object>
+                 <packing>
+                   <property name="expand">False</property>
+                   <property name="fill">True</property>
+                   <property name="position">0</property>
+                 </packing>
+               </child>
                 <child>
                   <object class="GtkLabel">
                     <property name="visible">True</property>


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