[gnome-control-center/T20818: 27/54] user-accounts: adapt to small screens



commit 94035c827ad2bd0f4e28aa5fa1574c2914d1a10b
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Jan 7 15:11:09 2016 -0200

    user-accounts: adapt to small screens
    
    Basically putting a scrollbar in the new
    user dialog.
    
    [endlessm/eos-shell#6133]

 panels/user-accounts/data/account-dialog.ui |   14 ++++++++++++++
 panels/user-accounts/um-account-dialog.c    |   20 ++++++++++++++++++++
 panels/user-accounts/um-account-dialog.h    |    3 +++
 panels/user-accounts/um-user-panel.c        |   11 +++++++++--
 4 files changed, 46 insertions(+), 2 deletions(-)
---
diff --git a/panels/user-accounts/data/account-dialog.ui b/panels/user-accounts/data/account-dialog.ui
index eb97e86..c2a119c 100644
--- a/panels/user-accounts/data/account-dialog.ui
+++ b/panels/user-accounts/data/account-dialog.ui
@@ -85,6 +85,16 @@
             <property name="can_focus">False</property>
             <property name="transition-type">none</property>
             <child>
+              <object class="GtkScrolledWindow" id="scrolledwindow">
+               <property name="visible">True</property>
+               <property name="can_focus">False</property>
+               <property name="hscrollbar_policy">never</property>
+               <property name="vscrollbar_policy">never</property>
+               <child>
+                 <object class="GtkViewport" id="viewport">
+                   <property name="visible">True</property>
+                   <property name="can_focus">False</property>
+                    <child>
               <object class="GtkGrid" id="local_area">
                 <property name="visible">True</property>
                 <property name="hexpand">True</property>
@@ -470,6 +480,10 @@
                  </packing>
                </child>
               </object>
+                   </child>
+                 </object>
+               </child>
+              </object>
               <packing>
                 <property name="name">_local</property>
               </packing>
diff --git a/panels/user-accounts/um-account-dialog.c b/panels/user-accounts/um-account-dialog.c
index 06b4fc2..344e649 100644
--- a/panels/user-accounts/um-account-dialog.c
+++ b/panels/user-accounts/um-account-dialog.c
@@ -70,6 +70,7 @@ static void   um_account_dialog_response  (GtkDialog *dialog,
 struct _UmAccountDialog {
         GtkDialog parent;
         GtkWidget *stack;
+        GtkWidget *scrolledwindow;
         GSimpleAsyncResult *async;
         GCancellable *cancellable;
         GPermission *permission;
@@ -1569,6 +1570,7 @@ um_account_dialog_class_init (UmAccountDialogClass *klass)
                                                      
"/org/gnome/control-center/user-accounts/account-dialog.ui");
 
         gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, stack);
+        gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, scrolledwindow);
         gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_username);
         gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_username_entry);
         gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_name);
@@ -1646,3 +1648,21 @@ um_account_dialog_finish (UmAccountDialog     *self,
         g_clear_object (&self->async);
         return user;
 }
+
+void
+um_account_dialog_set_is_small_screen (UmAccountDialog *self,
+                                       gboolean         is_small_screen)
+{
+        if (is_small_screen) {
+                GtkWindow *transient;
+                gint width, height;
+
+                transient = gtk_window_get_transient_for (GTK_WINDOW (self));
+
+                gtk_window_get_size (transient, &width, &height);
+                gtk_widget_set_size_request (GTK_WIDGET (self), width, height);
+                gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (self->scrolledwindow),
+                                                GTK_POLICY_NEVER,
+                                                GTK_POLICY_AUTOMATIC);
+        }
+}
diff --git a/panels/user-accounts/um-account-dialog.h b/panels/user-accounts/um-account-dialog.h
index 9e8361d..3991311 100644
--- a/panels/user-accounts/um-account-dialog.h
+++ b/panels/user-accounts/um-account-dialog.h
@@ -43,6 +43,9 @@ void             um_account_dialog_show     (UmAccountDialog     *self,
 ActUser *        um_account_dialog_finish   (UmAccountDialog     *self,
                                              GAsyncResult        *result);
 
+void             um_account_dialog_set_is_small_screen (UmAccountDialog *self,
+                                                        gboolean         is_small_screen);
+
 G_END_DECLS
 
 #endif
diff --git a/panels/user-accounts/um-user-panel.c b/panels/user-accounts/um-user-panel.c
index e27dc5e..67789c5 100644
--- a/panels/user-accounts/um-user-panel.c
+++ b/panels/user-accounts/um-user-panel.c
@@ -369,11 +369,18 @@ select_created_user (GObject *object,
 }
 
 static void
-add_user (GtkButton *button, CcUserPanelPrivate *d)
+add_user (GtkButton *button, CcUserPanel *self)
 {
+        CcUserPanelPrivate *d;
+        CcShell *shell;
+
+        d = self->priv;
+        shell = cc_panel_get_shell (CC_PANEL (self));
+
         d->account_dialog = um_account_dialog_new ();
         um_account_dialog_show (d->account_dialog, GTK_WINDOW (gtk_widget_get_toplevel (d->main_box)),
                                 d->permission, select_created_user, d);
+        um_account_dialog_set_is_small_screen (d->account_dialog, cc_shell_is_small_screen (shell));
 }
 
 static void
@@ -1336,7 +1343,7 @@ setup_main_window (CcUserPanel *self)
         g_signal_connect (d->carousel, "item-activated", G_CALLBACK (set_selected_user), d);
 
         button = get_widget (d, "add-user-toolbutton");
-        g_signal_connect (button, "clicked", G_CALLBACK (add_user), d);
+        g_signal_connect (button, "clicked", G_CALLBACK (add_user), self);
 
         button = get_widget (d, "remove-user-toolbutton");
         g_signal_connect (button, "clicked", G_CALLBACK (delete_user), self);


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