~cairo-dock-team/ubuntu/quantal/cairo-dock-plug-ins/3.0.2

« back to all changes in this revision

Viewing changes to drop-indicator/src/applet-init.c

Tags: upstream-2.2.0~0beta4
ImportĀ upstreamĀ versionĀ 2.2.0~0beta4

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include "applet-init.h"
26
26
 
27
27
 
28
 
CD_APPLET_PRE_INIT_BEGIN (N_("drop indicator"),
 
28
CD_APPLET_DEFINE_BEGIN (N_("drop indicator"),
29
29
        2, 0, 0,
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
36
 
 
37
 
 
38
 
static void _load_drop_indicator (void)
 
36
CD_APPLET_DEFINE_END
 
37
 
 
38
 
 
39
static void _load_indicators (void)
39
40
{
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;
44
44
        
45
 
        gchar *cImagePath;
46
 
        if (myConfig.cDropIndicatorImageName != NULL)
47
 
        {
48
 
                cImagePath = cairo_dock_generate_file_path (myConfig.cDropIndicatorImageName);
49
 
        }
50
 
        else
51
 
        {
52
 
                cImagePath = g_strdup_printf ("%s/%s", MY_APPLET_SHARE_DATA_DIR, MY_APPLET_DEFAULT_DROP_INDICATOR_NAME);
53
 
        }
54
 
        cd_drop_indicator_load_drop_indicator (cImagePath,
55
 
                pCairoContext,
 
45
        cd_drop_indicator_load_drop_indicator (myConfig.cDropIndicatorImageName,
56
46
                iInitialWidth,
57
47
                iInitialHeight);
58
 
        g_free (cImagePath);
59
48
        
60
 
        if (myConfig.cHoverIndicatorImageName != NULL)
61
 
        {
62
 
                cImagePath = cairo_dock_generate_file_path (myConfig.cHoverIndicatorImageName);
63
 
        }
64
 
        else
65
 
        {
66
 
                cImagePath = g_strdup_printf ("%s/%s", MY_APPLET_SHARE_DATA_DIR, MY_APPLET_DEFAULT_HOVER_INDICATOR_NAME);
67
 
        }
68
 
        cd_drop_indicator_load_hover_indicator (cImagePath,
69
 
                pCairoContext,
 
49
        cd_drop_indicator_load_hover_indicator (myConfig.cHoverIndicatorImageName,
70
50
                iInitialWidth/3,
71
51
                iInitialHeight*2/3);
72
 
        g_free (cImagePath);
73
 
        
74
 
        cairo_destroy (pCairoContext);
75
52
}
76
53
 
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))
80
57
                return;
81
58
        
82
 
        _load_drop_indicator ();
 
59
        _load_indicators ();
83
60
        
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);
90
67
 
91
68
 
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)
94
71
{
95
72
        cd_drop_indicator_stop_dock (NULL, pDock);
96
73
}
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);
102
79
        
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
105
82
 
106
83
 
109
86
        if (CD_APPLET_MY_CONFIG_CHANGED)
110
87
        {
111
88
                cd_drop_indicator_free_buffers ();
112
 
                _load_drop_indicator ();
 
89
                _load_indicators ();
113
90
        }
114
91
        
115
92
CD_APPLET_RELOAD_END