[gnome-panel/wip/applets/clock: 18/18] clock: add ClockPreferences [untested code]



commit 71a65643376335e94d82afd26f9056faab5cd628
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Fri Nov 14 18:33:51 2014 +0200

    clock: add ClockPreferences [untested code]

 applets/clock/Makefile.am         |    2 +
 applets/clock/clock-preferences.c |  143 +++++++++++++++++++++++++++++++++++++
 applets/clock/clock-preferences.h |   64 ++++++++++++++++
 3 files changed, 209 insertions(+), 0 deletions(-)
---
diff --git a/applets/clock/Makefile.am b/applets/clock/Makefile.am
index d25fbc7..fe567c5 100644
--- a/applets/clock/Makefile.am
+++ b/applets/clock/Makefile.am
@@ -36,6 +36,8 @@ CLOCK_SOURCES =               \
        clock-location-tile.h   \
        clock-map.c             \
        clock-map.h             \
+       clock-preferences.c     \
+       clock-preferences.h     \
        clock-sunpos.c          \
        clock-sunpos.h          \
        clock-time.c \
diff --git a/applets/clock/clock-preferences.c b/applets/clock/clock-preferences.c
new file mode 100644
index 0000000..405bbcd
--- /dev/null
+++ b/applets/clock/clock-preferences.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2014 Alberts Muktupāvels
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY 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/>.
+ *
+ * Authors:
+ *    Alberts Muktupāvels <alberts muktupavels gmail com>
+ */
+
+#include "clock-preferences.h"
+
+struct _ClockPreferencesPrivate
+{
+        GSettings *settings;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (ClockPreferences,
+                            clock_preferences,
+                            GTK_TYPE_WINDOW)
+
+enum
+{
+       PROP_0,
+       PROP_SETTINGS,
+       N_PROPERTIES
+};
+
+static GParamSpec *object_properties[N_PROPERTIES] = { NULL, };
+
+static void
+clock_preferences_finalize (GObject *object)
+{
+       ClockPreferences *preferences;
+
+       preferences = CLOCK_PREFERENCES (object);
+
+       g_clear_object (&preferences->priv->settings);
+
+       G_OBJECT_CLASS (clock_preferences_parent_class)->finalize (object);
+}
+
+static void
+clock_preferences_set_property (GObject      *object,
+                                guint         property_id,
+                                const GValue *value,
+                                GParamSpec   *pspec)
+{
+       ClockPreferences *preferences;
+       GSettings        *settings;
+
+       preferences = CLOCK_PREFERENCES (object);
+
+       switch (property_id)
+       {
+               case PROP_SETTINGS:
+                       settings = g_value_get_object (value);
+                       preferences->priv->settings = g_object_ref (settings);
+                       break;
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
+                                                          property_id,
+                                                          pspec);
+                       break;
+       }
+}
+
+static void
+clock_preferences_get_property (GObject    *object,
+                                guint       property_id,
+                                GValue     *value,
+                                GParamSpec *pspec)
+{
+       ClockPreferences *preferences;
+
+       preferences = CLOCK_PREFERENCES (object);
+
+       switch (property_id)
+       {
+               case PROP_SETTINGS:
+                       g_value_set_object (value, preferences->priv->settings);
+                       break;
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
+                                                          property_id,
+                                                          pspec);
+                       break;
+       }
+}
+
+static void
+clock_preferences_class_init (ClockPreferencesClass *class)
+{
+       GObjectClass   *object_class;
+       GtkWidgetClass *widget_class;
+
+       object_class = G_OBJECT_CLASS (class);
+       widget_class = GTK_WIDGET_CLASS (class);
+
+       object_class->finalize = clock_preferences_finalize;
+       object_class->set_property = clock_preferences_set_property;
+       object_class->get_property = clock_preferences_get_property;
+
+       object_properties[PROP_SETTINGS] =
+               g_param_spec_object ("settings",
+                                    "settings",
+                                    "settings",
+                                    G_TYPE_SETTINGS,
+                                    G_PARAM_CONSTRUCT_ONLY |
+                                    G_PARAM_WRITABLE);
+
+       g_object_class_install_properties (object_class,
+                                          N_PROPERTIES,
+                                          object_properties);
+}
+
+static void
+clock_preferences_init (ClockPreferences *preferences)
+{
+       preferences->priv = clock_preferences_get_instance_private (preferences);
+}
+
+GtkWidget *
+clock_preferences_new (GSettings *settings)
+{
+        GObject *object;
+
+        object = g_object_new (CLOCK_TYPE_PREFERENCES,
+                               "settings", settings,
+                               NULL);
+
+        return GTK_WIDGET (object);
+}
diff --git a/applets/clock/clock-preferences.h b/applets/clock/clock-preferences.h
new file mode 100644
index 0000000..3e87e7b
--- /dev/null
+++ b/applets/clock/clock-preferences.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2014 Alberts Muktupāvels
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY 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/>.
+ *
+ * Authors:
+ *    Alberts Muktupāvels <alberts muktupavels gmail com>
+ */
+
+#ifndef CLOCK_PREFERENCES_H
+#define CLOCK_PREFERENCES_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define CLOCK_TYPE_PREFERENCES         (clock_preferences_get_type ())
+#define CLOCK_PREFERENCES(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), \
+                                        CLOCK_TYPE_PREFERENCES,          \
+                                        ClockPreferences))
+#define CLOCK_PREFERENCES_CLASS(c)     (G_TYPE_CHECK_CLASS_CAST ((c),    \
+                                        CLOCK_TYPE_PREFERENCES,          \
+                                        ClockPreferencesClass))
+#define CLOCK_IS_PREFERENCES(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), \
+                                        CLOCK_TYPE_PREFERENCES))
+#define CLOCK_IS_PREFERENCES_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE ((c),    \
+                                        CLOCK_TYPE_PREFERENCES))
+#define CLOCK_PREFERENCES_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o),   \
+                                        CLOCK_TYPE_PREFERENCES,          \
+                                        ClockPreferencesClass))
+
+typedef struct _ClockPreferences        ClockPreferences;
+typedef struct _ClockPreferencesClass   ClockPreferencesClass;
+typedef struct _ClockPreferencesPrivate ClockPreferencesPrivate;
+
+struct _ClockPreferences
+{
+       GtkWindow                parent;
+       ClockPreferencesPrivate *priv;
+};
+
+struct _ClockPreferencesClass
+{
+       GtkWindowClass parent_class;
+};
+
+GType      clock_preferences_get_type (void);
+
+GtkWidget *clock_preferences_new      (GSettings *settings);
+
+G_END_DECLS
+
+#endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]