~ubuntu-branches/ubuntu/quantal/cairo-dock-plug-ins/quantal-201208191523

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2010-08-10 00:05:57 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20100810000557-pfxoz5w7hbyclcqh
Tags: 2.2.0~0beta4-0ubuntu1
* New Upstream Version (LP: #614625)
* Fixed a few bugs on LP:
 - LP: #483963: Dustbin applet does not display trashes on all volumes
 - LP: #485159: Some apps have problem with Systray
 - LP: #500677: ~/.xsession-errors is too much used by CD
 - LP: #500979: Shortcuts: the order gets messed up
 - LP: #521531: Mail: crashes on Maildir
 - LP: #519915: GTG: create a new applet to control GTG
 - LP: #526138: GMenu doesn't handle desktop file exec strings properly
 - LP: #531317: CMake: Added an error if the prefix of 'cairo-dock-plugins'
                 is not the same 'cairo-dock-core'
 - LP: #531319: CMake: check the version of 'cairo-dock' when building
                 'cairo-dock-plugins'
 - LP: #537115: Click at the position where icon lavel was, the icon
                 and dock still receive the event
 - LP: #537943: Terminal applet shortkey behaviour
 - LP: #538637: Trash applet doesn't create .trashinfo files on XFCE
 - More details on the 'ChangeLog' file
* debian/rules:
 - Autotools has been replaced by CMake
 - cdbs is now used.
* debian/copyright:
 - Updated with the new applets
* debian/control:
 - Autotools has been replaced by CMake
 - Added libcurl4-gnutls-dev, libindicator-dev, libdbusmenu-glib-dev
   libido-0.1-dev, libical-dev, libdbusmenu-gtk-dev as Build-deps
 - Bump Standard-Version to 3.9.1
 - Wget is required for dnd2share applet
 - Added the exact realease for 'cairo-dock-dev' in order to prevent any
    build error if this package is not already available (thx to didrocks)
* debian/cairo-dock-plug-ins*.install:
 - All sonames are now installed into lib32 or lib64 (lib*)

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