~ubuntu-branches/ubuntu/oneiric/cairo-dock-plug-ins/oneiric-201107051811

« back to all changes in this revision

Viewing changes to Recent-Events/src/applet-init.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2011-04-20 20:46:51 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20110420204651-ftnpzesj6uc7qeul
Tags: 2.3.0~1-0ubuntu1
* New Upstream Version (LP: #723995)
* Upstream short ChangeLog (since 2.3.0~0rc1):
 - Updated translations
 - Updated the integration of the new versions of kwin and compiz
    (Switcher, ShowDesktop, etc.)
 - Removed a lot of useless g_print
 - Updated a few plug-ins to fit with the new version of the API (gldit)
 - Fixed a few bugs
 - Updated MeMenu, MessagingMenu and Status-Notifier to works
    with the latest version of dbusmenu, etc.
* Switch to dpkg-source 3.0 (quilt) format
* debian/cairo-dock-plug-ins.install:
 - Added new files (interfaces for python, ruby, vala and mono)
* debian/control:
 - Added new dependences for new applets (sensors and zeitgeist)
    and new interfaces (python, valac, ruby and mono)
 - Updated the version of cairo-dock build-dependences
* debian/rules:
 - Added a new CMake flag to install python interface in debian/tmp
* Updated debian/watch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 "applet-config.h"
 
23
#include "applet-notifications.h"
 
24
#include "applet-struct.h"
 
25
#include "applet-init.h"
 
26
 
 
27
 
 
28
CD_APPLET_DEFINITION (N_("Recent-Events"),
 
29
        2, 2, 0,
 
30
        CAIRO_DOCK_CATEGORY_APPLET_ACCESSORY,
 
31
        ("This applet remembers you last actions to help you working faster.\n"
 
32
        "It also adds related actions on other icons' menu.\n"
 
33
        "You need to run Zeitgeist to use this applet."),
 
34
        "Fabounet")
 
35
 
 
36
 
 
37
//\___________ 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).
 
38
CD_APPLET_INIT_BEGIN
 
39
        if (myDesklet)
 
40
        {
 
41
                CD_APPLET_SET_DESKLET_RENDERER ("Simple");  // set a desklet renderer.
 
42
        }
 
43
        
 
44
        CD_APPLET_SET_DEFAULT_IMAGE_ON_MY_ICON_IF_NONE;  // set the default icon if none is specified in conf.
 
45
        
 
46
        
 
47
        CD_APPLET_REGISTER_FOR_CLICK_EVENT;
 
48
        CD_APPLET_REGISTER_FOR_MIDDLE_CLICK_EVENT;
 
49
        cairo_dock_register_notification_on_object (&myContainersMgr,
 
50
                NOTIFICATION_BUILD_ICON_MENU,
 
51
                (CairoDockNotificationFunc) CD_APPLET_ON_BUILD_MENU_FUNC,
 
52
                CAIRO_DOCK_RUN_FIRST,
 
53
                myApplet);
 
54
        
 
55
        cd_keybinder_bind (myConfig.cShortkey, (CDBindkeyHandler) cd_on_shortkey, myApplet);
 
56
CD_APPLET_INIT_END
 
57
 
 
58
 
 
59
//\___________ 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.
 
60
CD_APPLET_STOP_BEGIN
 
61
        CD_APPLET_UNREGISTER_FOR_CLICK_EVENT;
 
62
        CD_APPLET_UNREGISTER_FOR_MIDDLE_CLICK_EVENT;
 
63
        cairo_dock_remove_notification_func_on_object (&myContainersMgr,
 
64
                NOTIFICATION_BUILD_ICON_MENU, (CairoDockNotificationFunc) CD_APPLET_ON_BUILD_MENU_FUNC, myApplet);
 
65
        
 
66
        
 
67
CD_APPLET_STOP_END
 
68
 
 
69
 
 
70
//\___________ 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.
 
71
CD_APPLET_RELOAD_BEGIN
 
72
        if (CD_APPLET_MY_CONFIG_CHANGED)
 
73
        {
 
74
                if (myDesklet && CD_APPLET_MY_CONTAINER_TYPE_CHANGED)  // we are now in a desklet, set a renderer.
 
75
                {
 
76
                        CD_APPLET_SET_DESKLET_RENDERER ("Simple");
 
77
                }
 
78
                
 
79
                CD_APPLET_SET_DEFAULT_IMAGE_ON_MY_ICON_IF_NONE;  // set the default icon if none is specified in conf.
 
80
                
 
81
                cd_keybinder_bind (myConfig.cShortkey, (CDBindkeyHandler) cd_on_shortkey, myApplet);  // shortkey has been unbinded during reset_config.
 
82
        }
 
83
CD_APPLET_RELOAD_END