[gnome-control-center] user-accounts: port history dialog to use GtkListBox
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] user-accounts: port history dialog to use GtkListBox
- Date: Mon, 16 Sep 2013 11:35:59 +0000 (UTC)
commit 3f8d1ca21e2571d8afd871239a29dff81ff429de
Author: Ondrej Holy <oholy redhat com>
Date: Mon Sep 9 16:12:50 2013 +0200
user-accounts: port history dialog to use GtkListBox
Port is necessary to be consistent across panels.
https://bugzilla.gnome.org/show_bug.cgi?id=706239
panels/user-accounts/data/history-dialog.ui | 16 +++---------
panels/user-accounts/um-history-dialog.c | 33 ++++++++++++++++----------
2 files changed, 24 insertions(+), 25 deletions(-)
---
diff --git a/panels/user-accounts/data/history-dialog.ui b/panels/user-accounts/data/history-dialog.ui
index fb4751e..4cac138 100644
--- a/panels/user-accounts/data/history-dialog.ui
+++ b/panels/user-accounts/data/history-dialog.ui
@@ -128,20 +128,12 @@
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
- <object class="GtkViewport" id="viewport1">
+ <object class="GtkListBox" id="history-box">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <child>
- <object class="GtkGrid" id="history-grid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="border_width">12</property>
- <property name="row_spacing">12</property>
- <property name="column_spacing">12</property>
- <property name="column_homogeneous">True</property>
- </object>
- </child>
+ <property name="hexpand">True</property>
+ <property name="border_width">12</property>
+ <property name="selection_mode">none</property>
</object>
</child>
</object>
diff --git a/panels/user-accounts/um-history-dialog.c b/panels/user-accounts/um-history-dialog.c
index 13df362..4ec2983 100644
--- a/panels/user-accounts/um-history-dialog.c
+++ b/panels/user-accounts/um-history-dialog.c
@@ -123,13 +123,13 @@ show_week_label (UmHistoryDialog *um)
static void
clear_history (UmHistoryDialog *um)
{
- GtkWidget *grid;
+ GtkWidget *box;
GList *list, *it;
- grid = get_widget (um, "history-grid");
- list = gtk_container_get_children (GTK_CONTAINER (grid));
+ box = get_widget (um, "history-box");
+ list = gtk_container_get_children (GTK_CONTAINER (box));
for (it = list; it != NULL; it = it->next) {
- gtk_container_remove (GTK_CONTAINER (grid), GTK_WIDGET (it->data));
+ gtk_container_remove (GTK_CONTAINER (box), GTK_WIDGET (it->data));
}
g_list_free (list);
}
@@ -184,10 +184,10 @@ set_sensitivity (UmHistoryDialog *um)
}
static void
-add_record (GtkWidget *grid, GDateTime *datetime, gchar *record_string, gint line)
+add_record (GtkWidget *box, GDateTime *datetime, gchar *record_string, gint line)
{
gchar *date, *time, *str;
- GtkWidget *label;
+ GtkWidget *label, *row;
date = get_smart_date (datetime);
/* Translators: This is a time format string in the style of "22:58".
@@ -196,9 +196,14 @@ add_record (GtkWidget *grid, GDateTime *datetime, gchar *record_string, gint lin
/* Translators: This indicates a login date-time.
The first %s is a date, and the second %s a time. */
str = g_strdup_printf(C_("login date-time", "%s, %s"), date, time);
+
+ row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+ gtk_box_set_homogeneous (GTK_BOX (row), TRUE);
+ gtk_container_set_border_width (GTK_CONTAINER (row), 6);
+
label = gtk_label_new (str);
gtk_widget_set_halign (label, GTK_ALIGN_START);
- gtk_grid_attach (GTK_GRID (grid), label, 1, line, 1, 1);
+ gtk_box_pack_start (GTK_BOX (row), label, TRUE, TRUE, 0);
g_free (str);
g_free (date);
g_free (time);
@@ -206,7 +211,9 @@ add_record (GtkWidget *grid, GDateTime *datetime, gchar *record_string, gint lin
label = gtk_label_new (record_string);
gtk_widget_set_halign (label, GTK_ALIGN_START);
- gtk_grid_attach (GTK_GRID (grid), label, 2, line, 1, 1);
+ gtk_box_pack_start (GTK_BOX (row), label, TRUE, TRUE, 0);
+
+ gtk_list_box_insert (GTK_LIST_BOX (box), row, line);
}
static void
@@ -216,7 +223,7 @@ show_week (UmHistoryDialog *um)
GDateTime *datetime, *temp;
gint64 from, to;
gint i, line;
- GtkWidget *grid;
+ GtkWidget *box;
UmLoginHistory history;
show_week_label (um);
@@ -241,7 +248,7 @@ show_week (UmHistoryDialog *um)
}
/* Add new session records */
- grid = get_widget (um, "history-grid");
+ box = get_widget (um, "history-box");
line = 0;
for (;i >= 0; i--) {
history = g_array_index (login_history, UmLoginHistory, i);
@@ -257,18 +264,18 @@ show_week (UmHistoryDialog *um)
if (history.logout_time > 0 && history.logout_time < to) {
datetime = g_date_time_new_from_unix_local (history.logout_time);
- add_record (grid, datetime, _("Session Ended"), line);
+ add_record (box, datetime, _("Session Ended"), line);
line++;
}
if (history.login_time >= from) {
datetime = g_date_time_new_from_unix_local (history.login_time);
- add_record (grid, datetime, _("Session Started"), line);
+ add_record (box, datetime, _("Session Started"), line);
line++;
}
}
- gtk_widget_show_all (grid);
+ gtk_widget_show_all (box);
g_array_free (login_history, TRUE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]