Re: misc. properties



On 10 Oct 2001, Owen Taylor wrote:
> Some comments on the patch below. Other than that looks fine to
> commit.

        Ok, fixed up and committed; here is the next patch:

        I'm not convinced about the 'history' property - since, unless the
widget has it's children already registered it will not in fact set the
history correctly - whether this is worth 'fixing' by effecting the
history setting at a later time or something I don't know; also the name
'history' is rather curious for this property but ...

        Also, the 'text' property;

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.2378
diff -u -r1.2378 ChangeLog
--- ChangeLog	2001/10/11 20:37:50	1.2378
+++ ChangeLog	2001/10/12 03:34:43
@@ -1,3 +1,20 @@
+2001-10-13  Michael Meeks  <michael ximian com>
+
+	* gdk/x11/gdkim-x11.c (_gdk_x11_initialize_locale): kill
+	redundant return.
+
+	* gtk/gtkentry.c (gtk_entry_set_property),
+	(gtk_entry_get_property): impl 'text'
+	(gtk_entry_class_init): add the 'text' prop.
+
+2001-10-12  Michael Meeks  <michael ximian com>
+
+	* gtk/gtkoptionmenu.c (gtk_option_menu_set_property),
+	(gtk_option_menu_get_property): impl.
+	(gtk_option_menu_class_init): hook up the 'history'
+	property.
+	(gtk_option_menu_set_history): add notification.
+
 2001-10-11  Matthias Clasen  <matthiasc poet de>

 	* gtk/gtkcolorsel.c, gtk/gtkwidget.c, gtk/gtktreeview.c:
Index: gdk/x11/gdkim-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkim-x11.c,v
retrieving revision 1.25
diff -u -r1.25 gdkim-x11.c
--- gdk/x11/gdkim-x11.c	2001/10/10 21:54:25	1.25
+++ gdk/x11/gdkim-x11.c	2001/10/12 03:34:43
@@ -93,8 +93,6 @@
   GDK_NOTE (XIM,
 	    g_message ("%s multi-byte string functions.",
 		       gdk_use_mb ? "Using" : "Not using"));
-
-  return current_locale;
 }

 gchar*
Index: gtk/gtkentry.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkentry.c,v
retrieving revision 1.154
diff -u -r1.154 gtkentry.c
--- gtk/gtkentry.c	2001/10/03 21:50:57	1.154
+++ gtk/gtkentry.c	2001/10/12 03:34:44
@@ -78,7 +78,8 @@
   PROP_INVISIBLE_CHAR,
   PROP_ACTIVATES_DEFAULT,
   PROP_WIDTH_CHARS,
-  PROP_SCROLL_OFFSET
+  PROP_SCROLL_OFFSET,
+  PROP_TEXT
 };

 static guint signals[LAST_SIGNAL] = { 0 };
@@ -465,7 +466,6 @@
                                                      _("Number of characters to leave space for in the entry."),
                                                      -1,
                                                      G_MAXINT,
-
                                                      -1,
                                                      G_PARAM_READABLE | G_PARAM_WRITABLE));

@@ -476,9 +476,16 @@
                                                      _("Number of pixels of the entry scrolled off the screen to the left"),
                                                      0,
                                                      G_MAXINT,
-
                                                      0,
                                                      G_PARAM_READABLE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_TEXT,
+                                   g_param_spec_string ("text",
+							_("Text"),
+							_("The contents of the entry"),
+							"",
+							G_PARAM_READABLE | G_PARAM_WRITABLE));

   gtk_widget_class_install_style_property (widget_class,
 					   g_param_spec_boxed ("cursor_color",
@@ -809,6 +816,10 @@
       gtk_entry_set_width_chars (entry, g_value_get_int (value));
       break;

+    case PROP_TEXT:
+      gtk_entry_set_text (entry, g_value_get_string (value));
+      break;
+
     case PROP_SCROLL_OFFSET:
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -854,6 +865,9 @@
       break;
     case PROP_SCROLL_OFFSET:
       g_value_set_int (value, entry->scroll_offset);
+      break;
+    case PROP_TEXT:
+      g_value_set_string (value, gtk_entry_get_text (entry));
       break;

     default:
Index: gtk/gtkoptionmenu.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkoptionmenu.c,v
retrieving revision 1.52
diff -u -r1.52 gtkoptionmenu.c
--- gtk/gtkoptionmenu.c	2001/09/17 02:19:01	1.52
+++ gtk/gtkoptionmenu.c	2001/10/12 03:34:45
@@ -31,6 +31,10 @@
 #include "gtksignal.h"
 #include "gdk/gdkkeysyms.h"

+enum {
+  PROP_0,
+  PROP_HISTORY
+};

 #define CHILD_LEFT_SPACING        5
 #define CHILD_RIGHT_SPACING       1
@@ -82,6 +86,14 @@
 static GtkType gtk_option_menu_child_type   (GtkContainer       *container);
 static gint gtk_option_menu_scroll_event    (GtkWidget          *widget,
 					     GdkEventScroll     *event);
+static void gtk_option_menu_set_property    (GObject            *object,
+					     guint               prop_id,
+					     const GValue       *value,
+					     GParamSpec         *pspec);
+static void gtk_option_menu_get_property    (GObject            *object,
+					     guint               prop_id,
+					     GValue             *value,
+					     GParamSpec         *pspec);

 enum
 {
@@ -121,11 +133,13 @@
 static void
 gtk_option_menu_class_init (GtkOptionMenuClass *class)
 {
+  GObjectClass   *gobject_class;
   GtkObjectClass *object_class;
   GtkWidgetClass *widget_class;
   GtkButtonClass *button_class;
   GtkContainerClass *container_class;

+  gobject_class = (GObjectClass*) class;
   object_class = (GtkObjectClass*) class;
   widget_class = (GtkWidgetClass*) class;
   button_class = (GtkButtonClass*) class;
@@ -167,6 +181,19 @@
 							       _("Spacing around indicator"),
 							       GTK_TYPE_BORDER,
 							       G_PARAM_READABLE));
+
+  gobject_class->set_property = gtk_option_menu_set_property;
+  gobject_class->get_property = gtk_option_menu_get_property;
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_HISTORY,
+                                   g_param_spec_int ("history",
+						     _("History"),
+						     _("The index of the currently selected menu item"),
+						     0,
+						     G_MAXINT,
+						     0,
+						     G_PARAM_READABLE | G_PARAM_WRITABLE));
 }

 static GtkType
@@ -275,6 +302,8 @@

       if (menu_item != option_menu->menu_item)
         gtk_option_menu_update_contents (option_menu);
+
+      g_object_notify (G_OBJECT (option_menu), "history");
     }
 }

@@ -932,3 +961,40 @@
   return TRUE;
 }

+static void
+gtk_option_menu_set_property (GObject         *object,
+			      guint            prop_id,
+			      const GValue    *value,
+			      GParamSpec      *pspec)
+{
+  GtkOptionMenu *option_menu = GTK_OPTION_MENU (object);
+
+  switch (prop_id)
+    {
+    case PROP_HISTORY:
+      gtk_option_menu_set_history (option_menu, g_value_get_int (value));
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+gtk_option_menu_get_property (GObject         *object,
+			      guint            prop_id,
+			      GValue          *value,
+			      GParamSpec      *pspec)
+{
+  GtkOptionMenu *option_menu = GTK_OPTION_MENU (object);
+
+  switch (prop_id)
+    {
+    case PROP_HISTORY:
+      g_value_set_int (value, gtk_option_menu_get_history (option_menu));
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}

	HTH,

		Michael.

-- 
 mmeeks gnu org  <><, Pseudo Engineer, itinerant idiot





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]