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 program,
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
******************************************************************************/
30
#include <glib/gstdio.h>
32
#include "applet-struct.h"
33
#include "applet-load-icons.h"
34
#include "applet-read-data.h"
35
#include "applet-notifications.h"
38
CD_APPLET_ON_CLICK_BEGIN
41
if (pClickedContainer == CAIRO_CONTAINER (myIcon->pSubDock) && pClickedIcon != NULL) // on a clique sur une icone du sous-dock.
43
cd_debug (" clic sur %s", pClickedIcon->acName);
44
cd_weather_show_forecast_dialog (myApplet, pClickedIcon);
47
else if (myDesklet) // on a clique sur une icone du desklet.
49
if (pClickedIcon != NULL)
51
if (pClickedIcon == myIcon)
52
cd_weather_show_current_conditions_dialog (myApplet);
54
cd_weather_show_forecast_dialog (myApplet, pClickedIcon);
58
return CAIRO_DOCK_LET_PASS_NOTIFICATION;
59
CD_APPLET_ON_CLICK_END
62
static void _cd_weather_reload (GtkMenuItem *menu_item, CairoDockModuleInstance *myApplet)
64
cairo_dock_stop_task (myData.pTask);
66
cairo_dock_launch_task (myData.pTask);
68
CD_APPLET_ON_BUILD_MENU_BEGIN
69
GtkWidget *pSubMenu = CD_APPLET_CREATE_MY_SUB_MENU ();
70
CD_APPLET_ADD_IN_MENU (D_("Reload now"), _cd_weather_reload, pSubMenu);
71
CD_APPLET_ADD_ABOUT_IN_MENU (pSubMenu);
72
CD_APPLET_ON_BUILD_MENU_END
75
CD_APPLET_ON_MIDDLE_CLICK_BEGIN
76
if (pClickedIcon == myIcon)
78
cd_weather_show_current_conditions_dialog (myApplet);
81
return CAIRO_DOCK_LET_PASS_NOTIFICATION;
82
CD_APPLET_ON_MIDDLE_CLICK_END
85
CairoDialog *cd_weather_show_forecast_dialog (CairoDockModuleInstance *myApplet, Icon *pIcon)
88
g_list_foreach (myIcon->pSubDock->icons, (GFunc) cairo_dock_remove_dialog_if_any, NULL);
90
cairo_dock_remove_dialog_if_any (myIcon);
92
if (myData.bErrorRetrievingData)
94
cairo_dock_show_temporary_dialog_with_icon (D_("No data were available\n is connection alive ?"),
95
(myDock ? pIcon : myIcon),
96
(myDock ? CAIRO_CONTAINER (myIcon->pSubDock) : myContainer),
97
myConfig.cDialogDuration,
102
int iNumDay = ((int) pIcon->fOrder) / 2, iPart = ((int) pIcon->fOrder) - 2 * iNumDay;
103
g_return_val_if_fail (iNumDay < myConfig.iNbDays && iPart < 2, NULL);
105
Day *day = &myData.days[iNumDay];
106
DayPart *part = &day->part[iPart];
107
cairo_dock_show_temporary_dialog_with_icon ("%s (%s) : %s\n %s : %s%s -> %s%s\n %s : %s%%\n %s : %s%s (%s)\n %s : %s\n %s : %s %s %s",
108
(myDock ? pIcon : myIcon), (myDock ? CAIRO_CONTAINER (myIcon->pSubDock) : myContainer), myConfig.cDialogDuration, pIcon->acFileName,
109
day->cName, day->cDate, part->cWeatherDescription,
110
D_("Temperature"), _display (day->cTempMin), myData.units.cTemp, _display (day->cTempMax), myData.units.cTemp,
111
D_("Precipitation Probability"), _display (part->cPrecipitationProba),
112
D_("Wind"), _display (part->cWindSpeed), myData.units.cSpeed, _display (part->cWindDirection),
113
D_("Humidity"), _display (part->cHumidity), // unite ?...
114
D_("SunRise"), _display (day->cSunRise), _("SunSet"), _display (day->cSunSet));
117
CairoDialog *cd_weather_show_current_conditions_dialog (CairoDockModuleInstance *myApplet)
119
cairo_dock_remove_dialog_if_any (myIcon);
120
if (cairo_dock_task_is_running (myData.pTask))
122
cairo_dock_show_temporary_dialog_with_icon (D_("Data are being fetched, please re-try in a few seconds."),
130
if (myData.bErrorRetrievingData)
132
cairo_dock_show_temporary_dialog_with_icon (D_("No data were available\nRe-trying now ..."),
137
_cd_weather_reload (NULL, myApplet);
142
CurrentContitions *cc = &myData.currentConditions;
143
cairo_dock_show_temporary_dialog_with_icon ("%s (%s, %s)\n %s : %s%s (%s : %s%s)\n %s : %s%s (%s)\n %s : %s - %s : %s%s\n %s : %s %s %s",
144
myIcon, myContainer, myConfig.cDialogDuration, myIcon->acFileName,
145
cc->cWeatherDescription, cc->cDataAcquisitionDate, cc->cObservatory,
146
D_("Temperature"), _display (cc->cTemp), myData.units.cTemp, D_("feeled"), _display (cc->cFeeledTemp), myData.units.cTemp,
147
D_("Wind"), _display (cc->cWindSpeed), myData.units.cSpeed, _display (cc->cWindDirection),
148
D_("Humidity"), _display (cc->cHumidity), D_("Pressure"), _display (cc->cPressure), myData.units.cPressure, // unite ?...
149
D_("SunRise"), _display (cc->cSunRise), D_("SunSet"), _display (cc->cSunSet));