diff options
-rw-r--r-- | ChangeLog | 150 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 150 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 150 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 150 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 150 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 150 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 150 | ||||
-rw-r--r-- | gtk/gtkclist.c | 296 | ||||
-rw-r--r-- | gtk/gtkclist.h | 9 | ||||
-rw-r--r-- | gtk/gtkcontainer.c | 6 | ||||
-rw-r--r-- | gtk/gtkctree.c | 19 | ||||
-rw-r--r-- | gtk/gtkfeatures.h.in | 6 | ||||
-rw-r--r-- | gtk/gtkitemfactory.c | 480 | ||||
-rw-r--r-- | gtk/gtkitemfactory.h | 17 | ||||
-rw-r--r-- | gtk/gtklayout.c | 6 | ||||
-rw-r--r-- | gtk/gtkmenu.c | 293 | ||||
-rw-r--r-- | gtk/gtkmenu.h | 13 | ||||
-rw-r--r-- | gtk/gtkmenushell.c | 36 | ||||
-rw-r--r-- | gtk/gtkmenushell.h | 1 | ||||
-rw-r--r-- | gtk/gtksignal.c | 2 | ||||
-rw-r--r-- | gtk/gtkwidget.c | 28 | ||||
-rw-r--r-- | gtk/gtkwidget.h | 1 | ||||
-rw-r--r-- | gtk/testgtk.c | 6 | ||||
-rw-r--r-- | tests/testgtk.c | 6 |
24 files changed, 1781 insertions, 494 deletions
@@ -1,3 +1,153 @@ +Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> + + * merges from gtk-1-2: + +Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the + item factory class has been created. + (gtk_item_factory_parse_rc): likewise. + + * gtk/gtkmenu.c: + keep proper references for old_active_menu_item. + (gtk_menu_reparent): unset the usize of the new parent, + so the menu can sanely be size requested and we don't get nasty screen + artefacts upon next reparentation. + (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an + enter notify. only synthesize enter notifies if the pointer really is + inside the event window. + (gtk_menu_popdown): use gtk_menu_shell_deselect(). + (gtk_menu_popup): move the background setting stuff into + gtk_menu_tearoff_bg_copy() so it can be called from other places as well. + + * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use + gtk_menu_shell_select_item() to select the new item. + (gtk_menu_shell_deselect): export this function, so gtkmenu.c can + do the right thing for deselection as well. + +Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkwidget.[hc]: + (gtk_widget_accelerators_locked): return whether a widget's accelerators + are locked. + + * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or + existing accelerators if the widget's accelerators are locked. + +Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. + + * gtk/gtkmenu.c: truely forward key press and key release events to + the menu widget from the toplevel or tearoff window. we can't simply + connect to that, we need to stop further processing of the events as + well. + +Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkmenu.c: + (gtk_menu_key_press): pass event->keyval, event->state to + gtk_accelerator_valid, instead of event->keyval twice. + refuse to install single letter accelerators for menus that use + single letter shortcuts. + + * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use + gtk_menu_ensure_uline_accel_group(). + + * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() + which will always return an uline accel group, made + gtk_menu_get_uline_accel_group() return NULL if the group isn't + yet created. + +Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> + + * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. + + * gtk/gtkclist.c (gtk_clist_column_title_passive): + Leave button sensitive, trap button_press, button_release, + motion_notify, enter_notify and leave_notify events instead. + (gtk_clist_column_title_active): disconnect event handler. + (gtk_clist_drag_data_get): fixed memory leak. Reported by + Guillaume Laurent <glaurent@worldnet.fr> + +Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> + + * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few + width/height mixups. + + * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal + if needed. + +Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> + + * gtk/testgtk.c (create_item_factory): unref the item factory after + window's destruction. + + * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference + count on the menu shell around the menu item's activation, since the + signal emission may cause menu shell destruction. + + * gtk/gtkitemfactory.c: + the previous code leaked one accel group per menu. we use + gtk_menu_get_uline_accel_group() now to fix that, and with that + also create the underline accelerator group of the menus only if + required (i.e. an underline accelerator has been specified). + (gtk_item_factory_construct): + (gtk_item_factory_create_item): removed code that would create an + extra accel group for the menu (and leak references). + (gtk_item_factory_create_item): adapted the underline accelerator + installation code to properly feature gtk_menu_get_uline_accel_group(). + + * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive + menu->accel_group, this may return NULL if the accelerator group + hasn't been set yet. + added gtk_menu_get_uline_accel_group() to retrive the underline + accelerator group of the menu, this will be created on demand + and proper care is taken about its reference count. + + * gtk/gtkitemfactory.h: + * gtk/gtkitemfactory.c: + dumped the approach of keeping a widgets by action list on the + factory since the factory<->widget destroy negotiation didn't work + and would be hard to get going at all. instead we keep a list of + GtkItemFactoryItem items on the factory (GtkItemFactoryItems are + persistant throughout a program's life time). + also, i removed the static const gchar *key_* variables, and made + them inline strings (they weren't actually used anyways). + (gtk_item_factory_add_item): update ifactory->items. + (gtk_item_factory_destroy): destroy ifactory->items (and remove + the item factory pointer from the remaining ifactory widgets). + (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem + list to find the widget. + (gtk_item_factory_get_item): new function that works around + gtk_item_factory_get_widget() limitations, this function will only + return menu items, even for <Branch> entries. + +Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> + + * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our + font hash table, if we have a GdkFontPrivate entry for this font + already, simply increment its reference count, provided by Olaf Dietsche + <olaf.dietsche+list.gtk@netcologne.de>. + + * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix + provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. + +Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkcontainer.c: + (gtk_container_add_with_args): + (gtk_container_addv): + (gtk_container_add): before adding a child to a conatiner, make sure + it is (default) constructed, this is neccessary because under certain + circumstances the child will get relized and mapped immediatedly, in + which case it has to be constructed already. + +Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> + + * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal + values > 1 as TRUE also. + 1999-03-16 Tor Lillqvist <tml@iki.fi> * README.win32: New file. diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 27ac46be89..3e96e67fa9 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,153 @@ +Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> + + * merges from gtk-1-2: + +Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the + item factory class has been created. + (gtk_item_factory_parse_rc): likewise. + + * gtk/gtkmenu.c: + keep proper references for old_active_menu_item. + (gtk_menu_reparent): unset the usize of the new parent, + so the menu can sanely be size requested and we don't get nasty screen + artefacts upon next reparentation. + (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an + enter notify. only synthesize enter notifies if the pointer really is + inside the event window. + (gtk_menu_popdown): use gtk_menu_shell_deselect(). + (gtk_menu_popup): move the background setting stuff into + gtk_menu_tearoff_bg_copy() so it can be called from other places as well. + + * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use + gtk_menu_shell_select_item() to select the new item. + (gtk_menu_shell_deselect): export this function, so gtkmenu.c can + do the right thing for deselection as well. + +Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkwidget.[hc]: + (gtk_widget_accelerators_locked): return whether a widget's accelerators + are locked. + + * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or + existing accelerators if the widget's accelerators are locked. + +Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. + + * gtk/gtkmenu.c: truely forward key press and key release events to + the menu widget from the toplevel or tearoff window. we can't simply + connect to that, we need to stop further processing of the events as + well. + +Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkmenu.c: + (gtk_menu_key_press): pass event->keyval, event->state to + gtk_accelerator_valid, instead of event->keyval twice. + refuse to install single letter accelerators for menus that use + single letter shortcuts. + + * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use + gtk_menu_ensure_uline_accel_group(). + + * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() + which will always return an uline accel group, made + gtk_menu_get_uline_accel_group() return NULL if the group isn't + yet created. + +Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> + + * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. + + * gtk/gtkclist.c (gtk_clist_column_title_passive): + Leave button sensitive, trap button_press, button_release, + motion_notify, enter_notify and leave_notify events instead. + (gtk_clist_column_title_active): disconnect event handler. + (gtk_clist_drag_data_get): fixed memory leak. Reported by + Guillaume Laurent <glaurent@worldnet.fr> + +Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> + + * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few + width/height mixups. + + * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal + if needed. + +Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> + + * gtk/testgtk.c (create_item_factory): unref the item factory after + window's destruction. + + * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference + count on the menu shell around the menu item's activation, since the + signal emission may cause menu shell destruction. + + * gtk/gtkitemfactory.c: + the previous code leaked one accel group per menu. we use + gtk_menu_get_uline_accel_group() now to fix that, and with that + also create the underline accelerator group of the menus only if + required (i.e. an underline accelerator has been specified). + (gtk_item_factory_construct): + (gtk_item_factory_create_item): removed code that would create an + extra accel group for the menu (and leak references). + (gtk_item_factory_create_item): adapted the underline accelerator + installation code to properly feature gtk_menu_get_uline_accel_group(). + + * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive + menu->accel_group, this may return NULL if the accelerator group + hasn't been set yet. + added gtk_menu_get_uline_accel_group() to retrive the underline + accelerator group of the menu, this will be created on demand + and proper care is taken about its reference count. + + * gtk/gtkitemfactory.h: + * gtk/gtkitemfactory.c: + dumped the approach of keeping a widgets by action list on the + factory since the factory<->widget destroy negotiation didn't work + and would be hard to get going at all. instead we keep a list of + GtkItemFactoryItem items on the factory (GtkItemFactoryItems are + persistant throughout a program's life time). + also, i removed the static const gchar *key_* variables, and made + them inline strings (they weren't actually used anyways). + (gtk_item_factory_add_item): update ifactory->items. + (gtk_item_factory_destroy): destroy ifactory->items (and remove + the item factory pointer from the remaining ifactory widgets). + (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem + list to find the widget. + (gtk_item_factory_get_item): new function that works around + gtk_item_factory_get_widget() limitations, this function will only + return menu items, even for <Branch> entries. + +Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> + + * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our + font hash table, if we have a GdkFontPrivate entry for this font + already, simply increment its reference count, provided by Olaf Dietsche + <olaf.dietsche+list.gtk@netcologne.de>. + + * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix + provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. + +Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkcontainer.c: + (gtk_container_add_with_args): + (gtk_container_addv): + (gtk_container_add): before adding a child to a conatiner, make sure + it is (default) constructed, this is neccessary because under certain + circumstances the child will get relized and mapped immediatedly, in + which case it has to be constructed already. + +Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> + + * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal + values > 1 as TRUE also. + 1999-03-16 Tor Lillqvist <tml@iki.fi> * README.win32: New file. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 27ac46be89..3e96e67fa9 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,153 @@ +Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> + + * merges from gtk-1-2: + +Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the + item factory class has been created. + (gtk_item_factory_parse_rc): likewise. + + * gtk/gtkmenu.c: + keep proper references for old_active_menu_item. + (gtk_menu_reparent): unset the usize of the new parent, + so the menu can sanely be size requested and we don't get nasty screen + artefacts upon next reparentation. + (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an + enter notify. only synthesize enter notifies if the pointer really is + inside the event window. + (gtk_menu_popdown): use gtk_menu_shell_deselect(). + (gtk_menu_popup): move the background setting stuff into + gtk_menu_tearoff_bg_copy() so it can be called from other places as well. + + * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use + gtk_menu_shell_select_item() to select the new item. + (gtk_menu_shell_deselect): export this function, so gtkmenu.c can + do the right thing for deselection as well. + +Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkwidget.[hc]: + (gtk_widget_accelerators_locked): return whether a widget's accelerators + are locked. + + * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or + existing accelerators if the widget's accelerators are locked. + +Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. + + * gtk/gtkmenu.c: truely forward key press and key release events to + the menu widget from the toplevel or tearoff window. we can't simply + connect to that, we need to stop further processing of the events as + well. + +Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkmenu.c: + (gtk_menu_key_press): pass event->keyval, event->state to + gtk_accelerator_valid, instead of event->keyval twice. + refuse to install single letter accelerators for menus that use + single letter shortcuts. + + * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use + gtk_menu_ensure_uline_accel_group(). + + * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() + which will always return an uline accel group, made + gtk_menu_get_uline_accel_group() return NULL if the group isn't + yet created. + +Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> + + * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. + + * gtk/gtkclist.c (gtk_clist_column_title_passive): + Leave button sensitive, trap button_press, button_release, + motion_notify, enter_notify and leave_notify events instead. + (gtk_clist_column_title_active): disconnect event handler. + (gtk_clist_drag_data_get): fixed memory leak. Reported by + Guillaume Laurent <glaurent@worldnet.fr> + +Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> + + * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few + width/height mixups. + + * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal + if needed. + +Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> + + * gtk/testgtk.c (create_item_factory): unref the item factory after + window's destruction. + + * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference + count on the menu shell around the menu item's activation, since the + signal emission may cause menu shell destruction. + + * gtk/gtkitemfactory.c: + the previous code leaked one accel group per menu. we use + gtk_menu_get_uline_accel_group() now to fix that, and with that + also create the underline accelerator group of the menus only if + required (i.e. an underline accelerator has been specified). + (gtk_item_factory_construct): + (gtk_item_factory_create_item): removed code that would create an + extra accel group for the menu (and leak references). + (gtk_item_factory_create_item): adapted the underline accelerator + installation code to properly feature gtk_menu_get_uline_accel_group(). + + * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive + menu->accel_group, this may return NULL if the accelerator group + hasn't been set yet. + added gtk_menu_get_uline_accel_group() to retrive the underline + accelerator group of the menu, this will be created on demand + and proper care is taken about its reference count. + + * gtk/gtkitemfactory.h: + * gtk/gtkitemfactory.c: + dumped the approach of keeping a widgets by action list on the + factory since the factory<->widget destroy negotiation didn't work + and would be hard to get going at all. instead we keep a list of + GtkItemFactoryItem items on the factory (GtkItemFactoryItems are + persistant throughout a program's life time). + also, i removed the static const gchar *key_* variables, and made + them inline strings (they weren't actually used anyways). + (gtk_item_factory_add_item): update ifactory->items. + (gtk_item_factory_destroy): destroy ifactory->items (and remove + the item factory pointer from the remaining ifactory widgets). + (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem + list to find the widget. + (gtk_item_factory_get_item): new function that works around + gtk_item_factory_get_widget() limitations, this function will only + return menu items, even for <Branch> entries. + +Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> + + * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our + font hash table, if we have a GdkFontPrivate entry for this font + already, simply increment its reference count, provided by Olaf Dietsche + <olaf.dietsche+list.gtk@netcologne.de>. + + * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix + provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. + +Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkcontainer.c: + (gtk_container_add_with_args): + (gtk_container_addv): + (gtk_container_add): before adding a child to a conatiner, make sure + it is (default) constructed, this is neccessary because under certain + circumstances the child will get relized and mapped immediatedly, in + which case it has to be constructed already. + +Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> + + * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal + values > 1 as TRUE also. + 1999-03-16 Tor Lillqvist <tml@iki.fi> * README.win32: New file. diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 27ac46be89..3e96e67fa9 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,153 @@ +Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> + + * merges from gtk-1-2: + +Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the + item factory class has been created. + (gtk_item_factory_parse_rc): likewise. + + * gtk/gtkmenu.c: + keep proper references for old_active_menu_item. + (gtk_menu_reparent): unset the usize of the new parent, + so the menu can sanely be size requested and we don't get nasty screen + artefacts upon next reparentation. + (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an + enter notify. only synthesize enter notifies if the pointer really is + inside the event window. + (gtk_menu_popdown): use gtk_menu_shell_deselect(). + (gtk_menu_popup): move the background setting stuff into + gtk_menu_tearoff_bg_copy() so it can be called from other places as well. + + * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use + gtk_menu_shell_select_item() to select the new item. + (gtk_menu_shell_deselect): export this function, so gtkmenu.c can + do the right thing for deselection as well. + +Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkwidget.[hc]: + (gtk_widget_accelerators_locked): return whether a widget's accelerators + are locked. + + * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or + existing accelerators if the widget's accelerators are locked. + +Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. + + * gtk/gtkmenu.c: truely forward key press and key release events to + the menu widget from the toplevel or tearoff window. we can't simply + connect to that, we need to stop further processing of the events as + well. + +Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkmenu.c: + (gtk_menu_key_press): pass event->keyval, event->state to + gtk_accelerator_valid, instead of event->keyval twice. + refuse to install single letter accelerators for menus that use + single letter shortcuts. + + * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use + gtk_menu_ensure_uline_accel_group(). + + * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() + which will always return an uline accel group, made + gtk_menu_get_uline_accel_group() return NULL if the group isn't + yet created. + +Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> + + * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. + + * gtk/gtkclist.c (gtk_clist_column_title_passive): + Leave button sensitive, trap button_press, button_release, + motion_notify, enter_notify and leave_notify events instead. + (gtk_clist_column_title_active): disconnect event handler. + (gtk_clist_drag_data_get): fixed memory leak. Reported by + Guillaume Laurent <glaurent@worldnet.fr> + +Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> + + * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few + width/height mixups. + + * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal + if needed. + +Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> + + * gtk/testgtk.c (create_item_factory): unref the item factory after + window's destruction. + + * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference + count on the menu shell around the menu item's activation, since the + signal emission may cause menu shell destruction. + + * gtk/gtkitemfactory.c: + the previous code leaked one accel group per menu. we use + gtk_menu_get_uline_accel_group() now to fix that, and with that + also create the underline accelerator group of the menus only if + required (i.e. an underline accelerator has been specified). + (gtk_item_factory_construct): + (gtk_item_factory_create_item): removed code that would create an + extra accel group for the menu (and leak references). + (gtk_item_factory_create_item): adapted the underline accelerator + installation code to properly feature gtk_menu_get_uline_accel_group(). + + * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive + menu->accel_group, this may return NULL if the accelerator group + hasn't been set yet. + added gtk_menu_get_uline_accel_group() to retrive the underline + accelerator group of the menu, this will be created on demand + and proper care is taken about its reference count. + + * gtk/gtkitemfactory.h: + * gtk/gtkitemfactory.c: + dumped the approach of keeping a widgets by action list on the + factory since the factory<->widget destroy negotiation didn't work + and would be hard to get going at all. instead we keep a list of + GtkItemFactoryItem items on the factory (GtkItemFactoryItems are + persistant throughout a program's life time). + also, i removed the static const gchar *key_* variables, and made + them inline strings (they weren't actually used anyways). + (gtk_item_factory_add_item): update ifactory->items. + (gtk_item_factory_destroy): destroy ifactory->items (and remove + the item factory pointer from the remaining ifactory widgets). + (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem + list to find the widget. + (gtk_item_factory_get_item): new function that works around + gtk_item_factory_get_widget() limitations, this function will only + return menu items, even for <Branch> entries. + +Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> + + * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our + font hash table, if we have a GdkFontPrivate entry for this font + already, simply increment its reference count, provided by Olaf Dietsche + <olaf.dietsche+list.gtk@netcologne.de>. + + * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix + provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. + +Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkcontainer.c: + (gtk_container_add_with_args): + (gtk_container_addv): + (gtk_container_add): before adding a child to a conatiner, make sure + it is (default) constructed, this is neccessary because under certain + circumstances the child will get relized and mapped immediatedly, in + which case it has to be constructed already. + +Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> + + * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal + values > 1 as TRUE also. + 1999-03-16 Tor Lillqvist <tml@iki.fi> * README.win32: New file. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 27ac46be89..3e96e67fa9 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,153 @@ +Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> + + * merges from gtk-1-2: + +Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the + item factory class has been created. + (gtk_item_factory_parse_rc): likewise. + + * gtk/gtkmenu.c: + keep proper references for old_active_menu_item. + (gtk_menu_reparent): unset the usize of the new parent, + so the menu can sanely be size requested and we don't get nasty screen + artefacts upon next reparentation. + (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an + enter notify. only synthesize enter notifies if the pointer really is + inside the event window. + (gtk_menu_popdown): use gtk_menu_shell_deselect(). + (gtk_menu_popup): move the background setting stuff into + gtk_menu_tearoff_bg_copy() so it can be called from other places as well. + + * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use + gtk_menu_shell_select_item() to select the new item. + (gtk_menu_shell_deselect): export this function, so gtkmenu.c can + do the right thing for deselection as well. + +Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkwidget.[hc]: + (gtk_widget_accelerators_locked): return whether a widget's accelerators + are locked. + + * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or + existing accelerators if the widget's accelerators are locked. + +Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. + + * gtk/gtkmenu.c: truely forward key press and key release events to + the menu widget from the toplevel or tearoff window. we can't simply + connect to that, we need to stop further processing of the events as + well. + +Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkmenu.c: + (gtk_menu_key_press): pass event->keyval, event->state to + gtk_accelerator_valid, instead of event->keyval twice. + refuse to install single letter accelerators for menus that use + single letter shortcuts. + + * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use + gtk_menu_ensure_uline_accel_group(). + + * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() + which will always return an uline accel group, made + gtk_menu_get_uline_accel_group() return NULL if the group isn't + yet created. + +Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> + + * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. + + * gtk/gtkclist.c (gtk_clist_column_title_passive): + Leave button sensitive, trap button_press, button_release, + motion_notify, enter_notify and leave_notify events instead. + (gtk_clist_column_title_active): disconnect event handler. + (gtk_clist_drag_data_get): fixed memory leak. Reported by + Guillaume Laurent <glaurent@worldnet.fr> + +Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> + + * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few + width/height mixups. + + * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal + if needed. + +Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> + + * gtk/testgtk.c (create_item_factory): unref the item factory after + window's destruction. + + * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference + count on the menu shell around the menu item's activation, since the + signal emission may cause menu shell destruction. + + * gtk/gtkitemfactory.c: + the previous code leaked one accel group per menu. we use + gtk_menu_get_uline_accel_group() now to fix that, and with that + also create the underline accelerator group of the menus only if + required (i.e. an underline accelerator has been specified). + (gtk_item_factory_construct): + (gtk_item_factory_create_item): removed code that would create an + extra accel group for the menu (and leak references). + (gtk_item_factory_create_item): adapted the underline accelerator + installation code to properly feature gtk_menu_get_uline_accel_group(). + + * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive + menu->accel_group, this may return NULL if the accelerator group + hasn't been set yet. + added gtk_menu_get_uline_accel_group() to retrive the underline + accelerator group of the menu, this will be created on demand + and proper care is taken about its reference count. + + * gtk/gtkitemfactory.h: + * gtk/gtkitemfactory.c: + dumped the approach of keeping a widgets by action list on the + factory since the factory<->widget destroy negotiation didn't work + and would be hard to get going at all. instead we keep a list of + GtkItemFactoryItem items on the factory (GtkItemFactoryItems are + persistant throughout a program's life time). + also, i removed the static const gchar *key_* variables, and made + them inline strings (they weren't actually used anyways). + (gtk_item_factory_add_item): update ifactory->items. + (gtk_item_factory_destroy): destroy ifactory->items (and remove + the item factory pointer from the remaining ifactory widgets). + (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem + list to find the widget. + (gtk_item_factory_get_item): new function that works around + gtk_item_factory_get_widget() limitations, this function will only + return menu items, even for <Branch> entries. + +Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> + + * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our + font hash table, if we have a GdkFontPrivate entry for this font + already, simply increment its reference count, provided by Olaf Dietsche + <olaf.dietsche+list.gtk@netcologne.de>. + + * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix + provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. + +Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkcontainer.c: + (gtk_container_add_with_args): + (gtk_container_addv): + (gtk_container_add): before adding a child to a conatiner, make sure + it is (default) constructed, this is neccessary because under certain + circumstances the child will get relized and mapped immediatedly, in + which case it has to be constructed already. + +Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> + + * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal + values > 1 as TRUE also. + 1999-03-16 Tor Lillqvist <tml@iki.fi> * README.win32: New file. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 27ac46be89..3e96e67fa9 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,153 @@ +Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> + + * merges from gtk-1-2: + +Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the + item factory class has been created. + (gtk_item_factory_parse_rc): likewise. + + * gtk/gtkmenu.c: + keep proper references for old_active_menu_item. + (gtk_menu_reparent): unset the usize of the new parent, + so the menu can sanely be size requested and we don't get nasty screen + artefacts upon next reparentation. + (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an + enter notify. only synthesize enter notifies if the pointer really is + inside the event window. + (gtk_menu_popdown): use gtk_menu_shell_deselect(). + (gtk_menu_popup): move the background setting stuff into + gtk_menu_tearoff_bg_copy() so it can be called from other places as well. + + * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use + gtk_menu_shell_select_item() to select the new item. + (gtk_menu_shell_deselect): export this function, so gtkmenu.c can + do the right thing for deselection as well. + +Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkwidget.[hc]: + (gtk_widget_accelerators_locked): return whether a widget's accelerators + are locked. + + * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or + existing accelerators if the widget's accelerators are locked. + +Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. + + * gtk/gtkmenu.c: truely forward key press and key release events to + the menu widget from the toplevel or tearoff window. we can't simply + connect to that, we need to stop further processing of the events as + well. + +Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkmenu.c: + (gtk_menu_key_press): pass event->keyval, event->state to + gtk_accelerator_valid, instead of event->keyval twice. + refuse to install single letter accelerators for menus that use + single letter shortcuts. + + * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use + gtk_menu_ensure_uline_accel_group(). + + * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() + which will always return an uline accel group, made + gtk_menu_get_uline_accel_group() return NULL if the group isn't + yet created. + +Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> + + * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. + + * gtk/gtkclist.c (gtk_clist_column_title_passive): + Leave button sensitive, trap button_press, button_release, + motion_notify, enter_notify and leave_notify events instead. + (gtk_clist_column_title_active): disconnect event handler. + (gtk_clist_drag_data_get): fixed memory leak. Reported by + Guillaume Laurent <glaurent@worldnet.fr> + +Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> + + * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few + width/height mixups. + + * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal + if needed. + +Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> + + * gtk/testgtk.c (create_item_factory): unref the item factory after + window's destruction. + + * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference + count on the menu shell around the menu item's activation, since the + signal emission may cause menu shell destruction. + + * gtk/gtkitemfactory.c: + the previous code leaked one accel group per menu. we use + gtk_menu_get_uline_accel_group() now to fix that, and with that + also create the underline accelerator group of the menus only if + required (i.e. an underline accelerator has been specified). + (gtk_item_factory_construct): + (gtk_item_factory_create_item): removed code that would create an + extra accel group for the menu (and leak references). + (gtk_item_factory_create_item): adapted the underline accelerator + installation code to properly feature gtk_menu_get_uline_accel_group(). + + * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive + menu->accel_group, this may return NULL if the accelerator group + hasn't been set yet. + added gtk_menu_get_uline_accel_group() to retrive the underline + accelerator group of the menu, this will be created on demand + and proper care is taken about its reference count. + + * gtk/gtkitemfactory.h: + * gtk/gtkitemfactory.c: + dumped the approach of keeping a widgets by action list on the + factory since the factory<->widget destroy negotiation didn't work + and would be hard to get going at all. instead we keep a list of + GtkItemFactoryItem items on the factory (GtkItemFactoryItems are + persistant throughout a program's life time). + also, i removed the static const gchar *key_* variables, and made + them inline strings (they weren't actually used anyways). + (gtk_item_factory_add_item): update ifactory->items. + (gtk_item_factory_destroy): destroy ifactory->items (and remove + the item factory pointer from the remaining ifactory widgets). + (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem + list to find the widget. + (gtk_item_factory_get_item): new function that works around + gtk_item_factory_get_widget() limitations, this function will only + return menu items, even for <Branch> entries. + +Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> + + * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our + font hash table, if we have a GdkFontPrivate entry for this font + already, simply increment its reference count, provided by Olaf Dietsche + <olaf.dietsche+list.gtk@netcologne.de>. + + * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix + provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. + +Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkcontainer.c: + (gtk_container_add_with_args): + (gtk_container_addv): + (gtk_container_add): before adding a child to a conatiner, make sure + it is (default) constructed, this is neccessary because under certain + circumstances the child will get relized and mapped immediatedly, in + which case it has to be constructed already. + +Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> + + * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal + values > 1 as TRUE also. + 1999-03-16 Tor Lillqvist <tml@iki.fi> * README.win32: New file. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 27ac46be89..3e96e67fa9 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,153 @@ +Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> + + * merges from gtk-1-2: + +Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the + item factory class has been created. + (gtk_item_factory_parse_rc): likewise. + + * gtk/gtkmenu.c: + keep proper references for old_active_menu_item. + (gtk_menu_reparent): unset the usize of the new parent, + so the menu can sanely be size requested and we don't get nasty screen + artefacts upon next reparentation. + (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an + enter notify. only synthesize enter notifies if the pointer really is + inside the event window. + (gtk_menu_popdown): use gtk_menu_shell_deselect(). + (gtk_menu_popup): move the background setting stuff into + gtk_menu_tearoff_bg_copy() so it can be called from other places as well. + + * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use + gtk_menu_shell_select_item() to select the new item. + (gtk_menu_shell_deselect): export this function, so gtkmenu.c can + do the right thing for deselection as well. + +Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkwidget.[hc]: + (gtk_widget_accelerators_locked): return whether a widget's accelerators + are locked. + + * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or + existing accelerators if the widget's accelerators are locked. + +Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. + + * gtk/gtkmenu.c: truely forward key press and key release events to + the menu widget from the toplevel or tearoff window. we can't simply + connect to that, we need to stop further processing of the events as + well. + +Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkmenu.c: + (gtk_menu_key_press): pass event->keyval, event->state to + gtk_accelerator_valid, instead of event->keyval twice. + refuse to install single letter accelerators for menus that use + single letter shortcuts. + + * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use + gtk_menu_ensure_uline_accel_group(). + + * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() + which will always return an uline accel group, made + gtk_menu_get_uline_accel_group() return NULL if the group isn't + yet created. + +Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> + + * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. + + * gtk/gtkclist.c (gtk_clist_column_title_passive): + Leave button sensitive, trap button_press, button_release, + motion_notify, enter_notify and leave_notify events instead. + (gtk_clist_column_title_active): disconnect event handler. + (gtk_clist_drag_data_get): fixed memory leak. Reported by + Guillaume Laurent <glaurent@worldnet.fr> + +Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> + + * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few + width/height mixups. + + * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal + if needed. + +Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> + + * gtk/testgtk.c (create_item_factory): unref the item factory after + window's destruction. + + * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference + count on the menu shell around the menu item's activation, since the + signal emission may cause menu shell destruction. + + * gtk/gtkitemfactory.c: + the previous code leaked one accel group per menu. we use + gtk_menu_get_uline_accel_group() now to fix that, and with that + also create the underline accelerator group of the menus only if + required (i.e. an underline accelerator has been specified). + (gtk_item_factory_construct): + (gtk_item_factory_create_item): removed code that would create an + extra accel group for the menu (and leak references). + (gtk_item_factory_create_item): adapted the underline accelerator + installation code to properly feature gtk_menu_get_uline_accel_group(). + + * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive + menu->accel_group, this may return NULL if the accelerator group + hasn't been set yet. + added gtk_menu_get_uline_accel_group() to retrive the underline + accelerator group of the menu, this will be created on demand + and proper care is taken about its reference count. + + * gtk/gtkitemfactory.h: + * gtk/gtkitemfactory.c: + dumped the approach of keeping a widgets by action list on the + factory since the factory<->widget destroy negotiation didn't work + and would be hard to get going at all. instead we keep a list of + GtkItemFactoryItem items on the factory (GtkItemFactoryItems are + persistant throughout a program's life time). + also, i removed the static const gchar *key_* variables, and made + them inline strings (they weren't actually used anyways). + (gtk_item_factory_add_item): update ifactory->items. + (gtk_item_factory_destroy): destroy ifactory->items (and remove + the item factory pointer from the remaining ifactory widgets). + (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem + list to find the widget. + (gtk_item_factory_get_item): new function that works around + gtk_item_factory_get_widget() limitations, this function will only + return menu items, even for <Branch> entries. + +Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> + + * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our + font hash table, if we have a GdkFontPrivate entry for this font + already, simply increment its reference count, provided by Olaf Dietsche + <olaf.dietsche+list.gtk@netcologne.de>. + + * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix + provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. + +Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> + + * gtk/gtkcontainer.c: + (gtk_container_add_with_args): + (gtk_container_addv): + (gtk_container_add): before adding a child to a conatiner, make sure + it is (default) constructed, this is neccessary because under certain + circumstances the child will get relized and mapped immediatedly, in + which case it has to be constructed already. + +Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> + + * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal + values > 1 as TRUE also. + 1999-03-16 Tor Lillqvist <tml@iki.fi> * README.win32: New file. diff --git a/gtk/gtkclist.c b/gtk/gtkclist.c index 7fb73b7fad..5744748375 100644 --- a/gtk/gtkclist.c +++ b/gtk/gtkclist.c @@ -39,7 +39,7 @@ #define MAX_BUTTON 5 /* the number rows memchunk expands at a time */ -#define CLIST_OPTIMUM_SIZE 512 +#define CLIST_OPTIMUM_SIZE 64 /* the width of the column resize windows */ #define DRAG_WIDTH 6 @@ -438,11 +438,14 @@ static GList *gtk_clist_mergesort (GtkCList *clist, GList *list, gint num); /* Misc */ -static gboolean title_focus (GtkCList *clist, - gint dir); -static void real_row_move (GtkCList *clist, - gint source_row, - gint dest_row); +static gboolean title_focus (GtkCList *clist, + gint dir); +static void real_row_move (GtkCList *clist, + gint source_row, + gint dest_row); +static gint column_title_passive_func (GtkWidget *widget, + GdkEvent *event, + gpointer data); @@ -1291,44 +1294,110 @@ void gtk_clist_column_title_active (GtkCList *clist, gint column) { + GtkObject *object; + g_return_if_fail (clist != NULL); g_return_if_fail (GTK_IS_CLIST (clist)); if (column < 0 || column >= clist->columns) return; - if (!clist->column[column].button) + if (!clist->column[column].button || !clist->column[column].button_passive) return; - if (!GTK_WIDGET_SENSITIVE (clist->column[column].button) || - !GTK_WIDGET_CAN_FOCUS (clist->column[column].button)) - { - GTK_WIDGET_SET_FLAGS (clist->column[column].button, - GTK_SENSITIVE | GTK_CAN_FOCUS); - if (GTK_WIDGET_VISIBLE (clist)) - gtk_widget_queue_draw (clist->column[column].button); - } + object = GTK_OBJECT (clist->column[column].button); + + clist->column[column].button_passive = FALSE; + + gtk_signal_disconnect_by_func (object, + (GtkSignalFunc) column_title_passive_func, + GINT_TO_POINTER (gtk_signal_lookup + ("button_press_event", + GTK_TYPE_WIDGET))); + gtk_signal_disconnect_by_func (object, + (GtkSignalFunc) column_title_passive_func, + GINT_TO_POINTER (gtk_signal_lookup + ("button_release_event", + GTK_TYPE_WIDGET))); + gtk_signal_disconnect_by_func (object, + (GtkSignalFunc) column_title_passive_func, + GINT_TO_POINTER (gtk_signal_lookup + ("motion_notify_event", + GTK_TYPE_WIDGET))); + gtk_signal_disconnect_by_func (object, + (GtkSignalFunc) column_title_passive_func, + GINT_TO_POINTER (gtk_signal_lookup + ("enter_notify_event", + GTK_TYPE_WIDGET))); + gtk_signal_disconnect_by_func (object, + (GtkSignalFunc) column_title_passive_func, + GINT_TO_POINTER (gtk_signal_lookup + ("leave_notify_event", + GTK_TYPE_WIDGET))); + + GTK_WIDGET_SET_FLAGS (clist->column[column].button, GTK_CAN_FOCUS); + if (GTK_WIDGET_VISIBLE (clist)) + gtk_widget_queue_draw (clist->column[column].button); } void gtk_clist_column_title_passive (GtkCList *clist, gint column) { + GtkObject *object; + GtkButton *button; + g_return_if_fail (clist != NULL); g_return_if_fail (GTK_IS_CLIST (clist)); if (column < 0 || column >= clist->columns) return; - if (!clist->column[column].button) + if (!clist->column[column].button || clist->column[column].button_passive) return; - if (GTK_WIDGET_SENSITIVE (clist->column[column].button) || - GTK_WIDGET_CAN_FOCUS (clist->column[column].button)) - { - GTK_WIDGET_UNSET_FLAGS (clist->column[column].button, - GTK_SENSITIVE | GTK_CAN_FOCUS); - if (GTK_WIDGET_VISIBLE (clist)) - gtk_widget_queue_draw (clist->column[column].button); - } + object = GTK_OBJECT (clist->column[column].button); + button = GTK_BUTTON (clist->column[column].button); + + clist->column[column].button_passive = TRUE; + + + + gtk_signal_connect (object, "button_press_event", + (GtkSignalFunc) column_title_passive_func, + GINT_TO_POINTER (gtk_signal_lookup + ("button_press_event", + GTK_TYPE_WIDGET))); + + if (button->button_down) + gtk_button_released (button); + + gtk_signal_connect (object, "button_release_event", + (GtkSignalFunc) column_title_passive_func, + GINT_TO_POINTER (gtk_signal_lookup + ("button_release_event", + GTK_TYPE_WIDGET))); + gtk_signal_connect (object, "motion_notify_event", + (GtkSignalFunc) column_title_passive_func, + GINT_TO_POINTER (gtk_signal_lookup + ("motion_notify_event", + GTK_TYPE_WIDGET))); + gtk_signal_connect (object, "enter_notify_event", + (GtkSignalFunc) column_title_passive_func, + GINT_TO_POINTER (gtk_signal_lookup + ("enter_notify_event", + GTK_TYPE_WIDGET))); + + if (button->in_button) + gtk_button_leave (button); + + gtk_signal_connect (object, "leave_notify_event", + (GtkSignalFunc) column_title_passive_func, + GINT_TO_POINTER (gtk_signal_lookup + ("leave_notify_event", + GTK_TYPE_WIDGET))); + + GTK_WIDGET_UNSET_FLAGS (clist->column[column].button, GTK_CAN_FOCUS); + if (GTK_WIDGET_VISIBLE (clist)) + gtk_widget_queue_draw (clist->column[column].button); } void @@ -1764,6 +1833,7 @@ gtk_clist_set_column_max_width (GtkCList *clist, * new_column_width * column_button_create * column_button_clicked + * column_title_passive_func */ static void column_auto_resize (GtkCList *clist, @@ -2103,84 +2173,15 @@ column_button_clicked (GtkWidget *widget, gtk_signal_emit (GTK_OBJECT (clist), clist_signals[CLICK_COLUMN], i); } -void -gtk_clist_set_row_height (GtkCList *clist, - guint height) +static gint +column_title_passive_func (GtkWidget *widget, + GdkEvent *event, + gpointer data) { - GtkWidget *widget; - - g_return_if_fail (clist != NULL); - g_return_if_fail (GTK_IS_CLIST (clist)); - - widget = GTK_WIDGET (clist); - - if (height > 0) - { - clist->row_height = height; - GTK_CLIST_SET_FLAG (clist, CLIST_ROW_HEIGHT_SET); - } - else - { - GTK_CLIST_UNSET_FLAG (clist, CLIST_ROW_HEIGHT_SET); - clist->row_height = 0; - } - - if (GTK_WIDGET_REALIZED (clist)) - { - if (!GTK_CLIST_ROW_HEIGHT_SET(clist)) - { - clist->row_height = (widget->style->font->ascent + - widget->style->font->descent + 1); - clist->row_center_offset = widget->style->font->ascent + 1.5; - } - else - clist->row_center_offset = 1.5 + (clist->row_height + - widget->style->font->ascent - - widget->style->font->descent - 1) / 2; - } - - CLIST_REFRESH (clist); + gtk_signal_emit_stop (GTK_OBJECT (widget), GPOINTER_TO_INT (data)); + return FALSE; } -void -gtk_clist_moveto (GtkCList *clist, - gint row, - gint column, - gfloat row_align, - gfloat col_align) -{ - g_return_if_fail (clist != NULL); - g_return_if_fail (GTK_IS_CLIST (clist)); - - if (row < -1 || row >= clist->rows) - return; - if (column < -1 || column >= clist->columns) - return; - - row_align = CLAMP (row_align, 0, 1); - col_align = CLAMP (col_align, 0, 1); - - /* adjust horizontal scrollbar */ - if (clist->hadjustment && column >= 0) - { - gint x; - - x = (COLUMN_LEFT (clist, column) - CELL_SPACING - COLUMN_INSET - - (col_align * (clist->clist_window_width - 2 * COLUMN_INSET - - CELL_SPACING - clist->column[column].area.width))); - if (x < 0) - gtk_adjustment_set_value (clist->hadjustment, 0.0); - else if (x > LIST_WIDTH (clist) - clist->clist_window_width) - gtk_adjustment_set_value - (clist->hadjustment, LIST_WIDTH (clist) - clist->clist_window_width); - else - gtk_adjustment_set_value (clist->hadjustment, x); - } - - /* adjust vertical scrollbar */ - if (clist->vadjustment && row >= 0) - move_vertical (clist, row, row_align); -} /* PUBLIC CELL FUNCTIONS * gtk_clist_get_cell_type @@ -2934,6 +2935,8 @@ real_row_move (GtkCList *clist, } /* PUBLIC ROW FUNCTIONS + * gtk_clist_moveto + * gtk_clist_set_row_height * gtk_clist_set_row_data * gtk_clist_set_row_data_full * gtk_clist_get_row_data @@ -2945,6 +2948,85 @@ real_row_move (GtkCList *clist, * gtk_clist_set_background */ void +gtk_clist_moveto (GtkCList *clist, + gint row, + gint column, + gfloat row_align, + gfloat col_align) +{ + g_return_if_fail (clist != NULL); + g_return_if_fail (GTK_IS_CLIST (clist)); + + if (row < -1 || row >= clist->rows) + return; + if (column < -1 || column >= clist->columns) + return; + + row_align = CLAMP (row_align, 0, 1); + col_align = CLAMP (col_align, 0, 1); + + /* adjust horizontal scrollbar */ + if (clist->hadjustment && column >= 0) + { + gint x; + + x = (COLUMN_LEFT (clist, column) - CELL_SPACING - COLUMN_INSET - + (col_align * (clist->clist_window_width - 2 * COLUMN_INSET - + CELL_SPACING - clist->column[column].area.width))); + if (x < 0) + gtk_adjustment_set_value (clist->hadjustment, 0.0); + else if (x > LIST_WIDTH (clist) - clist->clist_window_width) + gtk_adjustment_set_value + (clist->hadjustment, LIST_WIDTH (clist) - clist->clist_window_width); + else + gtk_adjustment_set_value (clist->hadjustment, x); + } + + /* adjust vertical scrollbar */ + if (clist->vadjustment && row >= 0) + move_vertical (clist, row, row_align); +} + +void +gtk_clist_set_row_height (GtkCList *clist, + guint height) +{ + GtkWidget *widget; + + g_return_if_fail (clist != NULL); + g_return_if_fail (GTK_IS_CLIST (clist)); + + widget = GTK_WIDGET (clist); + + if (height > 0) + { + clist->row_height = height; + GTK_CLIST_SET_FLAG (clist, CLIST_ROW_HEIGHT_SET); + } + else + { + GTK_CLIST_UNSET_FLAG (clist, CLIST_ROW_HEIGHT_SET); + clist->row_height = 0; + } + + if (GTK_WIDGET_REALIZED (clist)) + { + if (!GTK_CLIST_ROW_HEIGHT_SET(clist)) + { + clist->row_height = (widget->style->font->ascent + + widget->style->font->descent + 1); + clist->row_center_offset = widget->style->font->ascent + 1.5; + } + else + clist->row_center_offset = 1.5 + (clist->row_height + + widget->style->font->ascent - + widget->style->font->descent - 1) / 2; + } + + CLIST_REFRESH (clist); +} + +void gtk_clist_set_row_data (GtkCList *clist, gint row, gpointer data) @@ -6356,6 +6438,7 @@ columns_new (GtkCList *clist) column[i].width_set = FALSE; column[i].resizeable = TRUE; column[i].auto_resize = FALSE; + column[i].button_passive = FALSE; column[i].justification = GTK_JUSTIFY_LEFT; } @@ -7708,21 +7791,18 @@ gtk_clist_drag_data_get (GtkWidget *widget, if (info) { - GtkCListCellInfo *ret_info; + GtkCListCellInfo ret_info; - ret_info = g_new (GtkCListCellInfo, 1); - ret_info->row = info->row; - ret_info->column = info->column; + ret_info.row = info->row; + ret_info.column = info->column; - gtk_selection_data_set (selection_data, - selection_data->target, - GTK_TYPE_POINTER, - (guchar *) ret_info, + gtk_selection_data_set (selection_data, selection_data->target, + GTK_TYPE_POINTER, (guchar *) &ret_info, sizeof (GtkCListCellInfo)); } else gtk_selection_data_set (selection_data, selection_data->target, - GTK_TYPE_POINTER, NULL, 0); + GTK_TYPE_POINTER, NULL, 0); } } diff --git a/gtk/gtkclist.h b/gtk/gtkclist.h index acf3c39f48..4a93988e3a 100644 --- a/gtk/gtkclist.h +++ b/gtk/gtkclist.h @@ -330,10 +330,11 @@ struct _GtkCListColumn gint max_width; GtkJustification justification; - guint visible : 1; - guint width_set : 1; - guint resizeable : 1; - guint auto_resize : 1; + guint visible : 1; + guint width_set : 1; + guint resizeable : 1; + guint auto_resize : 1; + guint button_passive : 1; }; struct _GtkCListRow diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index 205baeef07..e8220845db 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -264,6 +264,8 @@ gtk_container_add_with_args (GtkContainer *container, gtk_widget_ref (GTK_WIDGET (container)); gtk_widget_ref (widget); + if (!GTK_OBJECT_CONSTRUCTED (widget)) + gtk_object_default_construct (GTK_OBJECT (widget)); gtk_signal_emit (GTK_OBJECT (container), container_signals[ADD], widget); if (widget->parent) @@ -322,6 +324,8 @@ gtk_container_addv (GtkContainer *container, gtk_widget_ref (GTK_WIDGET (container)); gtk_widget_ref (widget); + if (!GTK_OBJECT_CONSTRUCTED (widget)) + gtk_object_default_construct (GTK_OBJECT (widget)); gtk_signal_emit (GTK_OBJECT (container), container_signals[ADD], widget); if (widget->parent) @@ -703,6 +707,8 @@ gtk_container_add (GtkContainer *container, g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (widget->parent == NULL); + if (!GTK_OBJECT_CONSTRUCTED (widget)) + gtk_object_default_construct (GTK_OBJECT (widget)); gtk_signal_emit (GTK_OBJECT (container), container_signals[ADD], widget); } diff --git a/gtk/gtkctree.c b/gtk/gtkctree.c index 11a7c3561d..007913a377 100644 --- a/gtk/gtkctree.c +++ b/gtk/gtkctree.c @@ -3065,24 +3065,7 @@ tree_delete (GtkCTree *ctree, GtkCTreeNode *node, gpointer data) { - GtkCList *clist; - - clist = GTK_CLIST (ctree); - - if (GTK_CTREE_ROW (node)->row.state == GTK_STATE_SELECTED) - { - GList *work; - - work = g_list_find (clist->selection, node); - if (work) - { - if (clist->selection_end && clist->selection_end == work) - clist->selection_end = clist->selection_end->prev; - clist->selection = g_list_remove_link (clist->selection, work); - g_list_free_1 (work); - } - } - + tree_unselect (ctree, node, NULL); row_delete (ctree, GTK_CTREE_ROW (node)); g_list_free_1 ((GList *)node); } diff --git a/gtk/gtkfeatures.h.in b/gtk/gtkfeatures.h.in index 34ffbf37c4..9fee280166 100644 --- a/gtk/gtkfeatures.h.in +++ b/gtk/gtkfeatures.h.in @@ -32,6 +32,12 @@ extern "C" { #define GTK_MICRO_VERSION (@GTK_MICRO_VERSION@) #define GTK_BINARY_AGE (@GTK_BINARY_AGE@) #define GTK_INTERFACE_AGE (@GTK_INTERFACE_AGE@) +#define GTK_CHECK_VERSION(major,minor,micro) \ + (GTK_MAJOR_VERSION > (major) || \ + (GTK_MAJOR_VERSION == (major) && GTK_MINOR_VERSION > (minor)) || \ + (GTK_MAJOR_VERSION == (major) && GTK_MINOR_VERSION == (minor) && \ + GTK_MICRO_VERSION >= (micro))) + /* new gtk_container_set_focus_[hv]adjustment() */ diff --git a/gtk/gtkitemfactory.c b/gtk/gtkitemfactory.c index a4fe946063..b0f2306af0 100644 --- a/gtk/gtkitemfactory.c +++ b/gtk/gtkitemfactory.c @@ -64,7 +64,6 @@ /* --- structures --- */ typedef struct _GtkIFCBData GtkIFCBData; -typedef struct _GtkIFActionLink GtkIFActionLink; typedef struct _GtkIFDumpData GtkIFDumpData; struct _GtkIFCBData { @@ -73,11 +72,6 @@ struct _GtkIFCBData gpointer func_data; guint callback_action; }; -struct _GtkIFActionLink -{ - GtkWidget *widget; - guint callback_action; -}; struct _GtkIFDumpData { GtkPrintFunc print_func; @@ -100,31 +94,20 @@ static GtkObjectClass *parent_class = NULL; static const gchar *item_factory_string = "Gtk-<ItemFactory>"; static GMemChunk *ifactory_item_chunks = NULL; static GMemChunk *ifactory_cb_data_chunks = NULL; -static const gchar *key_popup_data = "GtkItemFactory-popup-data"; static GQuark quark_popup_data = 0; -static const gchar *key_if_menu_pos = "GtkItemFactory-menu-position"; static GQuark quark_if_menu_pos = 0; -static const gchar *key_item_factory = "GtkItemFactory"; static GQuark quark_item_factory = 0; -static const gchar *key_item_factory_path = "GtkItemFactory-path"; -static GQuark quark_item_factory_path = 0; -static const gchar *key_type_item = "<Item>"; +static GQuark quark_item_path = 0; +static GQuark quark_action = 0; +static GQuark quark_accel_group = 0; static GQuark quark_type_item = 0; -static const gchar *key_type_title = "<Title>"; static GQuark quark_type_title = 0; -static const gchar *key_type_radio_item = "<RadioItem>"; static GQuark quark_type_radio_item = 0; -static const gchar *key_type_check_item = "<CheckItem>"; static GQuark quark_type_check_item = 0; -static const gchar *key_type_toggle_item = "<ToggleItem>"; static GQuark quark_type_toggle_item = 0; -static const gchar *key_type_tearoff_item = "<Tearoff>"; static GQuark quark_type_tearoff_item = 0; -static const gchar *key_type_separator_item = "<Separator>"; static GQuark quark_type_separator_item = 0; -static const gchar *key_type_branch = "<Branch>"; static GQuark quark_type_branch = 0; -static const gchar *key_type_last_branch = "<LastBranch>"; static GQuark quark_type_last_branch = 0; static GScannerConfig ifactory_scanner_config = { @@ -212,6 +195,7 @@ gtk_item_factory_class_init (GtkItemFactoryClass *class) class->cpair_comment_single = g_strdup (";\n"); class->item_ht = g_hash_table_new (g_str_hash, g_str_equal); + class->dummy = NULL; ifactory_item_chunks = g_mem_chunk_new ("GtkItemFactoryItem", sizeof (GtkItemFactoryItem), @@ -223,19 +207,21 @@ gtk_item_factory_class_init (GtkItemFactoryClass *class) sizeof (GtkIFCBData) * ITEM_BLOCK_SIZE, G_ALLOC_AND_FREE); - quark_popup_data = g_quark_from_static_string (key_popup_data); - quark_if_menu_pos = g_quark_from_static_string (key_if_menu_pos); - quark_item_factory = g_quark_from_static_string (key_item_factory); - quark_item_factory_path = g_quark_from_static_string (key_item_factory_path); - quark_type_item = g_quark_from_static_string (key_type_item); - quark_type_title = g_quark_from_static_string (key_type_title); - quark_type_radio_item = g_quark_from_static_string (key_type_radio_item); - quark_type_check_item = g_quark_from_static_string (key_type_check_item); - quark_type_toggle_item = g_quark_from_static_string (key_type_toggle_item); - quark_type_tearoff_item = g_quark_from_static_string (key_type_tearoff_item); - quark_type_separator_item = g_quark_from_static_string (key_type_separator_item); - quark_type_branch = g_quark_from_static_string (key_type_branch); - quark_type_last_branch = g_quark_from_static_string (key_type_last_branch); + quark_popup_data = g_quark_from_static_string ("GtkItemFactory-popup-data"); + quark_if_menu_pos = g_quark_from_static_string ("GtkItemFactory-menu-position"); + quark_item_factory = g_quark_from_static_string ("GtkItemFactory"); + quark_item_path = g_quark_from_static_string ("GtkItemFactory-path"); + quark_action = g_quark_from_static_string ("GtkItemFactory-action"); + quark_accel_group = g_quark_from_static_string ("GtkAccelGroup"); + quark_type_item = g_quark_from_static_string ("<Item>"); + quark_type_title = g_quark_from_static_string ("<Title>"); + quark_type_radio_item = g_quark_from_static_string ("<RadioItem>"); + quark_type_check_item = g_quark_from_static_string ("<CheckItem>"); + quark_type_toggle_item = g_quark_from_static_string ("<ToggleItem>"); + quark_type_tearoff_item = g_quark_from_static_string ("<Tearoff>"); + quark_type_separator_item = g_quark_from_static_string ("<Separator>"); + quark_type_branch = g_quark_from_static_string ("<Branch>"); + quark_type_last_branch = g_quark_from_static_string ("<LastBranch>"); } static void @@ -248,7 +234,7 @@ gtk_item_factory_init (GtkItemFactory *ifactory) ifactory->path = NULL; ifactory->accel_group = NULL; ifactory->widget = NULL; - ifactory->widgets_by_action = NULL; + ifactory->items = NULL; } GtkItemFactory* @@ -315,50 +301,48 @@ gtk_item_factory_propagate_accelerator (GtkItemFactoryItem *item, for (slist = widget_list; slist; slist = slist->next) { GtkWidget *widget; - GtkItemFactory *ifactory; + GtkAccelGroup *accel_group; + guint signal_id; widget = slist->data; - ifactory = gtk_item_factory_from_widget (widget); + accel_group = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_accel_group); - if (ifactory) + signal_id = gtk_signal_lookup ("activate", GTK_OBJECT_TYPE (widget)); + if (signal_id && accel_group) { - guint signal_id; - - signal_id = gtk_signal_lookup ("activate", GTK_OBJECT_TYPE (widget)); - if (signal_id) + if (item->accelerator_key) + gtk_widget_add_accelerator (widget, + "activate", + accel_group, + item->accelerator_key, + item->accelerator_mods, + GTK_ACCEL_VISIBLE); + else { - if (item->accelerator_key) - gtk_widget_add_accelerator (widget, - "activate", - ifactory->accel_group, - item->accelerator_key, - item->accelerator_mods, - GTK_ACCEL_VISIBLE); - else + GSList *work; + + work = gtk_accel_group_entries_from_object (GTK_OBJECT (widget)); + while (work) { - GSList *work; + GtkAccelEntry *ac_entry; - work = gtk_accel_group_entries_from_object (GTK_OBJECT (widget)); - while (work) - { - GtkAccelEntry *ac_entry; - - ac_entry = work->data; - work = work->next; - if (ac_entry->accel_flags & GTK_ACCEL_VISIBLE && - ac_entry->accel_group == ifactory->accel_group && - ac_entry->signal_id == signal_id) - gtk_widget_remove_accelerator (GTK_WIDGET (widget), - ac_entry->accel_group, - ac_entry->accelerator_key, - ac_entry->accelerator_mods); - } + ac_entry = work->data; + work = work->next; + if (ac_entry->accel_flags & GTK_ACCEL_VISIBLE && + ac_entry->accel_group == accel_group && + ac_entry->signal_id == signal_id) + gtk_widget_remove_accelerator (GTK_WIDGET (widget), + ac_entry->accel_group, + ac_entry->accelerator_key, + ac_entry->accelerator_mods); } } } + gtk_widget_unref (widget); } + g_slist_free (widget_list); item->in_propagation = FALSE; @@ -413,134 +397,123 @@ gtk_item_factory_item_remove_widget (GtkWidget *widget, { item->widgets = g_slist_remove (item->widgets, widget); gtk_object_remove_data_by_id (GTK_OBJECT (widget), quark_item_factory); - gtk_object_remove_data_by_id (GTK_OBJECT (widget), quark_item_factory_path); -} - -static void -ifactory_cb_data_free (gpointer mem) -{ - g_mem_chunk_free (ifactory_cb_data_chunks, mem); + gtk_object_remove_data_by_id (GTK_OBJECT (widget), quark_item_path); } -static void -gtk_item_factory_add_item (GtkItemFactory *ifactory, - const gchar *path, - const gchar *accelerator, - GtkItemFactoryCallback callback, - guint callback_action, - gpointer callback_data, - guint callback_type, - gchar *item_type, - GtkWidget *widget) +void +gtk_item_factory_add_foreign (GtkWidget *accel_widget, + const gchar *full_path, + GtkAccelGroup *accel_group, + guint keyval, + GdkModifierType modifiers) { GtkItemFactoryClass *class; GtkItemFactoryItem *item; - gchar *fpath; - - g_return_if_fail (widget != NULL); - g_return_if_fail (item_type != NULL); - class = GTK_ITEM_FACTORY_CLASS (GTK_OBJECT (ifactory)->klass); + g_return_if_fail (GTK_IS_WIDGET (accel_widget)); + g_return_if_fail (full_path != NULL); - fpath = g_strconcat (ifactory->path, path, NULL); - item = g_hash_table_lookup (class->item_ht, fpath); + class = gtk_type_class (GTK_TYPE_ITEM_FACTORY); - /* link the widget into its item-entry - */ + keyval = keyval != GDK_VoidSymbol ? keyval : 0; + + item = g_hash_table_lookup (class->item_ht, full_path); if (!item) { - guint keyval; - guint mods; - - if (accelerator) - gtk_accelerator_parse (accelerator, &keyval, &mods); - else - { - keyval = 0; - mods = 0; - } - item = g_chunk_new (GtkItemFactoryItem, ifactory_item_chunks); - item->path = fpath; - fpath = NULL; + item->path = g_strdup (full_path); item->accelerator_key = keyval; - item->accelerator_mods = mods; + item->accelerator_mods = modifiers; item->modified = FALSE; item->in_propagation = FALSE; - item->item_type = NULL; + item->dummy = NULL; item->widgets = NULL; g_hash_table_insert (class->item_ht, item->path, item); } - g_free (fpath); - - if (item->item_type == NULL) - { - g_assert (item->widgets == NULL); - - if (item_type != ITEM_FACTORY_STRING) - item->item_type = g_strdup (item_type); - else - item->item_type = ITEM_FACTORY_STRING; - } - item->widgets = g_slist_prepend (item->widgets, widget); - gtk_signal_connect (GTK_OBJECT (widget), + item->widgets = g_slist_prepend (item->widgets, accel_widget); + gtk_signal_connect (GTK_OBJECT (accel_widget), "destroy", GTK_SIGNAL_FUNC (gtk_item_factory_item_remove_widget), item); - /* set back pointers for the widget - */ - gtk_object_set_data_by_id (GTK_OBJECT (widget), quark_item_factory, ifactory); - gtk_object_set_data_by_id (GTK_OBJECT (widget), quark_item_factory_path, item->path); - gtk_widget_set_name (widget, item->path); - - /* set accelerator group on menu widgets + /* set the item path for the widget */ - if (GTK_IS_MENU (widget)) - gtk_menu_set_accel_group ((GtkMenu*) widget, ifactory->accel_group); + gtk_object_set_data_by_id (GTK_OBJECT (accel_widget), quark_item_path, item->path); + gtk_widget_set_name (accel_widget, item->path); + if (accel_group) + { + gtk_accel_group_ref (accel_group); + gtk_object_set_data_by_id_full (GTK_OBJECT (accel_widget), + quark_accel_group, + accel_group, + (GtkDestroyNotify) gtk_accel_group_unref); + } + else + gtk_object_set_data_by_id (GTK_OBJECT (accel_widget), quark_accel_group, NULL); /* install defined accelerators */ - if (gtk_signal_lookup ("activate", GTK_OBJECT_TYPE (widget))) + if (gtk_signal_lookup ("activate", GTK_OBJECT_TYPE (accel_widget))) { - if (item->accelerator_key) - gtk_widget_add_accelerator (widget, + if (item->accelerator_key && accel_group) + gtk_widget_add_accelerator (accel_widget, "activate", - ifactory->accel_group, + accel_group, item->accelerator_key, item->accelerator_mods, GTK_ACCEL_VISIBLE); else - gtk_widget_remove_accelerators (widget, + gtk_widget_remove_accelerators (accel_widget, "activate", TRUE); } /* keep track of accelerator changes */ - gtk_signal_connect_after (GTK_OBJECT (widget), + gtk_signal_connect_after (GTK_OBJECT (accel_widget), "add-accelerator", GTK_SIGNAL_FUNC (gtk_item_factory_item_add_accelerator), item); - gtk_signal_connect_after (GTK_OBJECT (widget), + gtk_signal_connect_after (GTK_OBJECT (accel_widget), "remove-accelerator", GTK_SIGNAL_FUNC (gtk_item_factory_item_remove_accelerator), item); +} - /* keep a per-action list of the widgets on the factory - */ - if (callback) - { - GtkIFActionLink *link; +static void +ifactory_cb_data_free (gpointer mem) +{ + g_mem_chunk_free (ifactory_cb_data_chunks, mem); +} - link = g_new (GtkIFActionLink, 1); - link->widget = widget; - link->callback_action = callback_action; - ifactory->widgets_by_action = g_slist_prepend (ifactory->widgets_by_action, link); - } +static void +gtk_item_factory_add_item (GtkItemFactory *ifactory, + const gchar *path, + const gchar *accelerator, + GtkItemFactoryCallback callback, + guint callback_action, + gpointer callback_data, + guint callback_type, + gchar *item_type, + GtkWidget *widget) +{ + GtkItemFactoryClass *class; + GtkItemFactoryItem *item; + gchar *fpath; + guint keyval, mods; + + g_return_if_fail (widget != NULL); + g_return_if_fail (item_type != NULL); + + class = GTK_ITEM_FACTORY_CLASS (GTK_OBJECT (ifactory)->klass); + + /* set accelerator group on menu widgets + */ + if (GTK_IS_MENU (widget)) + gtk_menu_set_accel_group ((GtkMenu*) widget, ifactory->accel_group); /* connect callback if neccessary */ @@ -562,6 +535,28 @@ gtk_item_factory_add_item (GtkItemFactory *ifactory, GTK_SIGNAL_FUNC (gtk_item_factory_callback_marshal), data); } + + /* link the widget into its item-entry + * and keep back pointer on both the item factory and the widget + */ + gtk_object_set_data_by_id (GTK_OBJECT (widget), quark_action, GUINT_TO_POINTER (callback_action)); + gtk_object_set_data_by_id (GTK_OBJECT (widget), quark_item_factory, ifactory); + if (accelerator) + gtk_accelerator_parse (accelerator, &keyval, &mods); + else + { + keyval = 0; + mods = 0; + } + fpath = g_strconcat (ifactory->path, path, NULL); + gtk_item_factory_add_foreign (widget, fpath, ifactory->accel_group, keyval, mods); + item = g_hash_table_lookup (class->item_ht, fpath); + g_free (fpath); + + g_return_if_fail (item != NULL); + + if (!g_slist_find (ifactory->items, item)) + ifactory->items = g_slist_prepend (ifactory->items, item); } void @@ -570,7 +565,6 @@ gtk_item_factory_construct (GtkItemFactory *ifactory, const gchar *path, GtkAccelGroup *accel_group) { - GtkAccelGroup *menu_group; guint len; g_return_if_fail (ifactory != NULL); @@ -604,15 +598,6 @@ gtk_item_factory_construct (GtkItemFactory *ifactory, gtk_object_ref (GTK_OBJECT (ifactory)); gtk_object_sink (GTK_OBJECT (ifactory)); - menu_group = gtk_accel_group_new (); - gtk_accel_group_attach (menu_group, GTK_OBJECT (ifactory->widget)); - - /* - gtk_signal_connect_object_while_alive (GTK_OBJECT (ifactory->widget), - "destroy", - GTK_SIGNAL_FUNC (gtk_object_destroy), - GTK_OBJECT (ifactory)); - */ gtk_item_factory_add_item (ifactory, "", NULL, NULL, 0, NULL, 0, @@ -681,10 +666,17 @@ gtk_item_factory_destroy (GtkObject *object) ifactory->widget = NULL; } - for (slist = ifactory->widgets_by_action; slist; slist = slist->next) - g_free (slist->data); - g_slist_free (ifactory->widgets_by_action); - ifactory->widgets_by_action = NULL; + for (slist = ifactory->items; slist; slist = slist->next) + { + GtkItemFactoryItem *item = slist->data; + GSList *link; + + for (link = item->widgets; link; link = link->next) + if (gtk_object_get_data_by_id (link->data, quark_item_factory)) + gtk_object_remove_data_by_id (link->data, quark_item_factory); + } + g_slist_free (ifactory->items); + ifactory->items = NULL; parent_class->destroy (object); } @@ -724,7 +716,7 @@ gtk_item_factory_path_from_widget (GtkWidget *widget) g_return_val_if_fail (widget != NULL, NULL); g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); - return gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_item_factory_path); + return gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_item_path); } static void @@ -824,20 +816,20 @@ gtk_item_factory_dump_rc (const gchar *file_name, } void -gtk_item_factory_create_items (GtkItemFactory *ifactory, - guint n_entries, - GtkItemFactoryEntry *entries, - gpointer callback_data) +gtk_item_factory_create_items (GtkItemFactory *ifactory, + guint n_entries, + GtkItemFactoryEntry *entries, + gpointer callback_data) { gtk_item_factory_create_items_ac (ifactory, n_entries, entries, callback_data, 1); } void -gtk_item_factory_create_items_ac (GtkItemFactory *ifactory, - guint n_entries, - GtkItemFactoryEntry *entries, - gpointer callback_data, - guint callback_type) +gtk_item_factory_create_items_ac (GtkItemFactory *ifactory, + guint n_entries, + GtkItemFactoryEntry *entries, + gpointer callback_data, + guint callback_type) { guint i; @@ -855,13 +847,12 @@ gtk_item_factory_create_items_ac (GtkItemFactory *ifactory, } GtkWidget* -gtk_item_factory_get_widget (GtkItemFactory *ifactory, - const gchar *path) +gtk_item_factory_get_widget (GtkItemFactory *ifactory, + const gchar *path) { GtkItemFactoryClass *class; GtkItemFactoryItem *item; - g_return_val_if_fail (ifactory != NULL, NULL); g_return_val_if_fail (GTK_IS_ITEM_FACTORY (ifactory), NULL); g_return_val_if_fail (path != NULL, NULL); @@ -893,27 +884,60 @@ gtk_item_factory_get_widget (GtkItemFactory *ifactory, } GtkWidget* -gtk_item_factory_get_widget_by_action (GtkItemFactory *ifactory, - guint action) +gtk_item_factory_get_widget_by_action (GtkItemFactory *ifactory, + guint action) { GSList *slist; - g_return_val_if_fail (ifactory != NULL, NULL); g_return_val_if_fail (GTK_IS_ITEM_FACTORY (ifactory), NULL); - for (slist = ifactory->widgets_by_action; slist; slist = slist->next) + for (slist = ifactory->items; slist; slist = slist->next) { - GtkIFActionLink *link; - - link = slist->data; + GtkItemFactoryItem *item = slist->data; + GSList *link; - if (link->callback_action == action) - return link->widget; + for (link = item->widgets; link; link = link->next) + if (gtk_object_get_data_by_id (link->data, quark_item_factory) == ifactory && + gtk_object_get_data_by_id (link->data, quark_action) == GUINT_TO_POINTER (action)) + return link->data; } return NULL; } +GtkWidget* +gtk_item_factory_get_item (GtkItemFactory *ifactory, + const gchar *path) +{ + GtkWidget *widget; + + g_return_val_if_fail (GTK_IS_ITEM_FACTORY (ifactory), NULL); + g_return_val_if_fail (path != NULL, NULL); + + widget = gtk_item_factory_get_widget (ifactory, path); + + if (GTK_IS_MENU (widget)) + widget = gtk_menu_get_attach_widget (GTK_MENU (widget)); + + return GTK_IS_ITEM (widget) ? widget : NULL; +} + +GtkWidget* +gtk_item_factory_get_item_by_action (GtkItemFactory *ifactory, + guint action) +{ + GtkWidget *widget; + + g_return_val_if_fail (GTK_IS_ITEM_FACTORY (ifactory), NULL); + + widget = gtk_item_factory_get_widget_by_action (ifactory, action); + + if (GTK_IS_MENU (widget)) + widget = gtk_menu_get_attach_widget (GTK_MENU (widget)); + + return GTK_IS_ITEM (widget) ? widget : NULL; +} + static gboolean gtk_item_factory_parse_path (GtkItemFactory *ifactory, gchar *str, @@ -975,8 +999,6 @@ gtk_item_factory_create_item (GtkItemFactory *ifactory, guint type_id; GtkType type; gchar *item_type_path; - GtkAccelGroup *parent_accel_group = NULL; - GSList *tmp_list; g_return_if_fail (ifactory != NULL); g_return_if_fail (GTK_IS_ITEM_FACTORY (ifactory)); @@ -988,7 +1010,7 @@ gtk_item_factory_create_item (GtkItemFactory *ifactory, if (!entry->item_type || entry->item_type[0] == 0) { - item_type_path = (gpointer) key_type_item; + item_type_path = "<Item>"; type_id = quark_type_item; } else @@ -1063,12 +1085,8 @@ gtk_item_factory_create_item (GtkItemFactory *ifactory, } g_free (parent_path); - g_return_if_fail (parent != NULL); + g_return_if_fail (GTK_IS_CONTAINER (parent)); - tmp_list = gtk_accel_groups_from_object (GTK_OBJECT (parent)); - if (tmp_list) - parent_accel_group = tmp_list->data; - widget = gtk_widget_new (type, "GtkWidget::visible", TRUE, "GtkWidget::sensitive", (type_id != quark_type_separator_item && @@ -1080,64 +1098,58 @@ gtk_item_factory_create_item (GtkItemFactory *ifactory, gtk_radio_menu_item_set_group (GTK_RADIO_MENU_ITEM (widget), radio_group); if (GTK_IS_CHECK_MENU_ITEM (widget)) gtk_check_menu_item_set_show_toggle (GTK_CHECK_MENU_ITEM (widget), TRUE); - - if ((type_id != quark_type_separator_item) && - (type_id != quark_type_tearoff_item) && + + /* install underline accelerators for this item + */ + if (type_id != quark_type_separator_item && + type_id != quark_type_tearoff_item && *name) { GtkWidget *label; - - label = - gtk_widget_new (GTK_TYPE_ACCEL_LABEL, - "GtkWidget::visible", TRUE, - "GtkWidget::parent", widget, - "GtkAccelLabel::accel_widget", widget, - "GtkMisc::xalign", 0.0, - NULL); - + + label = gtk_widget_new (GTK_TYPE_ACCEL_LABEL, + "GtkWidget::visible", TRUE, + "GtkWidget::parent", widget, + "GtkAccelLabel::accel_widget", widget, + "GtkMisc::xalign", 0.0, + NULL); + accel_key = gtk_label_parse_uline (GTK_LABEL (label), name); - - if ((accel_key != GDK_VoidSymbol) && GTK_IS_MENU_BAR (parent)) - { - gtk_widget_add_accelerator (widget, - "activate_item", - ifactory->accel_group, - accel_key, GDK_MOD1_MASK, - GTK_ACCEL_LOCKED); - } - - if ((accel_key != GDK_VoidSymbol) && parent_accel_group) + + if (accel_key != GDK_VoidSymbol) { - gtk_widget_add_accelerator (widget, - "activate_item", - parent_accel_group, - accel_key, 0, - GTK_ACCEL_LOCKED); + if (GTK_IS_MENU_BAR (parent)) + gtk_widget_add_accelerator (widget, + "activate_item", + ifactory->accel_group, + accel_key, GDK_MOD1_MASK, + GTK_ACCEL_LOCKED); + + if (GTK_IS_MENU (parent)) + gtk_widget_add_accelerator (widget, + "activate_item", + gtk_menu_ensure_uline_accel_group (GTK_MENU (parent)), + accel_key, 0, + GTK_ACCEL_LOCKED); } } - + g_free (name); - + if (type_id == quark_type_branch || type_id == quark_type_last_branch) { - GtkAccelGroup *menu_group; - if (entry->callback) g_warning ("gtk_item_factory_create_item(): Can't specify a callback on a branch: \"%s\"", entry->path); - - menu_group = gtk_accel_group_new (); if (type_id == quark_type_last_branch) gtk_menu_item_right_justify (GTK_MENU_ITEM (widget)); - + parent = widget; - widget = - gtk_widget_new (GTK_TYPE_MENU, - NULL); + widget = gtk_widget_new (GTK_TYPE_MENU, + NULL); - gtk_accel_group_attach (menu_group, GTK_OBJECT (widget)); gtk_menu_item_set_submenu (GTK_MENU_ITEM (parent), widget); } @@ -1199,7 +1211,7 @@ gtk_item_factory_create_menu_entries (guint n_entries, entry.callback = entries[i].callback; entry.callback_action = 0; if (gtk_pattern_match_string (&pspec_separator, path)) - entry.item_type = (gpointer) key_type_separator_item; + entry.item_type = "<Separator>"; else if (!gtk_pattern_match_string (&pspec_check, path)) entry.item_type = NULL; else @@ -1220,7 +1232,7 @@ gtk_item_factory_create_menu_entries (guint n_entries, path++; } *c = 0; - entry.item_type = (gpointer) key_type_toggle_item; + entry.item_type = "<ToggleItem>"; entry.path = cpath; } @@ -1483,7 +1495,7 @@ gtk_item_factory_parse_menu_path (GScanner *scanner, item->accelerator_mods = 0; item->modified = TRUE; item->in_propagation = FALSE; - item->item_type = NULL; + item->dummy = NULL; item->widgets = NULL; g_hash_table_insert (class->item_ht, item->path, item); @@ -1570,6 +1582,9 @@ gtk_item_factory_parse_rc_string (const gchar *rc_string) g_return_if_fail (rc_string != NULL); + if (!gtk_item_factory_class) + gtk_type_class (GTK_TYPE_ITEM_FACTORY); + ifactory_scanner_config.cpair_comment_single = gtk_item_factory_class->cpair_comment_single; scanner = g_scanner_new (&ifactory_scanner_config); @@ -1628,6 +1643,9 @@ gtk_item_factory_parse_rc (const gchar *file_name) if (fd < 0) return; + if (!gtk_item_factory_class) + gtk_type_class (GTK_TYPE_ITEM_FACTORY); + ifactory_scanner_config.cpair_comment_single = gtk_item_factory_class->cpair_comment_single; scanner = g_scanner_new (&ifactory_scanner_config); diff --git a/gtk/gtkitemfactory.h b/gtk/gtkitemfactory.h index 74e7f34bbb..dcf21514ab 100644 --- a/gtk/gtkitemfactory.h +++ b/gtk/gtkitemfactory.h @@ -69,7 +69,7 @@ struct _GtkItemFactory gchar *path; GtkAccelGroup *accel_group; GtkWidget *widget; - GSList *widgets_by_action; + GSList *items; GtkTranslateFunc translate_func; gpointer translate_data; @@ -118,7 +118,7 @@ struct _GtkItemFactoryItem guint accelerator_mods; guint modified : 1; guint in_propagation : 1; - gchar *item_type; + gchar *dummy; GSList *widgets; }; @@ -142,14 +142,23 @@ void gtk_item_factory_construct (GtkItemFactory *ifactory, void gtk_item_factory_parse_rc (const gchar *file_name); void gtk_item_factory_parse_rc_string (const gchar *rc_string); void gtk_item_factory_parse_rc_scanner (GScanner *scanner); +void gtk_item_factory_add_foreign (GtkWidget *accel_widget, + const gchar *full_path, + GtkAccelGroup *accel_group, + guint keyval, + GdkModifierType modifiers); GtkItemFactory* gtk_item_factory_from_widget (GtkWidget *widget); gchar* gtk_item_factory_path_from_widget (GtkWidget *widget); -GtkWidget* gtk_item_factory_get_widget (GtkItemFactory *ifactory, - const gchar *path); +GtkWidget* gtk_item_factory_get_item (GtkItemFactory *ifactory, + const gchar *path); +GtkWidget* gtk_item_factory_get_widget (GtkItemFactory *ifactory, + const gchar *path); GtkWidget* gtk_item_factory_get_widget_by_action (GtkItemFactory *ifactory, guint action); +GtkWidget* gtk_item_factory_get_item_by_action (GtkItemFactory *ifactory, + guint action); /* If `path_pspec' is passed as `NULL', this function will iterate over * all hash entries. otherwise only those entries will be dumped for which diff --git a/gtk/gtklayout.c b/gtk/gtklayout.c index 34af8ad067..cd630faa29 100644 --- a/gtk/gtklayout.c +++ b/gtk/gtklayout.c @@ -1015,7 +1015,7 @@ gtk_layout_adjustment_changed (GtkAdjustment *adjustment, 0, MAX ((gint)widget->allocation.height - dy, 0), widget->allocation.width, - MIN (dy, widget->allocation.width)); + MIN (dy, widget->allocation.height)); } else if (dy < 0) { @@ -1037,8 +1037,8 @@ gtk_layout_adjustment_changed (GtkAdjustment *adjustment, gtk_layout_expose_area (layout, 0, 0, - widget->allocation.height, - MIN (-dy, (gint)widget->allocation.width)); + widget->allocation.width, + MIN (-dy, (gint)widget->allocation.height)); } gtk_layout_position_children (layout); diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index 207f9cc0ce..16d48eda1a 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -73,7 +73,8 @@ static void gtk_menu_reparent (GtkMenu *menu, gboolean unrealize); static GtkMenuShellClass *parent_class = NULL; -static const gchar *attach_data_key = "gtk-menu-attach-data"; +static const gchar *attach_data_key = "gtk-menu-attach-data"; +static GQuark quark_uline_accel_group = 0; GtkType @@ -155,6 +156,33 @@ gtk_menu_class_init (GtkMenuClass *class) GTK_MENU_DIR_CHILD); } +static gint +gtk_menu_window_event (GtkWidget *window, + GdkEvent *event, + GtkWidget *menu) +{ + gboolean handled = FALSE; + + gtk_widget_ref (window); + gtk_widget_ref (menu); + + switch (event->type) + { + case GDK_KEY_PRESS: + case GDK_KEY_RELEASE: + gtk_widget_event (menu, event); + handled = TRUE; + break; + default: + break; + } + + gtk_widget_unref (window); + gtk_widget_unref (menu); + + return handled; +} + static void gtk_menu_init (GtkMenu *menu) { @@ -165,9 +193,10 @@ gtk_menu_init (GtkMenu *menu) menu->position_func_data = NULL; menu->toplevel = gtk_window_new (GTK_WINDOW_POPUP); - gtk_signal_connect_object (GTK_OBJECT (menu->toplevel), "key_press_event", - GTK_SIGNAL_FUNC (gtk_menu_key_press), - GTK_OBJECT (menu)); + gtk_signal_connect (GTK_OBJECT (menu->toplevel), + "event", + GTK_SIGNAL_FUNC (gtk_menu_window_event), + GTK_OBJECT (menu)); gtk_window_set_policy (GTK_WINDOW (menu->toplevel), FALSE, FALSE, TRUE); @@ -203,6 +232,12 @@ gtk_menu_destroy (GtkObject *object) gtk_menu_set_accel_group (menu, NULL); + if (menu->old_active_menu_item) + { + gtk_widget_unref (menu->old_active_menu_item); + menu->old_active_menu_item = NULL; + } + /* Add back the reference count for being a child */ gtk_object_ref (object); @@ -327,6 +362,42 @@ gtk_menu_insert (GtkMenu *menu, gtk_menu_shell_insert (GTK_MENU_SHELL (menu), child, position); } +static void +gtk_menu_tearoff_bg_copy (GtkMenu *menu) +{ + GtkWidget *widget; + + widget = GTK_WIDGET (menu); + + if (menu->torn_off) + { + GdkPixmap *pixmap; + GdkGC *gc; + GdkGCValues gc_values; + + gc_values.subwindow_mode = GDK_INCLUDE_INFERIORS; + gc = gdk_gc_new_with_values (widget->window, + &gc_values, GDK_GC_SUBWINDOW); + + pixmap = gdk_pixmap_new (widget->window, + widget->requisition.width, + widget->requisition.height, + -1); + + gdk_draw_pixmap (pixmap, gc, + widget->window, + 0, 0, 0, 0, -1, -1); + gdk_gc_unref (gc); + + gtk_widget_set_usize (menu->tearoff_window, + widget->requisition.width, + widget->requisition.height); + + gdk_window_set_back_pixmap (menu->tearoff_window->window, pixmap, FALSE); + gdk_pixmap_unref (pixmap); + } +} + void gtk_menu_popup (GtkMenu *menu, GtkWidget *parent_menu_shell, @@ -363,35 +434,12 @@ gtk_menu_popup (GtkMenu *menu, if ((current_event->type != GDK_BUTTON_PRESS) && (current_event->type != GDK_ENTER_NOTIFY)) menu_shell->ignore_enter = TRUE; - gdk_event_free(current_event); + gdk_event_free (current_event); } if (menu->torn_off) { - GdkPixmap *pixmap; - GdkGC *gc; - GdkGCValues gc_values; - - gc_values.subwindow_mode = GDK_INCLUDE_INFERIORS; - gc = gdk_gc_new_with_values (widget->window, - &gc_values, GDK_GC_SUBWINDOW); - - pixmap = gdk_pixmap_new (widget->window, - widget->requisition.width, - widget->requisition.height, - -1); - - gdk_draw_pixmap (pixmap, gc, - widget->window, - 0, 0, 0, 0, -1, -1); - gdk_gc_unref(gc); - - gtk_widget_set_usize (menu->tearoff_window, - widget->requisition.width, - widget->requisition.height); - - gdk_window_set_back_pixmap (menu->tearoff_window->window, pixmap, FALSE); - gdk_pixmap_unref (pixmap); + gtk_menu_tearoff_bg_copy (menu); /* We force an unrealize here so that we don't trigger redrawing/ * clearing code - we just want to reveal our backing pixmap. @@ -479,10 +527,13 @@ gtk_menu_popdown (GtkMenu *menu) if (menu_shell->active_menu_item) { + if (menu->old_active_menu_item) + gtk_widget_unref (menu->old_active_menu_item); menu->old_active_menu_item = menu_shell->active_menu_item; - gtk_menu_item_deselect (GTK_MENU_ITEM (menu_shell->active_menu_item)); - menu_shell->active_menu_item = NULL; + gtk_widget_ref (menu->old_active_menu_item); } + + gtk_menu_shell_deselect (menu_shell); /* The X Grab, if present, will automatically be removed when we hide * the window */ @@ -538,6 +589,8 @@ gtk_menu_get_active (GtkMenu *menu) } menu->old_active_menu_item = child; + if (menu->old_active_menu_item) + gtk_widget_ref (menu->old_active_menu_item); } return menu->old_active_menu_item; @@ -558,7 +611,12 @@ gtk_menu_set_active (GtkMenu *menu, { child = tmp_list->data; if (GTK_BIN (child)->child) - menu->old_active_menu_item = child; + { + if (menu->old_active_menu_item) + gtk_widget_unref (menu->old_active_menu_item); + menu->old_active_menu_item = child; + gtk_widget_ref (menu->old_active_menu_item); + } } } @@ -566,7 +624,6 @@ void gtk_menu_set_accel_group (GtkMenu *menu, GtkAccelGroup *accel_group) { - g_return_if_fail (menu != NULL); g_return_if_fail (GTK_IS_MENU (menu)); if (menu->accel_group != accel_group) @@ -579,6 +636,45 @@ gtk_menu_set_accel_group (GtkMenu *menu, } } +GtkAccelGroup* +gtk_menu_get_accel_group (GtkMenu *menu) +{ + g_return_val_if_fail (GTK_IS_MENU (menu), NULL); + + return menu->accel_group; +} + +GtkAccelGroup* +gtk_menu_ensure_uline_accel_group (GtkMenu *menu) +{ + GtkAccelGroup *accel_group; + + g_return_val_if_fail (GTK_IS_MENU (menu), NULL); + + if (!quark_uline_accel_group) + quark_uline_accel_group = g_quark_from_static_string ("GtkMenu-uline-accel-group"); + + accel_group = gtk_object_get_data_by_id (GTK_OBJECT (menu), quark_uline_accel_group); + if (!accel_group) + { + accel_group = gtk_accel_group_new (); + gtk_accel_group_attach (accel_group, GTK_OBJECT (menu)); + gtk_object_set_data_by_id_full (GTK_OBJECT (menu), + quark_uline_accel_group, + accel_group, + (GtkDestroyNotify) gtk_accel_group_unref); + } + + return accel_group; +} + +GtkAccelGroup* +gtk_menu_get_uline_accel_group (GtkMenu *menu) +{ + g_return_val_if_fail (GTK_IS_MENU (menu), NULL); + + return gtk_object_get_data_by_id (GTK_OBJECT (menu), quark_uline_accel_group); +} void gtk_menu_reposition (GtkMenu *menu) @@ -614,10 +710,10 @@ gtk_menu_set_tearoff_state (GtkMenu *menu, menu->tearoff_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_app_paintable (menu->tearoff_window, TRUE); - gtk_signal_connect_object (GTK_OBJECT (menu->tearoff_window), - "key_press_event", - GTK_SIGNAL_FUNC (gtk_menu_key_press), - GTK_OBJECT (menu)); + gtk_signal_connect (GTK_OBJECT (menu->tearoff_window), + "event", + GTK_SIGNAL_FUNC (gtk_menu_window_event), + GTK_OBJECT (menu)); gtk_widget_realize (menu->tearoff_window); title = gtk_object_get_data (GTK_OBJECT (menu), "gtk-menu-title"); @@ -888,16 +984,19 @@ gtk_menu_expose (GtkWidget *widget, GtkWidget *child; GdkEventExpose child_event; GList *children; + GtkMenu *menu; g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_MENU (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); + + menu_shell = GTK_MENU_SHELL (widget); + menu = GTK_MENU (widget); if (GTK_WIDGET_DRAWABLE (widget)) { gtk_menu_paint (widget); - menu_shell = GTK_MENU_SHELL (widget); child_event = *event; children = menu_shell->children; @@ -943,59 +1042,62 @@ gtk_menu_key_press (GtkWidget *widget, } /* Modify the accelerators */ - if (delete || gtk_accelerator_valid (event->keyval, event->keyval)) + if (menu_shell->active_menu_item && + GTK_BIN (menu_shell->active_menu_item)->child && + GTK_MENU_ITEM (menu_shell->active_menu_item)->submenu == NULL && + !gtk_widget_accelerators_locked (menu_shell->active_menu_item) && + (delete || + (gtk_accelerator_valid (event->keyval, event->state) && + (event->state || + !gtk_menu_get_uline_accel_group (GTK_MENU (menu_shell)) || + (event->keyval >= GDK_F1 && event->keyval <= GDK_F35))))) { - if (menu_shell->active_menu_item && - GTK_BIN (menu_shell->active_menu_item)->child && - GTK_MENU_ITEM (menu_shell->active_menu_item)->submenu == NULL) + GtkMenuItem *menu_item; + GtkAccelGroup *accel_group; + + menu_item = GTK_MENU_ITEM (menu_shell->active_menu_item); + + if (!GTK_MENU (widget)->accel_group) + accel_group = gtk_accel_group_get_default (); + else + accel_group = GTK_MENU (widget)->accel_group; + + gtk_widget_remove_accelerators (GTK_WIDGET (menu_item), + gtk_signal_name (menu_item->accelerator_signal), + TRUE); + + if (!delete && + 0 == gtk_widget_accelerator_signal (GTK_WIDGET (menu_item), + accel_group, + event->keyval, + event->state)) { - GtkMenuItem *menu_item; - GtkAccelGroup *accel_group; - - menu_item = GTK_MENU_ITEM (menu_shell->active_menu_item); - - if (!GTK_MENU (widget)->accel_group) - accel_group = gtk_accel_group_get_default (); - else - accel_group = GTK_MENU (widget)->accel_group; - - gtk_widget_remove_accelerators (GTK_WIDGET (menu_item), - gtk_signal_name (menu_item->accelerator_signal), - TRUE); + GSList *slist; - if (!delete && - 0 == gtk_widget_accelerator_signal (GTK_WIDGET (menu_item), - accel_group, - event->keyval, - event->state)) + slist = gtk_accel_group_entries_from_object (GTK_OBJECT (menu_item)); + while (slist) { - GSList *slist; + GtkAccelEntry *ac_entry; - slist = gtk_accel_group_entries_from_object (GTK_OBJECT (menu_item)); - while (slist) - { - GtkAccelEntry *ac_entry; - - ac_entry = slist->data; - - if (ac_entry->signal_id == menu_item->accelerator_signal) - break; - - slist = slist->next; - } - - if (!slist) - gtk_widget_add_accelerator (GTK_WIDGET (menu_item), - gtk_signal_name (menu_item->accelerator_signal), - accel_group, - event->keyval, - event->state, - GTK_ACCEL_VISIBLE); + ac_entry = slist->data; + + if (ac_entry->signal_id == menu_item->accelerator_signal) + break; + + slist = slist->next; } + + if (!slist) + gtk_widget_add_accelerator (GTK_WIDGET (menu_item), + gtk_signal_name (menu_item->accelerator_signal), + accel_group, + event->keyval, + event->state, + GTK_ACCEL_VISIBLE); } } - return FALSE; + return TRUE; } static gint @@ -1004,20 +1106,28 @@ gtk_menu_motion_notify (GtkWidget *widget, { g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_MENU (widget), FALSE); - + if (GTK_MENU_SHELL (widget)->ignore_enter) GTK_MENU_SHELL (widget)->ignore_enter = FALSE; - else + else { - GdkEvent send_event; + gint width, height; - send_event.crossing.type = GDK_ENTER_NOTIFY; - send_event.crossing.window = event->window; - send_event.crossing.time = event->time; - - gtk_widget_event (widget, &send_event); + gdk_window_get_size (event->window, &width, &height); + if (event->x >= 0 && event->x < width && + event->y >= 0 && event->y < height) + { + GdkEvent send_event; + + send_event.crossing.type = GDK_ENTER_NOTIFY; + send_event.crossing.window = event->window; + send_event.crossing.time = event->time; + send_event.crossing.send_event = TRUE; + + gtk_widget_event (widget, &send_event); + } } - + return FALSE; } @@ -1111,6 +1221,7 @@ gtk_menu_reparent (GtkMenu *menu, } else gtk_widget_reparent (GTK_WIDGET (menu), new_parent); + gtk_widget_set_usize (new_parent, -1, -1); if (was_floating) GTK_OBJECT_SET_FLAGS (object, GTK_FLOATING); diff --git a/gtk/gtkmenu.h b/gtk/gtkmenu.h index 7e37a0bcd6..38ddb510b8 100644 --- a/gtk/gtkmenu.h +++ b/gtk/gtkmenu.h @@ -117,8 +117,19 @@ GtkWidget* gtk_menu_get_active (GtkMenu *menu); void gtk_menu_set_active (GtkMenu *menu, guint index); -void gtk_menu_set_accel_group (GtkMenu *menu, +/* set/get the acclerator group that holds global accelerators (should + * be added to the corresponding toplevel with gtk_window_add_accel_group(). + */ +void gtk_menu_set_accel_group (GtkMenu *menu, GtkAccelGroup *accel_group); +GtkAccelGroup* gtk_menu_get_accel_group (GtkMenu *menu); + +/* get the accelerator group that is used internally by the menu for + * underline accelerators while the menu is popped up. + */ +GtkAccelGroup* gtk_menu_get_uline_accel_group (GtkMenu *menu); +GtkAccelGroup* gtk_menu_ensure_uline_accel_group (GtkMenu *menu); + /* A reference count is kept for a widget when it is attached to * a particular widget. This is typically a menu item; it may also diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c index 52ad415631..3b7953917b 100644 --- a/gtk/gtkmenushell.c +++ b/gtk/gtkmenushell.c @@ -137,7 +137,6 @@ static GtkWidget *gtk_menu_shell_get_item (GtkMenuShell *menu_shell, GdkEvent *event); static GtkType gtk_menu_shell_child_type (GtkContainer *container); -static void gtk_menu_shell_deselect (GtkMenuShell *menu_shell); static void gtk_real_menu_shell_move_current (GtkMenuShell *menu_shell, GtkMenuDirectionType direction); static void gtk_real_menu_shell_activate_current (GtkMenuShell *menu_shell, @@ -435,15 +434,7 @@ gtk_menu_shell_button_press (GtkWidget *widget, { if ((menu_item->parent == widget) && (menu_item != menu_shell->active_menu_item)) - { - if (menu_shell->active_menu_item) - gtk_menu_item_deselect (GTK_MENU_ITEM (menu_shell->active_menu_item)); - - menu_shell->active_menu_item = menu_item; - gtk_menu_item_set_placement (GTK_MENU_ITEM (menu_shell->active_menu_item), - MENU_SHELL_CLASS (menu_shell)->submenu_placement); - gtk_menu_item_select (GTK_MENU_ITEM (menu_shell->active_menu_item)); - } + gtk_menu_shell_select_item (menu_shell, menu_item); } } else @@ -755,7 +746,7 @@ gtk_menu_shell_is_item (GtkMenuShell *menu_shell, return FALSE; } -static GtkWidget * +static GtkWidget* gtk_menu_shell_get_item (GtkMenuShell *menu_shell, GdkEvent *event) { @@ -775,16 +766,15 @@ gtk_menu_shell_get_item (GtkMenuShell *menu_shell, /* Handlers for action signals */ void -gtk_menu_shell_select_item (GtkMenuShell *menu_shell, - GtkWidget *menu_item) +gtk_menu_shell_select_item (GtkMenuShell *menu_shell, + GtkWidget *menu_item) { g_return_if_fail (menu_shell != NULL); g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell)); g_return_if_fail (menu_item != NULL); g_return_if_fail (GTK_IS_MENU_ITEM (menu_item)); - if (menu_shell->active_menu_item) - gtk_menu_item_deselect (GTK_MENU_ITEM (menu_shell->active_menu_item)); + gtk_menu_shell_deselect (menu_shell); menu_shell->active_menu_item = menu_item; gtk_menu_item_set_placement (GTK_MENU_ITEM (menu_shell->active_menu_item), @@ -798,11 +788,16 @@ gtk_menu_shell_select_item (GtkMenuShell *menu_shell, gtk_widget_activate (menu_shell->active_menu_item); } -static void -gtk_menu_shell_deselect (GtkMenuShell *menu_shell) +void +gtk_menu_shell_deselect (GtkMenuShell *menu_shell) { - gtk_menu_item_deselect (GTK_MENU_ITEM (menu_shell->active_menu_item)); - menu_shell->active_menu_item = NULL; + g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell)); + + if (menu_shell->active_menu_item) + { + gtk_menu_item_deselect (GTK_MENU_ITEM (menu_shell->active_menu_item)); + menu_shell->active_menu_item = NULL; + } } void @@ -831,10 +826,13 @@ gtk_menu_shell_activate_item (GtkMenuShell *menu_shell, */ gdk_flush (); } + + gtk_widget_ref (GTK_WIDGET (menu_shell)); gtk_widget_activate (menu_item); if (deactivate) gtk_signal_emit (GTK_OBJECT (menu_shell), menu_shell_signals[SELECTION_DONE]); + gtk_widget_unref (GTK_WIDGET (menu_shell)); } /* Distance should be +/- 1 */ diff --git a/gtk/gtkmenushell.h b/gtk/gtkmenushell.h index f68282a5e7..6230f8ad28 100644 --- a/gtk/gtkmenushell.h +++ b/gtk/gtkmenushell.h @@ -94,6 +94,7 @@ void gtk_menu_shell_insert (GtkMenuShell *menu_shell, void gtk_menu_shell_deactivate (GtkMenuShell *menu_shell); void gtk_menu_shell_select_item (GtkMenuShell *menu_shell, GtkWidget *menu_item); +void gtk_menu_shell_deselect (GtkMenuShell *menu_shell); void gtk_menu_shell_activate_item (GtkMenuShell *menu_shell, GtkWidget *menu_item, gboolean force_deactivate); diff --git a/gtk/gtksignal.c b/gtk/gtksignal.c index 8d3f3ba40f..3288c90ae6 100644 --- a/gtk/gtksignal.c +++ b/gtk/gtksignal.c @@ -1768,7 +1768,7 @@ gtk_signal_connect_by_type (GtkObject *object, handler = gtk_signal_handler_new (); handler->id = gtk_handler_id++; handler->signal_id = signal_id; - handler->object_signal = object_signal; + handler->object_signal = object_signal != FALSE; handler->func = func; handler->func_data = func_data; handler->destroy_func = destroy_func; diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index b4a2eacb78..bd24f74cd2 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -2499,12 +2499,8 @@ gtk_widget_lock_accelerators (GtkWidget *widget) { g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); - - if (gtk_signal_handler_pending_by_func (GTK_OBJECT (widget), - widget_signals[ADD_ACCELERATOR], - TRUE, - GTK_SIGNAL_FUNC (gtk_widget_stop_add_accelerator), - NULL) == 0) + + if (!gtk_widget_accelerators_locked (widget)) { gtk_signal_connect (GTK_OBJECT (widget), "add_accelerator", @@ -2522,12 +2518,8 @@ gtk_widget_unlock_accelerators (GtkWidget *widget) { g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); - - if (gtk_signal_handler_pending_by_func (GTK_OBJECT (widget), - widget_signals[ADD_ACCELERATOR], - TRUE, - GTK_SIGNAL_FUNC (gtk_widget_stop_add_accelerator), - NULL) > 0) + + if (gtk_widget_accelerators_locked (widget)) { gtk_signal_disconnect_by_func (GTK_OBJECT (widget), GTK_SIGNAL_FUNC (gtk_widget_stop_add_accelerator), @@ -2538,6 +2530,18 @@ gtk_widget_unlock_accelerators (GtkWidget *widget) } } +gboolean +gtk_widget_accelerators_locked (GtkWidget *widget) +{ + g_return_if_fail (GTK_IS_WIDGET (widget)); + + return gtk_signal_handler_pending_by_func (GTK_OBJECT (widget), + widget_signals[ADD_ACCELERATOR], + TRUE, + GTK_SIGNAL_FUNC (gtk_widget_stop_add_accelerator), + NULL) > 0; +} + void gtk_widget_add_accelerator (GtkWidget *widget, const gchar *accel_signal, diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index c980387ab2..0d804bae21 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -491,6 +491,7 @@ guint gtk_widget_accelerator_signal (GtkWidget *widget, guint accel_mods); void gtk_widget_lock_accelerators (GtkWidget *widget); void gtk_widget_unlock_accelerators (GtkWidget *widget); +gboolean gtk_widget_accelerators_locked (GtkWidget *widget); gint gtk_widget_event (GtkWidget *widget, GdkEvent *event); diff --git a/gtk/testgtk.c b/gtk/testgtk.c index fef132601f..4bd90e368e 100644 --- a/gtk/testgtk.c +++ b/gtk/testgtk.c @@ -2418,8 +2418,12 @@ create_item_factory (void) accel_group = gtk_accel_group_new (); item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group); - gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL); + gtk_object_set_data_full (GTK_OBJECT (window), + "<main>", + item_factory, + (GtkDestroyNotify) gtk_object_unref); gtk_accel_group_attach (accel_group, GTK_OBJECT (window)); + gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL); gtk_window_set_title (GTK_WINDOW (window), "Item Factory"); gtk_container_set_border_width (GTK_CONTAINER (window), 0); diff --git a/tests/testgtk.c b/tests/testgtk.c index fef132601f..4bd90e368e 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -2418,8 +2418,12 @@ create_item_factory (void) accel_group = gtk_accel_group_new (); item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group); - gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL); + gtk_object_set_data_full (GTK_OBJECT (window), + "<main>", + item_factory, + (GtkDestroyNotify) gtk_object_unref); gtk_accel_group_attach (accel_group, GTK_OBJECT (window)); + gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL); gtk_window_set_title (GTK_WINDOW (window), "Item Factory"); gtk_container_set_border_width (GTK_CONTAINER (window), 0); |