~cairo-dock-team/cairo-dock-plug-ins/plug-ins

« back to all changes in this revision

Viewing changes to clock/src/applet-init.c

  • Committer: Matthieu Baerts
  • Date: 2012-11-27 13:52:41 UTC
  • Revision ID: matttbe@gmail.com-20121127135241-y6o25xa6r54lf2q7
Clock: if seconds are not shown, redrawn the applet each time at 00 second
Before the timer wasn't started with a delay and the applet was redrawn between 00 and 60 seconds

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
        pInterface->save_custom_widget = cd_clock_save_custom_widget;
50
50
CD_APPLET_DEFINE_END
51
51
 
 
52
static gboolean _cd_check_new_minute (CairoDockModuleInstance *myApplet)
 
53
{
 
54
        myData.iSidUpdateClock = g_timeout_add_seconds (60,
 
55
                (GSourceFunc) cd_clock_update_with_time,
 
56
                (gpointer) myApplet); // this new g_timeout should start approximately at 00" (between 00" and 01" ; better than between [00-60])
 
57
        cd_clock_update_with_time (myApplet); // update the time right now and not after 60sec
 
58
        return FALSE;
 
59
}
 
60
 
 
61
static void _cd_launch_timer (CairoDockModuleInstance *myApplet)
 
62
{
 
63
        cd_clock_update_with_time (myApplet); // should update myData.currentTime
 
64
 
 
65
        if (! myConfig.bShowSeconds)  // can be interesting to show the correct minute... Start the new timer with a delay
 
66
        {
 
67
                guint iWaitSeconds = 60 - myData.currentTime.tm_sec;
 
68
                cd_debug ("Waiting for a new minute during %d sec", iWaitSeconds);
 
69
 
 
70
                myData.iSidUpdateClock = g_timeout_add_seconds (iWaitSeconds,
 
71
                        (GSourceFunc) _cd_check_new_minute,
 
72
                        (gpointer) myApplet);
 
73
        }
 
74
        else
 
75
                myData.iSidUpdateClock = g_timeout_add_seconds (1, (GSourceFunc) cd_clock_update_with_time, (gpointer) myApplet);
 
76
}
52
77
 
53
78
CD_APPLET_INIT_BEGIN
54
79
        if (myDesklet)
96
121
        cd_clock_list_tasks (myApplet);
97
122
        
98
123
        //\_______________ On lance le timer.
99
 
        if (! myConfig.bShowSeconds)  // pour ne pas attendre 1 mn avant d'avoir le dessin.
100
 
                cd_clock_update_with_time (myApplet);
101
 
        myData.iSidUpdateClock = g_timeout_add_seconds ((myConfig.bShowSeconds ? 1: 60), (GSourceFunc) cd_clock_update_with_time, (gpointer) myApplet);
 
124
        _cd_launch_timer (myApplet);
102
125
CD_APPLET_INIT_END
103
126
 
104
127
 
166
189
                myData.iLastCheckedDay = -1;
167
190
                myData.iLastCheckedMonth = -1;
168
191
                myData.iLastCheckedYear = -1;
169
 
                cd_clock_update_with_time (myApplet);
170
 
                myData.iSidUpdateClock = g_timeout_add_seconds ((myConfig.bShowSeconds ? 1: 60), (GSourceFunc) cd_clock_update_with_time, (gpointer) myApplet);
 
192
                _cd_launch_timer (myApplet);
171
193
        }
172
194
        else
173
195
        {