diff options
-rw-r--r-- | ChangeLog | 39 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 39 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 39 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 39 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 39 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 39 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 39 | ||||
-rw-r--r-- | gtk/gtkeditable.c | 1 | ||||
-rw-r--r-- | gtk/gtkfilesel.c | 24 | ||||
-rw-r--r-- | gtk/gtkhscrollbar.c | 1 | ||||
-rw-r--r-- | gtk/gtktext.c | 85 | ||||
-rw-r--r-- | gtk/gtktext.h | 2 | ||||
-rw-r--r-- | gtk/gtkvscrollbar.c | 1 | ||||
-rw-r--r-- | gtk/gtkwindow.c | 28 | ||||
-rw-r--r-- | gtk/gtkwindow.h | 5 | ||||
-rw-r--r-- | gtk/testgtk.c | 123 | ||||
-rw-r--r-- | tests/testgtk.c | 123 |
17 files changed, 604 insertions, 62 deletions
@@ -1,3 +1,42 @@ +Tue Aug 11 15:04:52 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtktext.[ch]: Removed has_cursor, set the cursor + beginning of Text when creating the Text widget. + + * gtk/testgtk.c: Grab the focus on the text widget so + as to test out the above. + +Tue Aug 11 14:55:00 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkeditable.c: Reverted part of timj's change of Jul 16. + ::changed is a notification signal and should have no default + handler. A complete redraw of the Text widget does _not_ need to + be done on every text insertion. + +Tue Aug 11 13:07:29 1998 Owen Taylor <otaylor@redhat.com> + (gtk-abilleira-072198-patch) + + * gtk/gtkwindow.[ch]: + Add gtk_window_set_modal() which sets a flag; when + set the window does a gtk_grab_add() when the window + is shown, and a gtk_grab_remove() when the window + is hidden. + + * gtk/gtkfilesel.[ch]: Test if it is running in modal form and in + that case will run "Create Dir","Delete File" and "Rename File" + dialogs as modal too. + + * gtk/testgtk.c: Added a button with an example of creating modal + dialog boxes. Including file selection and color selection standard + dialogs. + +Tue Aug 11 00:44:47 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkhscrollbar.c gtk/gtkvscrollbar.c gtk/gtktoolbar.c: + Removed CAN_FOCUS by default from scrollbars, button + children of toolbar. (But not GTK_TOOLBAR_CHILD_WIDGET children) + (Scrollbar definitely good change, toolbar bit more questionable) + Tue Aug 11 17:49:33 1998 Tim Janik <timj@gtk.org> * examples/packbox/packbox.c: #include fixes (reported by Asbjoern diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 6f982cbee..866637bf5 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,42 @@ +Tue Aug 11 15:04:52 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtktext.[ch]: Removed has_cursor, set the cursor + beginning of Text when creating the Text widget. + + * gtk/testgtk.c: Grab the focus on the text widget so + as to test out the above. + +Tue Aug 11 14:55:00 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkeditable.c: Reverted part of timj's change of Jul 16. + ::changed is a notification signal and should have no default + handler. A complete redraw of the Text widget does _not_ need to + be done on every text insertion. + +Tue Aug 11 13:07:29 1998 Owen Taylor <otaylor@redhat.com> + (gtk-abilleira-072198-patch) + + * gtk/gtkwindow.[ch]: + Add gtk_window_set_modal() which sets a flag; when + set the window does a gtk_grab_add() when the window + is shown, and a gtk_grab_remove() when the window + is hidden. + + * gtk/gtkfilesel.[ch]: Test if it is running in modal form and in + that case will run "Create Dir","Delete File" and "Rename File" + dialogs as modal too. + + * gtk/testgtk.c: Added a button with an example of creating modal + dialog boxes. Including file selection and color selection standard + dialogs. + +Tue Aug 11 00:44:47 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkhscrollbar.c gtk/gtkvscrollbar.c gtk/gtktoolbar.c: + Removed CAN_FOCUS by default from scrollbars, button + children of toolbar. (But not GTK_TOOLBAR_CHILD_WIDGET children) + (Scrollbar definitely good change, toolbar bit more questionable) + Tue Aug 11 17:49:33 1998 Tim Janik <timj@gtk.org> * examples/packbox/packbox.c: #include fixes (reported by Asbjoern diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 6f982cbee..866637bf5 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,42 @@ +Tue Aug 11 15:04:52 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtktext.[ch]: Removed has_cursor, set the cursor + beginning of Text when creating the Text widget. + + * gtk/testgtk.c: Grab the focus on the text widget so + as to test out the above. + +Tue Aug 11 14:55:00 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkeditable.c: Reverted part of timj's change of Jul 16. + ::changed is a notification signal and should have no default + handler. A complete redraw of the Text widget does _not_ need to + be done on every text insertion. + +Tue Aug 11 13:07:29 1998 Owen Taylor <otaylor@redhat.com> + (gtk-abilleira-072198-patch) + + * gtk/gtkwindow.[ch]: + Add gtk_window_set_modal() which sets a flag; when + set the window does a gtk_grab_add() when the window + is shown, and a gtk_grab_remove() when the window + is hidden. + + * gtk/gtkfilesel.[ch]: Test if it is running in modal form and in + that case will run "Create Dir","Delete File" and "Rename File" + dialogs as modal too. + + * gtk/testgtk.c: Added a button with an example of creating modal + dialog boxes. Including file selection and color selection standard + dialogs. + +Tue Aug 11 00:44:47 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkhscrollbar.c gtk/gtkvscrollbar.c gtk/gtktoolbar.c: + Removed CAN_FOCUS by default from scrollbars, button + children of toolbar. (But not GTK_TOOLBAR_CHILD_WIDGET children) + (Scrollbar definitely good change, toolbar bit more questionable) + Tue Aug 11 17:49:33 1998 Tim Janik <timj@gtk.org> * examples/packbox/packbox.c: #include fixes (reported by Asbjoern diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 6f982cbee..866637bf5 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,42 @@ +Tue Aug 11 15:04:52 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtktext.[ch]: Removed has_cursor, set the cursor + beginning of Text when creating the Text widget. + + * gtk/testgtk.c: Grab the focus on the text widget so + as to test out the above. + +Tue Aug 11 14:55:00 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkeditable.c: Reverted part of timj's change of Jul 16. + ::changed is a notification signal and should have no default + handler. A complete redraw of the Text widget does _not_ need to + be done on every text insertion. + +Tue Aug 11 13:07:29 1998 Owen Taylor <otaylor@redhat.com> + (gtk-abilleira-072198-patch) + + * gtk/gtkwindow.[ch]: + Add gtk_window_set_modal() which sets a flag; when + set the window does a gtk_grab_add() when the window + is shown, and a gtk_grab_remove() when the window + is hidden. + + * gtk/gtkfilesel.[ch]: Test if it is running in modal form and in + that case will run "Create Dir","Delete File" and "Rename File" + dialogs as modal too. + + * gtk/testgtk.c: Added a button with an example of creating modal + dialog boxes. Including file selection and color selection standard + dialogs. + +Tue Aug 11 00:44:47 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkhscrollbar.c gtk/gtkvscrollbar.c gtk/gtktoolbar.c: + Removed CAN_FOCUS by default from scrollbars, button + children of toolbar. (But not GTK_TOOLBAR_CHILD_WIDGET children) + (Scrollbar definitely good change, toolbar bit more questionable) + Tue Aug 11 17:49:33 1998 Tim Janik <timj@gtk.org> * examples/packbox/packbox.c: #include fixes (reported by Asbjoern diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 6f982cbee..866637bf5 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,42 @@ +Tue Aug 11 15:04:52 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtktext.[ch]: Removed has_cursor, set the cursor + beginning of Text when creating the Text widget. + + * gtk/testgtk.c: Grab the focus on the text widget so + as to test out the above. + +Tue Aug 11 14:55:00 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkeditable.c: Reverted part of timj's change of Jul 16. + ::changed is a notification signal and should have no default + handler. A complete redraw of the Text widget does _not_ need to + be done on every text insertion. + +Tue Aug 11 13:07:29 1998 Owen Taylor <otaylor@redhat.com> + (gtk-abilleira-072198-patch) + + * gtk/gtkwindow.[ch]: + Add gtk_window_set_modal() which sets a flag; when + set the window does a gtk_grab_add() when the window + is shown, and a gtk_grab_remove() when the window + is hidden. + + * gtk/gtkfilesel.[ch]: Test if it is running in modal form and in + that case will run "Create Dir","Delete File" and "Rename File" + dialogs as modal too. + + * gtk/testgtk.c: Added a button with an example of creating modal + dialog boxes. Including file selection and color selection standard + dialogs. + +Tue Aug 11 00:44:47 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkhscrollbar.c gtk/gtkvscrollbar.c gtk/gtktoolbar.c: + Removed CAN_FOCUS by default from scrollbars, button + children of toolbar. (But not GTK_TOOLBAR_CHILD_WIDGET children) + (Scrollbar definitely good change, toolbar bit more questionable) + Tue Aug 11 17:49:33 1998 Tim Janik <timj@gtk.org> * examples/packbox/packbox.c: #include fixes (reported by Asbjoern diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 6f982cbee..866637bf5 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,42 @@ +Tue Aug 11 15:04:52 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtktext.[ch]: Removed has_cursor, set the cursor + beginning of Text when creating the Text widget. + + * gtk/testgtk.c: Grab the focus on the text widget so + as to test out the above. + +Tue Aug 11 14:55:00 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkeditable.c: Reverted part of timj's change of Jul 16. + ::changed is a notification signal and should have no default + handler. A complete redraw of the Text widget does _not_ need to + be done on every text insertion. + +Tue Aug 11 13:07:29 1998 Owen Taylor <otaylor@redhat.com> + (gtk-abilleira-072198-patch) + + * gtk/gtkwindow.[ch]: + Add gtk_window_set_modal() which sets a flag; when + set the window does a gtk_grab_add() when the window + is shown, and a gtk_grab_remove() when the window + is hidden. + + * gtk/gtkfilesel.[ch]: Test if it is running in modal form and in + that case will run "Create Dir","Delete File" and "Rename File" + dialogs as modal too. + + * gtk/testgtk.c: Added a button with an example of creating modal + dialog boxes. Including file selection and color selection standard + dialogs. + +Tue Aug 11 00:44:47 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkhscrollbar.c gtk/gtkvscrollbar.c gtk/gtktoolbar.c: + Removed CAN_FOCUS by default from scrollbars, button + children of toolbar. (But not GTK_TOOLBAR_CHILD_WIDGET children) + (Scrollbar definitely good change, toolbar bit more questionable) + Tue Aug 11 17:49:33 1998 Tim Janik <timj@gtk.org> * examples/packbox/packbox.c: #include fixes (reported by Asbjoern diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 6f982cbee..866637bf5 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,42 @@ +Tue Aug 11 15:04:52 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtktext.[ch]: Removed has_cursor, set the cursor + beginning of Text when creating the Text widget. + + * gtk/testgtk.c: Grab the focus on the text widget so + as to test out the above. + +Tue Aug 11 14:55:00 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkeditable.c: Reverted part of timj's change of Jul 16. + ::changed is a notification signal and should have no default + handler. A complete redraw of the Text widget does _not_ need to + be done on every text insertion. + +Tue Aug 11 13:07:29 1998 Owen Taylor <otaylor@redhat.com> + (gtk-abilleira-072198-patch) + + * gtk/gtkwindow.[ch]: + Add gtk_window_set_modal() which sets a flag; when + set the window does a gtk_grab_add() when the window + is shown, and a gtk_grab_remove() when the window + is hidden. + + * gtk/gtkfilesel.[ch]: Test if it is running in modal form and in + that case will run "Create Dir","Delete File" and "Rename File" + dialogs as modal too. + + * gtk/testgtk.c: Added a button with an example of creating modal + dialog boxes. Including file selection and color selection standard + dialogs. + +Tue Aug 11 00:44:47 1998 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkhscrollbar.c gtk/gtkvscrollbar.c gtk/gtktoolbar.c: + Removed CAN_FOCUS by default from scrollbars, button + children of toolbar. (But not GTK_TOOLBAR_CHILD_WIDGET children) + (Scrollbar definitely good change, toolbar bit more questionable) + Tue Aug 11 17:49:33 1998 Tim Janik <timj@gtk.org> * examples/packbox/packbox.c: #include fixes (reported by Asbjoern diff --git a/gtk/gtkeditable.c b/gtk/gtkeditable.c index b7e8c18ef..d2ff41437 100644 --- a/gtk/gtkeditable.c +++ b/gtk/gtkeditable.c @@ -290,7 +290,6 @@ gtk_editable_class_init (GtkEditableClass *class) class->insert_text = NULL; class->delete_text = NULL; - class->changed = (void (*) (GtkEditable*)) gtk_widget_queue_draw; class->activate = NULL; class->set_editable = gtk_editable_real_set_editable; diff --git a/gtk/gtkfilesel.c b/gtk/gtkfilesel.c index 9ee6ea9f7..f8903fbea 100644 --- a/gtk/gtkfilesel.c +++ b/gtk/gtkfilesel.c @@ -772,8 +772,12 @@ gtk_file_selection_create_dir (GtkWidget *widget, gpointer data) (gpointer) fs); gtk_window_set_title (GTK_WINDOW (dialog), "Create Directory"); gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); - gtk_widget_show (dialog); - + + /* If file dialog is grabbed, grab option dialog */ + /* When option dialog is closed, file dialog will be grabbed again */ + if (GTK_WINDOW(fs)->modal) + gtk_window_set_modal (GTK_WINDOW(dialog), TRUE); + vbox = gtk_vbox_new(FALSE, 0); gtk_container_border_width(GTK_CONTAINER(vbox), 8); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), vbox, @@ -811,6 +815,8 @@ gtk_file_selection_create_dir (GtkWidget *widget, gpointer data) GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); gtk_widget_grab_default(button); gtk_widget_show (button); + + gtk_widget_show (dialog); } static void @@ -871,6 +877,11 @@ gtk_file_selection_delete_file (GtkWidget *widget, gpointer data) (gpointer) fs); gtk_window_set_title (GTK_WINDOW (dialog), "Delete File"); gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); + + /* If file dialog is grabbed, grab option dialog */ + /* When option dialog is closed, file dialog will be grabbed again */ + if (GTK_WINDOW(fs)->modal) + gtk_window_set_modal (GTK_WINDOW(dialog), TRUE); vbox = gtk_vbox_new(FALSE, 0); gtk_container_border_width(GTK_CONTAINER(vbox), 8); @@ -906,6 +917,7 @@ gtk_file_selection_delete_file (GtkWidget *widget, gpointer data) gtk_widget_show (button); gtk_widget_show (dialog); + } static void @@ -969,7 +981,11 @@ gtk_file_selection_rename_file (GtkWidget *widget, gpointer data) (gpointer) fs); gtk_window_set_title (GTK_WINDOW (dialog), "Rename File"); gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); - gtk_widget_show (dialog); + + /* If file dialog is grabbed, grab option dialog */ + /* When option dialog closed, file dialog will be grabbed again */ + if (GTK_WINDOW(fs)->modal) + gtk_window_set_modal (GTK_WINDOW(dialog), TRUE); vbox = gtk_vbox_new(FALSE, 0); gtk_container_border_width(GTK_CONTAINER(vbox), 8); @@ -1014,6 +1030,8 @@ gtk_file_selection_rename_file (GtkWidget *widget, gpointer data) GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); gtk_widget_grab_default(button); gtk_widget_show (button); + + gtk_widget_show (dialog); } diff --git a/gtk/gtkhscrollbar.c b/gtk/gtkhscrollbar.c index 75068c338..c8c1bbc9b 100644 --- a/gtk/gtkhscrollbar.c +++ b/gtk/gtkhscrollbar.c @@ -93,7 +93,6 @@ gtk_hscrollbar_init (GtkHScrollbar *hscrollbar) GtkRequisition *requisition; widget = GTK_WIDGET (hscrollbar); - GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS); requisition = &widget->requisition; requisition->width = (RANGE_CLASS (widget)->min_slider_size + diff --git a/gtk/gtktext.c b/gtk/gtktext.c index b1c04fab2..e72551387 100644 --- a/gtk/gtktext.c +++ b/gtk/gtktext.c @@ -543,6 +543,8 @@ gtk_text_init (GtkText *text) text->tab_stops = g_list_prepend (text->tab_stops, (void*)8); text->tab_stops = g_list_prepend (text->tab_stops, (void*)8); + text->line_start_cache = NULL; + text->line_wrap = TRUE; text->word_wrap = FALSE; @@ -561,6 +563,7 @@ gtk_text_new (GtkAdjustment *hadj, text = gtk_type_new (GTK_TYPE_TEXT); gtk_text_set_adjustments (text, hadj, vadj); + gtk_editable_set_position (GTK_EDITABLE (text), 0); return GTK_WIDGET (text); } @@ -902,11 +905,10 @@ gtk_text_set_position (GtkEditable *editable, { GtkText *text = (GtkText *) editable; - undraw_cursor( text, FALSE ); - text->has_cursor = 1; - text->cursor_mark = find_mark( text, position ); - find_cursor( text, TRUE ); - draw_cursor( text, FALSE ); + undraw_cursor (text, FALSE); + text->cursor_mark = find_mark (text, position); + find_cursor (text, TRUE); + draw_cursor (text, FALSE); gtk_editable_select_region (editable, 0, 0); } @@ -1753,7 +1755,7 @@ gtk_text_key_press (GtkWidget *widget, key = event->keyval; return_val = TRUE; - if ((GTK_EDITABLE(text)->editable == FALSE) || !text->has_cursor) + if ((GTK_EDITABLE(text)->editable == FALSE)) { switch (event->keyval) { @@ -3324,17 +3326,17 @@ find_cursor_at_line (GtkText* text, const LineParams* start_line, gint pixel_hei static void find_cursor (GtkText* text, gboolean scroll) { - if (!text->has_cursor) - return; - - find_line_containing_point (text, text->cursor_mark.index, scroll); + if (GTK_WIDGET_REALIZED (text)) + { + find_line_containing_point (text, text->cursor_mark.index, scroll); - g_assert (text->cursor_mark.index >= text->first_line_start_index); + g_assert (text->cursor_mark.index >= text->first_line_start_index); - if (text->current_line) - find_cursor_at_line (text, - &CACHE_DATA(text->current_line), - pixel_height_of(text, text->current_line)); + if (text->current_line) + find_cursor_at_line (text, + &CACHE_DATA(text->current_line), + pixel_height_of(text, text->current_line)); + } GTK_EDITABLE (text)->current_pos = text->cursor_mark.index; } @@ -3392,8 +3394,6 @@ find_mouse_cursor (GtkText* text, gint x, gint y) pixel_height = - text->first_cut_pixels; - text->has_cursor = 1; - for (; cache; cache = cache->next) { pixel_height += LINE_HEIGHT(CACHE_DATA(cache)); @@ -3500,12 +3500,6 @@ move_cursor_ver (GtkText *text, int count) GtkPropertyMark mark; gint offset; - if (!text->has_cursor) - { - scroll_int (text, count * KEY_SCROLL_PIXELS); - return; - } - mark = find_this_line_start_mark (text, text->cursor_mark.index, &text->cursor_mark); offset = text->cursor_mark.index - mark.index; @@ -3550,9 +3544,6 @@ static void move_cursor_hor (GtkText *text, int count) { /* count should be +-1. */ - if (!text->has_cursor) - return; - if ( (count > 0 && text->cursor_mark.index + count > TEXT_LENGTH(text)) || (count < 0 && text->cursor_mark.index < (- count)) || (count == 0) ) @@ -4629,7 +4620,6 @@ undraw_cursor (GtkText* text, gint absolute) text->cursor_drawn_level = 0; if ((text->cursor_drawn_level ++ == 0) && - text->has_cursor && (editable->selection_start_pos == editable->selection_end_pos) && GTK_WIDGET_DRAWABLE (text)) { @@ -4678,35 +4668,25 @@ undraw_cursor (GtkText* text, gint absolute) static gint drawn_cursor_min (GtkText* text) { - if (text->has_cursor) - { - GdkFont* font; - - g_assert(text->cursor_mark.property); - - font = MARK_CURRENT_FONT(&text->cursor_mark); - - return text->cursor_pos_y - text->cursor_char_offset - font->ascent; - } - else - return 0; + GdkFont* font; + + g_assert(text->cursor_mark.property); + + font = MARK_CURRENT_FONT(&text->cursor_mark); + + return text->cursor_pos_y - text->cursor_char_offset - font->ascent; } static gint drawn_cursor_max (GtkText* text) { - if (text->has_cursor) - { - GdkFont* font; - - g_assert(text->cursor_mark.property); - - font = MARK_CURRENT_FONT(&text->cursor_mark); - - return text->cursor_pos_y - text->cursor_char_offset; - } - else - return 0; + GdkFont* font; + + g_assert(text->cursor_mark.property); + + font = MARK_CURRENT_FONT(&text->cursor_mark); + + return text->cursor_pos_y - text->cursor_char_offset; } static void @@ -4720,7 +4700,6 @@ draw_cursor (GtkText* text, gint absolute) text->cursor_drawn_level = 1; if ((--text->cursor_drawn_level == 0) && - text->has_cursor && editable->editable && (editable->selection_start_pos == editable->selection_end_pos) && GTK_WIDGET_DRAWABLE (text)) @@ -4811,7 +4790,7 @@ expose_text (GtkText* text, GdkRectangle *area, gboolean cursor) draw_line_wrap (text, pixels + CACHE_DATA(cache).font_ascent); } - if (cursor && text->has_cursor && GTK_WIDGET_HAS_FOCUS (text)) + if (cursor && GTK_WIDGET_HAS_FOCUS (text)) { if (CACHE_DATA(cache).start.index <= text->cursor_mark.index && CACHE_DATA(cache).end.index >= text->cursor_mark.index) diff --git a/gtk/gtktext.h b/gtk/gtktext.h index 6932cc15c..1de2de945 100644 --- a/gtk/gtktext.h +++ b/gtk/gtktext.h @@ -100,8 +100,6 @@ struct _GtkText /* FLAGS */ - /* True iff the cursor has been placed yet. */ - guint has_cursor : 1; /* True iff this buffer is wrapping lines, otherwise it is using a * horizontal scrollbar. */ guint line_wrap : 1; diff --git a/gtk/gtkvscrollbar.c b/gtk/gtkvscrollbar.c index 52ab2d25e..c8b960a31 100644 --- a/gtk/gtkvscrollbar.c +++ b/gtk/gtkvscrollbar.c @@ -92,7 +92,6 @@ gtk_vscrollbar_init (GtkVScrollbar *vscrollbar) GtkRequisition *requisition; widget = GTK_WIDGET (vscrollbar); - GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS); requisition = &widget->requisition; requisition->width = (RANGE_CLASS (widget)->slider_width + diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index fd5ba6c53..bf2693209 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -26,6 +26,7 @@ #include "gtksignal.h" #include "gtkwindow.h" #include "gtkbindings.h" +#include "gtkmain.h" enum { SET_FOCUS, @@ -199,6 +200,7 @@ gtk_window_init (GtkWindow *window) window->handling_resize = FALSE; window->position = GTK_WIN_POS_NONE; window->use_uposition = TRUE; + window->modal = FALSE; gtk_container_register_toplevel (GTK_CONTAINER (window)); } @@ -433,6 +435,24 @@ gtk_window_activate_default (GtkWindow *window) return FALSE; } +void +gtk_window_set_modal (GtkWindow *window, gboolean modal) +{ + g_return_if_fail (window != NULL); + g_return_if_fail (GTK_IS_WINDOW (window)); + + /* If the widget was showed already, adjust it's grab state */ + if (GTK_WIDGET_VISIBLE(GTK_WIDGET(window))) + { + if (window->modal && !modal) + gtk_grab_remove (GTK_WIDGET(window)); + else if (!window->modal && modal) + gtk_grab_add (GTK_WIDGET(window)); + } + + window->modal = modal; +} + static void gtk_window_shutdown (GtkObject *object) { @@ -485,6 +505,10 @@ gtk_window_show (GtkWidget *widget) GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE); gtk_container_check_resize (GTK_CONTAINER (widget)); gtk_widget_map (widget); + + if (GTK_WINDOW(widget)->modal) + gtk_grab_add(widget); + } static void @@ -495,6 +519,10 @@ gtk_window_hide (GtkWidget *widget) GTK_WIDGET_UNSET_FLAGS (widget, GTK_VISIBLE); gtk_widget_unmap (widget); + + if (GTK_WINDOW(widget)->modal) + gtk_grab_remove(widget); + } static void diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h index ce73469f5..ee35c9a9c 100644 --- a/gtk/gtkwindow.h +++ b/gtk/gtkwindow.h @@ -61,6 +61,7 @@ struct _GtkWindow guint handling_resize : 1; guint position : 2; guint use_uposition : 1; + guint modal : 1; }; struct _GtkWindowClass @@ -96,7 +97,9 @@ void gtk_window_position (GtkWindow *window, gint gtk_window_activate_focus (GtkWindow *window); gint gtk_window_activate_default (GtkWindow *window); - +/* If window is set modal, input will be grabbed when show and released when hide */ +void gtk_window_set_modal (GtkWindow *window, + gboolean modal); #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/gtk/testgtk.c b/gtk/testgtk.c index 6658a342e..dec2fa2d9 100644 --- a/gtk/testgtk.c +++ b/gtk/testgtk.c @@ -2139,6 +2139,127 @@ scrolled_windows_remove (GtkWidget *widget, GtkWidget *scrollwin) } /* + create_modal_window + */ + +static gboolean +cmw_destroy_cb(GtkWidget *widget) +{ + /* This is needed to get out of gtk_main */ + gtk_main_quit (); + + return FALSE; +} + +static void +cmw_color (GtkWidget *widget) +{ + GtkWidget *csd; + + csd=gtk_color_selection_dialog_new ("This is a modal color selection dialog"); + + /* Set as modal */ + gtk_window_set_modal (GTK_WINDOW(csd),TRUE); + + gtk_signal_connect (GTK_OBJECT(csd), "destroy", + GTK_SIGNAL_FUNC(cmw_destroy_cb),NULL); + + gtk_signal_connect_object (GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(csd)->ok_button), + "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), + GTK_OBJECT (csd)); + gtk_signal_connect_object (GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(csd)->cancel_button), + "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), + GTK_OBJECT (csd)); + + /* wait until destroy calls gtk_main_quit */ + gtk_widget_show (csd); + gtk_main (); +} + +static void +cmw_file (GtkWidget *widget) +{ + GtkWidget *fs; + + fs = gtk_file_selection_new("This is a modal file selection dialog"); + + /* Set as modal */ + gtk_window_set_modal (GTK_WINDOW(fs),TRUE); + + gtk_signal_connect (GTK_OBJECT(fs), "destroy", + GTK_SIGNAL_FUNC(cmw_destroy_cb),NULL); + + gtk_signal_connect_object (GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button), + "clicked",GTK_SIGNAL_FUNC(gtk_widget_destroy), + GTK_OBJECT (fs)); + gtk_signal_connect_object (GTK_OBJECT(GTK_FILE_SELECTION(fs)->cancel_button), + "clicked",GTK_SIGNAL_FUNC(gtk_widget_destroy), + GTK_OBJECT (fs)); + + /* wait until destroy calls gtk_main_quit */ + gtk_widget_show (fs); + + gtk_main(); +} + + +static void +create_modal_window (void) +{ + GtkWidget *window = NULL; + GtkWidget *box1,*box2; + GtkWidget *frame1; + GtkWidget *btnColor,*btnFile,*btnClose; + + /* Create modal window (Here you can use any window descendent )*/ + window=gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_title (GTK_WINDOW(window),"This window is modal"); + + /* Set window as modal */ + gtk_window_set_modal (GTK_WINDOW(window),TRUE); + + /* Create widgets */ + box1 = gtk_vbox_new (FALSE,5); + frame1 = gtk_frame_new ("Standard dialogs in modal form"); + box2 = gtk_vbox_new (TRUE,5); + btnColor = gtk_button_new_with_label ("Color"); + btnFile = gtk_button_new_with_label ("File Selection"); + btnClose = gtk_button_new_with_label ("Close"); + + /* Init widgets */ + gtk_container_border_width (GTK_CONTAINER(box1),3); + gtk_container_border_width (GTK_CONTAINER(box2),3); + + /* Pack widgets */ + gtk_container_add (GTK_CONTAINER (window), box1); + gtk_box_pack_start (GTK_BOX (box1), frame1, TRUE, TRUE, 4); + gtk_container_add (GTK_CONTAINER (frame1), box2); + gtk_box_pack_start (GTK_BOX (box2), btnColor, FALSE, FALSE, 4); + gtk_box_pack_start (GTK_BOX (box2), btnFile, FALSE, FALSE, 4); + gtk_box_pack_start (GTK_BOX (box1), gtk_hseparator_new (), FALSE, FALSE, 4); + gtk_box_pack_start (GTK_BOX (box1), btnClose, FALSE, FALSE, 4); + + /* connect signals */ + gtk_signal_connect_object (GTK_OBJECT (btnClose), "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + GTK_OBJECT (window)); + + gtk_signal_connect (GTK_OBJECT (window), "destroy", + GTK_SIGNAL_FUNC (cmw_destroy_cb),NULL); + + gtk_signal_connect (GTK_OBJECT (btnColor), "clicked", + GTK_SIGNAL_FUNC (cmw_color),NULL); + gtk_signal_connect (GTK_OBJECT (btnFile), "clicked", + GTK_SIGNAL_FUNC (cmw_file),NULL); + + /* Show widgets */ + gtk_widget_show_all (window); + + /* wait until dialog get destroyed */ + gtk_main(); +} + +/* * GtkScrolledWindow */ @@ -4865,6 +4986,7 @@ create_text (void) gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1, GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); + gtk_widget_grab_focus (text); gtk_widget_show (text); hscrollbar = gtk_hscrollbar_new (GTK_TEXT (text)->hadj); @@ -7171,6 +7293,7 @@ create_main_window (void) { "handle box", create_handle_box }, { "list", create_list }, { "menus", create_menus }, + { "modal window", create_modal_window }, { "notebook", create_notebook }, { "panes", create_panes }, { "pixmap", create_pixmap }, diff --git a/tests/testgtk.c b/tests/testgtk.c index 6658a342e..dec2fa2d9 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -2139,6 +2139,127 @@ scrolled_windows_remove (GtkWidget *widget, GtkWidget *scrollwin) } /* + create_modal_window + */ + +static gboolean +cmw_destroy_cb(GtkWidget *widget) +{ + /* This is needed to get out of gtk_main */ + gtk_main_quit (); + + return FALSE; +} + +static void +cmw_color (GtkWidget *widget) +{ + GtkWidget *csd; + + csd=gtk_color_selection_dialog_new ("This is a modal color selection dialog"); + + /* Set as modal */ + gtk_window_set_modal (GTK_WINDOW(csd),TRUE); + + gtk_signal_connect (GTK_OBJECT(csd), "destroy", + GTK_SIGNAL_FUNC(cmw_destroy_cb),NULL); + + gtk_signal_connect_object (GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(csd)->ok_button), + "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), + GTK_OBJECT (csd)); + gtk_signal_connect_object (GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(csd)->cancel_button), + "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), + GTK_OBJECT (csd)); + + /* wait until destroy calls gtk_main_quit */ + gtk_widget_show (csd); + gtk_main (); +} + +static void +cmw_file (GtkWidget *widget) +{ + GtkWidget *fs; + + fs = gtk_file_selection_new("This is a modal file selection dialog"); + + /* Set as modal */ + gtk_window_set_modal (GTK_WINDOW(fs),TRUE); + + gtk_signal_connect (GTK_OBJECT(fs), "destroy", + GTK_SIGNAL_FUNC(cmw_destroy_cb),NULL); + + gtk_signal_connect_object (GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button), + "clicked",GTK_SIGNAL_FUNC(gtk_widget_destroy), + GTK_OBJECT (fs)); + gtk_signal_connect_object (GTK_OBJECT(GTK_FILE_SELECTION(fs)->cancel_button), + "clicked",GTK_SIGNAL_FUNC(gtk_widget_destroy), + GTK_OBJECT (fs)); + + /* wait until destroy calls gtk_main_quit */ + gtk_widget_show (fs); + + gtk_main(); +} + + +static void +create_modal_window (void) +{ + GtkWidget *window = NULL; + GtkWidget *box1,*box2; + GtkWidget *frame1; + GtkWidget *btnColor,*btnFile,*btnClose; + + /* Create modal window (Here you can use any window descendent )*/ + window=gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_title (GTK_WINDOW(window),"This window is modal"); + + /* Set window as modal */ + gtk_window_set_modal (GTK_WINDOW(window),TRUE); + + /* Create widgets */ + box1 = gtk_vbox_new (FALSE,5); + frame1 = gtk_frame_new ("Standard dialogs in modal form"); + box2 = gtk_vbox_new (TRUE,5); + btnColor = gtk_button_new_with_label ("Color"); + btnFile = gtk_button_new_with_label ("File Selection"); + btnClose = gtk_button_new_with_label ("Close"); + + /* Init widgets */ + gtk_container_border_width (GTK_CONTAINER(box1),3); + gtk_container_border_width (GTK_CONTAINER(box2),3); + + /* Pack widgets */ + gtk_container_add (GTK_CONTAINER (window), box1); + gtk_box_pack_start (GTK_BOX (box1), frame1, TRUE, TRUE, 4); + gtk_container_add (GTK_CONTAINER (frame1), box2); + gtk_box_pack_start (GTK_BOX (box2), btnColor, FALSE, FALSE, 4); + gtk_box_pack_start (GTK_BOX (box2), btnFile, FALSE, FALSE, 4); + gtk_box_pack_start (GTK_BOX (box1), gtk_hseparator_new (), FALSE, FALSE, 4); + gtk_box_pack_start (GTK_BOX (box1), btnClose, FALSE, FALSE, 4); + + /* connect signals */ + gtk_signal_connect_object (GTK_OBJECT (btnClose), "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + GTK_OBJECT (window)); + + gtk_signal_connect (GTK_OBJECT (window), "destroy", + GTK_SIGNAL_FUNC (cmw_destroy_cb),NULL); + + gtk_signal_connect (GTK_OBJECT (btnColor), "clicked", + GTK_SIGNAL_FUNC (cmw_color),NULL); + gtk_signal_connect (GTK_OBJECT (btnFile), "clicked", + GTK_SIGNAL_FUNC (cmw_file),NULL); + + /* Show widgets */ + gtk_widget_show_all (window); + + /* wait until dialog get destroyed */ + gtk_main(); +} + +/* * GtkScrolledWindow */ @@ -4865,6 +4986,7 @@ create_text (void) gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1, GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); + gtk_widget_grab_focus (text); gtk_widget_show (text); hscrollbar = gtk_hscrollbar_new (GTK_TEXT (text)->hadj); @@ -7171,6 +7293,7 @@ create_main_window (void) { "handle box", create_handle_box }, { "list", create_list }, { "menus", create_menus }, + { "modal window", create_modal_window }, { "notebook", create_notebook }, { "panes", create_panes }, { "pixmap", create_pixmap }, |