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
******************************************************************************/
33
#include "applet-config.h"
34
#include "applet-struct.h"
35
#include "applet-notifications.h"
36
#include "applet-init.h"
39
CD_APPLET_PRE_INIT_BEGIN (N_("icon effects"),
41
CAIRO_DOCK_CATEGORY_THEME,
42
N_("This plug-in adds many special effects to your icons."),
43
"Fabounet (Fabrice Rey)")
46
CD_APPLET_DEFINE_COMMON_APPLET_INTERFACE
47
CD_APPLET_PRE_INIT_END
50
//\___________ Here is where you initiate your applet. myConfig is already set at this point, and also myIcon, myContainer, myDock, myDesklet (and myDrawContext if you're in dock mode). The macro CD_APPLET_MY_CONF_FILE and CD_APPLET_MY_KEY_FILE can give you access to the applet's conf-file and its corresponding key-file (also available during reload). If you're in desklet mode, myDrawContext is still NULL, and myIcon's buffers has not been filled, because you may not need them then (idem when reloading).
52
if (! g_bUseOpenGL || ! cairo_dock_reserve_data_slot (myApplet))
55
cairo_dock_register_notification (CAIRO_DOCK_ENTER_ICON, (CairoDockNotificationFunc) cd_icon_effect_on_enter, CAIRO_DOCK_RUN_AFTER, NULL);
56
cairo_dock_register_notification (CAIRO_DOCK_CLICK_ICON, (CairoDockNotificationFunc) cd_icon_effect_on_click, CAIRO_DOCK_RUN_FIRST, NULL);
57
cairo_dock_register_notification (CAIRO_DOCK_REQUEST_ICON_ANIMATION, (CairoDockNotificationFunc) cd_icon_effect_on_request, CAIRO_DOCK_RUN_FIRST, NULL);
58
cairo_dock_register_notification (CAIRO_DOCK_UPDATE_ICON, (CairoDockNotificationFunc) cd_icon_effect_update_icon, CAIRO_DOCK_RUN_AFTER, NULL);
59
cairo_dock_register_notification (CAIRO_DOCK_PRE_RENDER_ICON, (CairoDockNotificationFunc) cd_icon_effect_pre_render_icon, CAIRO_DOCK_RUN_AFTER, NULL);
60
cairo_dock_register_notification (CAIRO_DOCK_RENDER_ICON, (CairoDockNotificationFunc) cd_icon_effect_render_icon, CAIRO_DOCK_RUN_AFTER, NULL);
61
cairo_dock_register_notification (CAIRO_DOCK_STOP_ICON, (CairoDockNotificationFunc) cd_icon_effect_free_data, CAIRO_DOCK_RUN_AFTER, NULL);
63
myData.iAnimationID[CD_ICON_EFFECT_FIRE] = cairo_dock_register_animation ("fire");
64
myData.iAnimationID[CD_ICON_EFFECT_STARS] = cairo_dock_register_animation ("stars");
65
myData.iAnimationID[CD_ICON_EFFECT_RAIN] = cairo_dock_register_animation ("rain");
66
myData.iAnimationID[CD_ICON_EFFECT_SNOW] = cairo_dock_register_animation ("snow");
67
myData.iAnimationID[CD_ICON_EFFECT_SAND] = cairo_dock_register_animation ("storm");
69
if (! cairo_dock_is_loading ())
70
cairo_dock_update_animations_list_for_gui ();
74
static void _free_data_on_icon (Icon *pIcon, CairoDock *pDock, gpointer data)
76
cd_icon_effect_free_data (NULL, pIcon);
78
//\___________ Here is where you stop your applet. myConfig and myData are still valid, but will be reseted to 0 at the end of the function. In the end, your applet will go back to its original state, as if it had never been activated.
80
cairo_dock_remove_notification_func (CAIRO_DOCK_ENTER_ICON, (CairoDockNotificationFunc) cd_icon_effect_on_enter, NULL);
81
cairo_dock_remove_notification_func (CAIRO_DOCK_CLICK_ICON, (CairoDockNotificationFunc) cd_icon_effect_on_click, NULL);
82
cairo_dock_remove_notification_func (CAIRO_DOCK_REQUEST_ICON_ANIMATION, (CairoDockNotificationFunc) cd_icon_effect_on_request, NULL);
83
cairo_dock_remove_notification_func (CAIRO_DOCK_UPDATE_ICON, (CairoDockNotificationFunc) cd_icon_effect_update_icon, NULL);
84
cairo_dock_remove_notification_func (CAIRO_DOCK_PRE_RENDER_ICON, (CairoDockNotificationFunc) cd_icon_effect_pre_render_icon, NULL);
85
cairo_dock_remove_notification_func (CAIRO_DOCK_RENDER_ICON, (CairoDockNotificationFunc) cd_icon_effect_render_icon, NULL);
86
cairo_dock_remove_notification_func (CAIRO_DOCK_STOP_ICON, (CairoDockNotificationFunc) cd_icon_effect_free_data, NULL);
88
cairo_dock_unregister_animation ("fire");
89
cairo_dock_unregister_animation ("stars");
90
cairo_dock_unregister_animation ("rain");
91
cairo_dock_unregister_animation ("snow");
92
cairo_dock_unregister_animation ("storm");
93
cairo_dock_update_animations_list_for_gui ();
95
cairo_dock_foreach_icons ((CairoDockForeachIconFunc) _free_data_on_icon, NULL);
99
//\___________ The reload occurs in 2 occasions : when the user changes the applet's config, and when the user reload the cairo-dock's config or modify the desklet's size. The macro CD_APPLET_MY_CONFIG_CHANGED can tell you this. myConfig has already been reloaded at this point if you're in the first case, myData is untouched. You also have the macro CD_APPLET_MY_CONTAINER_TYPE_CHANGED that can tell you if you switched from dock/desklet to desklet/dock mode.
100
static gboolean _effect_is_used_in_table (CDIconEffects iEffect, CDIconEffects *pEffectList)
103
for (i = 0; i < CD_ICON_EFFECT_NB_EFFECTS; i ++)
105
if (pEffectList[i] == iEffect)
107
else if (myConfig.iEffectsUsed[i] == -1)
112
static gboolean _effect_is_used (CDIconEffects iEffect)
115
bUsed = _effect_is_used_in_table (iEffect, myConfig.iEffectsUsed);
118
bUsed = _effect_is_used_in_table (iEffect, myConfig.iEffectsOnClick[CAIRO_DOCK_LAUNCHER]);
121
bUsed = _effect_is_used_in_table (iEffect, myConfig.iEffectsOnClick[CAIRO_DOCK_APPLI]);
124
bUsed = _effect_is_used_in_table (iEffect, myConfig.iEffectsOnClick[CAIRO_DOCK_APPLET]);
127
CD_APPLET_RELOAD_BEGIN
128
if (CD_APPLET_MY_CONFIG_CHANGED)
130
if (myData.iFireTexture != 0 && ! _effect_is_used (CD_ICON_EFFECT_FIRE) && ! _effect_is_used (CD_ICON_EFFECT_SAND))
132
glDeleteTextures (1, &myData.iFireTexture);
133
myData.iFireTexture = 0;
135
if (myData.iStarTexture != 0 && ! _effect_is_used (CD_ICON_EFFECT_STARS))
137
glDeleteTextures (1, &myData.iStarTexture);
138
myData.iStarTexture = 0;
140
if (myData.iSnowTexture != 0 && ! _effect_is_used (CD_ICON_EFFECT_SNOW))
142
glDeleteTextures (1, &myData.iSnowTexture);
143
myData.iSnowTexture = 0;
145
if (myData.iRainTexture != 0 && ! _effect_is_used (CD_ICON_EFFECT_RAIN))
147
glDeleteTextures (1, &myData.iRainTexture);
148
myData.iRainTexture = 0;