[gtk+] Add a 'value' GObject property to GtkPrinterOption so that it can be used with g_object_bind_propert
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add a 'value' GObject property to GtkPrinterOption so that it can be used with g_object_bind_propert
- Date: Thu, 9 Jun 2011 14:54:24 +0000 (UTC)
commit 16d0fca4f540256c700184627f3b5669d18fabfc
Author: Richard Hughes <richard hughsie com>
Date: Thu Jun 9 15:30:31 2011 +0100
Add a 'value' GObject property to GtkPrinterOption so that it can be used with g_object_bind_property()
gtk/gtkprinteroption.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 64 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkprinteroption.c b/gtk/gtkprinteroption.c
index fbf2545..c2ba064 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]