Make AgWindowPrivate->chart a GObject property

This commit is contained in:
Gergely Polonkai 2014-09-29 17:09:08 +02:00
parent c0608379f1
commit fcef96e686

View File

@ -109,10 +109,18 @@ typedef struct {
GList *items; GList *items;
} LoadIdleData; } LoadIdleData;
enum {
PROP_0,
PROP_CHART,
PROP_COUNT
};
G_DEFINE_QUARK(ag_window_error_quark, ag_window_error); G_DEFINE_QUARK(ag_window_error_quark, ag_window_error);
G_DEFINE_TYPE_WITH_PRIVATE(AgWindow, ag_window, GTK_TYPE_APPLICATION_WINDOW); G_DEFINE_TYPE_WITH_PRIVATE(AgWindow, ag_window, GTK_TYPE_APPLICATION_WINDOW);
static GParamSpec *properties[PROP_COUNT];
static void static void
ag_window_gear_menu_action(GSimpleAction *action, ag_window_gear_menu_action(GSimpleAction *action,
GVariant *parameter, GVariant *parameter,
@ -2442,6 +2450,48 @@ ag_window_selection_mode_cancel_cb(GtkButton *button, AgWindow *window)
ag_window_set_selection_mode(window, FALSE); 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 static void
ag_window_class_init(AgWindowClass *klass) ag_window_class_init(AgWindowClass *klass)
{ {
@ -2450,6 +2500,25 @@ ag_window_class_init(AgWindowClass *klass)
widget_class->destroy = ag_window_destroy; widget_class->destroy = ag_window_destroy;
gobject_class->dispose = ag_window_dispose; 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( gtk_widget_class_set_template_from_resource(
widget_class, widget_class,