2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
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.
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/>.
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"
30
CD_APPLET_DEFINITION ("TomBoy",
32
CAIRO_DOCK_CATEGORY_CONTROLER,
33
N_("Control your TomBoy's notes directly in the dock !"),
34
"Necropotame (Adrien Pilleboue)")
39
myData.hNoteTable = g_hash_table_new_full (g_str_hash,
41
NULL, // l'URI est partage avec l'icone.
42
(GDestroyNotify) cairo_dock_free_icon);
44
myData.dbus_enable = dbus_connect_to_bus ();
45
if (myData.dbus_enable)
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,
53
cairo_dock_launch_task (myData.pTask);
55
else // sinon on signale par l'icone appropriee que le bus n'est pas accessible.
57
CD_APPLET_SET_USER_IMAGE_ON_MY_ICON (myConfig.cIconClose, "broken.svg");
60
if (myConfig.bNoDeletedSignal)
61
myData.iSidCheckNotes = g_timeout_add_seconds (2, (GSourceFunc) cd_tomboy_check_deleted_notes, (gpointer) NULL);
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;
71
CD_APPLET_UNREGISTER_FOR_BUILD_MENU_EVENT;
72
CD_APPLET_UNREGISTER_FOR_MIDDLE_CLICK_EVENT;
73
CD_APPLET_UNREGISTER_FOR_CLICK_EVENT;
75
if (myData.iSidCheckNotes != 0)
77
g_source_remove (myData.iSidCheckNotes);
78
myData.iSidCheckNotes = 0;
80
dbus_disconnect_from_bus ();
84
CD_APPLET_RELOAD_BEGIN
85
//\_______________ On recharge les surfaces.
88
//\_______________ On recharge les parametres qui ont pu changer.
89
if (CD_APPLET_MY_CONFIG_CHANGED)
91
if (myData.dbus_enable)
93
cairo_dock_stop_task (myData.pTask);
94
free_all_notes (); // il faut le faire en-dehors du thread.
96
//\___________ On arrete le timer.
97
if (myData.iSidCheckNotes != 0)
99
g_source_remove (myData.iSidCheckNotes);
100
myData.iSidCheckNotes = 0;
103
//\___________ On reconstruit le sous-dock (si l'icone de la note a change).
104
cairo_dock_launch_task (myData.pTask);
108
//\___________ On redessine l'icone principale.
109
if (myData.dbus_enable)
111
CD_APPLET_SET_SURFACE_ON_MY_ICON (myData.pSurfaceDefault);
113
else // on signale par l'icone appropriee que le bus n'est pas accessible.
115
CD_APPLET_SET_USER_IMAGE_ON_MY_ICON (myConfig.cIconClose, "broken.svg");