From f1e5569348a935def97ed99708864aa6b8096d5e Mon Sep 17 00:00:00 2001 From: David Barth Date: Thu, 22 Jul 2010 21:13:36 +0200 Subject: add a calendar widget to the menu --- src/datetime-service.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 2137065..5c7b76f 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -141,7 +141,8 @@ build_menus (DbusmenuMenuitem * root) if (calendar == NULL) { calendar = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (calendar, DBUSMENU_MENUITEM_PROP_LABEL, _("Open Calendar")); + /* dbusmenu_menuitem_property_set (calendar, DBUSMENU_MENUITEM_PROP_LABEL, _("Open Calendar")); */ + dbusmenu_menuitem_property_set (calendar, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CALENDAR_MENUITEM_TYPE); /* insensitive until we check for available apps */ dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE); g_signal_connect (G_OBJECT(calendar), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, -- cgit v1.2.3 From 2564f8526c2508be8847024f5aad6324db4fb256 Mon Sep 17 00:00:00 2001 From: David Barth Date: Thu, 22 Jul 2010 21:14:47 +0200 Subject: updates the label for changing settings --- src/datetime-service.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 5c7b76f..57dcc5e 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -141,7 +141,6 @@ build_menus (DbusmenuMenuitem * root) if (calendar == NULL) { calendar = dbusmenu_menuitem_new(); - /* dbusmenu_menuitem_property_set (calendar, DBUSMENU_MENUITEM_PROP_LABEL, _("Open Calendar")); */ dbusmenu_menuitem_property_set (calendar, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CALENDAR_MENUITEM_TYPE); /* insensitive until we check for available apps */ dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE); @@ -157,7 +156,7 @@ build_menus (DbusmenuMenuitem * root) dbusmenu_menuitem_child_append(root, separator); settings = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (settings, DBUSMENU_MENUITEM_PROP_LABEL, _("Set Time and Date...")); + dbusmenu_menuitem_property_set (settings, DBUSMENU_MENUITEM_PROP_LABEL, _("Time & Date Settings...")); /* insensitive until we check for available apps */ dbusmenu_menuitem_property_set_bool(settings, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE); g_signal_connect(G_OBJECT(settings), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), "time-admin"); -- cgit v1.2.3 From b798978db017df8d08e35a38cfa1e88fe3890f90 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 30 Aug 2010 14:34:16 -0500 Subject: Building us a dbus interface --- src/datetime-service.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 2137065..e6a5fc3 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -28,12 +28,14 @@ with this program. If not, see . #include #include +#include "datetime-interface.h" #include "dbus-shared.h" static IndicatorService * service = NULL; static GMainLoop * mainloop = NULL; static DbusmenuServer * server = NULL; static DbusmenuMenuitem * root = NULL; +static DatetimeInterface * dbus = NULL; /* Global Items */ static DbusmenuMenuitem * date = NULL; @@ -198,6 +200,8 @@ main (int argc, char ** argv) dbusmenu_server_set_root(server, root); build_menus(root); + dbus = g_object_new(DATETIME_INTERFACE_TYPE, NULL); + mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From 3e00412e0950f6c4e0d27c5f046120017c38738c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 30 Aug 2010 16:18:29 -0500 Subject: Watching the timezone file and updating based on it --- src/datetime-service.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index e6a5fc3..18dd073 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -23,6 +23,7 @@ with this program. If not, see . #include #include +#include #include #include @@ -168,6 +169,30 @@ build_menus (DbusmenuMenuitem * root) return; } +/* Run when the timezone file changes */ +static void +timezone_changed (GFileMonitor * monitor, GFile * file, GFile * otherfile, GFileMonitorEvent event, gpointer user_data) +{ + datetime_interface_update(DATETIME_INTERFACE(user_data)); + update_datetime(NULL); + return; +} + +/* Set up monitoring the timezone file */ +static void +build_timezone (DatetimeInterface * dbus) +{ + GFile * timezonefile = g_file_new_for_path(TIMEZONE_FILE); + GFileMonitor * monitor = g_file_monitor_file(timezonefile, G_FILE_MONITOR_NONE, NULL, NULL); + if (monitor != NULL) { + g_signal_connect(G_OBJECT(monitor), "changed", G_CALLBACK(timezone_changed), dbus); + g_debug("Monitoring timezone file: '" TIMEZONE_FILE "'"); + } else { + g_warning("Unable to monitor timezone file: '" TIMEZONE_FILE "'"); + } + return; +} + /* Repsonds to the service object saying it's time to shutdown. It stops the mainloop. */ static void @@ -200,8 +225,12 @@ main (int argc, char ** argv) dbusmenu_server_set_root(server, root); build_menus(root); + /* Setup dbus interface */ dbus = g_object_new(DATETIME_INTERFACE_TYPE, NULL); + /* Setup timezone watch */ + build_timezone(dbus); + mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From 94264e502d32ebff60ec8213dc2887ec569152ad Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 30 Aug 2010 22:00:43 -0500 Subject: Set a timer to update the date once a day. --- src/datetime-service.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 18dd073..5444c61 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -32,6 +32,8 @@ with this program. If not, see . #include "datetime-interface.h" #include "dbus-shared.h" +static void setup_timer (void); + static IndicatorService * service = NULL; static GMainLoop * mainloop = NULL; static DbusmenuServer * server = NULL; @@ -139,7 +141,6 @@ build_menus (DbusmenuMenuitem * root) dbusmenu_menuitem_child_append(root, date); g_idle_add(update_datetime, NULL); - /* TODO: Set up updating daily */ } if (calendar == NULL) { @@ -193,6 +194,43 @@ build_timezone (DatetimeInterface * dbus) return; } +/* Source ID for the timer */ +static guint timer = 0; + +/* Execute at a given time, update and setup a new + timer to go again. */ +static gboolean +timer_func (gpointer user_data) +{ + timer = 0; + /* Reset up each time to reduce error */ + setup_timer(); + update_datetime(NULL); + return FALSE; +} + +/* Sets up the time to launch the timer to update the + date in the datetime entry */ +static void +setup_timer (void) +{ + if (timer != 0) { + g_source_remove(timer); + timer = 0; + } + + time_t t; + t = time(NULL); + struct tm * ltime = localtime(&t); + + timer = g_timeout_add_seconds(((23 - ltime->tm_hour) * 60 * 60) + + ((59 - ltime->tm_min) * 60) + + ((60 - ltime->tm_sec)) + 60 /* one minute past */, + timer_func, NULL); + + return; +} + /* Repsonds to the service object saying it's time to shutdown. It stops the mainloop. */ static void @@ -231,9 +269,13 @@ main (int argc, char ** argv) /* Setup timezone watch */ build_timezone(dbus); + /* Setup the timer */ + setup_timer(); + mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); + g_object_unref(G_OBJECT(dbus)); g_object_unref(G_OBJECT(service)); g_object_unref(G_OBJECT(server)); g_object_unref(G_OBJECT(root)); -- cgit v1.2.3 From e22fcc15f62ec03acc0250152281f921e51a0a1b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 30 Aug 2010 22:01:22 -0500 Subject: If the timezone changes we need to setup a different timer. --- src/datetime-service.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 5444c61..8c881f7 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -176,6 +176,7 @@ timezone_changed (GFileMonitor * monitor, GFile * file, GFile * otherfile, GFile { datetime_interface_update(DATETIME_INTERFACE(user_data)); update_datetime(NULL); + setup_timer(); return; } -- cgit v1.2.3