Commit 85d4cd0f authored by CET 1998	Paolo Molaro's avatar CET 1998 Paolo Molaro Committed by Paolo Molaro

checked in gtk_entry_set_max_length (it truncates the texts if it's


Wed Mar 18 17:38:25 CET 1998	Paolo Molaro <lupus@debian.org>

	* gtk/gtkentry.[ch]: checked in gtk_entry_set_max_length
	(it truncates the texts if it's longer, now)
parent e648c2d6
Wed Mar 18 17:38:25 CET 1998 Paolo Molaro <lupus@debian.org>
* gtk/gtkentry.[ch]: checked in gtk_entry_set_max_length
(it truncates the texts if it's longer, now)
Wed Mar 18 02:06:52 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_border_width): use the resize queue.
......
Wed Mar 18 17:38:25 CET 1998 Paolo Molaro <lupus@debian.org>
* gtk/gtkentry.[ch]: checked in gtk_entry_set_max_length
(it truncates the texts if it's longer, now)
Wed Mar 18 02:06:52 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_border_width): use the resize queue.
......
Wed Mar 18 17:38:25 CET 1998 Paolo Molaro <lupus@debian.org>
* gtk/gtkentry.[ch]: checked in gtk_entry_set_max_length
(it truncates the texts if it's longer, now)
Wed Mar 18 02:06:52 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_border_width): use the resize queue.
......
Wed Mar 18 17:38:25 CET 1998 Paolo Molaro <lupus@debian.org>
* gtk/gtkentry.[ch]: checked in gtk_entry_set_max_length
(it truncates the texts if it's longer, now)
Wed Mar 18 02:06:52 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_border_width): use the resize queue.
......
Wed Mar 18 17:38:25 CET 1998 Paolo Molaro <lupus@debian.org>
* gtk/gtkentry.[ch]: checked in gtk_entry_set_max_length
(it truncates the texts if it's longer, now)
Wed Mar 18 02:06:52 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_border_width): use the resize queue.
......
Wed Mar 18 17:38:25 CET 1998 Paolo Molaro <lupus@debian.org>
* gtk/gtkentry.[ch]: checked in gtk_entry_set_max_length
(it truncates the texts if it's longer, now)
Wed Mar 18 02:06:52 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_border_width): use the resize queue.
......
Wed Mar 18 17:38:25 CET 1998 Paolo Molaro <lupus@debian.org>
* gtk/gtkentry.[ch]: checked in gtk_entry_set_max_length
(it truncates the texts if it's longer, now)
Wed Mar 18 02:06:52 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_border_width): use the resize queue.
......
......@@ -1422,18 +1422,18 @@ gtk_entry_insert_text (GtkEditable *editable,
entry = GTK_ENTRY (editable);
if (new_text_length < 0)
new_text_length = strlen (new_text);
/* Make sure we do not exceed the maximum size of the entry. */
if (entry->text_max_length != 0 &&
new_text_length + entry->text_length > entry->text_max_length)
new_text_length = entry->text_max_length - entry->text_length;
/* Don't insert anything, if there was nothing to insert. */
if (new_text_length == 0)
if (new_text_length <= 0)
return;
if (new_text_length < 0)
new_text_length = strlen (new_text);
start_pos = *position;
end_pos = start_pos + new_text_length;
last_pos = new_text_length + entry->text_length;
......@@ -1879,3 +1879,15 @@ gtk_entry_select_region (GtkEntry *entry,
{
gtk_editable_select_region (GTK_EDITABLE(entry), start, end);
}
void
gtk_entry_set_max_length (GtkEntry *entry,
guint16 max)
{
g_return_if_fail(entry != NULL);
g_return_if_fail(GTK_IS_ENTRY(entry));
if (max && entry->text_length > max)
gtk_editable_delete_text(GTK_EDITABLE(entry), max, -1);
entry->text_max_length = max;
}
......@@ -78,7 +78,9 @@ void gtk_entry_set_visibility (GtkEntry *entry,
gboolean visible);
void gtk_entry_set_editable (GtkEntry *entry,
gboolean editable);
/* text is truncated if needed */
void gtk_entry_set_max_length (GtkEntry *entry,
guint16 max);
#ifdef __cplusplus
}
#endif /* __cplusplus */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment