aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-03-18 13:21:21 -0500
committerTed Gould <ted@canonical.com>2009-03-18 13:21:21 -0500
commit1cf60571c0663efc4eab8e3c94002e521490a206 (patch)
tree666a927409394482bd345643ade84641bd5c50b5
parent8d5f26a09d68bf02cd08745f7333a38171f4d466 (diff)
downloadayatana-indicator-messages-1cf60571c0663efc4eab8e3c94002e521490a206.tar.gz
ayatana-indicator-messages-1cf60571c0663efc4eab8e3c94002e521490a206.tar.bz2
ayatana-indicator-messages-1cf60571c0663efc4eab8e3c94002e521490a206.zip
Putting the seconds into the private structure, a function to get them, and a signal when they change.
-rw-r--r--src/im-menu-item.c32
-rw-r--r--src/im-menu-item.h5
2 files changed, 37 insertions, 0 deletions
diff --git a/src/im-menu-item.c b/src/im-menu-item.c
index b5940ac..eaf65a6 100644
--- a/src/im-menu-item.c
+++ b/src/im-menu-item.c
@@ -27,6 +27,13 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <gtk/gtk.h>
#include "im-menu-item.h"
+enum {
+ TIME_CHANGED,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
typedef struct _ImMenuItemPrivate ImMenuItemPrivate;
struct _ImMenuItemPrivate
@@ -35,6 +42,8 @@ struct _ImMenuItemPrivate
IndicateListenerServer * server;
IndicateListenerIndicator * indicator;
+ glong seconds;
+
GtkHBox * hbox;
GtkLabel * user;
GtkLabel * time;
@@ -92,6 +101,16 @@ im_menu_item_class_init (ImMenuItemClass *klass)
object_class->dispose = im_menu_item_dispose;
object_class->finalize = im_menu_item_finalize;
+
+ signals[TIME_CHANGED] = g_signal_new(IM_MENU_ITEM_SIGNAL_TIME_CHANGED,
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ImMenuItemClass, time_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__LONG,
+ G_TYPE_NONE, 1, G_TYPE_LONG);
+
+ return;
}
static void
@@ -104,6 +123,8 @@ im_menu_item_init (ImMenuItem *self)
priv->server = NULL;
priv->indicator = NULL;
+ priv->seconds = 0;
+
/* build widgets first */
priv->icon = GTK_IMAGE(gtk_image_new());
priv->user = GTK_LABEL(gtk_label_new(""));
@@ -185,6 +206,8 @@ time_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateL
ImMenuItemPrivate * priv = IM_MENU_ITEM_GET_PRIVATE(self);
+ priv->seconds = propertydata->tv_sec;
+
time_t timet;
struct tm * structtm;
@@ -198,6 +221,8 @@ time_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateL
gtk_label_set_label(priv->time, timestring);
gtk_widget_show(GTK_WIDGET(priv->time));
+ g_signal_emit(G_OBJECT(self), signals[TIME_CHANGED], 0, priv->seconds, TRUE);
+
return;
}
@@ -276,3 +301,10 @@ im_menu_item_new (IndicateListener * listener, IndicateListenerServer * server,
return self;
}
+
+glong
+im_menu_item_get_seconds (ImMenuItem * menuitem)
+{
+ ImMenuItemPrivate * priv = IM_MENU_ITEM_GET_PRIVATE(menuitem);
+ return priv->seconds;
+}
diff --git a/src/im-menu-item.h b/src/im-menu-item.h
index a70f55a..34da453 100644
--- a/src/im-menu-item.h
+++ b/src/im-menu-item.h
@@ -36,11 +36,15 @@ G_BEGIN_DECLS
#define IS_IM_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IM_MENU_ITEM_TYPE))
#define IM_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IM_MENU_ITEM_TYPE, ImMenuItemClass))
+#define IM_MENU_ITEM_SIGNAL_TIME_CHANGED "time-changed"
+
typedef struct _ImMenuItem ImMenuItem;
typedef struct _ImMenuItemClass ImMenuItemClass;
struct _ImMenuItemClass {
GtkMenuItemClass parent_class;
+
+ void (*time_changed) (glong seconds);
};
struct _ImMenuItem {
@@ -49,6 +53,7 @@ struct _ImMenuItem {
GType im_menu_item_get_type (void);
ImMenuItem * im_menu_item_new (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator);
+glong im_menu_item_get_seconds (ImMenuItem * menuitem);
G_END_DECLS