aboutsummaryrefslogtreecommitdiff
path: root/src/location.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/location.c')
-rw-r--r--src/location.c108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/location.c b/src/location.c
new file mode 100644
index 0000000..12e25c3
--- /dev/null
+++ b/src/location.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2013 Canonical Ltd.
+ *
+ * Authors:
+ * Charles Kerr <charles.kerr@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/>.
+ */
+
+#include "location.h"
+
+G_DEFINE_TYPE (IndicatorDatetimeLocation,
+ indicator_datetime_location,
+ G_TYPE_OBJECT)
+
+enum
+{
+ PROP_0,
+ PROP_TIMEZONE,
+ PROP_LAST
+};
+
+static GParamSpec * properties[PROP_LAST] = { 0 };
+
+static void
+my_get_property (GObject * o,
+ guint property_id,
+ GValue * value,
+ GParamSpec * pspec)
+{
+ IndicatorDatetimeLocation * self = INDICATOR_DATETIME_LOCATION (o);
+
+ switch (property_id)
+ {
+ case PROP_TIMEZONE:
+ g_value_set_string (value, indicator_datetime_location_get_timezone (self));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (o, property_id, pspec);
+ }
+}
+
+static void
+my_dispose (GObject * object)
+{
+ G_OBJECT_CLASS (indicator_datetime_location_parent_class)->dispose (object);
+}
+
+static void
+/* cppcheck-suppress unusedFunction */
+indicator_datetime_location_class_init (IndicatorDatetimeLocationClass * klass)
+{
+ GObjectClass * object_class;
+ const GParamFlags flags = G_PARAM_READABLE | G_PARAM_STATIC_STRINGS;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->get_property = my_get_property;
+ object_class->dispose = my_dispose;
+
+ klass->get_timezone = NULL;
+
+ properties[PROP_0] = NULL;
+
+ properties[PROP_TIMEZONE] = g_param_spec_string ("timezone",
+ "Timezone",
+ "Timezone",
+ "",
+ flags);
+
+ g_object_class_install_properties (object_class, PROP_LAST, properties);
+}
+
+static void
+indicator_datetime_location_init (IndicatorDatetimeLocation * self G_GNUC_UNUSED)
+{
+}
+
+/***
+****
+***/
+
+const char *
+indicator_datetime_location_get_timezone (IndicatorDatetimeLocation * self)
+{
+ g_return_val_if_fail (INDICATOR_IS_DATETIME_LOCATION (self), NULL);
+
+ return INDICATOR_DATETIME_LOCATION_GET_CLASS (self)->get_timezone (self);
+}
+
+void
+indicator_datetime_location_notify_timezone (IndicatorDatetimeLocation * self)
+{
+ g_return_if_fail (INDICATOR_IS_DATETIME_LOCATION (self));
+
+ g_object_notify_by_pspec (G_OBJECT(self), properties[PROP_TIMEZONE]);
+}
+