Debian Codegraph @

weather/src/applet-init.c

raw
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 #include <stdlib.h>
21
22 #include "applet-struct.h"
23 #include "applet-config.h"
24 #include "applet-notifications.h"
25 #include "applet-load-icons.h"
26 #include "applet-read-data.h"
27 #include "applet-init.h"
28
29 CD_APPLET_DEFINE_BEGIN (N_("weather"),
30 2, 0, 0,
31 CAIRO_DOCK_CATEGORY_APPLET_ACCESSORY,
32 N_("This applet displays weather into your dock.\n"
33 "Data are provided by yahoo.com, you can find your location in the config panel.\n"
34 "It can detach itself to be a totally eye-candy 3D deskelt.\n"
35 "Middle-click on the main icon to have current conditions information, left-click on a sub-icon to have forcast information.\n"),
36 "Fabounet (Fabrice Rey)")
37 CD_APPLET_DEFINE_COMMON_APPLET_INTERFACE
38 CD_APPLET_ALLOW_EMPTY_TITLE
39 #ifdef CD_WEATHER_HAS_CODE_LOCATION
40 pInterface->load_custom_widget = cd_weather_load_custom_widget;
41 #endif
42 CD_APPLET_DEFINE_END
43
44
45 CD_APPLET_INIT_BEGIN
46 // On lance la mesure periodique.
47 cd_weather_launch_periodic_task (myApplet);
48
49 // On s'abonne aux notifications.
50 CD_APPLET_REGISTER_FOR_CLICK_EVENT;
51 CD_APPLET_REGISTER_FOR_DOUBLE_CLICK_EVENT;
52 CD_APPLET_REGISTER_FOR_MIDDLE_CLICK_EVENT;
53 CD_APPLET_REGISTER_FOR_BUILD_MENU_EVENT;
54
55 CD_APPLET_INIT_END
56
57
58 CD_APPLET_STOP_BEGIN
59 //\_______________ On se desabonne de nos notifications.
60 CD_APPLET_UNREGISTER_FOR_CLICK_EVENT;
61 CD_APPLET_UNREGISTER_FOR_DOUBLE_CLICK_EVENT;
62 CD_APPLET_UNREGISTER_FOR_MIDDLE_CLICK_EVENT;
63 CD_APPLET_UNREGISTER_FOR_BUILD_MENU_EVENT;
64 CD_APPLET_STOP_END
65
66
67 CD_APPLET_RELOAD_BEGIN
68 //\_______________ On recharge les donnees qui ont pu changer.
69 g_return_val_if_fail (myConfig.cLocationCode != NULL, FALSE);
70
71 if (CD_APPLET_MY_CONFIG_CHANGED)
72 {
73 if (myConfig.bSetName)
74 {
75 CD_APPLET_DELETE_MY_ICONS_LIST; // comme on va changer le nom, autant virer les icones du sous-dock des maintenant.
76 g_free (myIcon->cName);
77 myIcon->cName = NULL;
78 }
79
80 ///cd_weather_reset_all_datas (myApplet); // on bourrine.
81
82 // relaunch the periodic task immediately.
83 myData.bErrorRetrievingData = FALSE;
84 myData.bSetName = FALSE;
85 cd_weather_launch_periodic_task (myApplet); // discard the current one if needed.
86 }
87 CD_APPLET_RELOAD_END
88