~ubuntu-branches/ubuntu/saucy/cairo-dock-plug-ins/saucy

« back to all changes in this revision

Viewing changes to tomboy/src/tomboy-init.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2009-08-26 21:07:39 UTC
  • Revision ID: james.westby@ubuntu.com-20090826210739-gyjuuqezrzuluao4
Tags: upstream-2.0.8.1
ImportĀ upstreamĀ versionĀ 2.0.8.1

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 "tomboy-draw.h"
 
23
#include "tomboy-config.h"
 
24
#include "tomboy-dbus.h"
 
25
#include "tomboy-notifications.h"
 
26
#include "tomboy-struct.h"
 
27
#include "tomboy-init.h"
 
28
 
 
29
 
 
30
CD_APPLET_DEFINITION ("TomBoy",
 
31
        1, 5, 4,
 
32
        CAIRO_DOCK_CATEGORY_CONTROLER,
 
33
        N_("Control your TomBoy's notes directly in the dock !"),
 
34
        "Necropotame (Adrien Pilleboue)")
 
35
 
 
36
CD_APPLET_INIT_BEGIN
 
37
        load_all_surfaces();
 
38
        
 
39
        myData.hNoteTable = g_hash_table_new_full (g_str_hash,
 
40
                g_str_equal,
 
41
                NULL,  // l'URI est partage avec l'icone.
 
42
                (GDestroyNotify) cairo_dock_free_icon);
 
43
        
 
44
        myData.dbus_enable = dbus_connect_to_bus ();
 
45
        if (myData.dbus_enable)
 
46
        {
 
47
                dbus_detect_tomboy();
 
48
                free_all_notes ();  // il faut le faire en-dehors du thread.
 
49
                myData.pTask = cairo_dock_new_task (0,
 
50
                                (CairoDockGetDataAsyncFunc) getAllNotes,
 
51
                                (CairoDockUpdateSyncFunc) cd_tomboy_load_notes,
 
52
                                myApplet);
 
53
                cairo_dock_launch_task (myData.pTask);
 
54
        }
 
55
        else  // sinon on signale par l'icone appropriee que le bus n'est pas accessible.
 
56
        {
 
57
                CD_APPLET_SET_USER_IMAGE_ON_MY_ICON (myConfig.cIconClose, "broken.svg");
 
58
        }
 
59
        
 
60
        if (myConfig.bNoDeletedSignal)
 
61
                myData.iSidCheckNotes = g_timeout_add_seconds (2, (GSourceFunc) cd_tomboy_check_deleted_notes, (gpointer) NULL);
 
62
        
 
63
        //Enregistrement des notifications
 
64
        cairo_dock_register_notification (CAIRO_DOCK_CLICK_ICON, (CairoDockNotificationFunc) CD_APPLET_ON_CLICK_FUNC, CAIRO_DOCK_RUN_FIRST, myApplet);  // ici on s'enregistre explicitement avant le dock, pour pas qu'il essaye de lancer nos notes.
 
65
        CD_APPLET_REGISTER_FOR_MIDDLE_CLICK_EVENT;
 
66
        CD_APPLET_REGISTER_FOR_BUILD_MENU_EVENT;
 
67
CD_APPLET_INIT_END
 
68
 
 
69
 
 
70
CD_APPLET_STOP_BEGIN
 
71
        CD_APPLET_UNREGISTER_FOR_BUILD_MENU_EVENT;
 
72
        CD_APPLET_UNREGISTER_FOR_MIDDLE_CLICK_EVENT;
 
73
        CD_APPLET_UNREGISTER_FOR_CLICK_EVENT;
 
74
        
 
75
        if (myData.iSidCheckNotes != 0)
 
76
        {
 
77
                g_source_remove (myData.iSidCheckNotes);
 
78
                myData.iSidCheckNotes = 0;
 
79
        }
 
80
        dbus_disconnect_from_bus ();
 
81
CD_APPLET_STOP_END
 
82
 
 
83
 
 
84
CD_APPLET_RELOAD_BEGIN
 
85
        //\_______________ On recharge les surfaces.
 
86
        load_all_surfaces();
 
87
        
 
88
        //\_______________ On recharge les parametres qui ont pu changer.
 
89
        if (CD_APPLET_MY_CONFIG_CHANGED)
 
90
        {
 
91
                if (myData.dbus_enable)
 
92
                {
 
93
                        cairo_dock_stop_task (myData.pTask);
 
94
                        free_all_notes ();  // il faut le faire en-dehors du thread.
 
95
                        
 
96
                        //\___________ On arrete le timer.
 
97
                        if (myData.iSidCheckNotes != 0)
 
98
                        {
 
99
                                g_source_remove (myData.iSidCheckNotes);
 
100
                                myData.iSidCheckNotes = 0;
 
101
                        }
 
102
                        
 
103
                        //\___________ On reconstruit le sous-dock (si l'icone de la note a change).
 
104
                        cairo_dock_launch_task (myData.pTask);
 
105
                }
 
106
        }
 
107
        
 
108
        //\___________ On redessine l'icone principale.
 
109
        if (myData.dbus_enable)
 
110
        {
 
111
                CD_APPLET_SET_SURFACE_ON_MY_ICON (myData.pSurfaceDefault);
 
112
        }
 
113
        else  // on signale par l'icone appropriee que le bus n'est pas accessible.
 
114
        {
 
115
                CD_APPLET_SET_USER_IMAGE_ON_MY_ICON (myConfig.cIconClose, "broken.svg");
 
116
        }
 
117
CD_APPLET_RELOAD_END