diff options
author | Richard Hughes <richard@hughsie.com> | 2011-06-09 15:30:31 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2011-06-09 15:50:34 +0100 |
commit | 16d0fca4f540256c700184627f3b5669d18fabfc (patch) | |
tree | b982b336676d8e1f18dca858333f135af0870bfa /gtk | |
parent | 84b3d6383846e23fb85029f7e5e019fabd7fc1f4 (diff) | |
download | gtk+-16d0fca4f540256c700184627f3b5669d18fabfc.tar.gz |
Add a 'value' GObject property to GtkPrinterOption so that it can be used with g_object_bind_property()
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkprinteroption.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/gtk/gtkprinteroption.c b/gtk/gtkprinteroption.c index fbf2545b6d..c2ba064f20 100644 --- a/gtk/gtkprinteroption.c +++ b/gtk/gtkprinteroption.c @@ -22,6 +22,8 @@ #include <string.h> #include <gmodule.h> +#include "gtkintl.h" +#include "gtkprivate.h" #include "gtkprinteroption.h" /***************************************** @@ -33,8 +35,22 @@ enum { LAST_SIGNAL }; +enum { + PROP_0, + PROP_VALUE +}; + static guint signals[LAST_SIGNAL] = { 0 }; +static void gtk_printer_option_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void gtk_printer_option_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); + G_DEFINE_TYPE (GtkPrinterOption, gtk_printer_option, G_TYPE_OBJECT) static void @@ -71,6 +87,8 @@ gtk_printer_option_class_init (GtkPrinterOptionClass *class) GObjectClass *gobject_class = (GObjectClass *)class; gobject_class->finalize = gtk_printer_option_finalize; + gobject_class->set_property = gtk_printer_option_set_property; + gobject_class->get_property = gtk_printer_option_get_property; signals[CHANGED] = g_signal_new ("changed", @@ -80,6 +98,14 @@ gtk_printer_option_class_init (GtkPrinterOptionClass *class) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + + g_object_class_install_property (G_OBJECT_CLASS (class), + PROP_VALUE, + g_param_spec_string ("value", + P_("Option Value"), + P_("Value of the option"), + "", + GTK_PARAM_READWRITE)); } GtkPrinterOption * @@ -98,6 +124,44 @@ gtk_printer_option_new (const char *name, const char *display_text, } static void +gtk_printer_option_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GtkPrinterOption *option = GTK_PRINTER_OPTION (object); + + switch (prop_id) + { + case PROP_VALUE: + gtk_printer_option_set (option, g_value_get_string (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gtk_printer_option_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GtkPrinterOption *option = GTK_PRINTER_OPTION (object); + + switch (prop_id) + { + case PROP_VALUE: + g_value_set_string (value, option->value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void emit_changed (GtkPrinterOption *option) { g_signal_emit (option, signals[CHANGED], 0); |