@@ -72,21 +72,24 @@ static void timer_start_callback (GtkAction *action, TimerApplet *applet);
7272static void timer_pause_callback (GtkAction * action , TimerApplet * applet );
7373static void timer_stop_callback (GtkAction * action , TimerApplet * applet );
7474static void timer_about_callback (GtkAction * action , TimerApplet * applet );
75+ static void timer_reset_callback (GtkAction * action , TimerApplet * applet );
7576static void timer_preferences_callback (GtkAction * action , TimerApplet * applet );
7677
7778static const GtkActionEntry applet_menu_actions [] = {
7879 { "Start" , "media-playback-start" , N_ ("_Start timer" ), NULL , NULL , G_CALLBACK (timer_start_callback ) },
7980 { "Pause" , "media-playback-pause" , N_ ("P_ause timer" ), NULL , NULL , G_CALLBACK (timer_pause_callback ) },
8081 { "Stop" , "media-playback-stop" , N_ ("S_top timer" ), NULL , NULL , G_CALLBACK (timer_stop_callback ) },
82+ { "Reset" , "edit-undo" , N_ ("R_eset" ), NULL , NULL , G_CALLBACK (timer_reset_callback ) },
8183 { "Preferences" , "document-properties" , N_ ("_Preferences" ), NULL , NULL , G_CALLBACK (timer_preferences_callback ) },
8284 { "About" , "help-about" , N_ ("_About" ), NULL , NULL , G_CALLBACK (timer_about_callback ) }
8385};
8486
8587static char * ui = "<menuitem name='Item 1' action='Start' />"
8688 "<menuitem name='Item 2' action='Pause' />"
8789 "<menuitem name='Item 3' action='Stop' />"
88- "<menuitem name='Item 4' action='Preferences' />"
89- "<menuitem name='Item 5' action='About' />" ;
90+ "<menuitem name='Item 4' action='Reset' />"
91+ "<menuitem name='Item 5' action='Preferences' />"
92+ "<menuitem name='Item 6' action='About' />" ;
9093
9194static void
9295timer_applet_destroy (MatePanelApplet * applet_widget , TimerApplet * applet )
@@ -121,6 +124,9 @@ timer_callback (TimerApplet *applet)
121124
122125 if (!applet -> active )
123126 {
127+ applet -> pause = FALSE;
128+ applet -> elapsed = 0 ;
129+
124130 gtk_label_set_text (applet -> label , name );
125131 gtk_widget_set_tooltip_text (GTK_WIDGET (applet -> label ), "" );
126132 gtk_widget_hide (GTK_WIDGET (applet -> pause_image ));
@@ -137,7 +143,10 @@ timer_callback (TimerApplet *applet)
137143 if (remaining <= 0 )
138144 {
139145 applet -> active = FALSE;
140- gtk_label_set_text (applet -> label , _ ("Finished" ));
146+ applet -> timeout_id = 0 ;
147+
148+ label = g_strdup_printf ("Finished %s" , name );
149+ gtk_label_set_text (applet -> label , label );
141150 gtk_widget_set_tooltip_text (GTK_WIDGET (applet -> label ), name );
142151 gtk_widget_hide (GTK_WIDGET (applet -> pause_image ));
143152
@@ -197,6 +206,7 @@ timer_callback (TimerApplet *applet)
197206 gtk_action_set_sensitive (gtk_action_group_get_action (applet -> action_group , "Start" ), !applet -> active || applet -> pause );
198207 gtk_action_set_sensitive (gtk_action_group_get_action (applet -> action_group , "Pause" ), applet -> active && !applet -> pause );
199208 gtk_action_set_sensitive (gtk_action_group_get_action (applet -> action_group , "Stop" ), applet -> active );
209+ gtk_action_set_sensitive (gtk_action_group_get_action (applet -> action_group , "Reset" ), !applet -> active && !applet -> pause && applet -> elapsed );
200210 gtk_action_set_sensitive (gtk_action_group_get_action (applet -> action_group , "Preferences" ), !applet -> active && !applet -> pause );
201211
202212 g_free (name );
@@ -242,6 +252,16 @@ timer_stop_callback (GtkAction *action, TimerApplet *applet)
242252 timer_callback (applet );
243253}
244254
255+ /* reset action */
256+ static void
257+ timer_reset_callback (GtkAction * action , TimerApplet * applet )
258+ {
259+ applet -> active = FALSE;
260+ applet -> pause = FALSE;
261+ applet -> elapsed = 0 ;
262+ timer_callback (applet );
263+ }
264+
245265/* Show the about dialog */
246266static void
247267timer_about_callback (GtkAction * action , TimerApplet * applet )
@@ -359,6 +379,18 @@ timer_preferences_callback (GtkAction *action, TimerApplet *applet)
359379 gtk_widget_show_all (GTK_WIDGET (dialog ));
360380}
361381
382+ static gboolean
383+ timer_applet_click (TimerApplet * applet )
384+ {
385+ if (!applet -> active && !applet -> pause && applet -> elapsed )
386+ timer_reset_callback (NULL , applet );
387+ else if (applet -> active && !applet -> pause )
388+ timer_pause_callback (NULL , applet );
389+ else if (!applet -> active || applet -> pause )
390+ timer_start_callback (NULL , applet );
391+ return FALSE;
392+ }
393+
362394static void
363395timer_settings_changed (GSettings * settings , gchar * key , TimerApplet * applet )
364396{
@@ -412,6 +444,9 @@ timer_applet_fill (MatePanelApplet* applet_widget)
412444 G_CALLBACK (timer_applet_destroy ),
413445 applet );
414446
447+ g_signal_connect_swapped (GTK_WIDGET (applet -> applet ), "button-release-event" ,
448+ G_CALLBACK (timer_applet_click ), applet );
449+
415450 /* set up context menu */
416451 applet -> action_group = gtk_action_group_new ("Timer Applet Actions" );
417452 gtk_action_group_set_translation_domain (applet -> action_group , GETTEXT_PACKAGE );
0 commit comments