aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/calendar-menu-item.c100
-rw-r--r--src/calendar-menu-item.h59
-rw-r--r--src/indicator-datetime.c30
-rw-r--r--src/timezone-completion.c24
-rw-r--r--src/timezone-completion.h17
6 files changed, 38 insertions, 194 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 6ca07a8..254022e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -8,8 +8,6 @@ indicator_datetime_service_SOURCES = \
datetime-interface.c \
datetime-interface.h \
gen-datetime-service.xml.c \
- calendar-menu-item.c \
- calendar-menu-item.h \
datetime-service.c \
utils.c \
utils.h \
diff --git a/src/calendar-menu-item.c b/src/calendar-menu-item.c
deleted file mode 100644
index c2ceec3..0000000
--- a/src/calendar-menu-item.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
-Calendar menu item dbusmenu "transport" for the corresponding IDO widget.
-
-Copyright 2010 Canonical Ltd.
-
-Authors:
- David Barth <david.barth@canonical.com>
-
-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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gdk/gdk.h>
-#include <glib/gi18n.h>
-#include "calendar-menu-item.h"
-
-#include "dbus-shared.h"
-
-#include <libdbusmenu-glib/client.h>
-#include <libdbusmenu-glib/server.h>
-#include <libdbusmenu-glib/menuitem.h>
-
-enum {
- LAST_SIGNAL
-};
-
-/* static guint signals[LAST_SIGNAL] = { }; */
-
-typedef struct _CalendarMenuItemPrivate CalendarMenuItemPrivate;
-struct _CalendarMenuItemPrivate
-{
- void * placeholder;
-};
-
-#define CALENDAR_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CALENDAR_MENU_ITEM_TYPE, CalendarMenuItemPrivate))
-
-/* Prototypes */
-static void calendar_menu_item_class_init (CalendarMenuItemClass *klass);
-static void calendar_menu_item_init (CalendarMenuItem *self);
-static void calendar_menu_item_dispose (GObject *object);
-static void calendar_menu_item_finalize (GObject *object);
-
-G_DEFINE_TYPE (CalendarMenuItem, calendar_menu_item, DBUSMENU_TYPE_MENUITEM);
-
-static void
-calendar_menu_item_class_init (CalendarMenuItemClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (CalendarMenuItemPrivate));
-
- object_class->dispose = calendar_menu_item_dispose;
- object_class->finalize = calendar_menu_item_finalize;
-
- return;
-}
-
-static void
-calendar_menu_item_init (CalendarMenuItem *self)
-{
- return;
-}
-
-static void
-calendar_menu_item_dispose (GObject *object)
-{
- G_OBJECT_CLASS (calendar_menu_item_parent_class)->dispose (object);
-}
-
-static void
-calendar_menu_item_finalize (GObject *object)
-{
- G_OBJECT_CLASS (calendar_menu_item_parent_class)->finalize (object);
-
- return;
-}
-
-CalendarMenuItem *
-calendar_menu_item_new ()
-{
- CalendarMenuItem * self = g_object_new(CALENDAR_MENU_ITEM_TYPE, NULL);
-
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CALENDAR_MENUITEM_TYPE);
-
- return self;
-}
-
diff --git a/src/calendar-menu-item.h b/src/calendar-menu-item.h
deleted file mode 100644
index 7a56f96..0000000
--- a/src/calendar-menu-item.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
-Calendar menu item dbusmenu "transport" for the corresponding IDO widget.
-
-Copyright 2010 Canonical Ltd.
-
-Authors:
- David Barth <david.barth@canonical.com>
-
-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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef __CALENDAR_MENU_ITEM_H__
-#define __CALENDAR_MENU_ITEM_H__
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include <libdbusmenu-glib/menuitem.h>
-
-G_BEGIN_DECLS
-
-#define CALENDAR_MENU_ITEM_TYPE (calendar_menu_item_get_type ())
-#define CALENDAR_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALENDAR_MENU_ITEM_TYPE, CalendarMenuItem))
-#define CALENDAR_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALENDAR_MENU_ITEM_TYPE, CalendarMenuItemClass))
-#define IS_CALENDAR_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALENDAR_MENU_ITEM_TYPE))
-#define IS_CALENDAR_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALENDAR_MENU_ITEM_TYPE))
-#define CALENDAR_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CALENDAR_MENU_ITEM_TYPE, CalendarMenuItemClass))
-
-#define CALENDAR_MENU_ITEM_SIGNAL_ACTIVATE "activate"
-#define CALENDAR_MENUITEM_PROP_TEXT "text"
-
-typedef struct _CalendarMenuItem CalendarMenuItem;
-typedef struct _CalendarMenuItemClass CalendarMenuItemClass;
-
-struct _CalendarMenuItemClass {
- DbusmenuMenuitemClass parent_class;
-};
-
-struct _CalendarMenuItem {
- DbusmenuMenuitem parent;
-};
-
-GType calendar_menu_item_get_type (void);
-CalendarMenuItem * calendar_menu_item_new ();
-
-G_END_DECLS
-
-#endif /* __CALENDAR_MENU_ITEM_H__ */
-
diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c
index f773159..339ea2f 100644
--- a/src/indicator-datetime.c
+++ b/src/indicator-datetime.c
@@ -138,9 +138,6 @@ struct _indicator_item_t {
#define PROP_SHOW_WEEK_NUMBERS_S "show-week-numbers"
#define PROP_SHOW_CALENDAR_S "show-calendar"
-#define INDICATOR_DATETIME_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_DATETIME_TYPE, IndicatorDatetimePrivate))
-
enum {
STRFTIME_MASK_NONE = 0, /* Hours or minutes as we always test those */
STRFTIME_MASK_SECONDS = 1 << 0, /* Seconds count */
@@ -153,7 +150,7 @@ enum {
STRFTIME_MASK_ALL = (STRFTIME_MASK_SECONDS | STRFTIME_MASK_AMPM | STRFTIME_MASK_WEEK | STRFTIME_MASK_DAY | STRFTIME_MASK_MONTH | STRFTIME_MASK_YEAR)
};
-GType indicator_datetime_get_type (void);
+GType indicator_datetime_get_type (void) G_GNUC_CONST;
static void indicator_datetime_class_init (IndicatorDatetimeClass *klass);
static void indicator_datetime_init (IndicatorDatetime *self);
@@ -291,7 +288,9 @@ menu_visible_notfy_cb(GtkWidget * menu, G_GNUC_UNUSED GParamSpec *pspec, gpointe
static void
indicator_datetime_init (IndicatorDatetime *self)
{
- self->priv = INDICATOR_DATETIME_GET_PRIVATE(self);
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ INDICATOR_DATETIME_TYPE,
+ IndicatorDatetimePrivate);
self->priv->label = NULL;
self->priv->timer = 0;
@@ -400,11 +399,10 @@ service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data)
IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
g_return_if_fail(self != NULL);
+ IndicatorDatetimePrivate * priv = self->priv;
GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error);
- IndicatorDatetimePrivate * priv = INDICATOR_DATETIME_GET_PRIVATE(self);
-
if (priv->service_proxy_cancel != NULL) {
g_object_unref(priv->service_proxy_cancel);
priv->service_proxy_cancel = NULL;
@@ -537,7 +535,8 @@ bind_enum_get (GValue * value, GVariant * variant, gpointer user_data)
static void
timezone_update_all_labels (IndicatorDatetime * self)
{
- IndicatorDatetimePrivate *priv = INDICATOR_DATETIME_GET_PRIVATE(self);
+ IndicatorDatetimePrivate *priv = self->priv;
+
g_list_foreach(priv->timezone_items, (GFunc)timezone_update_labels, NULL);
}
@@ -776,9 +775,9 @@ set_label_to_time_in_zone (IndicatorDatetime * self, GtkLabel * label,
else {
timestr = g_date_time_format(datetime_now, format);
if (timestr == NULL) {
- g_warning ("The custom date format is not valid, check the
- g_date_time_format() documentation for the supported
- format specifiers ");
+ g_warning ("The custom date format is not valid, check the\n"
+ "g_date_time_format() documentation for the supported\n"
+ "format specifiers ");
timestr = g_strdup ("Date format not supported");
}
}
@@ -1392,8 +1391,7 @@ new_calendar_item (DbusmenuMenuitem * newitem,
/* Note: not checking parent, it's reasonable for it to be NULL */
IndicatorDatetime *self = INDICATOR_DATETIME(user_data);
- self->priv = INDICATOR_DATETIME_GET_PRIVATE(self);
-
+
IdoCalendarMenuItem *ido = IDO_CALENDAR_MENU_ITEM (ido_calendar_menu_item_new ());
self->priv->ido_calendar = ido;
@@ -1437,7 +1435,9 @@ timezone_toggled_cb (GtkCheckMenuItem *checkmenuitem, DbusmenuMenuitem * dbusite
static void
timezone_destroyed_cb (indicator_item_t * mi_data, DbusmenuMenuitem * dbusitem)
{
- IndicatorDatetimePrivate *priv = INDICATOR_DATETIME_GET_PRIVATE(mi_data->self);
+ IndicatorDatetime *self = INDICATOR_DATETIME (mi_data->self);
+ IndicatorDatetimePrivate *priv = self->priv;
+
priv->timezone_items = g_list_remove(priv->timezone_items, mi_data);
g_signal_handlers_disconnect_by_func(G_OBJECT(mi_data->gmi), G_CALLBACK(timezone_toggled_cb), dbusitem);
g_free(mi_data);
@@ -1455,7 +1455,7 @@ new_timezone_item(DbusmenuMenuitem * newitem,
/* Note: not checking parent, it's reasonable for it to be NULL */
IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
- IndicatorDatetimePrivate *priv = INDICATOR_DATETIME_GET_PRIVATE(self);
+ IndicatorDatetimePrivate *priv = self->priv;
// Menu item with a radio button and a right aligned time
indicator_item_t * mi_data = g_new0(indicator_item_t, 1);
diff --git a/src/timezone-completion.c b/src/timezone-completion.c
index d190035..f223bf4 100644
--- a/src/timezone-completion.c
+++ b/src/timezone-completion.c
@@ -35,7 +35,6 @@ enum {
/* static guint signals[LAST_SIGNAL] = { }; */
-typedef struct _TimezoneCompletionPrivate TimezoneCompletionPrivate;
struct _TimezoneCompletionPrivate
{
GtkTreeModel * initial_model;
@@ -48,8 +47,6 @@ struct _TimezoneCompletionPrivate
GHashTable * request_table;
};
-#define TIMEZONE_COMPLETION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), TIMEZONE_COMPLETION_TYPE, TimezoneCompletionPrivate))
-
#define GEONAME_URL "http://geoname-lookup.ubuntu.com/?query=%s&release=%s&lang=%s"
/* Prototypes */
@@ -71,7 +68,7 @@ match_func (GtkEntryCompletion *completion, const gchar *key,
static void
save_and_use_model (TimezoneCompletion * completion, GtkTreeModel * model)
{
- TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE(completion);
+ TimezoneCompletionPrivate * priv = completion->priv;
g_hash_table_insert (priv->request_table, g_strdup (priv->request_text), g_object_ref_sink (model));
@@ -129,7 +126,7 @@ static void
json_parse_ready (GObject *object, GAsyncResult *res, gpointer user_data)
{
TimezoneCompletion * completion = TIMEZONE_COMPLETION (user_data);
- TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE(completion);
+ TimezoneCompletionPrivate * priv = completion->priv;
GError * error = NULL;
const gchar * prev_name = NULL;
const gchar * prev_admin1 = NULL;
@@ -257,7 +254,7 @@ static void
geonames_data_ready (GObject *object, GAsyncResult *res, gpointer user_data)
{
TimezoneCompletion * completion = TIMEZONE_COMPLETION (user_data);
- TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion);
+ TimezoneCompletionPrivate * priv = completion->priv;
GError * error = NULL;
GFileInputStream * stream;
@@ -335,7 +332,7 @@ get_version (void)
static gboolean
request_zones (TimezoneCompletion * completion)
{
- TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion);
+ TimezoneCompletionPrivate * priv = completion->priv;
priv->queued_request = 0;
@@ -373,7 +370,7 @@ request_zones (TimezoneCompletion * completion)
static void
entry_changed (GtkEntry * entry, TimezoneCompletion * completion)
{
- TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion);
+ TimezoneCompletionPrivate * priv = completion->priv;
if (priv->queued_request) {
g_source_remove (priv->queued_request);
@@ -484,7 +481,7 @@ entry_keypress (GtkEntry * entry, GdkEventKey *event, TimezoneCompletion * comp
void
timezone_completion_watch_entry (TimezoneCompletion * completion, GtkEntry * entry)
{
- TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion);
+ TimezoneCompletionPrivate * priv = completion->priv;
if (priv->queued_request) {
g_source_remove (priv->queued_request);
@@ -604,7 +601,12 @@ timezone_completion_class_init (TimezoneCompletionClass *klass)
static void
timezone_completion_init (TimezoneCompletion * self)
{
- TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (self);
+ TimezoneCompletionPrivate *priv;
+
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ TIMEZONE_COMPLETION_TYPE,
+ TimezoneCompletionPrivate);
+ priv = self->priv;
priv->initial_model = GTK_TREE_MODEL (get_initial_model ());
@@ -630,7 +632,7 @@ timezone_completion_dispose (GObject * object)
G_OBJECT_CLASS (timezone_completion_parent_class)->dispose (object);
TimezoneCompletion * completion = TIMEZONE_COMPLETION (object);
- TimezoneCompletionPrivate * priv = TIMEZONE_COMPLETION_GET_PRIVATE (completion);
+ TimezoneCompletionPrivate * priv = completion->priv;
if (priv->changed_id) {
if (priv->entry)
diff --git a/src/timezone-completion.h b/src/timezone-completion.h
index fdfb234..1592d79 100644
--- a/src/timezone-completion.h
+++ b/src/timezone-completion.h
@@ -34,15 +34,18 @@ G_BEGIN_DECLS
#define IS_TIMEZONE_COMPLETION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TIMEZONE_COMPLETION_TYPE))
#define TIMEZONE_COMPLETION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TIMEZONE_COMPLETION_TYPE, TimezoneCompletionClass))
-typedef struct _TimezoneCompletion TimezoneCompletion;
-typedef struct _TimezoneCompletionClass TimezoneCompletionClass;
-
-struct _TimezoneCompletionClass {
- GtkEntryCompletionClass parent_class;
-};
+typedef struct _TimezoneCompletion TimezoneCompletion;
+typedef struct _TimezoneCompletionPrivate TimezoneCompletionPrivate;
+typedef struct _TimezoneCompletionClass TimezoneCompletionClass;
struct _TimezoneCompletion {
GtkEntryCompletion parent;
+
+ TimezoneCompletionPrivate *priv;
+};
+
+struct _TimezoneCompletionClass {
+ GtkEntryCompletionClass parent_class;
};
#define TIMEZONE_COMPLETION_ZONE 0
@@ -53,7 +56,7 @@ struct _TimezoneCompletion {
#define TIMEZONE_COMPLETION_LATITUDE 5
#define TIMEZONE_COMPLETION_LAST 6
-GType timezone_completion_get_type (void);
+GType timezone_completion_get_type (void) G_GNUC_CONST;
TimezoneCompletion * timezone_completion_new ();
void timezone_completion_watch_entry (TimezoneCompletion * completion, GtkEntry * entry);