| 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-dbus.h" |
| 24 |
#include "applet-struct.h" |
| 25 |
#include "interface-applet-signals.h" |
| 26 |
#include "applet-init.h" |
| 27 |
|
| 28 |
static AppletData s_myDataCopy; |
| 29 |
|
| 30 |
static void cd_dbus_save_my_data (GldiModuleInstance *myApplet); |
| 31 |
|
| 32 |
|
| 33 |
CD_APPLET_DEFINE_BEGIN ("Dbus", |
| 34 |
2, 2, 1, |
| 35 |
CAIRO_DOCK_CATEGORY_APPLET_SYSTEM, |
| 36 |
N_("This plug-in lets extern applications interact on the dock.\n" |
| 37 |
"The communication between both sides is based on Dbus"), |
| 38 |
"Necropotame & Fabounet") |
| 39 |
pInterface->initModule = CD_APPLET_INIT_FUNC; // no stop method -> the plug-in will be auto-loaded. |
| 40 |
pInterface->read_conf_file = CD_APPLET_READ_CONFIG_FUNC; /// inutile je pense... |
| 41 |
pInterface->reset_data = cd_dbus_save_my_data; |
| 42 |
CD_APPLET_REDEFINE_TITLE ("DBus"); |
| 43 |
CD_APPLET_SET_CONTAINER_TYPE (CAIRO_DOCK_MODULE_IS_PLUGIN); |
| 44 |
CD_APPLET_DEFINE_END |
| 45 |
|
| 46 |
|
| 47 |
//\___________ 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). |
| 48 |
CD_APPLET_INIT_BEGIN |
| 49 |
static gboolean s_bInitialized = FALSE; |
| 50 |
if (! CD_APPLET_RESERVE_DATA_SLOT ()) |
| 51 |
return; |
| 52 |
if (!s_bInitialized) // since the service lives on the bus, only launch it once. |
| 53 |
{ |
| 54 |
s_bInitialized = TRUE; |
| 55 |
cd_dbus_launch_service (); |
| 56 |
gldi_object_register_notification (&myContainerObjectMgr, |
| 57 |
NOTIFICATION_DROP_DATA, |
| 58 |
(GldiNotificationFunc) cd_dbus_applet_emit_on_drop_data, |
| 59 |
GLDI_RUN_FIRST, |
| 60 |
NULL); // to register new applets by dropping a package on the dock. |
| 61 |
} |
| 62 |
else |
| 63 |
{ |
| 64 |
memcpy (myDataPtr, &s_myDataCopy, sizeof (AppletData)); |
| 65 |
cd_dbus_clean_up_processes (TRUE); // TRUE <=> including applets spawned from our process. |
| 66 |
} |
| 67 |
CD_APPLET_INIT_END |
| 68 |
|
| 69 |
|
| 70 |
static void cd_dbus_save_my_data (GldiModuleInstance *myApplet) |
| 71 |
{ |
| 72 |
memcpy (&s_myDataCopy, myDataPtr, sizeof (AppletData)); |
| 73 |
} |