[gnome-initial-setup] accounts: Replace list store hacks with a button box
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup] accounts: Replace list store hacks with a button box
- Date: Fri, 22 Jun 2012 21:14:51 +0000 (UTC)
commit d739f1e965aa537108647ccaf458efbc9131ef16
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu Jun 21 16:27:07 2012 -0400
accounts: Replace list store hacks with a button box
We'll theme it later.
gnome-initial-setup/gis-account-page.c | 133 +------------------------------
gnome-initial-setup/setup.ui | 50 +++----------
2 files changed, 15 insertions(+), 168 deletions(-)
---
diff --git a/gnome-initial-setup/gis-account-page.c b/gnome-initial-setup/gis-account-page.c
index 9679bb7..65b5056 100644
--- a/gnome-initial-setup/gis-account-page.c
+++ b/gnome-initial-setup/gis-account-page.c
@@ -1,17 +1,6 @@
/* 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
@@ -283,29 +272,6 @@ 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;
-
- 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);
-
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- PANEL_ACCOUNT_COLUMN_ACTIVE, active,
- -1);
-
- if (name != NULL) {
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- PANEL_ACCOUNT_COLUMN_NAME, name,
- -1);
- }
-}
-
-static void
clear_account_page (SetupData *setup)
{
GtkWidget *fullname_entry;
@@ -341,8 +307,6 @@ 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
@@ -401,7 +365,8 @@ save_account_data (SetupData *setup)
}
static void
-show_local_account_dialog (SetupData *setup)
+show_local_account_dialog (GtkWidget *button,
+ SetupData *setup)
{
GtkWidget *dialog;
@@ -426,79 +391,7 @@ static void
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;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gboolean valid;
- gint type;
-
- model = gtk_tree_view_get_model (tv);
- valid = gtk_tree_model_get_iter_first (model, &iter);
-
- while (valid) {
- GtkTreePath *iter_path = gtk_tree_model_get_path (model, &iter);
-
- if (gtk_tree_path_compare (path, iter_path) == 0) {
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- PANEL_ACCOUNT_COLUMN_ACTIVE, TRUE,
- -1);
- } else {
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- PANEL_ACCOUNT_COLUMN_ACTIVE, FALSE,
- PANEL_ACCOUNT_COLUMN_NAME, "",
- -1);
- }
-
- gtk_tree_path_free (iter_path);
-
- valid = gtk_tree_model_iter_next (model, &iter);
- }
-
- type = gtk_tree_path_get_indices (path)[0];
-
- switch (type) {
- case PANEL_ACCOUNT_ROW_LOCAL:
- show_local_account_dialog (setup);
- break;
- case PANEL_ACCOUNT_ROW_REMOTE:
- clear_account_page (setup);
- break;
- default:
- break;
- }
+ gtk_widget_hide (WID("local-account-dialog"));
}
static void
@@ -546,28 +439,12 @@ prepare_account_page (SetupData *setup)
GtkWidget *local_account_cancel_button;
GtkWidget *local_account_done_button;
GtkWidget *local_account_avatar_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);
- g_object_set (cell, "width", 400, NULL);
-
- 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);
+ g_signal_connect (WID("account-new-local"), "clicked",
+ G_CALLBACK (show_local_account_dialog), setup);
fullname_entry = WID("account-fullname-entry");
username_combo = WID("account-username-combo");
diff --git a/gnome-initial-setup/setup.ui b/gnome-initial-setup/setup.ui
index 49a6c31..d16ef15 100644
--- a/gnome-initial-setup/setup.ui
+++ b/gnome-initial-setup/setup.ui
@@ -14,23 +14,6 @@
<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"/>
@@ -463,32 +446,19 @@
</packing>
</child>
<child>
- <object class="GtkScrolledWindow" id="account-scrolledwindow">
+ <object class="GtkButtonBox" id="account-buttons">
<property name="visible">True</property>
- <property name="halign">fill</property>
- <property name="valign">fill</property>
- <property name="vexpand">False</property>
- <property name="hscrollbar-policy">never</property>
- <property name="vscrollbar-policy">never</property>
- <property name="shadow-type">in</property>
+ <property name="orientation">vertical</property>
<child>
- <object class="GtkTreeView" id="account-list">
+ <object class="GtkButton" id="account-new-local">
<property name="visible">True</property>
- <property name="can-focus">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>
+ <property name="label" translatable="yes">Create a Local Account</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="account-enterprise-login">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Use an Enterprise Login</property>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]