~ubuntu-branches/ubuntu/saucy/cairo-dock-plug-ins/saucy

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2009-08-26 21:07:39 UTC
  • Revision ID: james.westby@ubuntu.com-20090826210739-gyjuuqezrzuluao4
Tags: upstream-2.0.8.1
ImportĀ upstreamĀ versionĀ 2.0.8.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
* This file is a part of the Cairo-Dock project
 
3
*
 
4
* Copyright : (C) see the 'copyright' file.
 
5
* E-mail    : see the 'copyright' file.
 
6
*
 
7
* This program is free software; you can redistribute it and/or
 
8
* modify it under the terms of the GNU General Public License
 
9
* as published by the Free Software Foundation; either version 3
 
10
* of the License, or (at your option) any later version.
 
11
*
 
12
* This program is distributed in the hope that it will be useful,
 
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
* GNU General Public License for more details.
 
16
* You should have received a copy of the GNU General Public License
 
17
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
*/
 
19
 
 
20
/**********************************************************************************
 
21
 
 
22
This file is a part of the cairo-dock clock applet,
 
23
released under the terms of the GNU General Public License.
 
24
 
 
25
Written by Fabrice Rey (for any bug report, please mail me to fabounet@users.berlios.de)
 
26
 
 
27
**********************************************************************************/
 
28
#include <string.h>
 
29
#include "stdlib.h"
 
30
 
 
31
#include "applet-struct.h"
 
32
#include "applet-draw.h"
 
33
#include "applet-digital.h" //Digital html like renderer
 
34
#include "applet-config.h"
 
35
#include "applet-theme.h"
 
36
#include "applet-notifications.h"
 
37
#include "applet-init.h"
 
38
 
 
39
 
 
40
CD_APPLET_PRE_INIT_BEGIN (N_("clock"),
 
41
        2, 0, 0,
 
42
        CAIRO_DOCK_CATEGORY_ACCESSORY,
 
43
        N_("This applet displays time and date in your dock.\n"
 
44
        "2 view are available : numeric and analogic, based on Cairo-Clock.\n"
 
45
        "It is compatible with the Cairo-Clock's themes, and you can detach itself to be a perfect clone of Cairo-Clock.\n"
 
46
        "It supports alarms, and a basic calendar, and allows you to setup time and date.\n"
 
47
        "Left-click to show/hide the calendar, Middle-click to stop an alarm."),
 
48
        "Fabounet (Fabrice Rey)")
 
49
        CD_APPLET_DEFINE_COMMON_APPLET_INTERFACE
 
50
        pInterface->load_custom_widget = cd_clock_load_custom_widget;
 
51
        pInterface->save_custom_widget = cd_clock_save_custom_widget;
 
52
CD_APPLET_PRE_INIT_END
 
53
 
 
54
 
 
55
CD_APPLET_INIT_BEGIN
 
56
        if (myDesklet)
 
57
        {
 
58
                CD_APPLET_SET_DESKLET_RENDERER ("Simple");
 
59
        }
 
60
        
 
61
        if (myConfig.cLocation != NULL)
 
62
                CD_APPLET_SET_NAME_FOR_MY_ICON (myConfig.cLocation+1);
 
63
        
 
64
        //\_______________ On charge notre theme.
 
65
        cd_clock_load_theme (myApplet);
 
66
        cd_clock_load_back_and_fore_ground (myApplet);
 
67
        g_print ("CD_APPLET_MY_CONTAINER_IS_OPENGL : %d\n", CD_APPLET_MY_CONTAINER_IS_OPENGL);
 
68
        if (CD_APPLET_MY_CONTAINER_IS_OPENGL)
 
69
                cd_clock_load_textures (myApplet);
 
70
        
 
71
        ///cd_clock_configure_digital (myApplet);  // mis en commentaire jusqu'a ce que ca soit fini.
 
72
        
 
73
        myData.cSystemLocation = g_strdup (g_getenv ("TZ"));
 
74
        myData.iLastCheckedMinute = -1;
 
75
        myData.iLastCheckedDay = -1;
 
76
        myData.iLastCheckedMonth = -1;
 
77
        myData.iLastCheckedYear = -1;
 
78
        
 
79
        //\_______________ On enregistre nos notifications.
 
80
        CD_APPLET_REGISTER_FOR_CLICK_EVENT;
 
81
        CD_APPLET_REGISTER_FOR_MIDDLE_CLICK_EVENT;
 
82
        CD_APPLET_REGISTER_FOR_BUILD_MENU_EVENT;
 
83
        if (CD_APPLET_MY_CONTAINER_IS_OPENGL && myConfig.bOldStyle && myConfig.bShowSeconds && myConfig.iSmoothAnimationDuration != 0)
 
84
        {
 
85
                CD_APPLET_REGISTER_FOR_UPDATE_ICON_SLOW_EVENT;
 
86
                cairo_dock_launch_animation (myContainer);
 
87
        }
 
88
        
 
89
        //\_______________ On lance le timer.
 
90
        if (! myConfig.bShowSeconds)  // pour ne pas attendre 1 mn avant d'avoir le dessin.
 
91
                cd_clock_update_with_time (myApplet);
 
92
        myData.iSidUpdateClock = g_timeout_add_seconds ((myConfig.bShowSeconds ? 1: 60), (GSourceFunc) cd_clock_update_with_time, (gpointer) myApplet);
 
93
CD_APPLET_INIT_END
 
94
 
 
95
 
 
96
CD_APPLET_STOP_BEGIN
 
97
        //\_______________ On se desabonne de nos notifications.
 
98
        CD_APPLET_UNREGISTER_FOR_CLICK_EVENT;
 
99
        CD_APPLET_UNREGISTER_FOR_MIDDLE_CLICK_EVENT;
 
100
        CD_APPLET_UNREGISTER_FOR_BUILD_MENU_EVENT;
 
101
        CD_APPLET_UNREGISTER_FOR_UPDATE_ICON_SLOW_EVENT;
 
102
        
 
103
        //\_______________ On stoppe le timer.
 
104
        g_source_remove (myData.iSidUpdateClock);
 
105
        myData.iSidUpdateClock = 0;
 
106
 
 
107
        cd_clock_free_timezone_list ();
 
108
CD_APPLET_STOP_END
 
109
 
 
110
 
 
111
CD_APPLET_RELOAD_BEGIN
 
112
        //\_______________ On recharge les donnees qui ont pu changer.
 
113
        if (myDesklet)
 
114
        {
 
115
                CD_APPLET_SET_DESKLET_RENDERER ("Simple");
 
116
        }
 
117
        
 
118
        ///cd_clock_configure_digital (myApplet);  // mis en commentaire jusqu'a ce que ca soit fini.
 
119
        
 
120
        if (CD_APPLET_MY_CONFIG_CHANGED)
 
121
        {
 
122
                //\_______________ On stoppe le timer.
 
123
                g_source_remove (myData.iSidUpdateClock);
 
124
                myData.iSidUpdateClock = 0;
 
125
                CD_APPLET_UNREGISTER_FOR_UPDATE_ICON_SLOW_EVENT;
 
126
                //\_______________ On efface tout
 
127
                cd_clock_clear_theme (myApplet, TRUE);
 
128
                //\_______________ On charge notre theme.
 
129
                cd_clock_load_theme (myApplet);
 
130
                //\_______________ On charge les surfaces d'avant et arriere-plan.
 
131
                cd_clock_load_back_and_fore_ground (myApplet);
 
132
                //\_______________ On charge les textures.
 
133
                if (CD_APPLET_MY_CONTAINER_IS_OPENGL)
 
134
                {
 
135
                        cd_clock_load_textures (myApplet);
 
136
                        cairo_dock_launch_animation (myContainer);
 
137
                }
 
138
                
 
139
                if (myConfig.cLocation != NULL)
 
140
                        CD_APPLET_SET_NAME_FOR_MY_ICON (myConfig.cLocation+1);
 
141
                
 
142
                if (CD_APPLET_MY_CONTAINER_IS_OPENGL && myConfig.bOldStyle && myConfig.bShowSeconds && myConfig.iSmoothAnimationDuration != 0)
 
143
                {
 
144
                        CD_APPLET_REGISTER_FOR_UPDATE_ICON_SLOW_EVENT;
 
145
                        cairo_dock_launch_animation (myContainer);
 
146
                }
 
147
                
 
148
                //\_______________ On relance le timer.
 
149
                myData.iLastCheckedMinute = -1;
 
150
                myData.iLastCheckedDay = -1;
 
151
                myData.iLastCheckedMonth = -1;
 
152
                myData.iLastCheckedYear = -1;
 
153
                cd_clock_update_with_time (myApplet);
 
154
                myData.iSidUpdateClock = g_timeout_add_seconds ((myConfig.bShowSeconds ? 1: 60), (GSourceFunc) cd_clock_update_with_time, (gpointer) myApplet);
 
155
        }
 
156
        else
 
157
        {
 
158
                //\_______________ On charge les surfaces d'avant et arriere-plan et les textures, les rsvg_handle ne dependent pas de la taille.
 
159
                cd_clock_clear_theme (myApplet, FALSE);
 
160
                cd_clock_load_back_and_fore_ground (myApplet);
 
161
                if (CD_APPLET_MY_CONTAINER_IS_OPENGL)
 
162
                        cd_clock_load_textures (myApplet);
 
163
 
 
164
                cd_clock_update_with_time (myApplet);
 
165
        }
 
166
CD_APPLET_RELOAD_END