diff options
author | Stefano Karapetsas <[email protected]> | 2014-10-01 11:11:25 +0200 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2014-10-01 11:11:25 +0200 |
commit | 283c4c4212b5a6e5d2c3da3e5ca274fbe23570c5 (patch) | |
tree | a6e954b74e218e0b528ca0157782aaba00508b83 | |
parent | 72a169c50fa65c7ab2f5ba72755c548e9d583981 (diff) | |
download | mate-applets-283c4c4212b5a6e5d2c3da3e5ca274fbe23570c5.tar.bz2 mate-applets-283c4c4212b5a6e5d2c3da3e5ca274fbe23570c5.tar.xz |
timerapplet: Show the name of the timer together with icon
Closes https://github.com/mate-desktop/mate-applets/issues/98
-rw-r--r-- | timerapplet/timerapplet.c | 19 |
1 files changed, 15 insertions, 4 deletions
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; } |