diff options
author | Tim Janik <timj@gtk.org> | 1998-07-16 20:23:12 +0000 |
---|---|---|
committer | Tim Janik <timj@src.gnome.org> | 1998-07-16 20:23:12 +0000 |
commit | 81517a6d4c09663ba97335affe5b1ec047a567d3 (patch) | |
tree | 4638e036b6e692136a617d1fdd7d8f8a05f6a3bf | |
parent | 5e3acecc12dc9b7671ea56150a66e2ae41a65a6e (diff) | |
download | gtk+-81517a6d4c09663ba97335affe5b1ec047a567d3.tar.gz |
signdness corrections all ove the place. implementation of object
Thu Jul 16 18:24:41 1998 Tim Janik <timj@gtk.org>
* gtk/gtknotebook.h:
* gtk/gtknotebook.c: signdness corrections all ove the place.
implementation of object arguments: GtkNotebook::enable_popup,
GtkNotebook::tab_pos, GtkNotebook::tab_border, GtkNotebook::show_tabs,
GtkNotebook::show_border, GtkNotebook::scrollable and GtkNotebook::page.
begun implementation of child args, we have GtkNotebook::tab_label, but
GtkNotebook::menu_label and GtkNotebook::position still lack the
implementation.
(gtk_notebook_remove_page):
(gtk_notebook_current_page): allow negative indices (-1) as alias for
the last page.
* gtk/gtkentry.h:
* gtk/gtkentry.c: GtkType and macro fixups. implementation of object
arguments GtkEntry::max_length and GtkEntry::visibility.
(gtk_entry_adjust_scroll): queue a redraw.
* gtk/gtkeditable.h:
* gtk/gtkeditable.c: GtkType und macro fixups. implementation of
object arguments GtkEditable::text_position and GtkEditable::editable.
new (action) signal GtkEditable::set_editable.
provide a default handler for GtkEditable::changed that queues a redraw.
* gtk/gtktext.h:
* gtk/gtktext.c: GtkType und macro fixups. override GtkEditable::
set_editable.
-rw-r--r-- | ChangeLog | 29 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 29 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 29 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 29 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 29 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 29 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 29 | ||||
-rw-r--r-- | gtk/gtkeditable.c | 166 | ||||
-rw-r--r-- | gtk/gtkeditable.h | 17 | ||||
-rw-r--r-- | gtk/gtkentry.c | 85 | ||||
-rw-r--r-- | gtk/gtkentry.h | 54 | ||||
-rw-r--r-- | gtk/gtklabel.c | 2 | ||||
-rw-r--r-- | gtk/gtknotebook.c | 305 | ||||
-rw-r--r-- | gtk/gtknotebook.h | 8 | ||||
-rw-r--r-- | gtk/gtktext.c | 70 | ||||
-rw-r--r-- | gtk/gtktext.h | 15 |
16 files changed, 805 insertions, 120 deletions
@@ -1,3 +1,32 @@ +Thu Jul 16 18:24:41 1998 Tim Janik <timj@gtk.org> + + * gtk/gtknotebook.h: + * gtk/gtknotebook.c: signdness corrections all ove the place. + implementation of object arguments: GtkNotebook::enable_popup, + GtkNotebook::tab_pos, GtkNotebook::tab_border, GtkNotebook::show_tabs, + GtkNotebook::show_border, GtkNotebook::scrollable and GtkNotebook::page. + begun implementation of child args, we have GtkNotebook::tab_label, but + GtkNotebook::menu_label and GtkNotebook::position still lack the + implementation. + (gtk_notebook_remove_page): + (gtk_notebook_current_page): allow negative indices (-1) as alias for + the last page. + + * gtk/gtkentry.h: + * gtk/gtkentry.c: GtkType and macro fixups. implementation of object + arguments GtkEntry::max_length and GtkEntry::visibility. + (gtk_entry_adjust_scroll): queue a redraw. + + * gtk/gtkeditable.h: + * gtk/gtkeditable.c: GtkType und macro fixups. implementation of + object arguments GtkEditable::text_position and GtkEditable::editable. + new (action) signal GtkEditable::set_editable. + provide a default handler for GtkEditable::changed that queues a redraw. + + * gtk/gtktext.h: + * gtk/gtktext.c: GtkType und macro fixups. override GtkEditable:: + set_editable. + Thu Jul 16 14:42:11 1998 Lars Hamann <lars@gtk.org> * gtk/gtkctree.c (gtk_ctree_button_release): fix for sigsegv in diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 7189dc8bc4..08e34e3b90 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,32 @@ +Thu Jul 16 18:24:41 1998 Tim Janik <timj@gtk.org> + + * gtk/gtknotebook.h: + * gtk/gtknotebook.c: signdness corrections all ove the place. + implementation of object arguments: GtkNotebook::enable_popup, + GtkNotebook::tab_pos, GtkNotebook::tab_border, GtkNotebook::show_tabs, + GtkNotebook::show_border, GtkNotebook::scrollable and GtkNotebook::page. + begun implementation of child args, we have GtkNotebook::tab_label, but + GtkNotebook::menu_label and GtkNotebook::position still lack the + implementation. + (gtk_notebook_remove_page): + (gtk_notebook_current_page): allow negative indices (-1) as alias for + the last page. + + * gtk/gtkentry.h: + * gtk/gtkentry.c: GtkType and macro fixups. implementation of object + arguments GtkEntry::max_length and GtkEntry::visibility. + (gtk_entry_adjust_scroll): queue a redraw. + + * gtk/gtkeditable.h: + * gtk/gtkeditable.c: GtkType und macro fixups. implementation of + object arguments GtkEditable::text_position and GtkEditable::editable. + new (action) signal GtkEditable::set_editable. + provide a default handler for GtkEditable::changed that queues a redraw. + + * gtk/gtktext.h: + * gtk/gtktext.c: GtkType und macro fixups. override GtkEditable:: + set_editable. + Thu Jul 16 14:42:11 1998 Lars Hamann <lars@gtk.org> * gtk/gtkctree.c (gtk_ctree_button_release): fix for sigsegv in diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 7189dc8bc4..08e34e3b90 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,32 @@ +Thu Jul 16 18:24:41 1998 Tim Janik <timj@gtk.org> + + * gtk/gtknotebook.h: + * gtk/gtknotebook.c: signdness corrections all ove the place. + implementation of object arguments: GtkNotebook::enable_popup, + GtkNotebook::tab_pos, GtkNotebook::tab_border, GtkNotebook::show_tabs, + GtkNotebook::show_border, GtkNotebook::scrollable and GtkNotebook::page. + begun implementation of child args, we have GtkNotebook::tab_label, but + GtkNotebook::menu_label and GtkNotebook::position still lack the + implementation. + (gtk_notebook_remove_page): + (gtk_notebook_current_page): allow negative indices (-1) as alias for + the last page. + + * gtk/gtkentry.h: + * gtk/gtkentry.c: GtkType and macro fixups. implementation of object + arguments GtkEntry::max_length and GtkEntry::visibility. + (gtk_entry_adjust_scroll): queue a redraw. + + * gtk/gtkeditable.h: + * gtk/gtkeditable.c: GtkType und macro fixups. implementation of + object arguments GtkEditable::text_position and GtkEditable::editable. + new (action) signal GtkEditable::set_editable. + provide a default handler for GtkEditable::changed that queues a redraw. + + * gtk/gtktext.h: + * gtk/gtktext.c: GtkType und macro fixups. override GtkEditable:: + set_editable. + Thu Jul 16 14:42:11 1998 Lars Hamann <lars@gtk.org> * gtk/gtkctree.c (gtk_ctree_button_release): fix for sigsegv in diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 7189dc8bc4..08e34e3b90 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,32 @@ +Thu Jul 16 18:24:41 1998 Tim Janik <timj@gtk.org> + + * gtk/gtknotebook.h: + * gtk/gtknotebook.c: signdness corrections all ove the place. + implementation of object arguments: GtkNotebook::enable_popup, + GtkNotebook::tab_pos, GtkNotebook::tab_border, GtkNotebook::show_tabs, + GtkNotebook::show_border, GtkNotebook::scrollable and GtkNotebook::page. + begun implementation of child args, we have GtkNotebook::tab_label, but + GtkNotebook::menu_label and GtkNotebook::position still lack the + implementation. + (gtk_notebook_remove_page): + (gtk_notebook_current_page): allow negative indices (-1) as alias for + the last page. + + * gtk/gtkentry.h: + * gtk/gtkentry.c: GtkType and macro fixups. implementation of object + arguments GtkEntry::max_length and GtkEntry::visibility. + (gtk_entry_adjust_scroll): queue a redraw. + + * gtk/gtkeditable.h: + * gtk/gtkeditable.c: GtkType und macro fixups. implementation of + object arguments GtkEditable::text_position and GtkEditable::editable. + new (action) signal GtkEditable::set_editable. + provide a default handler for GtkEditable::changed that queues a redraw. + + * gtk/gtktext.h: + * gtk/gtktext.c: GtkType und macro fixups. override GtkEditable:: + set_editable. + Thu Jul 16 14:42:11 1998 Lars Hamann <lars@gtk.org> * gtk/gtkctree.c (gtk_ctree_button_release): fix for sigsegv in diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 7189dc8bc4..08e34e3b90 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,32 @@ +Thu Jul 16 18:24:41 1998 Tim Janik <timj@gtk.org> + + * gtk/gtknotebook.h: + * gtk/gtknotebook.c: signdness corrections all ove the place. + implementation of object arguments: GtkNotebook::enable_popup, + GtkNotebook::tab_pos, GtkNotebook::tab_border, GtkNotebook::show_tabs, + GtkNotebook::show_border, GtkNotebook::scrollable and GtkNotebook::page. + begun implementation of child args, we have GtkNotebook::tab_label, but + GtkNotebook::menu_label and GtkNotebook::position still lack the + implementation. + (gtk_notebook_remove_page): + (gtk_notebook_current_page): allow negative indices (-1) as alias for + the last page. + + * gtk/gtkentry.h: + * gtk/gtkentry.c: GtkType and macro fixups. implementation of object + arguments GtkEntry::max_length and GtkEntry::visibility. + (gtk_entry_adjust_scroll): queue a redraw. + + * gtk/gtkeditable.h: + * gtk/gtkeditable.c: GtkType und macro fixups. implementation of + object arguments GtkEditable::text_position and GtkEditable::editable. + new (action) signal GtkEditable::set_editable. + provide a default handler for GtkEditable::changed that queues a redraw. + + * gtk/gtktext.h: + * gtk/gtktext.c: GtkType und macro fixups. override GtkEditable:: + set_editable. + Thu Jul 16 14:42:11 1998 Lars Hamann <lars@gtk.org> * gtk/gtkctree.c (gtk_ctree_button_release): fix for sigsegv in diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 7189dc8bc4..08e34e3b90 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,32 @@ +Thu Jul 16 18:24:41 1998 Tim Janik <timj@gtk.org> + + * gtk/gtknotebook.h: + * gtk/gtknotebook.c: signdness corrections all ove the place. + implementation of object arguments: GtkNotebook::enable_popup, + GtkNotebook::tab_pos, GtkNotebook::tab_border, GtkNotebook::show_tabs, + GtkNotebook::show_border, GtkNotebook::scrollable and GtkNotebook::page. + begun implementation of child args, we have GtkNotebook::tab_label, but + GtkNotebook::menu_label and GtkNotebook::position still lack the + implementation. + (gtk_notebook_remove_page): + (gtk_notebook_current_page): allow negative indices (-1) as alias for + the last page. + + * gtk/gtkentry.h: + * gtk/gtkentry.c: GtkType and macro fixups. implementation of object + arguments GtkEntry::max_length and GtkEntry::visibility. + (gtk_entry_adjust_scroll): queue a redraw. + + * gtk/gtkeditable.h: + * gtk/gtkeditable.c: GtkType und macro fixups. implementation of + object arguments GtkEditable::text_position and GtkEditable::editable. + new (action) signal GtkEditable::set_editable. + provide a default handler for GtkEditable::changed that queues a redraw. + + * gtk/gtktext.h: + * gtk/gtktext.c: GtkType und macro fixups. override GtkEditable:: + set_editable. + Thu Jul 16 14:42:11 1998 Lars Hamann <lars@gtk.org> * gtk/gtkctree.c (gtk_ctree_button_release): fix for sigsegv in diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 7189dc8bc4..08e34e3b90 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,32 @@ +Thu Jul 16 18:24:41 1998 Tim Janik <timj@gtk.org> + + * gtk/gtknotebook.h: + * gtk/gtknotebook.c: signdness corrections all ove the place. + implementation of object arguments: GtkNotebook::enable_popup, + GtkNotebook::tab_pos, GtkNotebook::tab_border, GtkNotebook::show_tabs, + GtkNotebook::show_border, GtkNotebook::scrollable and GtkNotebook::page. + begun implementation of child args, we have GtkNotebook::tab_label, but + GtkNotebook::menu_label and GtkNotebook::position still lack the + implementation. + (gtk_notebook_remove_page): + (gtk_notebook_current_page): allow negative indices (-1) as alias for + the last page. + + * gtk/gtkentry.h: + * gtk/gtkentry.c: GtkType and macro fixups. implementation of object + arguments GtkEntry::max_length and GtkEntry::visibility. + (gtk_entry_adjust_scroll): queue a redraw. + + * gtk/gtkeditable.h: + * gtk/gtkeditable.c: GtkType und macro fixups. implementation of + object arguments GtkEditable::text_position and GtkEditable::editable. + new (action) signal GtkEditable::set_editable. + provide a default handler for GtkEditable::changed that queues a redraw. + + * gtk/gtktext.h: + * gtk/gtktext.c: GtkType und macro fixups. override GtkEditable:: + set_editable. + Thu Jul 16 14:42:11 1998 Lars Hamann <lars@gtk.org> * gtk/gtkctree.c (gtk_ctree_button_release): fix for sigsegv in diff --git a/gtk/gtkeditable.c b/gtk/gtkeditable.c index e4bcc5230d..cdd6d88f17 100644 --- a/gtk/gtkeditable.c +++ b/gtk/gtkeditable.c @@ -38,6 +38,7 @@ enum { DELETE_TEXT, /* Binding actions */ ACTIVATE, + SET_EDITABLE, MOVE_CURSOR, MOVE_WORD, MOVE_PAGE, @@ -52,8 +53,21 @@ enum { LAST_SIGNAL }; +enum { + ARG_0, + ARG_TEXT_POSITION, + ARG_EDITABLE +}; + + static void gtk_editable_class_init (GtkEditableClass *klass); static void gtk_editable_init (GtkEditable *editable); +static void gtk_editable_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void gtk_editable_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); static void gtk_editable_finalize (GtkObject *object); static gint gtk_editable_selection_clear (GtkWidget *widget, GdkEventSelection *event); @@ -68,9 +82,11 @@ static void gtk_editable_set_selection (GtkEditable *editable, gint end); static guint32 gtk_editable_get_event_time (GtkEditable *editable); -static void gtk_real_editable_cut_clipboard (GtkEditable *editable); -static void gtk_real_editable_copy_clipboard (GtkEditable *editable); -static void gtk_real_editable_paste_clipboard (GtkEditable *editable); +static void gtk_editable_real_cut_clipboard (GtkEditable *editable); +static void gtk_editable_real_copy_clipboard (GtkEditable *editable); +static void gtk_editable_real_paste_clipboard (GtkEditable *editable); +static void gtk_editable_real_set_editable (GtkEditable *editable, + gboolean is_editable); static void gtk_editable_marshal_signal_1 (GtkObject * object, @@ -107,10 +123,10 @@ typedef void (*GtkEditableSignal3) (GtkObject * object, gint arg1, gpointer data); -guint +GtkType gtk_editable_get_type (void) { - static guint editable_type = 0; + static GtkType editable_type = 0; if (!editable_type) { @@ -126,7 +142,7 @@ gtk_editable_get_type (void) (GtkClassInitFunc) NULL, }; - editable_type = gtk_type_unique (gtk_widget_get_type (), &editable_info); + editable_type = gtk_type_unique (GTK_TYPE_WIDGET, &editable_info); } return editable_type; @@ -141,7 +157,7 @@ gtk_editable_class_init (GtkEditableClass *class) object_class = (GtkObjectClass*) class; widget_class = (GtkWidgetClass*) class; - parent_class = gtk_type_class (gtk_widget_get_type ()); + parent_class = gtk_type_class (GTK_TYPE_WIDGET); editable_signals[CHANGED] = gtk_signal_new ("changed", @@ -182,6 +198,15 @@ gtk_editable_class_init (GtkEditableClass *class) gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); + editable_signals[SET_EDITABLE] = + gtk_signal_new ("set-editable", + GTK_RUN_LAST | GTK_RUN_ACTION, + object_class->type, + GTK_SIGNAL_OFFSET (GtkEditableClass, set_editable), + gtk_editable_marshal_signal_3, + GTK_TYPE_NONE, 1, + GTK_TYPE_BOOL); + editable_signals[MOVE_CURSOR] = gtk_signal_new ("move_cursor", GTK_RUN_LAST | GTK_RUN_ACTION, @@ -282,6 +307,11 @@ gtk_editable_class_init (GtkEditableClass *class) gtk_object_class_add_signals (object_class, editable_signals, LAST_SIGNAL); + gtk_object_add_arg_type ("GtkEditable::text_position", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_TEXT_POSITION); + gtk_object_add_arg_type ("GtkEditable::editable", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_EDITABLE); + + object_class->set_arg = gtk_editable_set_arg; + object_class->get_arg = gtk_editable_get_arg; object_class->finalize = gtk_editable_finalize; widget_class->selection_clear_event = gtk_editable_selection_clear; @@ -289,9 +319,10 @@ gtk_editable_class_init (GtkEditableClass *class) class->insert_text = NULL; class->delete_text = NULL; - class->changed = NULL; + class->changed = (void (*) (GtkEditable*)) gtk_widget_queue_draw; class->activate = NULL; + class->set_editable = gtk_editable_real_set_editable; class->move_cursor = NULL; class->move_word = NULL; @@ -303,9 +334,9 @@ gtk_editable_class_init (GtkEditableClass *class) class->kill_word = NULL; class->kill_line = NULL; - class->cut_clipboard = gtk_real_editable_cut_clipboard; - class->copy_clipboard = gtk_real_editable_copy_clipboard; - class->paste_clipboard = gtk_real_editable_paste_clipboard; + class->cut_clipboard = gtk_editable_real_cut_clipboard; + class->copy_clipboard = gtk_editable_real_copy_clipboard; + class->paste_clipboard = gtk_editable_real_paste_clipboard; class->update_text = NULL; class->get_chars = NULL; @@ -314,6 +345,51 @@ gtk_editable_class_init (GtkEditableClass *class) } static void +gtk_editable_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ + GtkEditable *editable; + + editable = GTK_EDITABLE (object); + + switch (arg_id) + { + case ARG_TEXT_POSITION: + gtk_editable_set_position (editable, GTK_VALUE_INT (*arg)); + break; + case ARG_EDITABLE: + gtk_editable_set_editable (editable, GTK_VALUE_BOOL (*arg)); + break; + default: + break; + } +} + +static void +gtk_editable_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ + GtkEditable *editable; + + editable = GTK_EDITABLE (object); + + switch (arg_id) + { + case ARG_TEXT_POSITION: + GTK_VALUE_INT (*arg) = editable->current_pos; + break; + case ARG_EDITABLE: + GTK_VALUE_BOOL (*arg) = editable->editable; + break; + default: + arg->type = GTK_TYPE_INVALID; + break; + } +} + +static void gtk_editable_init (GtkEditable *editable) { GTK_WIDGET_SET_FLAGS (editable, GTK_CAN_FOCUS); @@ -492,6 +568,9 @@ gtk_editable_set_position (GtkEditable *editable, gint gtk_editable_get_position (GtkEditable *editable) { + g_return_val_if_fail (editable != NULL, -1); + g_return_val_if_fail (GTK_IS_EDITABLE (editable), -1); + return editable->current_pos; } @@ -688,6 +767,9 @@ gtk_editable_delete_selection (GtkEditable *editable) guint start; guint end; + g_return_if_fail (editable != NULL); + g_return_if_fail (GTK_IS_EDITABLE (editable)); + if (!editable->editable) return; @@ -713,6 +795,8 @@ gtk_editable_claim_selection (GtkEditable *editable, gboolean claim, guint32 time) { + g_return_if_fail (editable != NULL); + g_return_if_fail (GTK_IS_EDITABLE (editable)); g_return_if_fail (GTK_WIDGET_REALIZED (editable)); editable->has_selection = FALSE; @@ -735,6 +819,9 @@ gtk_editable_select_region (GtkEditable *editable, gint start, gint end) { + g_return_if_fail (editable != NULL); + g_return_if_fail (GTK_IS_EDITABLE (editable)); + if (GTK_WIDGET_REALIZED (editable)) gtk_editable_claim_selection (editable, start != end, GDK_CURRENT_TIME); @@ -785,36 +872,72 @@ gtk_editable_get_event_time (GtkEditable *editable) void gtk_editable_cut_clipboard (GtkEditable *editable) { + g_return_if_fail (editable != NULL); + g_return_if_fail (GTK_IS_EDITABLE (editable)); + gtk_signal_emit (GTK_OBJECT (editable), editable_signals[CUT_CLIPBOARD]); } void gtk_editable_copy_clipboard (GtkEditable *editable) { + g_return_if_fail (editable != NULL); + g_return_if_fail (GTK_IS_EDITABLE (editable)); + gtk_signal_emit (GTK_OBJECT (editable), editable_signals[COPY_CLIPBOARD]); } void gtk_editable_paste_clipboard (GtkEditable *editable) { + g_return_if_fail (editable != NULL); + g_return_if_fail (GTK_IS_EDITABLE (editable)); + gtk_signal_emit (GTK_OBJECT (editable), editable_signals[PASTE_CLIPBOARD]); } +void +gtk_editable_set_editable (GtkEditable *editable, + gboolean is_editable) +{ + g_return_if_fail (editable != NULL); + g_return_if_fail (GTK_IS_EDITABLE (editable)); + + gtk_signal_emit (GTK_OBJECT (editable), editable_signals[SET_EDITABLE], is_editable != FALSE); +} + static void -gtk_real_editable_cut_clipboard (GtkEditable *editable) +gtk_editable_real_set_editable (GtkEditable *editable, + gboolean is_editable) { - gtk_real_editable_copy_clipboard (editable); - gtk_editable_delete_selection (editable); + g_return_if_fail (editable != NULL); + g_return_if_fail (GTK_IS_EDITABLE (editable)); + + editable->editable = is_editable != FALSE; + gtk_widget_queue_draw (GTK_WIDGET (editable)); } static void -gtk_real_editable_copy_clipboard (GtkEditable *editable) +gtk_editable_real_cut_clipboard (GtkEditable *editable) { - guint32 time = gtk_editable_get_event_time (editable); + g_return_if_fail (editable != NULL); + g_return_if_fail (GTK_IS_EDITABLE (editable)); + + gtk_editable_real_copy_clipboard (editable); + gtk_editable_delete_selection (editable); +} +static void +gtk_editable_real_copy_clipboard (GtkEditable *editable) +{ + guint32 time; gint selection_start_pos; gint selection_end_pos; + g_return_if_fail (editable != NULL); + g_return_if_fail (GTK_IS_EDITABLE (editable)); + + time = gtk_editable_get_event_time (editable); selection_start_pos = MIN (editable->selection_start_pos, editable->selection_end_pos); selection_end_pos = MAX (editable->selection_start_pos, editable->selection_end_pos); @@ -830,10 +953,14 @@ gtk_real_editable_copy_clipboard (GtkEditable *editable) } static void -gtk_real_editable_paste_clipboard (GtkEditable *editable) +gtk_editable_real_paste_clipboard (GtkEditable *editable) { - guint32 time = gtk_editable_get_event_time (editable); + guint32 time; + g_return_if_fail (editable != NULL); + g_return_if_fail (GTK_IS_EDITABLE (editable)); + + time = gtk_editable_get_event_time (editable); if (editable->editable) gtk_selection_convert (GTK_WIDGET(editable), clipboard_atom, ctext_atom, time); @@ -842,6 +969,9 @@ gtk_real_editable_paste_clipboard (GtkEditable *editable) void gtk_editable_changed (GtkEditable *editable) { + g_return_if_fail (editable != NULL); + g_return_if_fail (GTK_IS_EDITABLE (editable)); + gtk_signal_emit (GTK_OBJECT (editable), editable_signals[CHANGED]); } diff --git a/gtk/gtkeditable.h b/gtk/gtkeditable.h index 8a374bb25f..57265a5344 100644 --- a/gtk/gtkeditable.h +++ b/gtk/gtkeditable.h @@ -26,12 +26,15 @@ #ifdef __cplusplus extern "C" { +#pragma } #endif /* __cplusplus */ -#define GTK_EDITABLE(obj) GTK_CHECK_CAST (obj, gtk_editable_get_type (), GtkEditable) -#define GTK_EDITABLE_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_editable_get_type (), GtkEditableClass) -#define GTK_IS_EDITABLE(obj) GTK_CHECK_TYPE (obj, gtk_editable_get_type ()) +#define GTK_TYPE_EDITABLE (gtk_editable_get_type ()) +#define GTK_EDITABLE(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_EDITABLE, GtkEditable)) +#define GTK_EDITABLE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_EDITABLE, GtkEditableClass)) +#define GTK_IS_EDITABLE(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_EDITABLE)) +#define GTK_IS_EDITABLE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_EDITABLE)) typedef struct _GtkEditable GtkEditable; @@ -70,6 +73,8 @@ struct _GtkEditableClass /* Bindings actions */ void (* activate) (GtkEditable *editable); + void (* set_editable) (GtkEditable *editable, + gboolean is_editable); void (* move_cursor) (GtkEditable *editable, gint x, gint y); @@ -110,7 +115,7 @@ struct _GtkEditableClass gint position); }; -guint gtk_editable_get_type (void); +GtkType gtk_editable_get_type (void); void gtk_editable_select_region (GtkEditable *editable, gint start, gint end); @@ -121,7 +126,7 @@ void gtk_editable_insert_text (GtkEditable *editable, void gtk_editable_delete_text (GtkEditable *editable, gint start_pos, gint end_pos); -gchar * gtk_editable_get_chars (GtkEditable *editable, +gchar* gtk_editable_get_chars (GtkEditable *editable, gint start_pos, gint end_pos); void gtk_editable_cut_clipboard (GtkEditable *editable); @@ -136,6 +141,8 @@ void gtk_editable_changed (GtkEditable *editable); void gtk_editable_set_position (GtkEditable *editable, gint position); gint gtk_editable_get_position (GtkEditable *editable); +void gtk_editable_set_editable (GtkEditable *editable, + gboolean is_editable); #ifdef __cplusplus diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 31d57151d9..01dfffa9ec 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -33,8 +33,21 @@ #define DRAW_TIMEOUT 20 #define INNER_BORDER 2 +enum { + ARG_0, + ARG_MAX_LENGTH, + ARG_VISIBILITY, +}; + + static void gtk_entry_class_init (GtkEntryClass *klass); static void gtk_entry_init (GtkEntry *entry); +static void gtk_entry_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void gtk_entry_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); static void gtk_entry_finalize (GtkObject *object); static void gtk_entry_realize (GtkWidget *widget); static void gtk_entry_unrealize (GtkWidget *widget); @@ -200,10 +213,10 @@ static GtkTextFunction alt_keys[26] = }; -guint +GtkType gtk_entry_get_type (void) { - static guint entry_type = 0; + static GtkType entry_type = 0; if (!entry_type) { @@ -219,7 +232,7 @@ gtk_entry_get_type (void) (GtkClassInitFunc) NULL, }; - entry_type = gtk_type_unique (gtk_editable_get_type (), &entry_info); + entry_type = gtk_type_unique (GTK_TYPE_EDITABLE, &entry_info); } return entry_type; @@ -235,9 +248,13 @@ gtk_entry_class_init (GtkEntryClass *class) object_class = (GtkObjectClass*) class; widget_class = (GtkWidgetClass*) class; editable_class = (GtkEditableClass*) class; + parent_class = gtk_type_class (GTK_TYPE_EDITABLE); - parent_class = gtk_type_class (gtk_editable_get_type ()); + gtk_object_add_arg_type ("GtkEntry::max_length", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_MAX_LENGTH); + gtk_object_add_arg_type ("GtkEntry::visibility", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_VISIBILITY); + object_class->set_arg = gtk_entry_set_arg; + object_class->get_arg = gtk_entry_get_arg; object_class->finalize = gtk_entry_finalize; widget_class->realize = gtk_entry_realize; @@ -275,6 +292,51 @@ gtk_entry_class_init (GtkEntryClass *class) } static void +gtk_entry_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ + GtkEntry *entry; + + entry = GTK_ENTRY (object); + + switch (arg_id) + { + case ARG_MAX_LENGTH: + gtk_entry_set_max_length (entry, GTK_VALUE_UINT (*arg)); + break; + case ARG_VISIBILITY: + gtk_entry_set_visibility (entry, GTK_VALUE_BOOL (*arg)); + break; + default: + break; + } +} + +static void +gtk_entry_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ + GtkEntry *entry; + + entry = GTK_ENTRY (object); + + switch (arg_id) + { + case ARG_MAX_LENGTH: + GTK_VALUE_UINT (*arg) = entry->text_max_length; + break; + case ARG_VISIBILITY: + GTK_VALUE_BOOL (*arg) = entry->visible; + break; + default: + arg->type = GTK_TYPE_INVALID; + break; + } +} + +static void gtk_entry_init (GtkEntry *entry) { GTK_WIDGET_SET_FLAGS (entry, GTK_CAN_FOCUS); @@ -300,15 +362,17 @@ gtk_entry_init (GtkEntry *entry) GtkWidget* gtk_entry_new (void) { - return GTK_WIDGET (gtk_type_new (gtk_entry_get_type ())); + return GTK_WIDGET (gtk_type_new (GTK_TYPE_ENTRY)); } GtkWidget* gtk_entry_new_with_max_length (guint16 max) { GtkEntry *entry; - entry = gtk_type_new (gtk_entry_get_type ()); + + entry = gtk_type_new (GTK_TYPE_ENTRY); entry->text_max_length = max; + return GTK_WIDGET (entry); } @@ -380,6 +444,7 @@ gtk_entry_set_position (GtkEntry *entry, GTK_EDITABLE(entry)->current_pos = entry->text_length; else GTK_EDITABLE(entry)->current_pos = position; + gtk_entry_adjust_scroll (entry); } static void @@ -403,13 +468,12 @@ gtk_entry_set_visibility (GtkEntry *entry, void gtk_entry_set_editable(GtkEntry *entry, - gboolean editable) + gboolean editable) { g_return_if_fail (entry != NULL); g_return_if_fail (GTK_IS_ENTRY (entry)); - GTK_EDITABLE (entry)->editable = editable; - gtk_entry_queue_draw (entry); + gtk_editable_set_editable (GTK_EDITABLE (entry), editable); } gchar* @@ -1471,9 +1535,10 @@ gtk_entry_adjust_scroll (GtkEntry *entry) if (xoffset < 0) entry->scroll_offset += xoffset; - else if (xoffset > text_area_width) entry->scroll_offset += xoffset - text_area_width + 1; + + gtk_widget_queue_draw (GTK_WIDGET (entry)); } static void diff --git a/gtk/gtkentry.h b/gtk/gtkentry.h index 7264c3cb0e..d1bf7df7a4 100644 --- a/gtk/gtkentry.h +++ b/gtk/gtkentry.h @@ -26,12 +26,15 @@ #ifdef __cplusplus extern "C" { +#pragma } #endif /* __cplusplus */ -#define GTK_ENTRY(obj) GTK_CHECK_CAST (obj, gtk_entry_get_type (), GtkEntry) -#define GTK_ENTRY_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_entry_get_type (), GtkEntryClass) -#define GTK_IS_ENTRY(obj) GTK_CHECK_TYPE (obj, gtk_entry_get_type ()) +#define GTK_TYPE_ENTRY (gtk_entry_get_type ()) +#define GTK_ENTRY(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_ENTRY, GtkEntry)) +#define GTK_ENTRY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_ENTRY, GtkEntryClass)) +#define GTK_IS_ENTRY(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_ENTRY)) +#define GTK_IS_ENTRY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ENTRY)) typedef struct _GtkEntry GtkEntry; @@ -71,29 +74,30 @@ struct _GtkEntryClass GtkEditableClass parent_class; }; -guint gtk_entry_get_type (void); -GtkWidget* gtk_entry_new (void); -GtkWidget* gtk_entry_new_with_max_length (guint16 max); -void gtk_entry_set_text (GtkEntry *entry, - const gchar *text); -void gtk_entry_append_text (GtkEntry *entry, - const gchar *text); -void gtk_entry_prepend_text (GtkEntry *entry, - const gchar *text); -void gtk_entry_set_position (GtkEntry *entry, - gint position); -gchar* gtk_entry_get_text (GtkEntry *entry); -void gtk_entry_select_region (GtkEntry *entry, - gint start, - gint end); -void gtk_entry_set_visibility (GtkEntry *entry, - gboolean visible); -void gtk_entry_set_editable (GtkEntry *entry, - gboolean editable); -void gtk_entry_adjust_scroll (GtkEntry *entry); +GtkType gtk_entry_get_type (void); +GtkWidget* gtk_entry_new (void); +GtkWidget* gtk_entry_new_with_max_length (guint16 max); +void gtk_entry_set_text (GtkEntry *entry, + const gchar *text); +void gtk_entry_append_text (GtkEntry *entry, + const gchar *text); +void gtk_entry_prepend_text (GtkEntry *entry, + const gchar *text); +void gtk_entry_set_position (GtkEntry *entry, + gint position); +gchar* gtk_entry_get_text (GtkEntry *entry); +void gtk_entry_select_region (GtkEntry *entry, + gint start, + gint end); +void gtk_entry_set_visibility (GtkEntry *entry, + gboolean visible); +void gtk_entry_set_editable (GtkEntry *entry, + gboolean editable); +void gtk_entry_adjust_scroll (GtkEntry *entry); /* text is truncated if needed */ -void gtk_entry_set_max_length (GtkEntry *entry, - guint16 max); +void gtk_entry_set_max_length (GtkEntry *entry, + guint16 max); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index cc5c2160ad..e96db1b3a6 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -111,7 +111,7 @@ gtk_label_set_arg (GtkObject *object, switch (arg_id) { case ARG_LABEL: - gtk_label_set (label, GTK_VALUE_STRING (*arg)); + gtk_label_set (label, GTK_VALUE_STRING (*arg) ? GTK_VALUE_STRING (*arg) : ""); break; case ARG_JUSTIFY: gtk_label_set_justify (label, GTK_VALUE_ENUM (*arg)); diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 858039943a..4d076c4e60 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -44,6 +44,24 @@ enum { STEP_NEXT }; +enum { + ARG_0, + ARG_TAB_POS, + ARG_SHOW_TABS, + ARG_SHOW_BORDER, + ARG_SCROLLABLE, + ARG_TAB_BORDER, + ARG_PAGE, + ARG_ENABLE_POPUP +}; + +enum { + CHILD_ARG_0, + CHILD_ARG_TAB_LABEL, + CHILD_ARG_MENU_LABEL, + CHILD_ARG_POSITION +}; + typedef void (*GtkNotebookSignal) (GtkObject *object, GtkNotebookPage *arg1, gint arg2, @@ -51,6 +69,20 @@ typedef void (*GtkNotebookSignal) (GtkObject *object, static void gtk_notebook_class_init (GtkNotebookClass *klass); static void gtk_notebook_init (GtkNotebook *notebook); +static void gtk_notebook_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void gtk_notebook_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id); +static void gtk_notebook_set_child_arg (GtkContainer *container, + GtkWidget *child, + GtkArg *arg, + guint arg_id); +static void gtk_notebook_get_child_arg (GtkContainer *container, + GtkWidget *child, + GtkArg *arg, + guint arg_id); static void gtk_notebook_destroy (GtkObject *object); static void gtk_notebook_map (GtkWidget *widget); static void gtk_notebook_unmap (GtkWidget *widget); @@ -84,13 +116,13 @@ static void gtk_notebook_remove (GtkContainer *container, GtkWidget *widget); static void gtk_notebook_real_remove (GtkNotebook *notebook, GList *list, - gint page_num); + guint page_num); static void gtk_notebook_foreach (GtkContainer *container, GtkCallback callback, gpointer callback_data); static void gtk_notebook_switch_page (GtkNotebook *notebook, GtkNotebookPage *page, - gint page_num); + guint page_num); static void gtk_notebook_draw_tab (GtkNotebook *notebook, GtkNotebookPage *page, GdkRectangle *area); @@ -124,7 +156,7 @@ static void gtk_notebook_switch_focus_tab (GtkNotebook *notebook, GList *new_child); static void gtk_real_notebook_switch_page (GtkNotebook *notebook, GtkNotebookPage *page, - gint page_num); + guint page_num); static void gtk_notebook_marshal_signal (GtkObject *object, GtkSignalFunc func, gpointer func_data, @@ -133,7 +165,7 @@ static void gtk_notebook_menu_switch_page (GtkWidget *widget, GtkNotebookPage *page); static void gtk_notebook_update_labels (GtkNotebook *notebook, GList *list, - gint page_num); + guint page_num); static void gtk_notebook_menu_detacher (GtkWidget *widget, GtkMenu *menu); static void gtk_notebook_menu_label_unparent (GtkWidget *widget, @@ -182,9 +214,22 @@ gtk_notebook_class_init (GtkNotebookClass *class) object_class = (GtkObjectClass*) class; widget_class = (GtkWidgetClass*) class; container_class = (GtkContainerClass*) class; - parent_class = gtk_type_class (gtk_container_get_type ()); + gtk_object_add_arg_type ("GtkNotebook::page", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_PAGE); + gtk_object_add_arg_type ("GtkNotebook::tab_pos", GTK_TYPE_POSITION_TYPE, GTK_ARG_READWRITE, ARG_TAB_POS); + gtk_object_add_arg_type ("GtkNotebook::tab_border", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_TAB_BORDER); + gtk_object_add_arg_type ("GtkNotebook::show_tabs", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_SHOW_TABS); + gtk_object_add_arg_type ("GtkNotebook::show_border", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_SHOW_BORDER); + gtk_object_add_arg_type ("GtkNotebook::scrollable", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_SCROLLABLE); + gtk_object_add_arg_type ("GtkNotebook::enable_popup", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_ENABLE_POPUP); + + gtk_container_add_child_arg_type ("GtkNotebook::tab_label", GTK_TYPE_STRING, GTK_ARG_READWRITE, CHILD_ARG_TAB_LABEL); + /* + * gtk_container_add_child_arg_type ("GtkNotebook::menu_label", GTK_TYPE_STRING, GTK_ARG_READWRITE, CHILD_ARG_MENU_LABEL); + * gtk_container_add_child_arg_type ("GtkNotebook::position", GTK_TYPE_INT, GTK_ARG_READWRITE, CHILD_ARG_POSITION); + */ + notebook_signals[SWITCH_PAGE] = gtk_signal_new ("switch_page", GTK_RUN_LAST, @@ -193,10 +238,12 @@ gtk_notebook_class_init (GtkNotebookClass *class) gtk_notebook_marshal_signal, GTK_TYPE_NONE, 2, GTK_TYPE_POINTER, - GTK_TYPE_INT); + GTK_TYPE_UINT); gtk_object_class_add_signals (object_class, notebook_signals, LAST_SIGNAL); + object_class->set_arg = gtk_notebook_set_arg; + object_class->get_arg = gtk_notebook_get_arg; object_class->destroy = gtk_notebook_destroy; widget_class->map = gtk_notebook_map; @@ -221,11 +268,202 @@ gtk_notebook_class_init (GtkNotebookClass *class) container_class->foreach = gtk_notebook_foreach; container_class->focus = gtk_notebook_focus; container_class->set_focus_child = gtk_notebook_set_focus_child; + container_class->get_child_arg = gtk_notebook_get_child_arg; + container_class->set_child_arg = gtk_notebook_set_child_arg; container_class->child_type = gtk_notebook_child_type; class->switch_page = gtk_real_notebook_switch_page; } +static void +gtk_notebook_set_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ + GtkNotebook *notebook; + + notebook = GTK_NOTEBOOK (object); + + switch (arg_id) + { + case ARG_SHOW_TABS: + gtk_notebook_set_show_tabs (notebook, GTK_VALUE_BOOL (*arg)); + break; + case ARG_SHOW_BORDER: + gtk_notebook_set_show_border (notebook, GTK_VALUE_BOOL (*arg)); + break; + case ARG_SCROLLABLE: + gtk_notebook_set_scrollable (notebook, GTK_VALUE_BOOL (*arg)); + break; + case ARG_ENABLE_POPUP: + if (GTK_VALUE_BOOL (*arg)) + gtk_notebook_popup_enable (notebook); + else + gtk_notebook_popup_disable (notebook); + break; + case ARG_PAGE: + gtk_notebook_set_page (notebook, GTK_VALUE_INT (*arg)); + break; + case ARG_TAB_POS: + gtk_notebook_set_tab_pos (notebook, GTK_VALUE_ENUM (*arg)); + break; + case ARG_TAB_BORDER: + gtk_notebook_set_tab_border (notebook, GTK_VALUE_UINT (*arg)); + break; + default: + break; + } +} + +static void +gtk_notebook_get_arg (GtkObject *object, + GtkArg *arg, + guint arg_id) +{ + GtkNotebook *notebook; + + notebook = GTK_NOTEBOOK (object); + + switch (arg_id) + { + case ARG_SHOW_TABS: + GTK_VALUE_BOOL (*arg) = notebook->show_tabs; + break; + case ARG_SHOW_BORDER: + GTK_VALUE_BOOL (*arg) = notebook->show_border; + break; + case ARG_SCROLLABLE: + GTK_VALUE_BOOL (*arg) = notebook->scrollable; + break; + case ARG_ENABLE_POPUP: + GTK_VALUE_BOOL (*arg) = notebook->menu != NULL; + break; + case ARG_PAGE: + GTK_VALUE_INT (*arg) = gtk_notebook_current_page (notebook); + break; + case ARG_TAB_POS: + GTK_VALUE_ENUM (*arg) = notebook->tab_pos; + break; + case ARG_TAB_BORDER: + GTK_VALUE_UINT (*arg) = notebook->tab_border; + break; + default: + arg->type = GTK_TYPE_INVALID; + break; + } +} + +static void +gtk_notebook_set_child_arg (GtkContainer *container, + GtkWidget *child, + GtkArg *arg, + guint arg_id) +{ + GtkNotebook *notebook; + GtkNotebookPage *page = NULL; + GList *list; + + notebook = GTK_NOTEBOOK (container); + + for (list = notebook->children; list; list = list->next) + { + page = list->data; + if (page->child == child) + break; + } + if (!list) + return; + + switch (arg_id) + { + case CHILD_ARG_TAB_LABEL: + /* a NULL pointer indicates a default_tab setting, otherwise + * we need to set the associated label + */ + if (GTK_VALUE_STRING (*arg)) + { + page->default_tab = FALSE; + if (page->tab_label) + gtk_widget_unparent (page->tab_label); + page->tab_label = gtk_label_new (GTK_VALUE_STRING (*arg)); + gtk_widget_set_parent (page->tab_label, GTK_WIDGET (notebook)); + if (notebook->show_tabs) + gtk_widget_show (page->tab_label); + } + else + { + page->default_tab = TRUE; + if (page->tab_label) + gtk_widget_unparent (page->tab_label); + if (!notebook->show_tabs) + page->tab_label = NULL; + else + { + gchar string[32]; + + sprintf (string, "Page %u", g_list_index (notebook->children, page) + 1); + page->tab_label = gtk_label_new (string); + gtk_widget_set_parent (page->tab_label, GTK_WIDGET (notebook)); + gtk_widget_show (page->tab_label); + } + } + break; + case CHILD_ARG_MENU_LABEL: + break; + case CHILD_ARG_POSITION: + break; + default: + break; + } +} + +static void +gtk_notebook_get_child_arg (GtkContainer *container, + GtkWidget *child, + GtkArg *arg, + guint arg_id) +{ + GtkNotebook *notebook; + GtkNotebookPage *page = NULL; + GList *list; + + notebook = GTK_NOTEBOOK (container); + + for (list = notebook->children; list; list = list->next) + { + page = list->data; + if (page->child == child) + break; + } + if (!list) + { + arg->type = GTK_TYPE_INVALID; + return; + } + + switch (arg_id) + { + case CHILD_ARG_TAB_LABEL: + if (page->default_tab) + GTK_VALUE_STRING (*arg) = NULL; + else + { + if (page->tab_label && GTK_IS_LABEL (page->tab_label)) + GTK_VALUE_STRING (*arg) = g_strdup (GTK_LABEL (page->tab_label)->label); + else + GTK_VALUE_STRING (*arg) = NULL; + } + break; + case CHILD_ARG_MENU_LABEL: + break; + case CHILD_ARG_POSITION: + break; + default: + arg->type = GTK_TYPE_INVALID; + break; + } +} + static GtkType gtk_notebook_child_type (GtkContainer *container) { @@ -439,15 +677,26 @@ gtk_notebook_insert_page_menu (GtkNotebook *notebook, void gtk_notebook_remove_page (GtkNotebook *notebook, - gint page_num) + gint page_num) { GList *list; g_return_if_fail (notebook != NULL); g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); - if ((list = g_list_nth (notebook->children, page_num))) - gtk_notebook_real_remove (notebook, list, page_num); + if (page_num >= 0) + { + list = g_list_nth (notebook->children, page_num); + if (list) + gtk_notebook_real_remove (notebook, list, page_num); + } + else + { + list = g_list_last (notebook->children); + if (list) + gtk_notebook_real_remove (notebook, list, + g_list_index (notebook->children, list->data)); + } } static void @@ -469,7 +718,7 @@ gtk_notebook_remove (GtkContainer *container, GtkNotebook *notebook; GtkNotebookPage *page; GList *children; - gint page_num; + guint page_num; g_return_if_fail (container != NULL); g_return_if_fail (GTK_IS_NOTEBOOK (container)); @@ -495,7 +744,7 @@ gtk_notebook_remove (GtkContainer *container, static void gtk_notebook_real_remove (GtkNotebook *notebook, GList *list, - gint page_num) + guint page_num) { GtkNotebookPage *page; GList * next_list; @@ -596,16 +845,26 @@ gtk_notebook_current_page (GtkNotebook *notebook) void gtk_notebook_set_page (GtkNotebook *notebook, - gint page_num) + gint page_num) { GList *list; - + g_return_if_fail (notebook != NULL); g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); - if ((list = g_list_nth (notebook->children, page_num))) - gtk_notebook_switch_page (notebook, - ((GtkNotebookPage *)(list->data)), page_num); + if (page_num >= 0) + { + list = g_list_nth (notebook->children, page_num); + if (list) + gtk_notebook_switch_page (notebook, list->data, page_num); + } + else + { + list = g_list_last (notebook->children); + if (list) + gtk_notebook_switch_page (notebook, list->data, + g_list_index (notebook->children, list->data)); + } } void @@ -1825,7 +2084,7 @@ gtk_notebook_draw_arrow (GtkNotebook *notebook, guint arrow) static void gtk_real_notebook_switch_page (GtkNotebook *notebook, GtkNotebookPage *page, - gint page_num) + guint page_num) { g_return_if_fail (notebook != NULL); g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); @@ -2633,7 +2892,7 @@ gtk_notebook_menu_switch_page (GtkWidget *widget, { GtkNotebook *notebook; GList *children; - gint page_num; + guint page_num; g_return_if_fail (widget != NULL); g_return_if_fail (page != NULL); @@ -2661,7 +2920,7 @@ gtk_notebook_menu_switch_page (GtkWidget *widget, static void gtk_notebook_switch_page (GtkNotebook *notebook, GtkNotebookPage *page, - gint page_num) + guint page_num) { g_return_if_fail (notebook != NULL); g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); @@ -2942,12 +3201,12 @@ gtk_notebook_key_press (GtkWidget *widget, void gtk_notebook_set_tab_border (GtkNotebook *notebook, - gint tab_border) + guint tab_border) { g_return_if_fail (notebook != NULL); g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); - if (notebook->tab_border != tab_border && tab_border > 0) + if (notebook->tab_border != tab_border) { notebook->tab_border = tab_border; @@ -2959,7 +3218,7 @@ gtk_notebook_set_tab_border (GtkNotebook *notebook, static void gtk_notebook_update_labels (GtkNotebook *notebook, GList *list, - gint page_num) + guint page_num) { GtkNotebookPage *page; gchar string[32]; @@ -2968,7 +3227,7 @@ gtk_notebook_update_labels (GtkNotebook *notebook, { page = list->data; list = list->next; - sprintf (string, "Page %d", page_num); + sprintf (string, "Page %u", page_num); if (notebook->show_tabs && page->default_tab) gtk_label_set (GTK_LABEL (page->tab_label), string); if (notebook->menu && page->default_menu) diff --git a/gtk/gtknotebook.h b/gtk/gtknotebook.h index c74ae40f10..183b7ee505 100644 --- a/gtk/gtknotebook.h +++ b/gtk/gtknotebook.h @@ -55,7 +55,7 @@ struct _GtkNotebook guint32 timer; - gint16 tab_border; + guint16 tab_border; guint show_tabs : 1; guint show_border : 1; @@ -72,9 +72,9 @@ struct _GtkNotebookClass { GtkContainerClass parent_class; - void (* switch_page) (GtkNotebook *notebook, + void (* switch_page) (GtkNotebook *notebook, GtkNotebookPage *page, - gint page_num); + guint page_num); }; struct _GtkNotebookPage @@ -130,7 +130,7 @@ void gtk_notebook_set_show_border (GtkNotebook *notebook, void gtk_notebook_set_scrollable (GtkNotebook *notebook, gint scrollable); void gtk_notebook_set_tab_border (GtkNotebook *notebook, - gint border_width); + guint border_width); void gtk_notebook_popup_enable (GtkNotebook *notebook); void gtk_notebook_popup_disable (GtkNotebook *notebook); diff --git a/gtk/gtktext.c b/gtk/gtktext.c index cacbf181ce..f15d62f23a 100644 --- a/gtk/gtktext.c +++ b/gtk/gtktext.c @@ -174,23 +174,25 @@ static void gtk_text_adjustment (GtkAdjustment *adjustment, static void gtk_text_disconnect (GtkAdjustment *adjustment, GtkText *text); -static void gtk_text_insert_text (GtkEditable *editable, - const gchar *new_text, - gint new_text_length, - gint *position); -static void gtk_text_delete_text (GtkEditable *editable, - gint start_pos, - gint end_pos); -static void gtk_text_update_text (GtkEditable *editable, - gint start_pos, - gint end_pos); -static gchar *gtk_text_get_chars (GtkEditable *editable, - gint start, - gint end); -static void gtk_text_set_selection (GtkEditable *editable, - gint start, - gint end); - +static void gtk_text_insert_text (GtkEditable *editable, + const gchar *new_text, + gint new_text_length, + gint *position); +static void gtk_text_delete_text (GtkEditable *editable, + gint start_pos, + gint end_pos); +static void gtk_text_update_text (GtkEditable *editable, + gint start_pos, + gint end_pos); +static gchar *gtk_text_get_chars (GtkEditable *editable, + gint start, + gint end); +static void gtk_text_set_selection (GtkEditable *editable, + gint start, + gint end); +static void gtk_text_real_set_editable (GtkEditable *editable, + gboolean is_editable); + /* Event handlers */ static void gtk_text_draw (GtkWidget *widget, GdkRectangle *area); @@ -445,10 +447,10 @@ static GtkTextFunction alt_keys[26] = /* Widget Crap */ /**********************************************************************/ -guint +GtkType gtk_text_get_type (void) { - static guint text_type = 0; + static GtkType text_type = 0; if (!text_type) { @@ -464,7 +466,7 @@ gtk_text_get_type (void) (GtkClassInitFunc) NULL, }; - text_type = gtk_type_unique (gtk_editable_get_type (), &text_info); + text_type = gtk_type_unique (GTK_TYPE_EDITABLE, &text_info); } return text_type; @@ -481,7 +483,7 @@ gtk_text_class_init (GtkTextClass *class) widget_class = (GtkWidgetClass*) class; editable_class = (GtkEditableClass*) class; - parent_class = gtk_type_class (gtk_editable_get_type ()); + parent_class = gtk_type_class (GTK_TYPE_EDITABLE); object_class->destroy = gtk_text_destroy; object_class->finalize = gtk_text_finalize; @@ -501,6 +503,7 @@ gtk_text_class_init (GtkTextClass *class) widget_class->focus_in_event = gtk_text_focus_in; widget_class->focus_out_event = gtk_text_focus_out; + editable_class->set_editable = gtk_text_real_set_editable; editable_class->insert_text = gtk_text_insert_text; editable_class->delete_text = gtk_text_delete_text; @@ -555,7 +558,7 @@ gtk_text_new (GtkAdjustment *hadj, { GtkText *text; - text = gtk_type_new (gtk_text_get_type ()); + text = gtk_type_new (GTK_TYPE_TEXT); gtk_text_set_adjustments (text, hadj, vadj); @@ -580,17 +583,28 @@ gtk_text_set_word_wrap (GtkText *text, void gtk_text_set_editable (GtkText *text, - gint editable) + gboolean is_editable) { - GtkWidget *widget; - g_return_if_fail (text != NULL); g_return_if_fail (GTK_IS_TEXT (text)); - widget = GTK_WIDGET (text); - GTK_EDITABLE(text)->editable = (editable != FALSE); + gtk_editable_set_editable (GTK_EDITABLE (text), is_editable); +} + +static void +gtk_text_real_set_editable (GtkEditable *editable, + gboolean is_editable) +{ + GtkText *text; + + g_return_if_fail (editable != NULL); + g_return_if_fail (GTK_IS_TEXT (editable)); + + text = GTK_TEXT (editable); + + editable->editable = (is_editable != FALSE); - if (editable) + if (is_editable) draw_cursor (text, TRUE); else undraw_cursor (text, TRUE); diff --git a/gtk/gtktext.h b/gtk/gtktext.h index 07bd5c5a0d..6932cc15c7 100644 --- a/gtk/gtktext.h +++ b/gtk/gtktext.h @@ -27,14 +27,17 @@ #ifdef __cplusplus extern "C" { +#pragma } #endif /* __cplusplus */ -#define GTK_TEXT(obj) GTK_CHECK_CAST (obj, gtk_text_get_type (), GtkText) -#define GTK_TEXT_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_text_get_type (), GtkTextClass) -#define GTK_IS_TEXT(obj) GTK_CHECK_TYPE (obj, gtk_text_get_type ()) - +#define GTK_TYPE_TEXT (gtk_text_get_type ()) +#define GTK_TEXT(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_TEXT, GtkText)) +#define GTK_TEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT, GtkTextClass)) +#define GTK_IS_TEXT(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_TEXT)) +#define GTK_IS_TEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT)) + typedef struct _GtkPropertyMark GtkPropertyMark; typedef struct _GtkText GtkText; typedef struct _GtkTextClass GtkTextClass; @@ -158,11 +161,11 @@ struct _GtkTextClass }; -guint gtk_text_get_type (void); +GtkType gtk_text_get_type (void); GtkWidget* gtk_text_new (GtkAdjustment *hadj, GtkAdjustment *vadj); void gtk_text_set_editable (GtkText *text, - gint editable); + gboolean editable); void gtk_text_set_word_wrap (GtkText *text, gint word_wrap); void gtk_text_set_adjustments (GtkText *text, |