Debian Codegraph @

illusion/src/applet-init.c

raw
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 "evaporate-tex.h"
23
24 #include "applet-config.h"
25 #include "applet-notifications.h"
26 #include "applet-struct.h"
27 #include "applet-init.h"
28
29
30 CD_APPLET_DEFINE_BEGIN (N_("illusion"),
31 2, 0, 0,
32 CAIRO_DOCK_CATEGORY_THEME,
33 N_("This plugin provides animations for the appearance &amp; disappearance of icons."),
34 "Fabounet (Fabrice Rey)")
35 if (! g_bUseOpenGL)
36 return FALSE;
37 CD_APPLET_DEFINE_COMMON_APPLET_INTERFACE
38 CD_APPLET_SET_CONTAINER_TYPE (CAIRO_DOCK_MODULE_IS_PLUGIN);
39 CD_APPLET_DEFINE_END
40
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).
43 CD_APPLET_INIT_BEGIN
44 if (! g_bUseOpenGL || ! CD_APPLET_RESERVE_DATA_SLOT ())
45 return;
46
47 gldi_object_register_notification (&myDockObjectMgr,
48 NOTIFICATION_REMOVE_ICON,
49 (GldiNotificationFunc) cd_illusion_on_remove_insert_icon,
50 GLDI_RUN_FIRST, NULL);
51 gldi_object_register_notification (&myDockObjectMgr,
52 NOTIFICATION_INSERT_ICON,
53 (GldiNotificationFunc) cd_illusion_on_remove_insert_icon,
54 GLDI_RUN_FIRST, NULL);
55 gldi_object_register_notification (&myIconObjectMgr,
56 NOTIFICATION_UPDATE_ICON,
57 (GldiNotificationFunc) cd_illusion_update_icon ,
58 GLDI_RUN_AFTER, NULL);
59 gldi_object_register_notification (&myIconObjectMgr,
60 NOTIFICATION_RENDER_ICON,
61 (GldiNotificationFunc) cd_illusion_render_icon,
62 GLDI_RUN_FIRST, NULL);
63 gldi_object_register_notification (&myIconObjectMgr,
64 NOTIFICATION_STOP_ICON,
65 (GldiNotificationFunc) cd_illusion_free_data,
66 GLDI_RUN_AFTER, NULL);
67 CD_APPLET_INIT_END
68
69 static void _free_data_on_icon (Icon *pIcon, G_GNUC_UNUSED gpointer data)
70 {
71 cd_illusion_free_data (NULL, pIcon);
72 }
73 //\___________ 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.
74 CD_APPLET_STOP_BEGIN
75 gldi_object_remove_notification (&myDockObjectMgr,
76 NOTIFICATION_REMOVE_ICON,
77 (GldiNotificationFunc) cd_illusion_on_remove_insert_icon, NULL);
78 gldi_object_remove_notification (&myDockObjectMgr,
79 NOTIFICATION_INSERT_ICON,
80 (GldiNotificationFunc) cd_illusion_on_remove_insert_icon, NULL);
81 gldi_object_remove_notification (&myIconObjectMgr,
82 NOTIFICATION_UPDATE_ICON,
83 (GldiNotificationFunc) cd_illusion_update_icon, NULL);
84 gldi_object_remove_notification (&myIconObjectMgr,
85 NOTIFICATION_RENDER_ICON,
86 (GldiNotificationFunc) cd_illusion_render_icon, NULL);
87 gldi_object_remove_notification (&myIconObjectMgr,
88 NOTIFICATION_STOP_ICON,
89 (GldiNotificationFunc) cd_illusion_free_data, NULL);
90
91 gldi_icons_foreach ((GldiIconFunc)_free_data_on_icon, NULL);
92 CD_APPLET_STOP_END
93
94
95 //\___________ 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.
96 CD_APPLET_RELOAD_BEGIN
97 // rien a faire, l'animation eventuellement en cours se poursuivra inchangee.
98
99 CD_APPLET_RELOAD_END