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
******************************************************************************/
31
#include <glib/gi18n.h>
35
#include "cd-mail-applet-struct.h"
36
#include "cd-mail-applet-etpan.h"
37
#include "cd-mail-applet-notifications.h"
40
CD_APPLET_ON_CLICK_BEGIN
42
if( myConfig.cMailApplication )
46
if (cairo_dock_get_current_active_window () == myIcon->Xid && myTaskBar.bMinimizeOnClick)
47
cairo_dock_minimize_xwindow (myIcon->Xid);
49
cairo_dock_show_xwindow (myIcon->Xid);
53
gboolean r = cairo_dock_launch_command (myConfig.cMailApplication);
57
cd_warning ("when couldn't execute '%s'", myConfig.cMailApplication);
58
cairo_dock_show_temporary_dialog (D_("A problem occured\nIf '%s' is not your usual mail application,\nyou can change it in the conf panel of this module"), myIcon, myContainer, 5000, myConfig.cMailApplication);
63
CD_APPLET_ON_CLICK_END
66
static void _cd_mail_force_update(CairoDockModuleInstance *myApplet)
69
if (myData.pMailAccounts != NULL)
71
for (i = 0; i < myData.pMailAccounts->len; i ++)
73
CDMailAccount *pMailAccount = g_ptr_array_index (myData.pMailAccounts, i);
76
cairo_dock_launch_task(pMailAccount->pAccountMailTimer);
81
CD_APPLET_ON_MIDDLE_CLICK_BEGIN
83
_cd_mail_force_update(myApplet);
85
CD_APPLET_ON_MIDDLE_CLICK_END
88
static void _cd_mail_update_account (GtkMenuItem *menu_item, CDMailAccount *pMailAccount)
92
CairoDockModuleInstance *myApplet = pMailAccount->pAppletInstance;
93
Icon *pIcon = (pMailAccount->icon ? pMailAccount->icon : myIcon);
94
CairoContainer *pContainer = (pMailAccount->icon ? CD_APPLET_MY_ICONS_LIST_CONTAINER : myContainer);
95
cairo_dock_set_quick_info (myDrawContext, "...", pIcon, cairo_dock_get_max_scale (pContainer));
97
cairo_dock_launch_task(pMailAccount->pAccountMailTimer);
100
static void _cd_mail_launch_mail_appli (GtkMenuItem *menu_item, CairoDockModuleInstance *myApplet)
102
cairo_dock_launch_command (myConfig.cMailApplication);
104
CD_APPLET_ON_BUILD_MENU_BEGIN
106
GtkWidget *pSubMenu = CD_APPLET_CREATE_MY_SUB_MENU ();
107
if(myData.pMailAccounts && myData.pMailAccounts->len > 0)
109
/* add a "update account" item for each mailbox */
110
GtkWidget *pRefreshAccountSubMenu = CD_APPLET_ADD_SUB_MENU (D_("Refresh a mail account"), pSubMenu);
113
for (i = 0; i < myData.pMailAccounts->len; i ++)
115
CDMailAccount *pMailAccount = g_ptr_array_index (myData.pMailAccounts, i);
116
CD_APPLET_ADD_IN_MENU_WITH_DATA (pMailAccount->name, _cd_mail_update_account, pRefreshAccountSubMenu, pMailAccount);
119
if (myConfig.cMailApplication)
121
gchar *cLabel = g_strdup_printf (D_("Launch %s"), myConfig.cMailApplication);
122
CD_APPLET_ADD_IN_MENU (cLabel, _cd_mail_launch_mail_appli, pSubMenu);
125
CD_APPLET_ADD_ABOUT_IN_MENU (pSubMenu);
127
CD_APPLET_ON_BUILD_MENU_END
130
CD_APPLET_ON_SCROLL_BEGIN
131
if (myData.pMailAccounts == NULL)
132
return CAIRO_DOCK_LET_PASS_NOTIFICATION;
134
CDMailAccount *pMailAccount;
136
for (i = 0; i < myData.pMailAccounts->len; i++)
138
pMailAccount = g_ptr_array_index (myData.pMailAccounts, i);
139
if (pMailAccount->name && (myData.pMailAccounts->len == 1 || strcmp (pMailAccount->name, CD_APPLET_CLICKED_ICON->acName) == 0))
142
if (i == myData.pMailAccounts->len || pMailAccount == NULL)
143
return CAIRO_DOCK_LET_PASS_NOTIFICATION;
145
if (cairo_dock_task_is_running (pMailAccount->pAccountMailTimer))
147
g_print ("account is being checked, wait a second\n");
148
return CAIRO_DOCK_LET_PASS_NOTIFICATION;
151
struct mail_flags *pFlags = NULL;
152
mailmessage *pMessage = NULL;
156
for (l = pMailAccount->pUnseenMessageList; l != NULL; l = l->next)
159
cairo_dock_remove_dialog_if_any (CD_APPLET_CLICKED_ICON);
160
cairo_dock_show_temporary_dialog_with_icon (cMessage, CD_APPLET_CLICKED_ICON, CD_APPLET_CLICKED_CONTAINER, 10e3, "same icon");
162
// on marque le message comme lu.
163
///r = mailmessage_get_flags (pMessage, &pFlags);
166
CD_APPLET_ON_SCROLL_END
169
CD_APPLET_ON_UPDATE_ICON_BEGIN
170
double fSpeedX, fSpeedY;
171
if (myData.iNbUnreadMails == 0)
178
fSpeedX = 2 * MIN (5., sqrt (myData.iNbUnreadMails));
181
if( myData.iNbUnreadMails > 0 || myData.current_rotX != 0 ) // mails non lus ou on finit la rotation en cours.
183
myData.current_rotX += fSpeedX;
185
if( myData.iNbUnreadMails > 0 || myData.current_rotY != 0 ) // mails non lus ou on finit la rotation en cours.
187
myData.current_rotY += fSpeedY;
190
if( myData.current_rotX>=360.f )
192
if (myData.iNbUnreadMails > 0)
193
myData.current_rotX -= 360.f; // on se ramene juste dans [0;360[
195
myData.current_rotX = 0; // on s'arrete la.
197
if( myData.current_rotY>=360.f )
199
if (myData.iNbUnreadMails > 0)
200
myData.current_rotY -= 360.f;
202
myData.current_rotY = 0;
205
cd_mail_render_3D_to_texture (myApplet);
207
if( myData.iNbUnreadMails <= 0 && myData.current_rotX == 0 && myData.current_rotY == 0 )
209
CD_APPLET_STOP_UPDATE_ICON;
211
CD_APPLET_ON_UPDATE_ICON_END