]> Pileus Git - ~andy/gtk/commitdiff
Clamp @max parameter passed in to [0, MAX_SIZE], improve docs. Fix default
authorOwen Taylor <otaylor@redhat.com>
Sat, 2 Mar 2002 21:01:20 +0000 (21:01 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Sat, 2 Mar 2002 21:01:20 +0000 (21:01 +0000)
Sat Mar  2 15:48:04 2002  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtkentry.c (gtk_entry_new_with_max_length,
        gtk_entry_set_max_length): Clamp @max parameter passed in to
        [0, MAX_SIZE], improve docs. Fix default and range
        for ::max-length property, range for ::ncursor_position,
        ::selection_bound properties. (#55916, Vitaly Tishkov)

        * gtk/gtkmain.c (rewrite_event_for_grabs): Fix typo

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkentry.c
gtk/gtkmain.c

index 5fc8dfbc550127c84deaf4623bf40929ebc73747..e1a60c606f667c9c4842c48593f220c4642b850c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Sat Mar  2 15:48:04 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c (gtk_entry_new_with_max_length,
+       gtk_entry_set_max_length): Clamp @max parameter passed in to 
+       [0, MAX_SIZE], improve docs. Fix default and range 
+       for ::max-length property, range for ::ncursor_position,
+       ::selection_bound properties. (#55916, Vitaly Tishkov)
+
+       * gtk/gtkmain.c (rewrite_event_for_grabs): Fix typo
+
 Fri Mar  1 18:39:44 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/x11/{gdkevents-x11.c,gdkmain-x11.c,gdkprivate-x11.h,
index 5fc8dfbc550127c84deaf4623bf40929ebc73747..e1a60c606f667c9c4842c48593f220c4642b850c 100644 (file)
@@ -1,3 +1,13 @@
+Sat Mar  2 15:48:04 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c (gtk_entry_new_with_max_length,
+       gtk_entry_set_max_length): Clamp @max parameter passed in to 
+       [0, MAX_SIZE], improve docs. Fix default and range 
+       for ::max-length property, range for ::ncursor_position,
+       ::selection_bound properties. (#55916, Vitaly Tishkov)
+
+       * gtk/gtkmain.c (rewrite_event_for_grabs): Fix typo
+
 Fri Mar  1 18:39:44 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/x11/{gdkevents-x11.c,gdkmain-x11.c,gdkprivate-x11.h,
index 5fc8dfbc550127c84deaf4623bf40929ebc73747..e1a60c606f667c9c4842c48593f220c4642b850c 100644 (file)
@@ -1,3 +1,13 @@
+Sat Mar  2 15:48:04 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c (gtk_entry_new_with_max_length,
+       gtk_entry_set_max_length): Clamp @max parameter passed in to 
+       [0, MAX_SIZE], improve docs. Fix default and range 
+       for ::max-length property, range for ::ncursor_position,
+       ::selection_bound properties. (#55916, Vitaly Tishkov)
+
+       * gtk/gtkmain.c (rewrite_event_for_grabs): Fix typo
+
 Fri Mar  1 18:39:44 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/x11/{gdkevents-x11.c,gdkmain-x11.c,gdkprivate-x11.h,
index 5fc8dfbc550127c84deaf4623bf40929ebc73747..e1a60c606f667c9c4842c48593f220c4642b850c 100644 (file)
@@ -1,3 +1,13 @@
+Sat Mar  2 15:48:04 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c (gtk_entry_new_with_max_length,
+       gtk_entry_set_max_length): Clamp @max parameter passed in to 
+       [0, MAX_SIZE], improve docs. Fix default and range 
+       for ::max-length property, range for ::ncursor_position,
+       ::selection_bound properties. (#55916, Vitaly Tishkov)
+
+       * gtk/gtkmain.c (rewrite_event_for_grabs): Fix typo
+
 Fri Mar  1 18:39:44 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/x11/{gdkevents-x11.c,gdkmain-x11.c,gdkprivate-x11.h,
index 5fc8dfbc550127c84deaf4623bf40929ebc73747..e1a60c606f667c9c4842c48593f220c4642b850c 100644 (file)
@@ -1,3 +1,13 @@
+Sat Mar  2 15:48:04 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c (gtk_entry_new_with_max_length,
+       gtk_entry_set_max_length): Clamp @max parameter passed in to 
+       [0, MAX_SIZE], improve docs. Fix default and range 
+       for ::max-length property, range for ::ncursor_position,
+       ::selection_bound properties. (#55916, Vitaly Tishkov)
+
+       * gtk/gtkmain.c (rewrite_event_for_grabs): Fix typo
+
 Fri Mar  1 18:39:44 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/x11/{gdkevents-x11.c,gdkmain-x11.c,gdkprivate-x11.h,
index 5fc8dfbc550127c84deaf4623bf40929ebc73747..e1a60c606f667c9c4842c48593f220c4642b850c 100644 (file)
@@ -1,3 +1,13 @@
+Sat Mar  2 15:48:04 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c (gtk_entry_new_with_max_length,
+       gtk_entry_set_max_length): Clamp @max parameter passed in to 
+       [0, MAX_SIZE], improve docs. Fix default and range 
+       for ::max-length property, range for ::ncursor_position,
+       ::selection_bound properties. (#55916, Vitaly Tishkov)
+
+       * gtk/gtkmain.c (rewrite_event_for_grabs): Fix typo
+
 Fri Mar  1 18:39:44 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/x11/{gdkevents-x11.c,gdkmain-x11.c,gdkprivate-x11.h,
index 5fc8dfbc550127c84deaf4623bf40929ebc73747..e1a60c606f667c9c4842c48593f220c4642b850c 100644 (file)
@@ -1,3 +1,13 @@
+Sat Mar  2 15:48:04 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c (gtk_entry_new_with_max_length,
+       gtk_entry_set_max_length): Clamp @max parameter passed in to 
+       [0, MAX_SIZE], improve docs. Fix default and range 
+       for ::max-length property, range for ::ncursor_position,
+       ::selection_bound properties. (#55916, Vitaly Tishkov)
+
+       * gtk/gtkmain.c (rewrite_event_for_grabs): Fix typo
+
 Fri Mar  1 18:39:44 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/x11/{gdkevents-x11.c,gdkmain-x11.c,gdkprivate-x11.h,
index 830a9af1712c17190cc73bd54ca62f7b0410a09b..7752125799468b5de9794c9b9ce28a00e183fed4 100644 (file)
@@ -435,7 +435,7 @@ gtk_entry_class_init (GtkEntryClass *class)
                                                      _("Cursor Position"),
                                                      _("The current position of the insertion cursor in chars."),
                                                      0,
-                                                     G_MAXINT,
+                                                     MAX_SIZE,
                                                      0,
                                                      G_PARAM_READABLE));
   
@@ -445,7 +445,7 @@ gtk_entry_class_init (GtkEntryClass *class)
                                                      _("Selection Bound"),
                                                      _("The position of the opposite end of the selection from the cursor in chars."),
                                                      0,
-                                                     G_MAXINT,
+                                                     MAX_SIZE,
                                                      0,
                                                      G_PARAM_READABLE));
   
@@ -461,10 +461,10 @@ gtk_entry_class_init (GtkEntryClass *class)
                                    PROP_MAX_LENGTH,
                                    g_param_spec_int ("max_length",
                                                      _("Maximum length"),
-                                                     _("Maximum number of characters for this entry"),
-                                                     -1,
-                                                     G_MAXINT,
-                                                     -1,
+                                                     _("Maximum number of characters for this entry. Zero if no maximum."),
+                                                     0,
+                                                     MAX_SIZE,
+                                                     0,
                                                      G_PARAM_READABLE | G_PARAM_WRITABLE));
   g_object_class_install_property (gobject_class,
                                    PROP_VISIBILITY,
@@ -3257,11 +3257,30 @@ gtk_entry_new (void)
   return GTK_WIDGET (gtk_type_new (GTK_TYPE_ENTRY));
 }
 
+/**
+ * gtk_entry_new_with_max_length:
+ * @max: the maximum length of the entry, or 0 for no maximum.
+ *   (other than the maximum length of entries.) The value passed in will
+ *   be clamped to the range 0-65536.
+ *
+ * Creates a new #GtkEntry widget with the given maximum length.
+ * 
+ * Note: the existance of this function is inconsistent
+ * with the rest of the GTK+ API. The normal setup would
+ * be to just require the user to make an extra call
+ * to gtk_entry_set_max_length() instead. It is not
+ * expected that this function will be removed, but
+ * it would be better practice not to use it.
+ * 
+ * Return value: a new #GtkEntry.
+ **/
 GtkWidget*
 gtk_entry_new_with_max_length (gint max)
 {
   GtkEntry *entry;
 
+  max = CLAMP (max, 0, MAX_SIZE);
+
   entry = gtk_type_new (GTK_TYPE_ENTRY);
   entry->text_max_length = max;
 
@@ -3417,12 +3436,25 @@ gtk_entry_select_region  (GtkEntry       *entry,
   gtk_editable_select_region (GTK_EDITABLE (entry), start, end);
 }
 
+/**
+ * gtk_entry_set_max_length:
+ * @entry: a #GtkEntry.
+ * @max: the maximum length of the entry, or 0 for no maximum.
+ *   (other than the maximum length of entries.) The value passed in will
+ *   be clamped to the range 0-65536.
+ * 
+ * Sets the maximum allowed length of the contents of the widget. If
+ * the current contents are longer than the given length, then they
+ * will be truncated to fit.
+ **/
 void
 gtk_entry_set_max_length (GtkEntry     *entry,
                           gint          max)
 {
   g_return_if_fail (GTK_IS_ENTRY (entry));
 
+  max = CLAMP (max, 0, MAX_SIZE);
+
   if (max > 0 && entry->text_length > max)
     gtk_editable_delete_text (GTK_EDITABLE (entry), max, -1);
   
index c38607a39cc66b9c588f0da5291268224d4f9b3d..666f21254c52cdc7d298295b18b85eb9a05a30b5 100644 (file)
@@ -1056,7 +1056,7 @@ static GdkEvent *
 rewrite_event_for_grabs (GdkEvent *event)
 {
   GdkWindow *grab_window;
-  GtkWidget *event_widget, *grab_widget;;
+  GtkWidget *event_widget, *grab_widget;
   gboolean owner_events;
 
   switch (event->type)