From 283c4c4212b5a6e5d2c3da3e5ca274fbe23570c5 Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Wed, 1 Oct 2014 11:11:25 +0200 Subject: timerapplet: Show the name of the timer together with icon Closes https://github.com/mate-desktop/mate-applets/issues/98 --- timerapplet/timerapplet.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'timerapplet') diff --git a/timerapplet/timerapplet.c b/timerapplet/timerapplet.c index e5cda715..c5ff8a45 100644 --- a/timerapplet/timerapplet.c +++ b/timerapplet/timerapplet.c @@ -115,12 +115,13 @@ timer_callback (TimerApplet *applet) gint hours, minutes, seconds, duration, remaining; label = NULL; - name = NULL; tooltip = NULL; + name = g_settings_get_string (applet->settings, NAME_KEY); + if (!applet->active) { - gtk_label_set_text (applet->label, ""); + gtk_label_set_text (applet->label, name); gtk_widget_set_tooltip_text (GTK_WIDGET (applet->label), ""); gtk_widget_hide (GTK_WIDGET (applet->pause_image)); } @@ -130,7 +131,6 @@ timer_callback (TimerApplet *applet) applet->elapsed += STEP; duration = g_settings_get_int (applet->settings, DURATION_KEY); - name = g_settings_get_string (applet->settings, NAME_KEY); remaining = duration - (applet->elapsed / 1000); @@ -190,7 +190,6 @@ timer_callback (TimerApplet *applet) } g_free (label); - g_free (name); g_free (tooltip); } @@ -200,6 +199,8 @@ timer_callback (TimerApplet *applet) gtk_action_set_sensitive (gtk_action_group_get_action (applet->action_group, "Stop"), applet->active); gtk_action_set_sensitive (gtk_action_group_get_action (applet->action_group, "Preferences"), !applet->active && !applet->pause); + g_free (name); + return retval; } @@ -370,6 +371,12 @@ timer_preferences_callback (GtkAction *action, TimerApplet *applet) gtk_widget_show_all (GTK_WIDGET (dialog)); } +static void +timer_settings_changed (GSettings *settings, gchar *key, TimerApplet *applet) +{ + timer_callback (applet); +} + static gboolean timer_applet_fill (MatePanelApplet* applet_widget) { @@ -427,6 +434,10 @@ timer_applet_fill (MatePanelApplet* applet_widget) /* execute callback to set actions sensitiveness */ timer_callback (applet); + /* GSettings callback */ + g_signal_connect (G_OBJECT (applet->settings), "changed", + G_CALLBACK (timer_settings_changed), applet); + return TRUE; } -- cgit v1.2.1