~cairo-dock-team/ubuntu/quantal/cairo-dock-plug-ins/3.0.2

« back to all changes in this revision

Viewing changes to keyboard-indicator/src/applet-init.c

Tags: upstream-2.2.0~0beta4
ImportĀ upstreamĀ versionĀ 2.2.0~0beta4

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
 
#include "stdlib.h"
 
20
#include <stdlib.h>
 
21
#include <libxklavier/xklavier.h>
21
22
 
22
23
#include "applet-config.h"
23
24
#include "applet-xklavier.h"
24
25
#include "applet-notifications.h"
25
26
#include "applet-struct.h"
 
27
#include "applet-draw.h"
26
28
#include "applet-init.h"
27
29
 
28
30
 
29
31
CD_APPLET_DEFINITION (N_("keyboard indicator"),
30
32
        2, 0, 0,
31
 
        CAIRO_DOCK_CATEGORY_DESKTOP,
 
33
        CAIRO_DOCK_CATEGORY_APPLET_SYSTEM,
32
34
        N_("This applet lets you control the keyboard layout.\n\
33
35
        It can also display the current num and caps lock.\n\
34
36
        Left-click to switch to the next layout\n\
78
80
        
79
81
        myData.iCurrentGroup = -1;  // pour forcer le redessin.
80
82
        
 
83
        /*Display *dsp = (Display*)cairo_dock_get_Xdisplay (); // const
 
84
        XklEngine *pEngine = xkl_engine_get_instance (dsp);
 
85
        xkl_engine_start_listen (pEngine, XKLL_MANAGE_WINDOW_STATES | XKLL_MANAGE_LAYOUTS);*/
 
86
        
81
87
        Window Xid = cairo_dock_get_current_active_window ();
82
88
        cd_xkbd_keyboard_state_changed (myApplet, &Xid);
83
89
CD_APPLET_INIT_END
85
91
 
86
92
//\___________ Here is where you stop your applet. myConfig and myData are still valid, but will be reseted to 0 at the end of the function. In the end, your applet will go back to its original state, as if it had never been activated.
87
93
CD_APPLET_STOP_BEGIN
 
94
        /*Display *dsp = (Display*)cairo_dock_get_Xdisplay (); // const
 
95
        XklEngine *pEngine = xkl_engine_get_instance (dsp);
 
96
        xkl_engine_stop_listen (pEngine, XKLL_MANAGE_WINDOW_STATES | XKLL_MANAGE_LAYOUTS);*/
88
97
        CD_APPLET_UNREGISTER_FOR_CLICK_EVENT;
89
98
        CD_APPLET_UNREGISTER_FOR_BUILD_MENU_EVENT;
90
99
        CD_APPLET_UNREGISTER_FOR_SCROLL_EVENT;
97
106
 
98
107
//\___________ 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.
99
108
CD_APPLET_RELOAD_BEGIN
100
 
        if (myDesklet)
101
 
        {
102
 
                CD_APPLET_SET_DESKLET_RENDERER ("Simple");  // set a desklet renderer.
103
 
        }
104
 
        
105
109
        myConfig.textDescription.iSize = (int) myIcon->fHeight * myConfig.fTextRatio;
106
110
        
107
111
        if (CD_APPLET_MY_CONFIG_CHANGED)
108
112
        {
 
113
                if (myDesklet && CD_APPLET_MY_CONTAINER_TYPE_CHANGED)  // we are now in a desklet, set a renderer.
 
114
                {
 
115
                        CD_APPLET_SET_DESKLET_RENDERER ("Simple");
 
116
                }
 
117
                
109
118
                CD_APPLET_REMOVE_TRANSITION_ON_MY_ICON;  // prudence.
110
119
                _load_bg_image ();
111
120
                
115
124
                Window Xid = cairo_dock_get_current_active_window ();
116
125
                cd_xkbd_keyboard_state_changed (myApplet, &Xid);
117
126
        }
 
127
        else
 
128
        {
 
129
                myData.iCurrentGroup = -1;
 
130
                cd_xkbd_keyboard_state_changed (myApplet, NULL);
 
131
        }
118
132
CD_APPLET_RELOAD_END