2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
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.
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/>.
22
#include "applet-config.h"
23
#include "applet-notifications.h"
24
#include "applet-struct.h"
25
#include "applet-session.h"
26
#include "applet-search.h"
27
#include "applet-listing.h"
28
#include "applet-backend-files.h"
29
#include "applet-backend-web.h"
30
#include "applet-backend-command.h"
31
#include "applet-init.h"
34
CD_APPLET_DEFINITION ("Scooby-Do",
36
CAIRO_DOCK_CATEGORY_PLUG_IN,
37
N_("A Gnome-Do-like plug-in that lets you control your dock from the keyboard.\n"
38
"It has 2 modes, each one being triggered by a keyboard shortcut:\n"
39
"- the navigation mode : use the arrows to navigate into the docks and sub-docks,\n"
40
" or type the name of a launcher and press Tab to automatically jump to the next suitable launcher\n"
41
" press Enter to click on the icon, Shift+Enter for Shift+click, Alt+Enter for middle click, and Ctrl+Enter for left click\n"
42
"- the finder mode : type some text to launch any command, file or calculation.\n"
43
" use the arrows to navigate between the results, press Enter to validate, maintain CTRL, ALT or SHIFT to keep the results.\n"
44
"Escape or the same shortkey to cancel."),
45
"Fabounet (Fabrice Rey)")
48
//\___________ 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).
50
cairo_dock_register_notification (CAIRO_DOCK_KEY_PRESSED, (CairoDockNotificationFunc) cd_do_key_pressed, CAIRO_DOCK_RUN_AFTER, NULL);
52
cd_keybinder_bind (myConfig.cShortkeyNav, (CDBindkeyHandler) cd_do_on_shortkey_nav, myApplet);
53
cd_keybinder_bind (myConfig.cShortkeySearch, (CDBindkeyHandler) cd_do_on_shortkey_search, myApplet);
55
cd_do_register_files_backend ();
56
cd_do_register_web_backend ();
57
cd_do_register_command_backend ();
61
//\___________ 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.
63
cairo_dock_remove_notification_func (CAIRO_DOCK_KEY_PRESSED, (CairoDockNotificationFunc) cd_do_key_pressed, NULL);
65
cd_do_exit_session ();
66
cd_do_stop_all_backends ();
70
//\___________ 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.
71
CD_APPLET_RELOAD_BEGIN
72
if (CD_APPLET_MY_CONFIG_CHANGED)
74
cd_keybinder_bind (myConfig.cShortkeyNav, (CDBindkeyHandler) cd_do_on_shortkey_nav, myApplet); // shortkey were unbinded during reset_config.
75
cd_keybinder_bind (myConfig.cShortkeySearch, (CDBindkeyHandler) cd_do_on_shortkey_search, myApplet); // shortkey were unbinded during reset_config.
77
cd_do_destroy_listing (myData.pListing);
78
myData.pListing = NULL;
80
if (myData.sCurrentText != NULL)
82
/// recharger surfaces / textures
85
cairo_dock_redraw_container (CAIRO_CONTAINER (g_pMainDock));