From 088f7d086c0a95bd18cc094da185059357ce93ec Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 30 Aug 2010 13:59:10 -0500 Subject: Adding an object to be the interface object for dbus --- src/datetime-interface.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/datetime-interface.c (limited to 'src/datetime-interface.c') diff --git a/src/datetime-interface.c b/src/datetime-interface.c new file mode 100644 index 0000000..3ea5106 --- /dev/null +++ b/src/datetime-interface.c @@ -0,0 +1,46 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "datetime-interface.h" + +static void datetime_interface_class_init (DatetimeInterfaceClass *klass); +static void datetime_interface_init (DatetimeInterface *self); +static void datetime_interface_dispose (GObject *object); +static void datetime_interface_finalize (GObject *object); + +G_DEFINE_TYPE (DatetimeInterface, datetime_interface, G_TYPE_OBJECT); + +static void +datetime_interface_class_init (DatetimeInterfaceClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->dispose = datetime_interface_dispose; + object_class->finalize = datetime_interface_finalize; + + return; +} + +static void +datetime_interface_init (DatetimeInterface *self) +{ + + return; +} + +static void +datetime_interface_dispose (GObject *object) +{ + + G_OBJECT_CLASS (datetime_interface_parent_class)->dispose (object); + return; +} + +static void +datetime_interface_finalize (GObject *object) +{ + + G_OBJECT_CLASS (datetime_interface_parent_class)->finalize (object); + return; +} -- cgit v1.2.3 From ffe6f9fb45bf8ab898246dc79cfc2e09463ea6de Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 30 Aug 2010 14:23:27 -0500 Subject: Connecting onto the dbus --- src/datetime-interface.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/datetime-interface.c') diff --git a/src/datetime-interface.c b/src/datetime-interface.c index 3ea5106..a500354 100644 --- a/src/datetime-interface.c +++ b/src/datetime-interface.c @@ -3,6 +3,8 @@ #endif #include "datetime-interface.h" +#include "datetime-service-server.h" +#include "dbus-shared.h" static void datetime_interface_class_init (DatetimeInterfaceClass *klass); static void datetime_interface_init (DatetimeInterface *self); @@ -19,12 +21,18 @@ datetime_interface_class_init (DatetimeInterfaceClass *klass) object_class->dispose = datetime_interface_dispose; object_class->finalize = datetime_interface_finalize; + dbus_g_object_type_install_info(DATETIME_INTERFACE_TYPE, &dbus_glib__datetime_service_server_object_info); + return; } static void datetime_interface_init (DatetimeInterface *self) { + DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); + dbus_g_connection_register_g_object(connection, + SERVICE_OBJ, + G_OBJECT(self)); return; } -- cgit v1.2.3 From 9a852c72209e4c5c5292553a3abbc61911a27027 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 30 Aug 2010 14:55:47 -0500 Subject: Adding in the update time signal --- src/datetime-interface.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/datetime-interface.c') diff --git a/src/datetime-interface.c b/src/datetime-interface.c index a500354..d70d53a 100644 --- a/src/datetime-interface.c +++ b/src/datetime-interface.c @@ -6,6 +6,13 @@ #include "datetime-service-server.h" #include "dbus-shared.h" +enum { + UPDATE_TIME, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + static void datetime_interface_class_init (DatetimeInterfaceClass *klass); static void datetime_interface_init (DatetimeInterface *self); static void datetime_interface_dispose (GObject *object); @@ -21,6 +28,14 @@ datetime_interface_class_init (DatetimeInterfaceClass *klass) object_class->dispose = datetime_interface_dispose; object_class->finalize = datetime_interface_finalize; + signals[UPDATE_TIME] = g_signal_new("update-time", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (DatetimeInterfaceClass, update_time), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0, G_TYPE_NONE); + dbus_g_object_type_install_info(DATETIME_INTERFACE_TYPE, &dbus_glib__datetime_service_server_object_info); return; -- cgit v1.2.3 From 48830abd993c31546bad23cc30684a537c31332c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 30 Aug 2010 14:58:40 -0500 Subject: Adding a way to emit the signal --- src/datetime-interface.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/datetime-interface.c') diff --git a/src/datetime-interface.c b/src/datetime-interface.c index d70d53a..246fcb3 100644 --- a/src/datetime-interface.c +++ b/src/datetime-interface.c @@ -67,3 +67,11 @@ datetime_interface_finalize (GObject *object) G_OBJECT_CLASS (datetime_interface_parent_class)->finalize (object); return; } + +void +datetime_interface_update (DatetimeInterface *self) +{ + g_return_if_fail(IS_DATETIME_INTERFACE(self)); + g_signal_emit(G_OBJECT(self), signals[UPDATE_TIME], 0, TRUE); + return; +} -- cgit v1.2.3 From 5c882ecc2474d48fbe7675b76cb23f9875905483 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 30 Aug 2010 22:11:36 -0500 Subject: Copyright stuffs --- src/datetime-interface.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/datetime-interface.c') diff --git a/src/datetime-interface.c b/src/datetime-interface.c index 246fcb3..c58c5af 100644 --- a/src/datetime-interface.c +++ b/src/datetime-interface.c @@ -1,3 +1,24 @@ +/* +An indicator to time and date related information in the menubar. + +Copyright 2010 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + #ifdef HAVE_CONFIG_H #include "config.h" #endif -- cgit v1.2.3