From fcef96e686fe9b6eb0c879cd63c70a7aa6a70735 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Mon, 29 Sep 2014 17:09:08 +0200 Subject: [PATCH] Make AgWindowPrivate->chart a GObject property --- src/ag-window.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/src/ag-window.c b/src/ag-window.c index 7df22c9..0f5861b 100644 --- a/src/ag-window.c +++ b/src/ag-window.c @@ -109,10 +109,18 @@ typedef struct { GList *items; } LoadIdleData; +enum { + PROP_0, + PROP_CHART, + PROP_COUNT +}; + G_DEFINE_QUARK(ag_window_error_quark, ag_window_error); G_DEFINE_TYPE_WITH_PRIVATE(AgWindow, ag_window, GTK_TYPE_APPLICATION_WINDOW); +static GParamSpec *properties[PROP_COUNT]; + static void ag_window_gear_menu_action(GSimpleAction *action, GVariant *parameter, @@ -2442,6 +2450,48 @@ ag_window_selection_mode_cancel_cb(GtkButton *button, AgWindow *window) ag_window_set_selection_mode(window, FALSE); } +static void +ag_window_set_property(GObject *gobject, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + AgWindow *window = AG_WINDOW(gobject); + + switch (prop_id) { + case PROP_CHART: + ag_window_set_chart(window, (g_value_get_object(value))); + + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec); + + break; + } +} + +static void +ag_window_get_property(GObject *gobject, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + AgWindowPrivate *priv = ag_window_get_instance_private(AG_WINDOW(gobject)); + + switch (prop_id) { + case PROP_CHART: + g_value_set_object(value, priv->chart); + + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec); + + break; + } +} + static void ag_window_class_init(AgWindowClass *klass) { @@ -2450,6 +2500,25 @@ ag_window_class_init(AgWindowClass *klass) widget_class->destroy = ag_window_destroy; gobject_class->dispose = ag_window_dispose; + gobject_class->set_property = ag_window_set_property; + gobject_class->get_property = ag_window_get_property; + + properties[PROP_CHART] = g_param_spec_object( + "chart", + "Chart", + "The AgChart associated with this window", + AG_TYPE_CHART, + G_PARAM_STATIC_NICK + | G_PARAM_STATIC_NAME + | G_PARAM_STATIC_BLURB + | G_PARAM_READABLE + | G_PARAM_WRITABLE + ); + g_object_class_install_property( + gobject_class, + PROP_CHART, + properties[PROP_CHART] + ); gtk_widget_class_set_template_from_resource( widget_class,