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/>.
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"
30
CD_APPLET_DEFINE_BEGIN ("Cairo-Penguin",
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);
45
CD_APPLET_SET_STATIC_ICON;
46
penguin_load_theme (myApplet, myConfig.cThemePath);
48
penguin_start_animating_with_delay (myApplet);
50
gldi_object_register_notification (myContainer,
51
NOTIFICATION_CLICK_ICON,
52
(GldiNotificationFunc) CD_APPLET_ON_CLICK_FUNC,
55
gldi_object_register_notification (myContainer,
56
NOTIFICATION_MIDDLE_CLICK_ICON,
57
(GldiNotificationFunc) CD_APPLET_ON_MIDDLE_CLICK_FUNC,
60
gldi_object_register_notification (myContainer,
61
NOTIFICATION_BUILD_CONTAINER_MENU,
62
(GldiNotificationFunc) on_build_container_menu,
65
gldi_object_register_notification (myContainer,
66
NOTIFICATION_BUILD_ICON_MENU,
67
(GldiNotificationFunc) CD_APPLET_ON_BUILD_MENU_FUNC,
70
gldi_object_register_notification (myDock,
72
(GldiNotificationFunc) cd_on_dock_destroyed,
79
//\_______________ On se desabonne de nos notifications.
80
gldi_object_remove_notification (myContainer,
81
NOTIFICATION_CLICK_ICON,
82
(GldiNotificationFunc) CD_APPLET_ON_CLICK_FUNC,
84
gldi_object_remove_notification (myContainer,
85
NOTIFICATION_MIDDLE_CLICK_ICON,
86
(GldiNotificationFunc) CD_APPLET_ON_MIDDLE_CLICK_FUNC,
88
gldi_object_remove_notification (myContainer,
89
NOTIFICATION_BUILD_ICON_MENU,
90
(GldiNotificationFunc) CD_APPLET_ON_BUILD_MENU_FUNC,
92
gldi_object_remove_notification (myDock,
94
(GldiNotificationFunc) cd_on_dock_destroyed,
96
penguin_remove_notfications();
98
if (myData.iSidRestartDelayed != 0)
100
g_source_remove (myData.iSidRestartDelayed);
101
myData.iSidRestartDelayed = 0;
106
CD_APPLET_RELOAD_BEGIN
107
//\_______________ On recharge les donnees qui ont pu changer.
108
if (CD_APPLET_MY_CONFIG_CHANGED)
110
//\_______________ On stoppe tout.
111
if (myData.iSidRestartDelayed != 0)
113
g_source_remove (myData.iSidRestartDelayed);
114
myData.iSidRestartDelayed = 0;
116
penguin_remove_notfications();
118
//\_______________ On efface sa derniere position.
119
PenguinAnimation *pAnimation = penguin_get_current_animation ();
120
if (pAnimation != NULL)
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);
130
//\_______________ On recharge tout de zero (changement de theme).
131
cd_penguin_reset_data (myApplet);
133
penguin_load_theme (myApplet, myConfig.cThemePath);
135
//\_______________ On libere le pingouin ou au contraire on le cloisonne.
138
gldi_icon_detach (myIcon);
142
gldi_icon_insert_in_container (myIcon, myContainer, ! CAIRO_DOCK_ANIMATE_ICON);
145
penguin_start_animating (myApplet);
149
// rien a faire, la taille du pingouin est fixe.