~ubuntu-branches/ubuntu/oneiric/cairo-dock-plug-ins/oneiric-updates

« back to all changes in this revision

Viewing changes to weather/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 program,
 
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 <stdlib.h>
 
29
 
 
30
#include "applet-struct.h"
 
31
#include "applet-config.h"
 
32
#include "applet-notifications.h"
 
33
#include "applet-load-icons.h"
 
34
#include "applet-read-data.h"
 
35
#include "applet-init.h"
 
36
 
 
37
CD_APPLET_PRE_INIT_BEGIN (N_("weather"),
 
38
        2, 0, 0,
 
39
        CAIRO_DOCK_CATEGORY_ACCESSORY,
 
40
        N_("This applet displays weather into your dock.\n"
 
41
        "Data are provided by www.weather.com, you can find your location in the config panel.\n"
 
42
        "It can detach itself to be a totally eye-candy 3D deskelt.\n"
 
43
        "Middle-click on the main icon to have current conditions information, left-click on a sub-icon to have forcast information.\n"),
 
44
        "Fabounet (Fabrice Rey)")
 
45
        CD_APPLET_DEFINE_COMMON_APPLET_INTERFACE
 
46
        pInterface->load_custom_widget = cd_weather_load_custom_widget;
 
47
CD_APPLET_PRE_INIT_END
 
48
 
 
49
 
 
50
CD_APPLET_INIT_BEGIN
 
51
        // On lance la mesure periodique.
 
52
        myData.pTask = cairo_dock_new_task (myConfig.iCheckInterval,
 
53
                (CairoDockGetDataAsyncFunc) cd_weather_get_distant_data,
 
54
                (CairoDockUpdateSyncFunc) cd_weather_update_from_data,
 
55
                myApplet);
 
56
        cairo_dock_launch_task (myData.pTask);
 
57
        
 
58
        /**if (myConfig.iDeskletRenderer == MY_DESKLET_MAIN_ICON)
 
59
        {
 
60
                gpointer data[3] = {"Loading...", NULL, FALSE};
 
61
                CD_APPLET_SET_DESKLET_RENDERER_WITH_DATA ("Mediaplayer", data);
 
62
        }*/
 
63
        
 
64
        // On s'abonne aux notifications.
 
65
        CD_APPLET_REGISTER_FOR_CLICK_EVENT;
 
66
        CD_APPLET_REGISTER_FOR_MIDDLE_CLICK_EVENT;
 
67
        CD_APPLET_REGISTER_FOR_BUILD_MENU_EVENT;
 
68
CD_APPLET_INIT_END
 
69
 
 
70
 
 
71
CD_APPLET_STOP_BEGIN
 
72
        //\_______________ On se desabonne de nos notifications.
 
73
        CD_APPLET_UNREGISTER_FOR_CLICK_EVENT;
 
74
        CD_APPLET_UNREGISTER_FOR_MIDDLE_CLICK_EVENT;
 
75
        CD_APPLET_UNREGISTER_FOR_BUILD_MENU_EVENT;
 
76
CD_APPLET_STOP_END
 
77
 
 
78
 
 
79
CD_APPLET_RELOAD_BEGIN
 
80
        //\_______________ On recharge les donnees qui ont pu changer.
 
81
        g_return_val_if_fail (myConfig.cLocationCode != NULL, FALSE);
 
82
        
 
83
        if (CD_APPLET_MY_CONFIG_CHANGED)
 
84
        {
 
85
                if (myConfig.bSetName)
 
86
                {
 
87
                        CD_APPLET_DELETE_MY_ICONS_LIST;  // comme on va changer le nom, autant virer les icones du sous-dock des maintenant.
 
88
                        g_free (myIcon->acName);
 
89
                        myIcon->acName = NULL;
 
90
                }
 
91
                if (myDesklet) //Placé avant pour être sur d'avoir les infos affichées au redraw.
 
92
                {
 
93
                  ///if (myConfig.iDeskletRenderer == MY_DESKLET_CAROUSSEL)
 
94
                  {
 
95
                          gpointer pConfig[2] = {GINT_TO_POINTER (myConfig.bDesklet3D), GINT_TO_POINTER (FALSE)};
 
96
                          CD_APPLET_SET_DESKLET_RENDERER_WITH_DATA ("Caroussel", pConfig);
 
97
                        }
 
98
                        /**else if (myConfig.iDeskletRenderer == MY_DESKLET_MAIN_ICON)
 
99
                        {
 
100
                          gpointer data[3] = {"Loading...", NULL, FALSE};
 
101
                                CD_APPLET_SET_DESKLET_RENDERER_WITH_DATA ("Mediaplayer", data);
 
102
                        }*/
 
103
                }
 
104
        
 
105
                cd_weather_reset_all_datas (myApplet);  // on bourrine.
 
106
                
 
107
                myData.pTask = cairo_dock_new_task (myConfig.iCheckInterval,
 
108
                        (CairoDockGetDataAsyncFunc) cd_weather_get_distant_data,
 
109
                        (CairoDockUpdateSyncFunc) cd_weather_update_from_data,
 
110
                        myApplet);
 
111
                cairo_dock_launch_task (myData.pTask);
 
112
 
 
113
        }
 
114
        else
 
115
        {
 
116
                // rien a faire, cairo-dock va recharger notre sous-dock.
 
117
        }
 
118
CD_APPLET_RELOAD_END
 
119