29
27
#include "applet-init.h"
32
CD_APPLET_DEFINITION (N_("Status Notifier"),
30
CD_APPLET_DEFINE_BEGIN ("Status-Notifier",
34
32
CAIRO_DOCK_CATEGORY_APPLET_DESKTOP,
35
("A <b>notification area</b> for your dock\n"
36
"Also called 'systray'.\n"
37
"It is designed to work on any desktop that supports the latest systray specifications (KDE, Gnome, etc)"),
33
N_("A <b>notification area</b> for your dock\n"
34
"Programs can use it to display their current status.\n"
35
"If a program doesn't appear inside when it should, it's probably because it doesn't support the this feature yet. Please fill a bug report to the devs."),
38
36
"Fabounet (Fabrice Rey)")
37
CD_APPLET_DEFINE_COMMON_APPLET_INTERFACE
38
CD_APPLET_REDEFINE_TITLE (N_("Notification Area"))
41
42
//\___________ 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).
57
58
CD_APPLET_REGISTER_FOR_CLICK_EVENT;
58
59
CD_APPLET_REGISTER_FOR_MIDDLE_CLICK_EVENT;
59
60
CD_APPLET_REGISTER_FOR_BUILD_MENU_EVENT;
60
/*cairo_dock_register_notification (CAIRO_DOCK_ENTER_ICON,
61
/*cairo_dock_register_notification_on_object (&myIconsMgr,
62
CAIRO_DOCK_ENTER_ICON,
61
63
(CairoDockNotificationFunc) cd_status_notifier_on_enter_icon,
62
64
CAIRO_DOCK_RUN_AFTER, myApplet);*/
63
cairo_dock_register_notification (CAIRO_DOCK_BUILD_CONTAINER_MENU,
65
cairo_dock_register_notification_on_object (&myContainersMgr,
66
NOTIFICATION_BUILD_CONTAINER_MENU,
64
67
(CairoDockNotificationFunc) cd_status_notifier_on_right_click,
65
68
CAIRO_DOCK_RUN_FIRST, myApplet);
70
if (myConfig.bCompactMode)
72
cairo_dock_register_notification_on_object (myContainer,
73
NOTIFICATION_MOUSE_MOVED,
74
(CairoDockNotificationFunc) on_mouse_moved,
75
CAIRO_DOCK_RUN_AFTER, myApplet);
78
cairo_dock_register_notification_on_object (myContainer,
79
NOTIFICATION_RENDER_DESKLET,
80
(CairoDockNotificationFunc) on_render_desklet,
81
CAIRO_DOCK_RUN_AFTER, myApplet);
82
cairo_dock_register_notification_on_object (myContainer,
83
NOTIFICATION_UPDATE_DESKLET,
84
(CairoDockNotificationFunc) on_update_desklet,
85
CAIRO_DOCK_RUN_AFTER, myApplet);
86
cairo_dock_register_notification_on_object (myContainer,
87
NOTIFICATION_LEAVE_DESKLET,
88
(CairoDockNotificationFunc) on_leave_desklet,
89
CAIRO_DOCK_RUN_AFTER, myApplet);
93
myData.iDefaultWidth = myIcon->iImageWidth;
94
myData.iDefaultHeight = myIcon->iImageHeight;
95
cd_debug ("=== default size: %dx%d", myData.iDefaultWidth, myData.iDefaultHeight);
67
97
cd_satus_notifier_launch_service ();
73
103
CD_APPLET_UNREGISTER_FOR_MIDDLE_CLICK_EVENT;
74
104
CD_APPLET_UNREGISTER_FOR_CLICK_EVENT;
75
105
CD_APPLET_UNREGISTER_FOR_BUILD_MENU_EVENT;
76
cairo_dock_remove_notification_func (CAIRO_DOCK_BUILD_CONTAINER_MENU,
106
cairo_dock_remove_notification_func_on_object (&myContainersMgr,
107
NOTIFICATION_BUILD_CONTAINER_MENU,
77
108
(CairoDockNotificationFunc) cd_status_notifier_on_right_click,
110
cairo_dock_remove_notification_func_on_object (myContainer,
111
NOTIFICATION_MOUSE_MOVED,
112
(CairoDockNotificationFunc) on_mouse_moved, myApplet);
113
cairo_dock_remove_notification_func_on_object (myContainer,
114
NOTIFICATION_RENDER_DESKLET,
115
(CairoDockNotificationFunc) on_render_desklet, myApplet);
116
cairo_dock_remove_notification_func_on_object (myContainer,
117
NOTIFICATION_UPDATE_DESKLET,
118
(CairoDockNotificationFunc) on_update_desklet, myApplet);
119
cairo_dock_remove_notification_func_on_object (myContainer,
120
NOTIFICATION_LEAVE_DESKLET,
121
(CairoDockNotificationFunc) on_leave_desklet, myApplet);
79
123
cd_satus_notifier_stop_service ();
80
124
CD_APPLET_STOP_END
83
127
//\___________ 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.
84
128
CD_APPLET_RELOAD_BEGIN
129
myData.iDefaultWidth = myIcon->iImageWidth;
130
myData.iDefaultHeight = myIcon->iImageHeight;
131
cd_debug ("=== default size <- %dx%d", myData.iDefaultWidth, myData.iDefaultHeight);
85
133
if (CD_APPLET_MY_CONFIG_CHANGED)
135
cairo_dock_remove_notification_func_on_object (CD_APPLET_MY_OLD_CONTAINER,
136
NOTIFICATION_MOUSE_MOVED,
137
(CairoDockNotificationFunc) on_mouse_moved, myApplet);
138
cairo_dock_remove_notification_func_on_object (CD_APPLET_MY_OLD_CONTAINER,
139
NOTIFICATION_RENDER_DESKLET,
140
(CairoDockNotificationFunc) on_render_desklet, myApplet);
141
cairo_dock_remove_notification_func_on_object (CD_APPLET_MY_OLD_CONTAINER,
142
NOTIFICATION_UPDATE_DESKLET,
143
(CairoDockNotificationFunc) on_update_desklet, myApplet);
144
cairo_dock_remove_notification_func_on_object (CD_APPLET_MY_OLD_CONTAINER,
145
NOTIFICATION_LEAVE_DESKLET,
146
(CairoDockNotificationFunc) on_leave_desklet, myApplet);
148
if (myConfig.bCompactMode)
150
cairo_dock_register_notification_on_object (myContainer,
151
NOTIFICATION_MOUSE_MOVED,
152
(CairoDockNotificationFunc) on_mouse_moved,
153
CAIRO_DOCK_RUN_AFTER, myApplet);
156
cairo_dock_register_notification_on_object (myContainer,
157
NOTIFICATION_RENDER_DESKLET,
158
(CairoDockNotificationFunc) on_render_desklet,
159
CAIRO_DOCK_RUN_AFTER, myApplet);
160
cairo_dock_register_notification_on_object (myContainer,
161
NOTIFICATION_UPDATE_DESKLET,
162
(CairoDockNotificationFunc) on_update_desklet,
163
CAIRO_DOCK_RUN_AFTER, myApplet);
164
cairo_dock_register_notification_on_object (myContainer,
165
NOTIFICATION_LEAVE_DESKLET,
166
(CairoDockNotificationFunc) on_leave_desklet,
167
CAIRO_DOCK_RUN_AFTER, myApplet);
87
171
if (myConfig.bCompactMode)
89
173
if (myDesklet && CD_APPLET_MY_CONTAINER_TYPE_CHANGED) // we are now in a desklet, set a renderer.