[gnome-control-center/wip/feborges/new-users-panel: 18/20] user-accounts: Change "Account Activity" granularity to days
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/feborges/new-users-panel: 18/20] user-accounts: Change "Account Activity" granularity to days
- Date: Wed, 29 Jun 2016 12:08:32 +0000 (UTC)
commit 5950f60945f0ca874a1b9678580fe9ddcfcd5af0
Author: Felipe Borges <felipeborges gnome org>
Date: Tue Jun 21 14:37:54 2016 +0200
user-accounts: Change "Account Activity" granularity to days
Before we were grouping the "Account Activity" data in weeks.
Now we group them in days.
This change is part of the effort towards the redesign specified
at https://wiki.gnome.org/Design/SystemSettings/UserAccounts
https://bugzilla.gnome.org/show_bug.cgi?id=767065
panels/user-accounts/um-history-dialog.c | 90 +++++++++++++-----------------
1 files changed, 39 insertions(+), 51 deletions(-)
---
diff --git a/panels/user-accounts/um-history-dialog.c b/panels/user-accounts/um-history-dialog.c
index db9c05a..a02cae6 100644
--- a/panels/user-accounts/um-history-dialog.c
+++ b/panels/user-accounts/um-history-dialog.c
@@ -39,8 +39,8 @@ struct _UmHistoryDialog {
GtkWidget *dialog;
GtkBuilder *builder;
- GDateTime *week;
- GDateTime *current_week;
+ GDateTime *day;
+ GDateTime *current_day;
ActUser *user;
};
@@ -59,42 +59,31 @@ get_widget (UmHistoryDialog *um,
}
static void
-show_week_label (UmHistoryDialog *um)
+show_day_label (UmHistoryDialog *um)
{
- gchar *label, *from, *to;
+ gchar *label, *day;
GDateTime *date;
GTimeSpan span;
- span = g_date_time_difference (um->current_week, um->week);
+ span = g_date_time_difference (um->current_day, um->day);
if (span == 0) {
- label = g_strdup (_("This Week"));
+ label = g_strdup (_("Today"));
}
- else if (span == G_TIME_SPAN_DAY * 7) {
- label = g_strdup (_("Last Week"));
+ else if (span == G_TIME_SPAN_DAY) {
+ label = g_strdup (_("Yesterday"));
}
else {
- date = g_date_time_add_days (um->week, 6);
+ date = g_date_time_add_days (um->day, 1);
/* Translators: This is a date format string in the style of "Feb 18",
- shown as the first day of a week on login history dialog. */
- from = g_date_time_format (um->week, C_("login history week label","%b %e"));
- if (g_date_time_get_year (um->week) == g_date_time_get_year (um->current_week)) {
- /* Translators: This is a date format string in the style of "Feb 24",
- shown as the last day of a week on login history dialog. */
- to = g_date_time_format (date, C_("login history week label","%b %e"));
- }
- else {
- /* Translators: This is a date format string in the style of "Feb 24, 2013",
- shown as the last day of a week on login history dialog. */
- to = g_date_time_format (date, C_("login history week label","%b %e, %Y"));
- }
+ shown as the day number on login history dialog. */
+ day = g_date_time_format (um->day, C_("login history day label","%b %e"));
- /* Translators: This indicates a week label on a login history.
- The first %s is the first day of a week, and the second %s the last day. */
- label = g_strdup_printf(C_("login history week label", "%s - %s"), from, to);
+ /* Translators: This indicates a day label on a login history.
+ The %s is the day label. */
+ label = g_strdup_printf(C_("login history day label", "%s"), day);
g_date_time_unref (date);
- g_free (from);
- g_free (to);
+ g_free (day);
}
gtk_header_bar_set_subtitle (GTK_HEADER_BAR (get_widget (um, "dialog-header-bar")), label);
@@ -156,12 +145,12 @@ set_sensitivity (UmHistoryDialog *um)
login_history = get_login_history (um->user);
if (login_history != NULL) {
history = g_array_index (login_history, UmLoginHistory, 0);
- sensitive = g_date_time_to_unix (um->week) > history.login_time;
+ sensitive = g_date_time_to_unix (um->day) > history.login_time;
g_array_free (login_history, TRUE);
}
gtk_widget_set_sensitive (get_widget (um, "previous-button"), sensitive);
- sensitive = (g_date_time_compare (um->current_week, um->week) == 1);
+ sensitive = (g_date_time_compare (um->current_day, um->day) == 1);
gtk_widget_set_sensitive (get_widget (um, "next-button"), sensitive);
}
@@ -199,7 +188,7 @@ add_record (GtkWidget *box, GDateTime *datetime, gchar *record_string, gint line
}
static void
-show_week (UmHistoryDialog *um)
+show_day (UmHistoryDialog *um)
{
GArray *login_history;
GDateTime *datetime, *temp;
@@ -208,7 +197,7 @@ show_week (UmHistoryDialog *um)
GtkWidget *box;
UmLoginHistory history;
- show_week_label (um);
+ show_day_label (um);
clear_history (um);
set_sensitivity (um);
@@ -217,9 +206,9 @@ show_week (UmHistoryDialog *um)
return;
}
- /* Find first record for week */
- from = g_date_time_to_unix (um->week);
- temp = g_date_time_add_weeks (um->week, 1);
+ /* Find first record for day */
+ from = g_date_time_to_unix (um->day);
+ temp = g_date_time_add_days (um->day, 1);
to = g_date_time_to_unix (temp);
g_date_time_unref (temp);
for (i = login_history->len - 1; i >= 0; i--) {
@@ -268,11 +257,11 @@ show_previous (GtkButton *button,
{
GDateTime *temp;
- temp = um->week;
- um->week = g_date_time_add_weeks (um->week, -1);
+ temp = um->day;
+ um->day = g_date_time_add_days (um->day, -1);
g_date_time_unref (temp);
- show_week (um);
+ show_day (um);
}
static void
@@ -281,11 +270,11 @@ show_next (GtkButton *button,
{
GDateTime *temp;
- temp = um->week;
- um->week = g_date_time_add_weeks (um->week, 1);
+ temp = um->day;
+ um->day = g_date_time_add_days (um->day, 1);
g_date_time_unref (temp);
- show_week (um);
+ show_day (um);
}
static void
@@ -324,23 +313,22 @@ um_history_dialog_show (UmHistoryDialog *um,
{
GDateTime *temp, *local;
- if (um->week)
- g_date_time_unref (um->week);
- if (um->current_week)
- g_date_time_unref (um->current_week);
+ if (um->day)
+ g_date_time_unref (um->day);
+ if (um->current_day)
+ g_date_time_unref (um->current_day);
- /* Set the first day of this week */
local = g_date_time_new_now_local ();
temp = g_date_time_new_local (g_date_time_get_year (local),
g_date_time_get_month (local),
g_date_time_get_day_of_month (local),
0, 0, 0);
- um->week = g_date_time_add_days (temp, 1 - g_date_time_get_day_of_week (temp));
- um->current_week = g_date_time_ref (um->week);
+ um->day = g_date_time_add_days (temp, 1 );
+ um->current_day = g_date_time_ref (um->day);
g_date_time_unref (local);
g_date_time_unref (temp);
- show_week (um);
+ show_day (um);
gtk_window_set_transient_for (GTK_WINDOW (um->dialog), parent);
gtk_window_present (GTK_WINDOW (um->dialog));
@@ -394,12 +382,12 @@ um_history_dialog_free (UmHistoryDialog *um)
g_clear_object (&um->user);
g_clear_object (&um->builder);
- if (um->week) {
- g_date_time_unref (um->week);
+ if (um->day) {
+ g_date_time_unref (um->day);
}
- if (um->current_week) {
- g_date_time_unref (um->current_week);
+ if (um->current_day) {
+ g_date_time_unref (um->current_day);
}
g_free (um);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]