~ubuntu-branches/ubuntu/quantal/cairo-dock-plug-ins/quantal-201208191523

« back to all changes in this revision

Viewing changes to Status-Notifier/src/applet-init.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2011-04-20 20:46:51 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20110420204651-ftnpzesj6uc7qeul
Tags: 2.3.0~1-0ubuntu1
* New Upstream Version (LP: #723995)
* Upstream short ChangeLog (since 2.3.0~0rc1):
 - Updated translations
 - Updated the integration of the new versions of kwin and compiz
    (Switcher, ShowDesktop, etc.)
 - Removed a lot of useless g_print
 - Updated a few plug-ins to fit with the new version of the API (gldit)
 - Fixed a few bugs
 - Updated MeMenu, MessagingMenu and Status-Notifier to works
    with the latest version of dbusmenu, etc.
* Switch to dpkg-source 3.0 (quilt) format
* debian/cairo-dock-plug-ins.install:
 - Added new files (interfaces for python, ruby, vala and mono)
* debian/control:
 - Added new dependences for new applets (sensors and zeitgeist)
    and new interfaces (python, valac, ruby and mono)
 - Updated the version of cairo-dock build-dependences
* debian/rules:
 - Added a new CMake flag to install python interface in debian/tmp
* Updated debian/watch

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
18
*/
19
19
 
20
 
//\________________ Add your name in the copyright file (and / or modify your name here)
21
 
 
22
20
#include "stdlib.h"
23
21
 
24
22
#include "applet-config.h"
29
27
#include "applet-init.h"
30
28
 
31
29
 
32
 
CD_APPLET_DEFINITION (N_("Status Notifier"),
33
 
        2, 2, 0,
 
30
CD_APPLET_DEFINE_BEGIN ("Status-Notifier",
 
31
        2, 3, 0,
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"))
 
39
CD_APPLET_DEFINE_END
39
40
 
40
41
 
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);
66
69
        
 
70
        if (myConfig.bCompactMode)
 
71
        {
 
72
                cairo_dock_register_notification_on_object (myContainer,
 
73
                        NOTIFICATION_MOUSE_MOVED,
 
74
                        (CairoDockNotificationFunc) on_mouse_moved,
 
75
                        CAIRO_DOCK_RUN_AFTER, myApplet);
 
76
                if (myDesklet)
 
77
                {
 
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);
 
90
                }
 
91
        }
 
92
        
 
93
        myData.iDefaultWidth = myIcon->iImageWidth;
 
94
        myData.iDefaultHeight = myIcon->iImageHeight;
 
95
        cd_debug ("=== default size: %dx%d", myData.iDefaultWidth, myData.iDefaultHeight);
 
96
        
67
97
        cd_satus_notifier_launch_service ();
68
98
CD_APPLET_INIT_END
69
99
 
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,
78
109
                myApplet);
 
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);
 
122
        
79
123
        cd_satus_notifier_stop_service ();
80
124
CD_APPLET_STOP_END
81
125
 
82
126
 
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);
 
132
        
85
133
        if (CD_APPLET_MY_CONFIG_CHANGED)
86
134
        {
 
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);
 
147
                
 
148
                if (myConfig.bCompactMode)
 
149
                {
 
150
                        cairo_dock_register_notification_on_object (myContainer,
 
151
                                NOTIFICATION_MOUSE_MOVED,
 
152
                                (CairoDockNotificationFunc) on_mouse_moved,
 
153
                                CAIRO_DOCK_RUN_AFTER, myApplet);
 
154
                        if (myDesklet)
 
155
                        {
 
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);
 
168
                        }
 
169
                }
 
170
                
87
171
                if (myConfig.bCompactMode)
88
172
                {
89
173
                        if (myDesklet && CD_APPLET_MY_CONTAINER_TYPE_CHANGED)  // we are now in a desklet, set a renderer.
91
175
                                CD_APPLET_SET_DESKLET_RENDERER ("Simple");  // set a desklet renderer.
92
176
                        }
93
177
                        CD_APPLET_DELETE_MY_ICONS_LIST;
 
178
                        if (myDock)  // on ne veut pas d'un sous-dock vide.
 
179
                        {
 
180
                                cairo_dock_destroy_dock (myIcon->pSubDock, myIcon->cName);
 
181
                                myIcon->pSubDock = NULL;
 
182
                        }
94
183
                        cd_satus_notifier_reload_compact_mode ();
95
 
                        
96
184
                }
97
185
                else
98
186
                {