summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2014-01-28 10:14:37 +0100
committerStefano Karapetsas <[email protected]>2014-01-28 10:14:37 +0100
commitce4d1059de86051ff25081260132c11fbc3ac4b3 (patch)
tree131de744fa567a0b1aaeb2cd5fa77591e5e42630
parentd5b35083e4de1d7457ebd937172bb0054e1fa089 (diff)
downloadmate-screensaver-ce4d1059de86051ff25081260132c11fbc3ac4b3.tar.bz2
mate-screensaver-ce4d1059de86051ff25081260132c11fbc3ac4b3.tar.xz
Show date and time in lock dialog
Closes #18 https://github.com/mate-desktop/mate-screensaver/issues/18
-rw-r--r--configure.ac2
-rw-r--r--data/lock-dialog-default.ui60
-rw-r--r--src/gs-lock-plug.c65
3 files changed, 126 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 3a093c7..9d2db45 100644
--- a/configure.ac
+++ b/configure.ac
@@ -45,7 +45,7 @@ GLIB_GSETTINGS
# Dependencies
DBUS_REQUIRED_VERSION=0.30
-GLIB_REQUIRED_VERSION=2.15.0
+GLIB_REQUIRED_VERSION=2.26.0
X11_REQUIRED_VERSION=1.0
LIBMATE_MENU_REQUIRED_VERSION=1.5.0
MATE_DESKTOP_REQUIRED_VERSION=1.7.1
diff --git a/data/lock-dialog-default.ui b/data/lock-dialog-default.ui
index 5dfa8a2..2c03ad9 100644
--- a/data/lock-dialog-default.ui
+++ b/data/lock-dialog-default.ui
@@ -49,6 +49,66 @@
<property name="homogeneous">False</property>
<property name="spacing">12</property>
<child>
+ <object class="GtkVBox" id="vbox4">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+ <child>
+ <object class="GtkLabel" id="auth-time-label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">&lt;span size="xx-large" weight="ultrabold"&gt;%s&lt;/span&gt;</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </object>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="auth-date-label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">&lt;span size="large"&gt;%s&lt;/span&gt;</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </object>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkImage" id="auth-face-image">
<property name="visible">True</property>
<property name="xalign">0.5</property>
diff --git a/src/gs-lock-plug.c b/src/gs-lock-plug.c
index 3945c1b..8b47e96 100644
--- a/src/gs-lock-plug.c
+++ b/src/gs-lock-plug.c
@@ -93,6 +93,8 @@ struct GSLockPlugPrivate
GtkWidget *notebook;
GtkWidget *auth_face_image;
+ GtkWidget *auth_time_label;
+ GtkWidget *auth_date_label;
GtkWidget *auth_realname_label;
GtkWidget *auth_username_label;
GtkWidget *auth_prompt_label;
@@ -124,6 +126,7 @@ struct GSLockPlugPrivate
guint timeout;
+ guint datetime_timeout_id;
guint cancel_timeout_id;
guint auth_check_idle_id;
guint response_idle_id;
@@ -288,6 +291,35 @@ set_status_text (GSLockPlug *plug,
}
}
+static void
+date_time_update (GSLockPlug *plug)
+{
+ GDateTime *datetime;
+ gchar *time;
+ gchar *date;
+ gchar *str;
+
+ datetime = g_date_time_new_now_local ();
+ /* Translators: Time format, see https://developer.gnome.org/glib/stable/glib-GDateTime.html#g-date-time-format */
+ time = g_date_time_format (datetime, _("%l:%M %p"));
+ /* Translators: Date format, see https://developer.gnome.org/glib/stable/glib-GDateTime.html#g-date-time-format */
+ date = g_date_time_format (datetime, _("%A, %B %e"));
+
+ str = g_strdup_printf ("<span size=\"xx-large\" weight=\"ultrabold\">%s</span>", time);
+ gtk_label_set_text (GTK_LABEL (plug->priv->auth_time_label), str);
+ gtk_label_set_use_markup (GTK_LABEL (plug->priv->auth_time_label), TRUE);
+ g_free (str);
+
+ str = g_strdup_printf ("<span size=\"large\">%s</span>", date);
+ gtk_label_set_markup (GTK_LABEL (plug->priv->auth_date_label), str);
+ gtk_label_set_use_markup (GTK_LABEL (plug->priv->auth_date_label), TRUE);
+ g_free (str);
+
+ g_free (time);
+ g_free (date);
+ g_date_time_unref (datetime);
+}
+
void
gs_lock_plug_set_sensitive (GSLockPlug *plug,
gboolean sensitive)
@@ -299,6 +331,16 @@ gs_lock_plug_set_sensitive (GSLockPlug *plug,
}
static void
+remove_datetime_timeout (GSLockPlug *plug)
+{
+ if (plug->priv->datetime_timeout_id > 0)
+ {
+ g_source_remove (plug->priv->datetime_timeout_id);
+ plug->priv->datetime_timeout_id = 0;
+ }
+}
+
+static void
remove_cancel_timeout (GSLockPlug *plug)
{
if (plug->priv->cancel_timeout_id > 0)
@@ -1898,6 +1940,23 @@ create_page_one (GSLockPlug *plug)
vbox = gtk_vbox_new (FALSE, 12);
gtk_container_add (GTK_CONTAINER (align), vbox);
+ vbox2 = gtk_vbox_new (FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
+
+ str = g_strdup ("<span size=\"xx-large\" weight=\"ultrabold\">%s</span>");
+ plug->priv->auth_time_label = gtk_label_new (str);
+ g_free (str);
+ gtk_misc_set_alignment (GTK_MISC (plug->priv->auth_time_label), 0.5, 0.5);
+ gtk_label_set_use_markup (GTK_LABEL (plug->priv->auth_time_label), TRUE);
+ gtk_box_pack_start (GTK_BOX (vbox2), plug->priv->auth_time_label, FALSE, FALSE, 0);
+
+ str = g_strdup ("<span size=\"large\">%s</span>");
+ plug->priv->auth_date_label = gtk_label_new (str);
+ g_free (str);
+ gtk_misc_set_alignment (GTK_MISC (plug->priv->auth_date_label), 0.5, 0.5);
+ gtk_label_set_use_markup (GTK_LABEL (plug->priv->auth_date_label), TRUE);
+ gtk_box_pack_start (GTK_BOX (vbox2), plug->priv->auth_date_label, FALSE, FALSE, 0);
+
plug->priv->auth_face_image = gtk_image_new ();
gtk_box_pack_start (GTK_BOX (vbox), plug->priv->auth_face_image, TRUE, TRUE, 0);
gtk_misc_set_alignment (GTK_MISC (plug->priv->auth_face_image), 0.5, 1.0);
@@ -2063,6 +2122,8 @@ load_theme (GSLockPlug *plug)
plug->priv->auth_face_image = GTK_WIDGET (gtk_builder_get_object(builder, "auth-face-image"));
plug->priv->auth_action_area = GTK_WIDGET (gtk_builder_get_object(builder, "auth-action-area"));
+ plug->priv->auth_time_label = GTK_WIDGET (gtk_builder_get_object(builder, "auth-time-label"));
+ plug->priv->auth_date_label = GTK_WIDGET (gtk_builder_get_object(builder, "auth-date-label"));
plug->priv->auth_realname_label = GTK_WIDGET (gtk_builder_get_object(builder, "auth-realname-label"));
plug->priv->auth_username_label = GTK_WIDGET (gtk_builder_get_object(builder, "auth-username-label"));
plug->priv->auth_prompt_label = GTK_WIDGET (gtk_builder_get_object(builder, "auth-prompt-label"));
@@ -2096,6 +2157,7 @@ load_theme (GSLockPlug *plug)
gtk_widget_set_no_show_all (plug->priv->auth_note_button, TRUE);
}
+ date_time_update (plug);
gtk_widget_show_all (lock_dialog);
plug->priv->status_message_label = GTK_WIDGET (gtk_builder_get_object(builder, "status-message-label"));
@@ -2158,8 +2220,10 @@ gs_lock_plug_init (GSLockPlug *plug)
create_page_one (plug);
+ date_time_update (plug);
gtk_widget_show_all (plug->priv->vbox);
}
+ plug->priv->datetime_timeout_id = g_timeout_add_seconds (1, (GSourceFunc) date_time_update, plug);
if (plug->priv->note_text_view != NULL)
{
@@ -2324,6 +2388,7 @@ gs_lock_plug_finalize (GObject *object)
remove_response_idle (plug);
remove_cancel_timeout (plug);
+ remove_datetime_timeout (plug);
#ifdef WITH_LIBNOTIFY
notify_uninit ();
#endif