25
25
#include "applet-init.h"
28
CD_APPLET_PRE_INIT_BEGIN (N_("drop indicator"),
28
CD_APPLET_DEFINE_BEGIN (N_("drop indicator"),
30
30
CAIRO_DOCK_CATEGORY_THEME,
31
N_("This plug-in displays an animated indicator when you drop something in the dock."),
31
N_("This plug-in displays an animated indicator when you drop something into the dock."),
32
32
"Fabounet (Fabrice Rey)")
33
33
CD_APPLET_DEFINE_COMMON_APPLET_INTERFACE;
34
CD_APPLET_SET_CONTAINER_TYPE (CAIRO_DOCK_MODULE_IS_PLUGIN);
34
35
CD_APPLET_ATTACH_TO_INTERNAL_MODULE ("Indicators");
35
CD_APPLET_PRE_INIT_END
38
static void _load_drop_indicator (void)
39
static void _load_indicators (void)
40
cairo_t* pCairoContext = cairo_dock_create_context_from_window (CAIRO_CONTAINER (g_pMainDock));
41
41
double fMaxScale = cairo_dock_get_max_scale (g_pMainDock);
42
42
double iInitialWidth = myIcons.tIconAuthorizedWidth[CAIRO_DOCK_LAUNCHER] * fMaxScale;
43
43
double iInitialHeight = myIcons.tIconAuthorizedHeight[CAIRO_DOCK_LAUNCHER] * fMaxScale / 2;
46
if (myConfig.cDropIndicatorImageName != NULL)
48
cImagePath = cairo_dock_generate_file_path (myConfig.cDropIndicatorImageName);
52
cImagePath = g_strdup_printf ("%s/%s", MY_APPLET_SHARE_DATA_DIR, MY_APPLET_DEFAULT_DROP_INDICATOR_NAME);
54
cd_drop_indicator_load_drop_indicator (cImagePath,
45
cd_drop_indicator_load_drop_indicator (myConfig.cDropIndicatorImageName,
60
if (myConfig.cHoverIndicatorImageName != NULL)
62
cImagePath = cairo_dock_generate_file_path (myConfig.cHoverIndicatorImageName);
66
cImagePath = g_strdup_printf ("%s/%s", MY_APPLET_SHARE_DATA_DIR, MY_APPLET_DEFAULT_HOVER_INDICATOR_NAME);
68
cd_drop_indicator_load_hover_indicator (cImagePath,
49
cd_drop_indicator_load_hover_indicator (myConfig.cHoverIndicatorImageName,
71
51
iInitialHeight*2/3);
74
cairo_destroy (pCairoContext);
77
54
//\___________ 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).
79
56
if (! cairo_dock_reserve_data_slot (myApplet))
82
_load_drop_indicator ();
84
61
cairo_dock_register_notification (CAIRO_DOCK_RENDER_DOCK, (CairoDockNotificationFunc) cd_drop_indicator_render, CAIRO_DOCK_RUN_AFTER, NULL);
85
62
cairo_dock_register_notification (CAIRO_DOCK_MOUSE_MOVED, (CairoDockNotificationFunc) cd_drop_indicator_mouse_moved, CAIRO_DOCK_RUN_AFTER, NULL);
92
69
//\___________ 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.
93
static void _free_data_on_dock (gchar *cDockName, CairoDock *pDock, gpointer data)
70
static void _free_data_on_dock (const gchar *cDockName, CairoDock *pDock, gpointer data)
95
72
cd_drop_indicator_stop_dock (NULL, pDock);
100
77
cairo_dock_remove_notification_func (CAIRO_DOCK_UPDATE_DOCK, (CairoDockNotificationFunc) cd_drop_indicator_update_dock, NULL);
101
78
cairo_dock_remove_notification_func (CAIRO_DOCK_STOP_DOCK, (CairoDockNotificationFunc) cd_drop_indicator_stop_dock, NULL);
103
cairo_dock_foreach_docks (_free_data_on_dock, NULL);
80
cairo_dock_foreach_docks ((GHFunc)_free_data_on_dock, NULL);
104
81
CD_APPLET_STOP_END