| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 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 |
|
| 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 |
|
| 108 |
if (CD_APPLET_MY_CONFIG_CHANGED) |
| 109 |
{ |
| 110 |
|
| 111 |
if (myData.iSidRestartDelayed != 0) |
| 112 |
{ |
| 113 |
g_source_remove (myData.iSidRestartDelayed); |
| 114 |
myData.iSidRestartDelayed = 0; |
| 115 |
} |
| 116 |
penguin_remove_notfications(); |
| 117 |
|
| 118 |
|
| 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 |
|
| 131 |
cd_penguin_reset_data (myApplet); |
| 132 |
|
| 133 |
penguin_load_theme (myApplet, myConfig.cThemePath); |
| 134 |
|
| 135 |
|
| 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 |
|
| 150 |
} |
| 151 |
CD_APPLET_RELOAD_END |