Debian Codegraph @

Cairo-Penguin/src/applet-init.c

raw symbols SCIP
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 #include "stdlib.h"
21
22 #include "applet-struct.h"
23 #include "applet-config.h"
24 #include "applet-notifications.h"
25 #include "applet-theme.h"
26 #include "applet-animation.h"
27 #include "applet-init.h"
28
29
30 CD_APPLET_DEFINE_BEGIN ("Cairo-Penguin",
31 2, 0, 0,
32 CAIRO_DOCK_CATEGORY_APPLET_FUN,
33 N_("Add a lively Penguin in your dock !\n"
34 "Left click to change the animation,\n"
35 "Middle-click to disturb him ^_^\n"
36 "Tux images are taken from Pingus, some other characters are available or can be added easily."),
37 "Fabounet (Fabrice Rey)")
38 CD_APPLET_DEFINE_COMMON_APPLET_INTERFACE
39 CD_APPLET_REDEFINE_TITLE (N_("Cairo-Penguin"));
40 CD_APPLET_SET_CONTAINER_TYPE (CAIRO_DOCK_MODULE_CAN_DOCK);
41 CD_APPLET_DEFINE_END
42
43
44 CD_APPLET_INIT_BEGIN
45 CD_APPLET_SET_STATIC_ICON;
46 penguin_load_theme (myApplet, myConfig.cThemePath);
47
48 penguin_start_animating_with_delay (myApplet);
49
50 gldi_object_register_notification (myContainer,
51 NOTIFICATION_CLICK_ICON,
52 (GldiNotificationFunc) CD_APPLET_ON_CLICK_FUNC,
53 GLDI_RUN_FIRST,
54 myApplet);
55 gldi_object_register_notification (myContainer,
56 NOTIFICATION_MIDDLE_CLICK_ICON,
57 (GldiNotificationFunc) CD_APPLET_ON_MIDDLE_CLICK_FUNC,
58 GLDI_RUN_FIRST,
59 myApplet);
60 gldi_object_register_notification (myContainer,
61 NOTIFICATION_BUILD_CONTAINER_MENU,
62 (GldiNotificationFunc) on_build_container_menu,
63 GLDI_RUN_FIRST,
64 myApplet);
65 gldi_object_register_notification (myContainer,
66 NOTIFICATION_BUILD_ICON_MENU,
67 (GldiNotificationFunc) CD_APPLET_ON_BUILD_MENU_FUNC,
68 GLDI_RUN_FIRST,
69 myApplet);
70 gldi_object_register_notification (myDock,
71 NOTIFICATION_DESTROY,
72 (GldiNotificationFunc) cd_on_dock_destroyed,
73 GLDI_RUN_AFTER,
74 myApplet);
75 CD_APPLET_INIT_END
76
77
78 CD_APPLET_STOP_BEGIN
79 //\_______________ On se desabonne de nos notifications.
80 gldi_object_remove_notification (myContainer,
81 NOTIFICATION_CLICK_ICON,
82 (GldiNotificationFunc) CD_APPLET_ON_CLICK_FUNC,
83 myApplet);
84 gldi_object_remove_notification (myContainer,
85 NOTIFICATION_MIDDLE_CLICK_ICON,
86 (GldiNotificationFunc) CD_APPLET_ON_MIDDLE_CLICK_FUNC,
87 myApplet);
88 gldi_object_remove_notification (myContainer,
89 NOTIFICATION_BUILD_ICON_MENU,
90 (GldiNotificationFunc) CD_APPLET_ON_BUILD_MENU_FUNC,
91 myApplet);
92 gldi_object_remove_notification (myDock,
93 NOTIFICATION_DESTROY,
94 (GldiNotificationFunc) cd_on_dock_destroyed,
95 myApplet);
96 penguin_remove_notfications();
97
98 if (myData.iSidRestartDelayed != 0)
99 {
100 g_source_remove (myData.iSidRestartDelayed);
101 myData.iSidRestartDelayed = 0;
102 }
103 CD_APPLET_STOP_END
104
105
106 CD_APPLET_RELOAD_BEGIN
107 //\_______________ On recharge les donnees qui ont pu changer.
108 if (CD_APPLET_MY_CONFIG_CHANGED)
109 {
110 //\_______________ On stoppe tout.
111 if (myData.iSidRestartDelayed != 0)
112 {
113 g_source_remove (myData.iSidRestartDelayed);
114 myData.iSidRestartDelayed = 0;
115 }
116 penguin_remove_notfications();
117
118 //\_______________ On efface sa derniere position.
119 PenguinAnimation *pAnimation = penguin_get_current_animation ();
120 if (pAnimation != NULL)
121 {
122 GdkRectangle area;
123 area.x = (myDock->container.iWidth - myDock->fFlatDockWidth) / 2 + myData.iCurrentPositionX;
124 area.y = myDock->container.iHeight - myData.iCurrentPositionY - pAnimation->iFrameHeight;
125 area.width = pAnimation->iFrameWidth;
126 area.height = pAnimation->iFrameHeight + myDock->container.bUseReflect * myDock->iIconSize * myIconsParam.fReflectHeightRatio;
127 cairo_dock_redraw_container_area (myContainer, &area);
128 }
129
130 //\_______________ On recharge tout de zero (changement de theme).
131 cd_penguin_reset_data (myApplet);
132
133 penguin_load_theme (myApplet, myConfig.cThemePath);
134
135 //\_______________ On libere le pingouin ou au contraire on le cloisonne.
136 if (myConfig.bFree)
137 {
138 gldi_icon_detach (myIcon);
139 }
140 else
141 {
142 gldi_icon_insert_in_container (myIcon, myContainer, ! CAIRO_DOCK_ANIMATE_ICON);
143 }
144
145 penguin_start_animating (myApplet);
146 }
147 else
148 {
149 // rien a faire, la taille du pingouin est fixe.
150 }
151 CD_APPLET_RELOAD_END