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-slider.h"
26
#include "applet-init.h"
29
CD_APPLET_DEFINITION (N_("slider"),
31
CAIRO_DOCK_CATEGORY_APPLET_ACCESSORY,
32
N_("This applet is a basic image slider\n"
33
" You just have to select a directory and a display effect and you're done\n"
34
"Click to play/pause or to edit the current image.\n"
35
"Middle-click to open the images folder."),
36
"ChAnGFu (Rémy Robertson) & Fabounet (Fabrice Rey)")
38
//\___________ 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).
41
CD_APPLET_SET_DESKLET_RENDERER ("Simple");
42
CD_APPLET_ALLOW_NO_CLICKABLE_DESKLET;
45
CD_APPLET_GET_MY_ICON_EXTENT (&myData.iSurfaceWidth, &myData.iSurfaceHeight);
47
cd_slider_start (myApplet, TRUE); // TRUE <=> with delay
49
CD_APPLET_REGISTER_FOR_CLICK_EVENT;
50
CD_APPLET_REGISTER_FOR_BUILD_MENU_EVENT;
51
CD_APPLET_REGISTER_FOR_MIDDLE_CLICK_EVENT;
52
CD_APPLET_REGISTER_FOR_SCROLL_EVENT;
53
CD_APPLET_REGISTER_FOR_UPDATE_ICON_EVENT;
57
//\___________ 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.
59
CD_APPLET_UNREGISTER_FOR_CLICK_EVENT;
60
CD_APPLET_UNREGISTER_FOR_BUILD_MENU_EVENT;
61
CD_APPLET_UNREGISTER_FOR_MIDDLE_CLICK_EVENT;
62
CD_APPLET_UNREGISTER_FOR_SCROLL_EVENT;
63
CD_APPLET_UNREGISTER_FOR_UPDATE_ICON_EVENT;
65
cd_slider_stop (myApplet);
69
//\___________ 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.
70
CD_APPLET_RELOAD_BEGIN
71
CD_APPLET_GET_MY_ICON_EXTENT (&myData.iSurfaceWidth, &myData.iSurfaceHeight); // meme si le container n'a pas change, car un desklet se redimensionne, et l'icone avec.
73
//\_______________ Reload all changed data.
74
if (CD_APPLET_MY_CONFIG_CHANGED)
76
if ((!myConfig.bImageName || myDock) && myIcon->cQuickInfo != NULL) // remove quick-info if not displayed any more.
78
CD_APPLET_SET_QUICK_INFO_ON_MY_ICON (NULL);
81
if (myDesklet && CD_APPLET_MY_CONTAINER_TYPE_CHANGED) // we are now in a desklet, set a renderer.
83
CD_APPLET_SET_DESKLET_RENDERER ("Simple");
84
CD_APPLET_ALLOW_NO_CLICKABLE_DESKLET;
87
if (cairo_dock_strings_differ (myData.cDirectory, myConfig.cDirectory)
88
|| myData.bSubDirs != myConfig.bSubDirs
89
|| myData.bRandom != myConfig.bRandom) // need to reload the images list.
91
cd_slider_stop (myApplet);
93
cd_slider_start (myApplet, FALSE); // FALSE <=> immediately
95
else // jump tp next slide to show the differences (new animation, new frame width, etc)
97
cd_slider_jump_to_next_slide (myApplet);
104
if (myData.pElement == NULL)
105
myData.pElement = myData.pList;
107
myData.pElement = cairo_dock_get_previous_element (myData.pElement, myData.pList);
108
cd_slider_jump_to_next_slide (myApplet); // a quick'n'dirty but safe way to reload correctly the current image at the new applet's size.