2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
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.
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/>.
20
/**********************************************************************************
22
This file is a part of the cairo-dock clock applet,
23
released under the terms of the GNU General Public License.
25
Written by Fabrice Rey (for any bug report, please mail me to fabounet@users.berlios.de)
27
**********************************************************************************/
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"
40
CD_APPLET_PRE_INIT_BEGIN (N_("clock"),
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
58
CD_APPLET_SET_DESKLET_RENDERER ("Simple");
61
if (myConfig.cLocation != NULL)
62
CD_APPLET_SET_NAME_FOR_MY_ICON (myConfig.cLocation+1);
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);
71
///cd_clock_configure_digital (myApplet); // mis en commentaire jusqu'a ce que ca soit fini.
73
myData.cSystemLocation = g_strdup (g_getenv ("TZ"));
74
myData.iLastCheckedMinute = -1;
75
myData.iLastCheckedDay = -1;
76
myData.iLastCheckedMonth = -1;
77
myData.iLastCheckedYear = -1;
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)
85
CD_APPLET_REGISTER_FOR_UPDATE_ICON_SLOW_EVENT;
86
cairo_dock_launch_animation (myContainer);
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);
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;
103
//\_______________ On stoppe le timer.
104
g_source_remove (myData.iSidUpdateClock);
105
myData.iSidUpdateClock = 0;
107
cd_clock_free_timezone_list ();
111
CD_APPLET_RELOAD_BEGIN
112
//\_______________ On recharge les donnees qui ont pu changer.
115
CD_APPLET_SET_DESKLET_RENDERER ("Simple");
118
///cd_clock_configure_digital (myApplet); // mis en commentaire jusqu'a ce que ca soit fini.
120
if (CD_APPLET_MY_CONFIG_CHANGED)
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)
135
cd_clock_load_textures (myApplet);
136
cairo_dock_launch_animation (myContainer);
139
if (myConfig.cLocation != NULL)
140
CD_APPLET_SET_NAME_FOR_MY_ICON (myConfig.cLocation+1);
142
if (CD_APPLET_MY_CONTAINER_IS_OPENGL && myConfig.bOldStyle && myConfig.bShowSeconds && myConfig.iSmoothAnimationDuration != 0)
144
CD_APPLET_REGISTER_FOR_UPDATE_ICON_SLOW_EVENT;
145
cairo_dock_launch_animation (myContainer);
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);
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);
164
cd_clock_update_with_time (myApplet);