]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkpreview.c
Fixed a small typo, it should be GTK_WINDOW_GROUP_GET_CLASS and not
[~andy/gtk] / gtk / gtkpreview.c
index 39d2618a0f3c0a49c4feb076c49f2f8a19f7bd40..cb0cf04190dbcc4e42b83be9966bf1052de59bd6 100644 (file)
@@ -2,23 +2,23 @@
  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
+ * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU Library General Public
+ * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  */
 
 /*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
+ * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
  * file for a list of people on the GTK+ Team.  See the ChangeLog
  * files for a list of changes.  These files are distributed with
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
 #include "gdk/gdkrgb.h"
 #include "gtkpreview.h"
 #include "gtksignal.h"
+#include "gtkintl.h"
 
 
 #define PREVIEW_CLASS(w)      GTK_PREVIEW_CLASS (GTK_OBJECT (w)->klass)
 
 enum {
-  ARG_0,
-  ARG_EXPAND
+  PROP_0,
+  PROP_EXPAND
 };
 
 
 static void   gtk_preview_class_init    (GtkPreviewClass  *klass);
 static void   gtk_preview_init          (GtkPreview       *preview);
-static void   gtk_preview_set_arg      (GtkObject        *object,
-                                        GtkArg           *arg,
-                                        guint             arg_id);
-static void   gtk_preview_get_arg      (GtkObject        *object,
-                                        GtkArg           *arg,
-                                        guint             arg_id);
-static void   gtk_preview_finalize      (GtkObject        *object);
+static void   gtk_preview_set_property  (GObject          *object,
+                                        guint             prop_id,
+                                        const GValue     *value,
+                                        GParamSpec       *pspec);
+static void   gtk_preview_get_property  (GObject          *object,
+                                        guint             prop_id,
+                                        GValue           *value,
+                                        GParamSpec       *pspec);
+static void   gtk_preview_finalize      (GObject          *object);
 static void   gtk_preview_realize       (GtkWidget        *widget);
 static void   gtk_preview_size_allocate (GtkWidget        *widget,
                                         GtkAllocation    *allocation);
@@ -95,6 +98,7 @@ gtk_preview_get_type (void)
 static void
 gtk_preview_class_init (GtkPreviewClass *klass)
 {
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
   GtkObjectClass *object_class;
   GtkWidgetClass *widget_class;
 
@@ -104,9 +108,10 @@ gtk_preview_class_init (GtkPreviewClass *klass)
   parent_class = gtk_type_class (GTK_TYPE_WIDGET);
   preview_class = klass;
 
-  object_class->set_arg = gtk_preview_set_arg;
-  object_class->get_arg = gtk_preview_get_arg;
-  object_class->finalize = gtk_preview_finalize;
+  gobject_class->finalize = gtk_preview_finalize;
+
+  gobject_class->set_property = gtk_preview_set_property;
+  gobject_class->get_property = gtk_preview_get_property;
 
   widget_class->realize = gtk_preview_realize;
   widget_class->size_allocate = gtk_preview_size_allocate;
@@ -123,43 +128,51 @@ gtk_preview_class_init (GtkPreviewClass *klass)
   klass->info.cmap = gdk_rgb_get_cmap ();
   klass->info.visual = gdk_rgb_get_visual ();
 
-  gtk_object_add_arg_type ("GtkPreview::expand",
-                          GTK_TYPE_BOOL,
-                          GTK_ARG_READWRITE,
-                          ARG_EXPAND);
+  g_object_class_install_property (gobject_class,
+                                   PROP_EXPAND,
+                                   g_param_spec_boolean ("expand",
+                                                        _("Expand"),
+                                                        _("Whether the preview widget should take up the entire space it is allocated"),
+                                                        FALSE,
+                                                        G_PARAM_READWRITE));
 }
 
 static void
-gtk_preview_set_arg (GtkObject *object,
-                    GtkArg    *arg,
-                    guint      arg_id)
+gtk_preview_set_property (GObject      *object,
+                         guint         prop_id,
+                         const GValue *value,
+                         GParamSpec   *pspec)
 {
   GtkPreview *preview = GTK_PREVIEW (object);
   
-  switch (arg_id)
+  switch (prop_id)
     {
-    case ARG_EXPAND:
-      gtk_preview_set_expand (preview, GTK_VALUE_BOOL (*arg));
+    case PROP_EXPAND:
+      gtk_preview_set_expand (preview, g_value_get_boolean (value));
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
     }
 }
 
 static void
-gtk_preview_get_arg (GtkObject *object,
-                    GtkArg    *arg,
-                    guint      arg_id)
+gtk_preview_get_property (GObject      *object,
+                         guint         prop_id,
+                         GValue       *value,
+                         GParamSpec   *pspec)
 {
   GtkPreview *preview;
   
   preview = GTK_PREVIEW (object);
   
-  switch (arg_id)
+  switch (prop_id)
     {
-    case ARG_EXPAND:
-      GTK_VALUE_BOOL (*arg) = preview->expand;
+    case PROP_EXPAND:
+      g_value_set_boolean (value, preview->expand);
       break;
     default:
-      arg->type = GTK_TYPE_INVALID;
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
     }
 }
@@ -182,7 +195,6 @@ gtk_preview_init (GtkPreview *preview)
 void
 gtk_preview_uninit (void)
 {
-
   /* unimplemented */
 }
 
@@ -359,6 +371,8 @@ gtk_preview_set_expand (GtkPreview *preview,
     {
       preview->expand = expand;
       gtk_widget_queue_resize (GTK_WIDGET (preview));
+      g_object_notify (G_OBJECT (preview), "expand"); 
     }
 }
 
@@ -438,11 +452,10 @@ gtk_preview_get_info (void)
 
 
 static void
-gtk_preview_finalize (GtkObject *object)
+gtk_preview_finalize (GObject *object)
 {
   GtkPreview *preview;
 
-  g_return_if_fail (object != NULL);
   g_return_if_fail (GTK_IS_PREVIEW (object));
 
   preview = GTK_PREVIEW (object);
@@ -450,7 +463,7 @@ gtk_preview_finalize (GtkObject *object)
     g_free (preview->buffer);
   preview->type = (GtkPreviewType) -1;
 
-  (* GTK_OBJECT_CLASS (parent_class)->finalize) (object);
+  G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
 static void