[gdm/wip/initial-setup2] Design updates



commit ab09560ec59f42f25e480e2b4433fc204064c1c3
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu May 3 18:36:09 2012 -0400

    Design updates
    
    Also, more complete account step implementation

 gui/initial-setup/gdm-initial-setup.c |  119 +++++++++++++++++++++++++++++++--
 gui/initial-setup/setup.ui            |   68 ++++++++++++++-----
 2 files changed, 161 insertions(+), 26 deletions(-)
---
diff --git a/gui/initial-setup/gdm-initial-setup.c b/gui/initial-setup/gdm-initial-setup.c
index 4f4466f..1f67b6c 100644
--- a/gui/initial-setup/gdm-initial-setup.c
+++ b/gui/initial-setup/gdm-initial-setup.c
@@ -786,6 +786,19 @@ out: ;
 
 /* Account page {{{1 */
 
+enum {
+        PANEL_ACCOUNT_COLUMN_ACTIVE,
+        PANEL_ACCOUNT_COLUMN_TITLE,
+        PANEL_ACCOUNT_COLUMN_NAME
+};
+
+enum {
+        PANEL_ACCOUNT_ROW_LOCAL,
+        PANEL_ACCOUNT_ROW_REMOTE
+};
+
+static gboolean skip_account = FALSE;
+
 static void
 update_account_page_status (SetupData *setup)
 {
@@ -1009,6 +1022,32 @@ save_when_loaded (ActUser *user, GParamSpec *pspec, SetupData *setup)
 }
 
 static void
+set_account_model_row (SetupData *setup, gint row, gboolean active, const gchar *name)
+{
+        GtkTreeModel *model;
+        GtkTreeIter iter;
+        gchar *n = NULL;
+
+        model = gtk_tree_view_get_model (GTK_TREE_VIEW (WID("account-list")));
+
+        gtk_tree_model_get_iter_first (model, &iter);
+        if (row == PANEL_ACCOUNT_ROW_REMOTE)
+                gtk_tree_model_iter_next (model, &iter);
+
+        if (name == NULL) {
+                gtk_tree_model_get (model, &iter, PANEL_ACCOUNT_COLUMN_NAME, &n, -1);
+                name = (const gchar *)n;
+        }
+
+        gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+                            PANEL_ACCOUNT_COLUMN_ACTIVE, active,
+                            PANEL_ACCOUNT_COLUMN_NAME, name,
+                            -1);
+
+        g_free (n);
+}
+
+static void
 clear_account_page (SetupData *setup)
 {
         GtkWidget *fullname_entry;
@@ -1044,6 +1083,8 @@ clear_account_page (SetupData *setup)
         gtk_list_store_clear (GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (username_combo))));
         gtk_entry_set_text (GTK_ENTRY (password_entry), "");
         gtk_entry_set_text (GTK_ENTRY (confirm_entry), "");
+
+        set_account_model_row (setup, PANEL_ACCOUNT_ROW_LOCAL, FALSE, "");
 }
 
 static void
@@ -1102,9 +1143,8 @@ save_account_data (SetupData *setup)
 }
 
 static void
-show_local_account_dialog (GtkButton *button, gpointer data)
+show_local_account_dialog (SetupData *setup)
 {
-        SetupData *setup = data;
         GtkWidget *dialog;
 
         dialog = WID("local-account-dialog");
@@ -1129,12 +1169,56 @@ create_local_account (GtkButton *button, gpointer data)
 {
         SetupData *setup = data;
         GtkWidget *dialog;
+        const gchar *realname;
 
         dialog = WID("local-account-dialog");
+
+        realname = gtk_entry_get_text (OBJ (GtkEntry*, "account-fullname-entry"));
+        set_account_model_row (setup, PANEL_ACCOUNT_ROW_LOCAL, TRUE, realname);
+
         gtk_widget_hide (dialog);
 }
 
 static void
+account_set_active_data (GtkCellLayout   *layout,
+                         GtkCellRenderer *cell,
+                         GtkTreeModel    *model,
+                         GtkTreeIter     *iter,
+                         gpointer         data)
+{
+        gboolean active;
+
+        gtk_tree_model_get (model, iter,
+                            PANEL_ACCOUNT_COLUMN_ACTIVE, &active,
+                            -1);
+
+        g_object_set (cell, "text", active ? "\342\254\251" : " ", NULL);
+}
+
+static void
+account_row_activated (GtkTreeView       *tv,
+                       GtkTreePath       *path,
+                       GtkTreeViewColumn *column,
+                       gpointer           data)
+{
+        SetupData *setup = data;
+        gint type;
+
+        type = gtk_tree_path_get_indices (path)[0];
+
+        if (type == PANEL_ACCOUNT_ROW_LOCAL) {
+                set_account_model_row (setup, PANEL_ACCOUNT_ROW_LOCAL, TRUE, NULL);
+                set_account_model_row (setup, PANEL_ACCOUNT_ROW_REMOTE, FALSE, "");
+                show_local_account_dialog (setup);
+        }
+        else {
+                set_account_model_row (setup, PANEL_ACCOUNT_ROW_LOCAL, FALSE, "");
+                set_account_model_row (setup, PANEL_ACCOUNT_ROW_REMOTE, TRUE, NULL);
+                clear_account_page (setup);
+        }
+}
+
+static void
 prepare_account_page (SetupData *setup)
 {
         GtkWidget *fullname_entry;
@@ -1143,9 +1227,29 @@ prepare_account_page (SetupData *setup)
         GtkWidget *admin_check;
         GtkWidget *password_entry;
         GtkWidget *confirm_entry;
-        GtkWidget *local_account_create_button;
         GtkWidget *local_account_cancel_button;
         GtkWidget *local_account_done_button;
+        GtkTreeViewColumn *col;
+        GtkCellRenderer *cell;
+
+        if (!skip_account)
+                gtk_widget_show (WID("account-page"));
+
+        col = OBJ(GtkTreeViewColumn*, "account-list-column");
+        cell = gtk_cell_renderer_text_new ();
+        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (col), cell, FALSE);
+        gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (col), cell,
+                                            account_set_active_data, NULL, NULL);
+        cell = gtk_cell_renderer_text_new ();
+        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (col), cell, TRUE);
+        gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (col), cell, "text", PANEL_ACCOUNT_COLUMN_TITLE);
+
+        cell = gtk_cell_renderer_text_new ();
+        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (col), cell, FALSE);
+        gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (col), cell, "text", PANEL_ACCOUNT_COLUMN_NAME);
+
+        g_signal_connect (WID("account-list"), "row-activated",
+                          G_CALLBACK (account_row_activated), setup);
 
         fullname_entry = WID("account-fullname-entry");
         username_combo = WID("account-username-combo");
@@ -1153,7 +1257,6 @@ prepare_account_page (SetupData *setup)
         admin_check = WID("account-admin-check");
         password_entry = WID("account-password-entry");
         confirm_entry = WID("account-confirm-entry");
-        local_account_create_button = WID("local-account-button");
         local_account_cancel_button = WID("local-account-cancel-button");
         local_account_done_button = WID("local-account-done-button");
 
@@ -1171,8 +1274,6 @@ prepare_account_page (SetupData *setup)
                           G_CALLBACK (confirm_changed), setup);
         g_signal_connect_after (confirm_entry, "focus-out-event",
                                 G_CALLBACK (confirm_entry_focus_out), setup);
-        g_signal_connect (local_account_create_button, "clicked",
-                          G_CALLBACK (show_local_account_dialog), setup);
         g_signal_connect (local_account_cancel_button, "clicked",
                           G_CALLBACK (hide_local_account_dialog), setup);
         g_signal_connect (local_account_done_button, "clicked",
@@ -1938,10 +2039,14 @@ main (int argc, char *argv[])
 {
         SetupData *setup;
         GError *error;
+        GOptionEntry entries[] = {
+                { "skip-account", 0, 0, G_OPTION_ARG_NONE, &skip_account, "Skip account creation", NULL },
+                { NULL, 0 }
+        };
 
         setup = g_new0 (SetupData, 1);
 
-        gtk_init (&argc, &argv);
+        gtk_init_with_args (&argc, &argv, "", entries, GETTEXT_PACKAGE, NULL);
 
         error = NULL;
         if (g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error) == NULL) {
diff --git a/gui/initial-setup/setup.ui b/gui/initial-setup/setup.ui
index 1082e82..6fb3d8f 100644
--- a/gui/initial-setup/setup.ui
+++ b/gui/initial-setup/setup.ui
@@ -14,6 +14,23 @@
       <column type="guint"/>      <!-- column-name pulse -->
     </columns>
   </object>
+  <object class="GtkListStore" id="liststore-account">
+    <columns>
+      <column type="gboolean"/>   <!-- column-name active -->
+      <column type="gchararray"/> <!-- column-name title -->
+      <column type="gchararray"/> <!-- column-name name -->
+    </columns>
+    <data>
+      <row>
+        <col id="0">False</col>
+        <col id="1">Create a Local Account</col>
+      </row>
+      <row>
+        <col id="0">False</col>
+        <col id="1">Use an Enterprise Login</col>
+      </row>
+    </data>
+  </object>
   <object class="GtkListStore" id="account-username-model">
     <columns>
       <column type="gchararray"/>
@@ -344,6 +361,7 @@
                 <property name="model">liststore-wireless</property>
                 <property name="headers-visible">False</property>
                 <property name="search-column">2</property>
+                <property name="enable-grid-lines">horizontal</property>
                 <property name="show-expanders">False</property>
                 <child internal-child="selection">
                   <object class="GtkTreeSelection" id="network-list-selection">
@@ -414,7 +432,7 @@
     <child>
       <object class="GtkGrid" id="account-page">
         <property name="name">account-page</property>
-        <property name="visible">True</property>
+        <property name="visible">False</property>
         <child>
           <object class="GtkLabel" id="account-title">
             <property name="visible">True</property>
@@ -436,11 +454,37 @@
           </packing>
         </child>
         <child>
-          <object class="GtkButton" id="local-account-button">
+          <object class="GtkScrolledWindow" id="account-scrolledwindow">
             <property name="visible">True</property>
-            <property name="label" translatable="yes">Create a _Local Account</property>
-            <property name="use_underline">True</property>
-            <property name="halign">center</property>
+            <property name="halign">fill</property>
+            <property name="valign">fill</property>
+            <property name="hexpand">True</property>
+            <property name="vexpand">False</property>
+            <property name="hscrollbar-policy">never</property>
+            <property name="vscrollbar-policy">never</property>
+            <property name="shadow-type">in</property>
+            <child>
+              <object class="GtkTreeView" id="account-list">
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="hexpand">True</property>
+                <property name="vexpand">True</property>
+                <property name="halign">fill</property>
+                <property name="valign">fill</property>
+                <property name="model">liststore-account</property>
+                <property name="headers-visible">False</property>
+                <property name="enable-grid-lines">horizontal</property>
+                <property name="show-expanders">False</property>
+                <child internal-child="selection">
+                  <object class="GtkTreeSelection" id="account-list-selection">
+                    <property name="mode">none</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkTreeViewColumn" id="account-list-column"/>
+                </child>
+              </object>
+            </child>
           </object>
           <packing>
             <property name="left_attach">0</property>
@@ -449,20 +493,6 @@
             <property name="height">1</property>
           </packing>
         </child>
-        <child>
-          <object class="GtkButton" id="remote-account-button">
-            <property name="visible">True</property>
-            <property name="label" translatable="yes">Use an _Enterprise Login</property>
-            <property name="halign">center</property>
-            <property name="use_underline">True</property>
-          </object>
-          <packing>
-            <property name="left_attach">0</property>
-            <property name="top_attach">2</property>
-            <property name="width">1</property>
-            <property name="height">1</property>
-          </packing>
-        </child>
       </object>
       <packing>
         <property name="title" translatable="yes">Account</property>



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