From 8d461077788a54834bb7770fb19af119ae41eb32 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 18 May 2010 22:27:08 -0500 Subject: Adding a service manager to start the service. --- src/indicator-datetime.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/indicator-datetime.c') diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 434883e..448d736 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -10,6 +10,9 @@ /* Indicator Stuff */ #include #include +#include + +#include "dbus-shared.h" #define INDICATOR_DATETIME_TYPE (indicator_datetime_get_type ()) @@ -40,6 +43,8 @@ struct _IndicatorDatetimePrivate { guint idle_measure; gint max_width; + + IndicatorServiceManager * sm; }; #define INDICATOR_DATETIME_GET_PRIVATE(o) \ @@ -91,6 +96,10 @@ indicator_datetime_init (IndicatorDatetime *self) self->priv->idle_measure = 0; self->priv->max_width = 0; + self->priv->sm = NULL; + + self->priv->sm = indicator_service_manager_new_version(SERVICE_NAME, SERVICE_VERSION); + return; } @@ -124,6 +133,11 @@ indicator_datetime_dispose (GObject *object) self->priv->idle_measure = 0; } + if (self->priv->sm != NULL) { + g_object_unref(G_OBJECT(self->priv->sm)); + self->priv->sm = NULL; + } + G_OBJECT_CLASS (indicator_datetime_parent_class)->dispose (object); return; } -- cgit v1.2.3 From 69996154dbde58371e67ab88b8eb16dd5decca2d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 May 2010 11:41:27 -0500 Subject: Switching the menu to be from the service. --- src/indicator-datetime.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/indicator-datetime.c') diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 448d736..f114476 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -12,6 +12,9 @@ #include #include +/* DBusMenu */ +#include + #include "dbus-shared.h" @@ -45,6 +48,7 @@ struct _IndicatorDatetimePrivate { gint max_width; IndicatorServiceManager * sm; + DbusmenuGtkMenu * menu; }; #define INDICATOR_DATETIME_GET_PRIVATE(o) \ @@ -97,6 +101,7 @@ indicator_datetime_init (IndicatorDatetime *self) self->priv->max_width = 0; self->priv->sm = NULL; + self->priv->menu = NULL; self->priv->sm = indicator_service_manager_new_version(SERVICE_NAME, SERVICE_VERSION); @@ -133,6 +138,11 @@ indicator_datetime_dispose (GObject *object) self->priv->idle_measure = 0; } + if (self->priv->menu != NULL) { + g_object_unref(G_OBJECT(self->priv->menu)); + self->priv->menu = NULL; + } + if (self->priv->sm != NULL) { g_object_unref(G_OBJECT(self->priv->sm)); self->priv->sm = NULL; @@ -348,6 +358,12 @@ get_menu (IndicatorObject * io) { IndicatorDatetime * self = INDICATOR_DATETIME(io); + if (self->priv->menu == NULL) { + self->priv->menu = dbusmenu_gtkmenu_new(SERVICE_NAME, MENU_OBJ); + } + + return GTK_MENU(self->priv->menu); + GtkWidget * menu = NULL; GtkWidget * item = NULL; -- cgit v1.2.3 From f257b20a08c111c630e72f31d0e1431eb238253e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 12 Jul 2010 15:12:26 -0500 Subject: Removing some now service provided code. --- src/indicator-datetime.c | 91 ------------------------------------------------ 1 file changed, 91 deletions(-) (limited to 'src/indicator-datetime.c') diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index f114476..af2c417 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -40,8 +40,6 @@ struct _IndicatorDatetime { struct _IndicatorDatetimePrivate { GtkLabel * label; - GtkMenuItem * date; - GtkMenuItem * calendar; guint timer; guint idle_measure; @@ -93,8 +91,6 @@ indicator_datetime_init (IndicatorDatetime *self) self->priv = INDICATOR_DATETIME_GET_PRIVATE(self); self->priv->label = NULL; - self->priv->date = NULL; - self->priv->calendar = NULL; self->priv->timer = 0; self->priv->idle_measure = 0; @@ -118,16 +114,6 @@ indicator_datetime_dispose (GObject *object) self->priv->label = NULL; } - if (self->priv->date != NULL) { - g_object_unref(self->priv->date); - self->priv->date = NULL; - } - - if (self->priv->calendar != NULL) { - g_object_unref(self->priv->calendar); - self->priv->calendar = NULL; - } - if (self->priv->timer != 0) { g_source_remove(self->priv->timer); self->priv->timer = 0; @@ -212,15 +198,6 @@ update_label (IndicatorDatetime * io) self->priv->idle_measure = g_idle_add(idle_measure, io); } - if (self->priv->date == NULL) return; - - /* Note: may require some localization tweaks */ - strftime(longstr, 128, "%A, %e %B %Y", ltime); - - utf8 = g_locale_to_utf8(longstr, -1, NULL, NULL, NULL); - gtk_menu_item_set_label(self->priv->date, utf8); - g_free(utf8); - return; } @@ -241,17 +218,6 @@ minute_timer_func (gpointer user_data) return FALSE; } -static void -activate_cb (GtkWidget *widget, const gchar *command) -{ - GError * error = NULL; - - if (!g_spawn_command_line_async(command, &error)) { - g_warning("Unable to start %s: %s", (char *)command, error->message); - g_error_free(error); - } -} - /* Does a quick meausre of how big the string is in pixels with a Pango layout */ static gint @@ -335,24 +301,6 @@ get_label (IndicatorObject * io) return self->priv->label; } -static void -check_for_calendar_application (IndicatorDatetime * self) -{ - GtkMenuItem * item = self->priv->calendar; - g_return_if_fail (item != NULL); - - gchar *evo = g_find_program_in_path("evolution"); - if (evo != NULL) { - g_signal_connect (GTK_MENU_ITEM (item), "activate", - G_CALLBACK (activate_cb), "evolution -c calendar"); - gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE); - gtk_widget_show(GTK_WIDGET(item)); - g_free(evo); - } else { - gtk_widget_hide(GTK_WIDGET(item)); - } -} - static GtkMenu * get_menu (IndicatorObject * io) { @@ -363,43 +311,4 @@ get_menu (IndicatorObject * io) } return GTK_MENU(self->priv->menu); - - GtkWidget * menu = NULL; - GtkWidget * item = NULL; - - menu = gtk_menu_new(); - - if (self->priv->date == NULL) { - item = gtk_menu_item_new_with_label("No date yet..."); - gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - self->priv->date = GTK_MENU_ITEM (item); - update_label(self); - } - - if (self->priv->calendar == NULL) { - item = gtk_menu_item_new_with_label(_("Open Calendar")); - /* insensitive until we check for available apps */ - gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - self->priv->calendar = GTK_MENU_ITEM (item); - } - - gtk_menu_shell_append (GTK_MENU_SHELL (menu), - gtk_separator_menu_item_new ()); - - GtkWidget *settings_mi = gtk_menu_item_new_with_label (_("Set Time and Date...")); - g_signal_connect (GTK_MENU_ITEM (settings_mi), "activate", - G_CALLBACK (activate_cb), "time-admin"); - gtk_menu_shell_append (GTK_MENU_SHELL(menu), settings_mi); - gtk_widget_show(settings_mi); - - /* show_all to reveal the separator */ - gtk_widget_show_all(menu); - - /* Note: maybe should move that to an idle loop if that helps with - boot performance */ - check_for_calendar_application (self); - - return GTK_MENU(menu); } -- cgit v1.2.3 From df30f437fd80697d97544fafa43999a05debefb0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 12 Jul 2010 15:34:19 -0500 Subject: Legal stuffs --- src/indicator-datetime.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/indicator-datetime.c') diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index af2c417..cb33c75 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -1,3 +1,24 @@ +/* +An indicator to show date and time information. + +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