user-accounts: Rename UmHistoryDialog to CcLoginHistoryDialog

Um is a naming hangover from before this was part of g-c-c.
This commit is contained in:
Robert Ancell 2018-11-07 09:38:10 +13:00 committed by Ondrej Holy
parent 5eec53c52c
commit 3eaf71065e
7 changed files with 87 additions and 88 deletions

View file

@ -30,13 +30,12 @@
#include <gtk/gtk.h>
#include <act/act.h>
#include "cc-login-history-dialog.h"
#include "cc-util.h"
#include "um-history-dialog.h"
#include "um-resources.h"
#include "um-utils.h"
struct _UmHistoryDialog
struct _CcLoginHistoryDialog
{
GtkDialog parent_instance;
@ -51,21 +50,21 @@ struct _UmHistoryDialog
ActUser *user;
};
G_DEFINE_TYPE (UmHistoryDialog, um_history_dialog, GTK_TYPE_DIALOG)
G_DEFINE_TYPE (CcLoginHistoryDialog, cc_login_history_dialog, GTK_TYPE_DIALOG)
typedef struct {
gint64 login_time;
gint64 logout_time;
const gchar *type;
} UmLoginHistory;
} CcLoginHistory;
static void
show_week_label (UmHistoryDialog *um)
show_week_label (CcLoginHistoryDialog *self)
{
g_autofree gchar *label = NULL;
GTimeSpan span;
span = g_date_time_difference (um->current_week, um->week);
span = g_date_time_difference (self->current_week, self->week);
if (span == 0) {
label = g_strdup (_("This Week"));
}
@ -77,11 +76,11 @@ show_week_label (UmHistoryDialog *um)
g_autofree gchar *to = NULL;
g_autoptr(GDateTime) date = NULL;
date = g_date_time_add_days (um->week, 6);
date = g_date_time_add_days (self->week, 6);
/* 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)) {
from = g_date_time_format (self->week, C_("login history week label","%b %e"));
if (g_date_time_get_year (self->week) == g_date_time_get_year (self->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"));
@ -97,18 +96,18 @@ show_week_label (UmHistoryDialog *um)
label = g_strdup_printf(C_("login history week label", "%s — %s"), from, to);
}
gtk_header_bar_set_subtitle (um->header_bar, label);
gtk_header_bar_set_subtitle (self->header_bar, label);
}
static void
clear_history (UmHistoryDialog *um)
clear_history (CcLoginHistoryDialog *self)
{
g_autoptr(GList) list = NULL;
GList *it;
list = gtk_container_get_children (GTK_CONTAINER (um->history_box));
list = gtk_container_get_children (GTK_CONTAINER (self->history_box));
for (it = list; it != NULL; it = it->next) {
gtk_container_remove (GTK_CONTAINER (um->history_box), GTK_WIDGET (it->data));
gtk_container_remove (GTK_CONTAINER (self->history_box), GTK_WIDGET (it->data));
}
}
@ -120,7 +119,7 @@ get_login_history (ActUser *user)
GVariant *variant;
const GVariant *value;
const gchar *key;
UmLoginHistory history;
CcLoginHistory history;
login_history = NULL;
value = act_user_get_login_history (user);
@ -133,7 +132,7 @@ get_login_history (ActUser *user)
}
if (login_history == NULL) {
login_history = g_array_new (FALSE, TRUE, sizeof (UmLoginHistory));
login_history = g_array_new (FALSE, TRUE, sizeof (CcLoginHistory));
}
g_array_append_val (login_history, history);
@ -143,25 +142,25 @@ get_login_history (ActUser *user)
}
static void
set_sensitivity (UmHistoryDialog *um)
set_sensitivity (CcLoginHistoryDialog *self)
{
g_autoptr(GArray) login_history = NULL;
UmLoginHistory history;
CcLoginHistory history;
gboolean sensitive = FALSE;
login_history = get_login_history (um->user);
login_history = get_login_history (self->user);
if (login_history != NULL) {
history = g_array_index (login_history, UmLoginHistory, 0);
sensitive = g_date_time_to_unix (um->week) > history.login_time;
history = g_array_index (login_history, CcLoginHistory, 0);
sensitive = g_date_time_to_unix (self->week) > history.login_time;
}
gtk_widget_set_sensitive (GTK_WIDGET (um->previous_button), sensitive);
gtk_widget_set_sensitive (GTK_WIDGET (self->previous_button), sensitive);
sensitive = (g_date_time_compare (um->current_week, um->week) == 1);
gtk_widget_set_sensitive (GTK_WIDGET (um->next_button), sensitive);
sensitive = (g_date_time_compare (self->current_week, self->week) == 1);
gtk_widget_set_sensitive (GTK_WIDGET (self->next_button), sensitive);
}
static void
add_record (UmHistoryDialog *um, GDateTime *datetime, gchar *record_string, gint line)
add_record (CcLoginHistoryDialog *self, GDateTime *datetime, gchar *record_string, gint line)
{
g_autofree gchar *date = NULL;
g_autofree gchar *time = NULL;
@ -191,34 +190,34 @@ add_record (UmHistoryDialog *um, GDateTime *datetime, gchar *record_string, gint
gtk_widget_set_halign (label, GTK_ALIGN_START);
gtk_box_pack_start (GTK_BOX (row), label, TRUE, TRUE, 0);
gtk_list_box_insert (um->history_box, row, line);
gtk_list_box_insert (self->history_box, row, line);
}
static void
show_week (UmHistoryDialog *um)
show_week (CcLoginHistoryDialog *self)
{
g_autoptr(GArray) login_history = NULL;
g_autoptr(GDateTime) datetime = NULL;
g_autoptr(GDateTime) temp = NULL;
gint64 from, to;
gint i, line;
UmLoginHistory history;
CcLoginHistory history;
show_week_label (um);
clear_history (um);
set_sensitivity (um);
show_week_label (self);
clear_history (self);
set_sensitivity (self);
login_history = get_login_history (um->user);
login_history = get_login_history (self->user);
if (login_history == NULL) {
return;
}
/* Find first record for week */
from = g_date_time_to_unix (um->week);
temp = g_date_time_add_weeks (um->week, 1);
from = g_date_time_to_unix (self->week);
temp = g_date_time_add_weeks (self->week, 1);
to = g_date_time_to_unix (temp);
for (i = login_history->len - 1; i >= 0; i--) {
history = g_array_index (login_history, UmLoginHistory, i);
history = g_array_index (login_history, CcLoginHistory, i);
if (history.login_time < to) {
break;
}
@ -227,7 +226,7 @@ show_week (UmHistoryDialog *um)
/* Add new session records */
line = 0;
for (;i >= 0; i--) {
history = g_array_index (login_history, UmLoginHistory, i);
history = g_array_index (login_history, CcLoginHistory, i);
/* Display only x-session and tty records */
if (!g_str_has_prefix (history.type, ":") &&
@ -241,94 +240,94 @@ 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 (um, datetime, _("Session Ended"), line);
add_record (self, datetime, _("Session Ended"), line);
line++;
}
if (history.login_time >= from) {
datetime = g_date_time_new_from_unix_local (history.login_time);
add_record (um, datetime, _("Session Started"), line);
add_record (self, datetime, _("Session Started"), line);
line++;
}
}
}
static void
previous_button_clicked_cb (UmHistoryDialog *um)
previous_button_clicked_cb (CcLoginHistoryDialog *self)
{
g_autoptr(GDateTime) temp = NULL;
temp = um->week;
um->week = g_date_time_add_weeks (um->week, -1);
temp = self->week;
self->week = g_date_time_add_weeks (self->week, -1);
show_week (um);
show_week (self);
}
static void
next_button_clicked_cb (UmHistoryDialog *um)
next_button_clicked_cb (CcLoginHistoryDialog *self)
{
g_autoptr(GDateTime) temp = NULL;
temp = um->week;
um->week = g_date_time_add_weeks (um->week, 1);
temp = self->week;
self->week = g_date_time_add_weeks (self->week, 1);
show_week (um);
show_week (self);
}
static void
um_history_dialog_dispose (GObject *object)
cc_login_history_dialog_dispose (GObject *object)
{
UmHistoryDialog *um = UM_HISTORY_DIALOG (object);
CcLoginHistoryDialog *self = CC_LOGIN_HISTORY_DIALOG (object);
g_clear_object (&um->user);
g_clear_pointer (&um->week, g_date_time_unref);
g_clear_pointer (&um->current_week, g_date_time_unref);
g_clear_object (&self->user);
g_clear_pointer (&self->week, g_date_time_unref);
g_clear_pointer (&self->current_week, g_date_time_unref);
G_OBJECT_CLASS (um_history_dialog_parent_class)->dispose (object);
G_OBJECT_CLASS (cc_login_history_dialog_parent_class)->dispose (object);
}
void
um_history_dialog_class_init (UmHistoryDialogClass *klass)
cc_login_history_dialog_class_init (CcLoginHistoryDialogClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->dispose = um_history_dialog_dispose;
object_class->dispose = cc_login_history_dialog_dispose;
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/user-accounts/um-history-dialog.ui");
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/user-accounts/cc-login-history-dialog.ui");
gtk_widget_class_bind_template_child (widget_class, UmHistoryDialog, header_bar);
gtk_widget_class_bind_template_child (widget_class, UmHistoryDialog, history_box);
gtk_widget_class_bind_template_child (widget_class, UmHistoryDialog, next_button);
gtk_widget_class_bind_template_child (widget_class, UmHistoryDialog, previous_button);
gtk_widget_class_bind_template_child (widget_class, CcLoginHistoryDialog, header_bar);
gtk_widget_class_bind_template_child (widget_class, CcLoginHistoryDialog, history_box);
gtk_widget_class_bind_template_child (widget_class, CcLoginHistoryDialog, next_button);
gtk_widget_class_bind_template_child (widget_class, CcLoginHistoryDialog, previous_button);
gtk_widget_class_bind_template_callback (widget_class, next_button_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, previous_button_clicked_cb);
}
void
um_history_dialog_init (UmHistoryDialog *um)
cc_login_history_dialog_init (CcLoginHistoryDialog *self)
{
g_resources_register (um_get_resource ());
gtk_widget_init_template (GTK_WIDGET (um));
gtk_widget_init_template (GTK_WIDGET (self));
}
UmHistoryDialog *
um_history_dialog_new (ActUser *user)
CcLoginHistoryDialog *
cc_login_history_dialog_new (ActUser *user)
{
UmHistoryDialog *um;
CcLoginHistoryDialog *self;
g_autoptr(GDateTime) temp = NULL;
g_autoptr(GDateTime) local = NULL;
g_autofree gchar *title = NULL;
g_return_val_if_fail (ACT_IS_USER (user), NULL);
um = g_object_new (UM_TYPE_HISTORY_DIALOG,
"use-header-bar", 1,
NULL);
self = g_object_new (CC_TYPE_LOGIN_HISTORY_DIALOG,
"use-header-bar", 1,
NULL);
um->user = g_object_ref (user);
self->user = g_object_ref (user);
/* Set the first day of this week */
local = g_date_time_new_now_local ();
@ -336,16 +335,16 @@ um_history_dialog_new (ActUser *user)
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);
self->week = g_date_time_add_days (temp, 1 - g_date_time_get_day_of_week (temp));
self->current_week = g_date_time_ref (self->week);
/* Translators: This is the title of the "Account Activity" dialog.
The %s is the user real name. */
title = g_strdup_printf (_("%s — Account Activity"),
act_user_get_real_name (um->user));
gtk_header_bar_set_title (um->header_bar, title);
act_user_get_real_name (self->user));
gtk_header_bar_set_title (self->header_bar, title);
show_week (um);
show_week (self);
return um;
return self;
}

View file

@ -25,9 +25,9 @@
G_BEGIN_DECLS
#define UM_TYPE_HISTORY_DIALOG (um_history_dialog_get_type ())
G_DECLARE_FINAL_TYPE (UmHistoryDialog, um_history_dialog, UM, HISTORY_DIALOG, GtkDialog)
#define CC_TYPE_LOGIN_HISTORY_DIALOG (cc_login_history_dialog_get_type ())
G_DECLARE_FINAL_TYPE (CcLoginHistoryDialog, cc_login_history_dialog, CC, LOGIN_HISTORY_DIALOG, GtkDialog)
UmHistoryDialog *um_history_dialog_new (ActUser *user);
CcLoginHistoryDialog *cc_login_history_dialog_new (ActUser *user);
G_END_DECLS

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.8 -->
<template class="UmHistoryDialog" parent="GtkDialog">
<template class="CcLoginHistoryDialog" parent="GtkDialog">
<property name="can_focus">False</property>
<property name="resizable">False</property>
<property name="modal">True</property>
@ -24,7 +24,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="valign">center</property>
<signal name="clicked" handler="previous_button_clicked_cb" object="UmHistoryDialog" swapped="yes"/>
<signal name="clicked" handler="previous_button_clicked_cb" object="CcLoginHistoryDialog" swapped="yes"/>
<style>
<class name="image-button"/>
</style>
@ -47,7 +47,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="valign">center</property>
<signal name="clicked" handler="next_button_clicked_cb" object="UmHistoryDialog" swapped="yes"/>
<signal name="clicked" handler="next_button_clicked_cb" object="CcLoginHistoryDialog" swapped="yes"/>
<style>
<class name="image-button"/>
</style>

View file

@ -42,13 +42,13 @@
#include "um-account-dialog.h"
#include "cc-language-chooser.h"
#include "cc-login-history-dialog.h"
#include "cc-password-dialog.h"
#include "um-carousel.h"
#include "um-photo-dialog.h"
#include "um-fingerprint-dialog.h"
#include "um-utils.h"
#include "um-resources.h"
#include "um-history-dialog.h"
#include "cc-common-language.h"
#include "cc-util.h"
@ -1070,13 +1070,13 @@ change_fingerprint (CcUserPanel *self)
static void
show_history (CcUserPanel *self)
{
UmHistoryDialog *dialog;
CcLoginHistoryDialog *dialog;
ActUser *user;
GtkWindow *parent;
gint parent_width;
user = get_selected_user (self);
dialog = um_history_dialog_new (user);
dialog = cc_login_history_dialog_new (user);
parent = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self)));
gtk_window_get_size (parent, &parent_width, NULL);

View file

@ -101,6 +101,7 @@ common_sources = files(
)
resource_data = files(
'cc-login-history-dialog.ui',
'cc-password-dialog.ui',
'cc-user-panel.ui',
'data/icons/left-index-finger.png',
@ -121,7 +122,6 @@ resource_data = files(
'data/carousel.ui',
'data/join-dialog.ui',
'data/user-accounts-dialog.css',
'um-history-dialog.ui',
)
common_sources += gnome.compile_resources(
@ -145,12 +145,12 @@ common_sources += gnome.gdbus_codegen(
sources = common_sources + files(
'cc-crop-area.c',
'cc-login-history-dialog.c',
'cc-password-dialog.c',
'cc-user-panel.c',
'run-passwd.c',
'um-carousel.c',
'um-fingerprint-dialog.c',
'um-history-dialog.c',
'um-photo-dialog.c',
'um-user-image.c',
)

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/control-center/user-accounts">
<file preprocess="xml-stripblanks">cc-login-history-dialog.ui</file>
<file preprocess="xml-stripblanks">cc-password-dialog.ui</file>
<file preprocess="xml-stripblanks">cc-user-panel.ui</file>
<file alias="account-dialog.ui" preprocess="xml-stripblanks">data/account-dialog.ui</file>
@ -22,6 +23,5 @@
<file alias="right-little-finger.png">data/icons/right-little-finger.png</file>
<file alias="right-ring-finger.png">data/icons/right-ring-finger.png</file>
<file alias="right-thumb.png">data/icons/right-thumb.png</file>
<file preprocess="xml-stripblanks">um-history-dialog.ui</file>
</gresource>
</gresources>

View file

@ -193,6 +193,8 @@ panels/universal-access/gnome-universal-access-panel.desktop.in.in
panels/universal-access/uap.ui
panels/universal-access/zoom-options.c
panels/universal-access/zoom-options.ui
panels/user-accounts/cc-login-history-dialog.c
panels/user-accounts/cc-login-history-dialog.ui
panels/user-accounts/cc-password-dialog.c
panels/user-accounts/cc-password-dialog.ui
panels/user-accounts/cc-user-panel.c
@ -207,8 +209,6 @@ panels/user-accounts/pw-utils.c
panels/user-accounts/run-passwd.c
panels/user-accounts/um-account-dialog.c
panels/user-accounts/um-fingerprint-dialog.c
panels/user-accounts/um-history-dialog.c
panels/user-accounts/um-history-dialog.ui
panels/user-accounts/um-photo-dialog.c
panels/user-accounts/um-realm-manager.c
panels/user-accounts/um-utils.c