]> Pileus Git - ~andy/gtk/commitdiff
Add a 'value' GObject property to GtkPrinterOption so that it can be used with g_obje...
authorRichard Hughes <richard@hughsie.com>
Thu, 9 Jun 2011 14:30:31 +0000 (15:30 +0100)
committerRichard Hughes <richard@hughsie.com>
Thu, 9 Jun 2011 14:50:34 +0000 (15:50 +0100)
gtk/gtkprinteroption.c

index fbf2545b6d06a07180e64c33a211bb356d4b5f5a..c2ba064f20c4e540e6c6a26547761680dbd37bda 100644 (file)
@@ -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 *
@@ -97,6 +123,44 @@ gtk_printer_option_new (const char *name, const char *display_text,
   return option;
 }
 
+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)
 {