~ubuntu-branches/ubuntu/saucy/cairo-dock-plug-ins/saucy

« back to all changes in this revision

Viewing changes to Animated-icons/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
 
 
29
#include "stdlib.h"
 
30
 
 
31
#include "chrome-tex.h"
 
32
 
 
33
#include "applet-config.h"
 
34
#include "applet-rotation.h"
 
35
#include "applet-mesh-factory.h"
 
36
#include "applet-notifications.h"
 
37
#include "applet-struct.h"
 
38
#include "applet-init.h"
 
39
 
 
40
 
 
41
CD_APPLET_DEFINITION (N_("Animated icons"),
 
42
        2, 0, 0,
 
43
        CAIRO_DOCK_CATEGORY_THEME,
 
44
        N_("This plug-in provides many different animations for your icons."),
 
45
        "Fabounet (Fabrice Rey)")
 
46
 
 
47
 
 
48
//\___________ 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).
 
49
CD_APPLET_INIT_BEGIN
 
50
        if (! cairo_dock_reserve_data_slot (myApplet))
 
51
                return;
 
52
        
 
53
        cairo_dock_register_notification (CAIRO_DOCK_ENTER_ICON, (CairoDockNotificationFunc) cd_animations_on_enter, CAIRO_DOCK_RUN_AFTER, NULL);
 
54
        cairo_dock_register_notification (CAIRO_DOCK_CLICK_ICON, (CairoDockNotificationFunc) cd_animations_on_click, CAIRO_DOCK_RUN_FIRST, NULL);
 
55
        cairo_dock_register_notification (CAIRO_DOCK_REQUEST_ICON_ANIMATION, (CairoDockNotificationFunc) cd_animations_on_request, CAIRO_DOCK_RUN_FIRST, NULL);
 
56
        cairo_dock_register_notification (CAIRO_DOCK_UPDATE_ICON, (CairoDockNotificationFunc) cd_animations_update_icon , CAIRO_DOCK_RUN_AFTER, NULL);
 
57
        cairo_dock_register_notification (CAIRO_DOCK_RENDER_ICON, (CairoDockNotificationFunc) cd_animations_render_icon, CAIRO_DOCK_RUN_FIRST, NULL);
 
58
        cairo_dock_register_notification (CAIRO_DOCK_RENDER_ICON, (CairoDockNotificationFunc) cd_animations_post_render_icon, CAIRO_DOCK_RUN_AFTER, NULL);
 
59
        cairo_dock_register_notification (CAIRO_DOCK_STOP_ICON, (CairoDockNotificationFunc) cd_animations_free_data, CAIRO_DOCK_RUN_AFTER, NULL);
 
60
        
 
61
        myData.iAnimationID[CD_ANIMATIONS_BOUNCE] = cairo_dock_register_animation ("bounce");
 
62
        myData.iAnimationID[CD_ANIMATIONS_ROTATE] = cairo_dock_register_animation ("rotate");
 
63
        myData.iAnimationID[CD_ANIMATIONS_BLINK] = cairo_dock_register_animation ("blink");
 
64
        myData.iAnimationID[CD_ANIMATIONS_PULSE] = cairo_dock_register_animation ("pulse");
 
65
        myData.iAnimationID[CD_ANIMATIONS_WOBBLY] = cairo_dock_register_animation ("wobbly");
 
66
        myData.iAnimationID[CD_ANIMATIONS_WAVE] = cairo_dock_register_animation ("wave");
 
67
        myData.iAnimationID[CD_ANIMATIONS_SPOT] = cairo_dock_register_animation ("spot");
 
68
        
 
69
        if (! cairo_dock_is_loading ())
 
70
                cairo_dock_update_animations_list_for_gui ();
 
71
CD_APPLET_INIT_END
 
72
 
 
73
static void _free_data_on_icon (Icon *pIcon, CairoDock *pDock, gpointer data)
 
74
{
 
75
        cd_animations_free_data (NULL, pIcon);
 
76
}
 
77
//\___________ 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.
 
78
CD_APPLET_STOP_BEGIN
 
79
        cairo_dock_remove_notification_func (CAIRO_DOCK_ENTER_ICON, (CairoDockNotificationFunc) cd_animations_on_enter, NULL);
 
80
        cairo_dock_remove_notification_func (CAIRO_DOCK_CLICK_ICON, (CairoDockNotificationFunc) cd_animations_on_click, NULL);
 
81
        cairo_dock_remove_notification_func (CAIRO_DOCK_REQUEST_ICON_ANIMATION, (CairoDockNotificationFunc) cd_animations_on_request, NULL);
 
82
        cairo_dock_remove_notification_func (CAIRO_DOCK_UPDATE_ICON, (CairoDockNotificationFunc) cd_animations_update_icon, NULL);
 
83
        cairo_dock_remove_notification_func (CAIRO_DOCK_RENDER_ICON, (CairoDockNotificationFunc) cd_animations_render_icon, NULL);
 
84
        cairo_dock_remove_notification_func (CAIRO_DOCK_RENDER_ICON, (CairoDockNotificationFunc) cd_animations_post_render_icon, NULL);
 
85
        cairo_dock_remove_notification_func (CAIRO_DOCK_STOP_ICON, (CairoDockNotificationFunc) cd_animations_free_data, NULL);
 
86
        
 
87
        cairo_dock_unregister_animation ("bounce");
 
88
        cairo_dock_unregister_animation ("rotate");
 
89
        cairo_dock_unregister_animation ("blink");
 
90
        cairo_dock_unregister_animation ("pulse");
 
91
        cairo_dock_unregister_animation ("wobbly");
 
92
        cairo_dock_unregister_animation ("wave");
 
93
        cairo_dock_unregister_animation ("spot");
 
94
        cairo_dock_update_animations_list_for_gui ();
 
95
        
 
96
        cairo_dock_foreach_icons ((CairoDockForeachIconFunc) _free_data_on_icon, NULL);
 
97
CD_APPLET_STOP_END
 
98
   
 
99
   
 
100
//\___________ 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.
 
101
CD_APPLET_RELOAD_BEGIN
 
102
        //\_______________ On recharge les donnees qui ont pu changer.
 
103
        if (CD_APPLET_MY_CONFIG_CHANGED && g_bUseOpenGL)
 
104
        {
 
105
                if (myConfig.iRotationDuration == 0)
 
106
                {
 
107
                        if (myData.iChromeTexture != 0)
 
108
                        {
 
109
                                glDeleteTextures (1, &myData.iChromeTexture);
 
110
                                myData.iChromeTexture = 0;
 
111
                        }
 
112
                        if (myData.iCallList[CD_CUBE_MESH] != 0)
 
113
                        {
 
114
                                glDeleteLists (myData.iCallList[CD_CUBE_MESH], 1);
 
115
                                myData.iCallList[CD_CUBE_MESH] = 0;
 
116
                        }
 
117
                        if (myData.iCallList[CD_CAPSULE_MESH] != 0)
 
118
                        {
 
119
                                glDeleteLists (myData.iCallList[CD_CAPSULE_MESH], 1);
 
120
                                myData.iCallList[CD_CAPSULE_MESH] = 0;
 
121
                        }
 
122
                        if (myData.iCallList[CD_SQUARE_MESH] != 0)
 
123
                        {
 
124
                                glDeleteLists (myData.iCallList[CD_SQUARE_MESH], 1);
 
125
                                myData.iCallList[CD_SQUARE_MESH] = 0;
 
126
                        }
 
127
                }
 
128
                else
 
129
                {
 
130
                        if (myConfig.iMeshType != CD_CUBE_MESH && myData.iCallList[CD_CUBE_MESH] != 0)
 
131
                        {
 
132
                                glDeleteLists (myData.iCallList[CD_CUBE_MESH], 1);
 
133
                                myData.iCallList[CD_CUBE_MESH] = 0;
 
134
                        }
 
135
                        if (myConfig.iMeshType != CD_CAPSULE_MESH && myData.iCallList[CD_CAPSULE_MESH] != 0)
 
136
                        {
 
137
                                glDeleteLists (myData.iCallList[CD_CAPSULE_MESH], 1);
 
138
                                myData.iCallList[CD_CAPSULE_MESH] = 0;
 
139
                        }
 
140
                        
 
141
                        if (myData.iCallList[myConfig.iMeshType] == 0)
 
142
                                myData.iCallList[myConfig.iMeshType] = cd_animations_load_mesh (myConfig.iMeshType);
 
143
                }
 
144
                
 
145
                if (myConfig.iSpotDuration == 0)
 
146
                {
 
147
                        if (myData.iSpotTexture != 0)
 
148
                        {
 
149
                                glDeleteTextures (1, &myData.iSpotTexture);
 
150
                                myData.iSpotTexture = 0;
 
151
                        }
 
152
                        if (myData.iHaloTexture != 0)
 
153
                        {
 
154
                                glDeleteTextures (1, &myData.iHaloTexture);
 
155
                                myData.iHaloTexture = 0;
 
156
                        }
 
157
                        if (myData.iSpotFrontTexture != 0)
 
158
                        {
 
159
                                glDeleteTextures (1, &myData.iSpotFrontTexture);
 
160
                                myData.iSpotFrontTexture = 0;
 
161
                        }
 
162
                        if (myData.iRaysTexture != 0)
 
163
                        {
 
164
                                glDeleteTextures (1, &myData.iRaysTexture);
 
165
                                myData.iRaysTexture = 0;
 
166
                        }
 
167
                }
 
168
        }
 
169
CD_APPLET_RELOAD_END