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/>.
23
#include <glib/gstdio.h>
25
#include "cd-mail-applet-config.h"
26
#include "cd-mail-applet-notifications.h"
27
#include "cd-mail-applet-struct.h"
28
#include "cd-mail-applet-accounts.h"
29
#include "cd-mail-applet-etpan.h"
30
#include "cd-mail-applet-init.h"
33
CD_APPLET_DEFINE_BEGIN (N_("mail"),
35
CAIRO_DOCK_CATEGORY_APPLET_INTERNET,
36
N_("This applet is very useful to warn you when you get new e-mails\n"
37
"It can check in any kind of mailbox (yahoo, gmail, etc)\n"
38
"Left-click to launch the prefered mail application,\n"
39
"Middle-click to refresh all the mailboxes."),
40
"Tofe (Christophe Chapuis) & Fabounet (Fabrice Rey)")
41
CD_APPLET_DEFINE_COMMON_APPLET_INTERFACE
42
pInterface->load_custom_widget = cd_mail_load_custom_widget;
43
pInterface->save_custom_widget = cd_mail_save_custom_widget;
47
GLuint cd_mail_load_cube_calllist (void)
49
GLuint iCallList = glGenLists (1);
50
glNewList(iCallList, GL_COMPILE); // Go pour la compilation de la display list
51
glPolygonMode (GL_FRONT, GL_FILL);
53
double a = .5 / sqrt (2);
55
// Front Face (note that the texture's corners have to match the quad's corners)
56
//glColor3f(1.0f,0.5f,0.0f);
58
glTexCoord2d(0., 0.); glVertex3f(-a, a, a); // Bottom Left Of The Texture and Quad
59
glTexCoord2d(1., 0.); glVertex3f( a, a, a); // Bottom Right Of The Texture and Quad
60
glTexCoord2d(1., 1.); glVertex3f( a, -a, a); // Top Right Of The Texture and Quad
61
glTexCoord2d(0., 1.); glVertex3f(-a, -a, a); // Top Left Of The Texture and Quad
64
glTexCoord2d(1., 0.); glVertex3f( -a, a, -a); // Bottom Right Of The Texture and Quad
65
glTexCoord2d(1., 1.); glVertex3f( -a, -a, -a); // Top Right Of The Texture and Quad
66
glTexCoord2d(0., 1.); glVertex3f(a, -a, -a); // Top Left Of The Texture and Quad
67
glTexCoord2d(0., 0.); glVertex3f(a, a, -a); // Bottom Left Of The Texture and Quad
69
//glColor3f(1.0f,0.f,1.0f);
71
glTexCoord2d(0., 1.); glVertex3f(-a, a, a); // Top Left Of The Texture and Quad
72
glTexCoord2d(0., 0.); glVertex3f(-a, a, -a); // Bottom Left Of The Texture and Quad
73
glTexCoord2d(1., 0.); glVertex3f( a, a, -a); // Bottom Right Of The Texture and Quad
74
glTexCoord2d(1., 1.); glVertex3f( a, a, a); // Top Right Of The Texture and Quad
77
glTexCoord2d(1., 1.); glVertex3f( a, -a, -a); // Top Right Of The Texture and Quad
78
glTexCoord2d(0., 1.); glVertex3f(-a, -a, -a); // Top Left Of The Texture and Quad
79
glTexCoord2d(0., 0.); glVertex3f(-a, -a, a); // Bottom Left Of The Texture and Quad
80
glTexCoord2d(1., 0.); glVertex3f( a, -a, a); // Bottom Right Of The Texture and Quad
82
//glColor3f(0.f,0.5f,1.0f);
84
glTexCoord2d(1., 0.); glVertex3f( a, a, -a); // Bottom Right Of The Texture and Quad
85
glTexCoord2d(1., 1.); glVertex3f( a, -a, -a); // Top Right Of The Texture and Quad
86
glTexCoord2d(0., 1.); glVertex3f( a, -a, a); // Top Left Of The Texture and Quad
87
glTexCoord2d(0., 0.); glVertex3f( a, a, a); // Bottom Left Of The Texture and Quad
90
glTexCoord2d(0., 0.); glVertex3f(-a, a, -a); // Bottom Left Of The Texture and Quad
91
glTexCoord2d(1., 0.); glVertex3f(-a, a, a); // Bottom Right Of The Texture and Quad
92
glTexCoord2d(1., 1.); glVertex3f(-a, -a, a); // Top Right Of The Texture and Quad
93
glTexCoord2d(0., 1.); glVertex3f(-a, -a, -a); // Top Left Of The Texture and Quad
96
glEndList(); // Fini la display list
101
static void _load_theme (CairoDockModuleInstance *myApplet, GError **erreur)
103
//\_______________ On charge le theme si necessaire, avec en priorite les images utilisateur.
104
if (myConfig.cNoMailUserImage != NULL)
106
gchar *cPath = cairo_dock_search_icon_s_path (myConfig.cNoMailUserImage);
107
if (! g_file_test (cPath, G_FILE_TEST_EXISTS))
109
g_free (myConfig.cNoMailUserImage);
110
myConfig.cNoMailUserImage = NULL;
114
if (myConfig.cHasMailUserImage != NULL)
116
gchar *cPath = cairo_dock_search_icon_s_path (myConfig.cHasMailUserImage);
117
if (! g_file_test (cPath, G_FILE_TEST_EXISTS))
119
g_free (myConfig.cHasMailUserImage);
120
myConfig.cHasMailUserImage = NULL;
124
if (myConfig.cThemePath != NULL && (myConfig.cNoMailUserImage == NULL || myConfig.cHasMailUserImage == NULL))
126
GError *tmp_erreur = NULL;
127
GDir *dir = g_dir_open (myConfig.cThemePath, 0, &tmp_erreur);
128
if (tmp_erreur != NULL)
130
g_propagate_error (erreur, tmp_erreur);
134
const gchar *cElementName;
136
while ((cElementName = g_dir_read_name (dir)) != NULL)
138
cElementPath = g_strdup_printf ("%s/%s", myConfig.cThemePath, cElementName);
139
cd_debug (" Mail theme item: %s", cElementPath);
140
if (strncmp (cElementName, "no_mail", 7) == 0 && myConfig.cNoMailUserImage == NULL)
142
myConfig.cNoMailUserImage = cElementPath;
144
else if (strncmp (cElementName, "has_mail", 8) == 0 && myConfig.cHasMailUserImage == NULL)
146
myConfig.cHasMailUserImage = cElementPath;
148
else if (strncmp (cElementName, "new_mail_sound", 14) == 0 && myConfig.cNewMailUserSound == NULL)
150
myConfig.cNewMailUserSound = cElementPath;
154
g_free (cElementPath);
159
if (myConfig.cNoMailUserImage == NULL || myConfig.cHasMailUserImage == NULL || myConfig.cNewMailUserSound == NULL)
161
cd_warning ("mail : couldn't find images, this theme is not valid");
164
// textures et calllist.
165
if (myData.iNoMailTexture != 0)
167
_cairo_dock_delete_texture (myData.iNoMailTexture);
168
myData.iNoMailTexture = 0;
170
if (myData.iHasMailTexture != 0)
172
_cairo_dock_delete_texture (myData.iHasMailTexture);
173
myData.iHasMailTexture = 0;
175
if (CD_APPLET_MY_CONTAINER_IS_OPENGL && myDesklet)
177
if (myConfig.cNoMailUserImage != NULL)
178
myData.iNoMailTexture = cairo_dock_create_texture_from_image(myConfig.cNoMailUserImage);
179
if (myConfig.cHasMailUserImage != NULL)
180
myData.iHasMailTexture = cairo_dock_create_texture_from_image(myConfig.cHasMailUserImage);
182
if (myData.iCubeCallList == 0)
183
myData.iCubeCallList = cd_mail_load_cube_calllist();
186
// on cree le repertoire de l'historique si necessaire.
187
myData.cWorkingDirPath = g_strdup_printf ("%s/mail", g_cCairoDockDataDir);
188
if (! g_file_test (myData.cWorkingDirPath, G_FILE_TEST_EXISTS))
190
cd_debug ("Plugin Mail : le dossier '%s' n'existe pas encore -> On le cree", myData.cWorkingDirPath);
191
if (g_mkdir (myData.cWorkingDirPath, 7*8*8+7*8+0) != 0)
193
cd_warning ("couldn't create directory '%s' !\nNo read history will be available.", myData.cWorkingDirPath);
201
CD_APPLET_SET_DESKLET_RENDERER ("Simple");
204
//\_______________ On charge surfaces et textures.
205
GError *erreur = NULL;
206
_load_theme (myApplet, &erreur);
209
cd_warning ("mail : %s", erreur->message);
210
g_error_free (erreur);
214
//\_______________ On gere l'appli 'mail'
215
if (myConfig.bStealTaskBarIcon)
216
CD_APPLET_MANAGE_APPLICATION (myConfig.cMailClass ? myConfig.cMailClass : myConfig.cMailApplication);*/
218
//\_______________ On initialise tous les comptes et on lance un timer pour chacun.
219
cd_mail_init_accounts(myApplet);
221
//\_______________ On s'abonne aux notifications.
222
CD_APPLET_REGISTER_FOR_CLICK_EVENT;
223
CD_APPLET_REGISTER_FOR_BUILD_MENU_EVENT;
224
CD_APPLET_REGISTER_FOR_MIDDLE_CLICK_EVENT;
225
CD_APPLET_REGISTER_FOR_SCROLL_EVENT;
226
if (CD_APPLET_MY_CONTAINER_IS_OPENGL && myDesklet)
228
CD_APPLET_REGISTER_FOR_UPDATE_ICON_EVENT;
235
//\_______________ On se desabonne de nos notifications.
236
CD_APPLET_UNREGISTER_FOR_CLICK_EVENT;
237
CD_APPLET_UNREGISTER_FOR_BUILD_MENU_EVENT;
238
CD_APPLET_UNREGISTER_FOR_MIDDLE_CLICK_EVENT;
239
CD_APPLET_UNREGISTER_FOR_SCROLL_EVENT;
240
CD_APPLET_UNREGISTER_FOR_UPDATE_ICON_EVENT;
242
///CD_APPLET_MANAGE_APPLICATION (NULL);
246
CD_APPLET_RELOAD_BEGIN
248
//\_______________ On recharge les donnees qui ont pu changer.
249
if (CD_APPLET_MY_CONFIG_CHANGED )
251
CD_APPLET_UNREGISTER_FOR_UPDATE_ICON_EVENT;
253
/**if (myConfig.bStealTaskBarIcon)
254
CD_APPLET_MANAGE_APPLICATION (myConfig.cMailClass ? myConfig.cMailClass : myConfig.cMailApplication);
256
CD_APPLET_MANAGE_APPLICATION (NULL);*/
258
GError *erreur = NULL;
259
_load_theme (myApplet, &erreur);
262
cd_warning ("mail : when trying to load theme : %s", erreur->message);
263
g_error_free (erreur);
267
if (CD_APPLET_MY_CONTAINER_IS_OPENGL && myDesklet)
269
CD_APPLET_REGISTER_FOR_UPDATE_ICON_EVENT;
272
cd_mail_init_accounts(myApplet); // la config vient d'etre rechargee, donc les comptes sont tout neufs.