~cairo-dock-team/cairo-dock-plug-ins/plug-ins

« back to all changes in this revision

Viewing changes to Remote-Control/src/applet-init.c

  • Committer: Matthieu Baerts
  • Date: 2014-10-19 00:26:10 UTC
  • Revision ID: matttbe@gmail.com-20141019002610-ulf26s9b4c4rw10r
We just switched from BZR to Git.
Follow us on Github: https://github.com/Cairo-Dock

Note: we will only use Github to manage our source code and all pull requests.
Please continue to report your bugs/ideas/messages on our forum or Launchpad! 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
* This file is a part of the Cairo-Dock project
3
 
*
4
 
* Copyright : (C) see the 'copyright' file.
5
 
* E-mail    : see the 'copyright' file.
6
 
*
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.
11
 
*
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/>.
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-session.h"
26
 
#include "applet-init.h"
27
 
 
28
 
 
29
 
CD_APPLET_DEFINE_BEGIN ("Remote-Control",
30
 
        2, 2, 0,
31
 
        CAIRO_DOCK_CATEGORY_APPLET_SYSTEM,
32
 
        N_("This plug-in lets you control your dock from the keyboard\n"
33
 
        "Press the shortcut (by default Super + Return), then either:\n"
34
 
        " - press the number of the icon that you want to activate"
35
 
        " - or use the arrows to navigate into the docks and sub-docks (Ctrl + Page up/down to change to another main dock)\n"
36
 
        " - or type the name of a launcher and press Tab to automatically jump to the next suitable launcher\n"
37
 
        "Press Enter to click on the icon, Shift+Enter for Shift+click, Alt+Enter for middle click, and Ctrl+Enter for left click\n"
38
 
        "Escape or the same shortkey will cancel."),
39
 
        "Fabounet (Fabrice Rey)")
40
 
        CD_APPLET_DEFINE_COMMON_APPLET_INTERFACE
41
 
        CD_APPLET_SET_CONTAINER_TYPE (CAIRO_DOCK_MODULE_IS_PLUGIN);
42
 
        CD_APPLET_REDEFINE_TITLE (N_("Control from keyboard"))
43
 
CD_APPLET_DEFINE_END
44
 
 
45
 
 
46
 
//\___________ 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).
47
 
CD_APPLET_INIT_BEGIN
48
 
        myData.pKeyBinding = CD_APPLET_BIND_KEY (myConfig.cShortkey,
49
 
                D_("Enable/disable the keyboard control of the dock"),
50
 
                "Configuration", "shortkey",
51
 
                (CDBindkeyHandler) cd_do_on_shortkey_nav);
52
 
CD_APPLET_INIT_END
53
 
 
54
 
 
55
 
//\___________ 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.
56
 
CD_APPLET_STOP_BEGIN
57
 
        cd_do_exit_session ();
58
 
 
59
 
        gldi_object_unref (GLDI_OBJECT(myData.pKeyBinding));
60
 
CD_APPLET_STOP_END
61
 
 
62
 
 
63
 
//\___________ 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.
64
 
CD_APPLET_RELOAD_BEGIN
65
 
        if (CD_APPLET_MY_CONFIG_CHANGED)
66
 
        {
67
 
                cd_do_exit_session ();
68
 
                gldi_shortkey_rebind (myData.pKeyBinding, myConfig.cShortkey, NULL);
69
 
        }
70
 
CD_APPLET_RELOAD_END