diff --git a/ChangeLog b/ChangeLog index 7b6bd69c6e..df694dbdb3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,37 @@ +Thu Jun 18 03:30:06 1998 Tim Janik + + * gtk/gtkaccellabel.h: + * gtk/gtkaccellabel.c: new function gtk_accel_label_accelerator_width to + request the size of the accelerator portion of an accel label. + (gtk_accel_label_size_request): don't request for the accelerators size. + (gtk_accel_label_expose_event): only draw the accelerator if we got + enough extra space. + + * gtk/gtkmenuitem.c (gtk_menu_item_size_request): request accelerator + width from children. + + * gtk/gtkmenu.c (gtk_menu_key_press): when adding an accelerator to an + object (after removal has been requested) check if there is still an + accelerator remaining to avoid adding two accelerators on an object. + this can happen for locked accelerators (or accelerator-frozen widgets). + (gtk_menu_size_request): feature childrens accelerator width in size + requests. + + * gtk/gtknotebook.c (gtk_notebook_menu_item_create): use + gtk_widget_freeze_accelerators() for dynamically created menu items. + + * gtk/gtksignal.h: + * gtk/gtksignal.c: new function gtk_signal_handler_pending_by_func() + which will return a handler_id > 0 if the specified function is pending + for `signal_id'. + + * gtk/gtkwidget.h: + * gtk/gtkwidget.c: remove gtk_widget_stop_accelerator, which was just + a signal handler function to stop accelerator addition. + added gtk_widget_freeze_accelerators and gtk_widget_thaw_accelerators + which will prevent (undo) any accelerators from being added to or + removed from a widget. + Wed Jun 17 21:59:09 1998 Stefan Jeske * gtkspinbutton.h gtkspinbutton.c testgtk.c: diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 7b6bd69c6e..df694dbdb3 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,37 @@ +Thu Jun 18 03:30:06 1998 Tim Janik + + * gtk/gtkaccellabel.h: + * gtk/gtkaccellabel.c: new function gtk_accel_label_accelerator_width to + request the size of the accelerator portion of an accel label. + (gtk_accel_label_size_request): don't request for the accelerators size. + (gtk_accel_label_expose_event): only draw the accelerator if we got + enough extra space. + + * gtk/gtkmenuitem.c (gtk_menu_item_size_request): request accelerator + width from children. + + * gtk/gtkmenu.c (gtk_menu_key_press): when adding an accelerator to an + object (after removal has been requested) check if there is still an + accelerator remaining to avoid adding two accelerators on an object. + this can happen for locked accelerators (or accelerator-frozen widgets). + (gtk_menu_size_request): feature childrens accelerator width in size + requests. + + * gtk/gtknotebook.c (gtk_notebook_menu_item_create): use + gtk_widget_freeze_accelerators() for dynamically created menu items. + + * gtk/gtksignal.h: + * gtk/gtksignal.c: new function gtk_signal_handler_pending_by_func() + which will return a handler_id > 0 if the specified function is pending + for `signal_id'. + + * gtk/gtkwidget.h: + * gtk/gtkwidget.c: remove gtk_widget_stop_accelerator, which was just + a signal handler function to stop accelerator addition. + added gtk_widget_freeze_accelerators and gtk_widget_thaw_accelerators + which will prevent (undo) any accelerators from being added to or + removed from a widget. + Wed Jun 17 21:59:09 1998 Stefan Jeske * gtkspinbutton.h gtkspinbutton.c testgtk.c: diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 7b6bd69c6e..df694dbdb3 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,37 @@ +Thu Jun 18 03:30:06 1998 Tim Janik + + * gtk/gtkaccellabel.h: + * gtk/gtkaccellabel.c: new function gtk_accel_label_accelerator_width to + request the size of the accelerator portion of an accel label. + (gtk_accel_label_size_request): don't request for the accelerators size. + (gtk_accel_label_expose_event): only draw the accelerator if we got + enough extra space. + + * gtk/gtkmenuitem.c (gtk_menu_item_size_request): request accelerator + width from children. + + * gtk/gtkmenu.c (gtk_menu_key_press): when adding an accelerator to an + object (after removal has been requested) check if there is still an + accelerator remaining to avoid adding two accelerators on an object. + this can happen for locked accelerators (or accelerator-frozen widgets). + (gtk_menu_size_request): feature childrens accelerator width in size + requests. + + * gtk/gtknotebook.c (gtk_notebook_menu_item_create): use + gtk_widget_freeze_accelerators() for dynamically created menu items. + + * gtk/gtksignal.h: + * gtk/gtksignal.c: new function gtk_signal_handler_pending_by_func() + which will return a handler_id > 0 if the specified function is pending + for `signal_id'. + + * gtk/gtkwidget.h: + * gtk/gtkwidget.c: remove gtk_widget_stop_accelerator, which was just + a signal handler function to stop accelerator addition. + added gtk_widget_freeze_accelerators and gtk_widget_thaw_accelerators + which will prevent (undo) any accelerators from being added to or + removed from a widget. + Wed Jun 17 21:59:09 1998 Stefan Jeske * gtkspinbutton.h gtkspinbutton.c testgtk.c: diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 7b6bd69c6e..df694dbdb3 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,37 @@ +Thu Jun 18 03:30:06 1998 Tim Janik + + * gtk/gtkaccellabel.h: + * gtk/gtkaccellabel.c: new function gtk_accel_label_accelerator_width to + request the size of the accelerator portion of an accel label. + (gtk_accel_label_size_request): don't request for the accelerators size. + (gtk_accel_label_expose_event): only draw the accelerator if we got + enough extra space. + + * gtk/gtkmenuitem.c (gtk_menu_item_size_request): request accelerator + width from children. + + * gtk/gtkmenu.c (gtk_menu_key_press): when adding an accelerator to an + object (after removal has been requested) check if there is still an + accelerator remaining to avoid adding two accelerators on an object. + this can happen for locked accelerators (or accelerator-frozen widgets). + (gtk_menu_size_request): feature childrens accelerator width in size + requests. + + * gtk/gtknotebook.c (gtk_notebook_menu_item_create): use + gtk_widget_freeze_accelerators() for dynamically created menu items. + + * gtk/gtksignal.h: + * gtk/gtksignal.c: new function gtk_signal_handler_pending_by_func() + which will return a handler_id > 0 if the specified function is pending + for `signal_id'. + + * gtk/gtkwidget.h: + * gtk/gtkwidget.c: remove gtk_widget_stop_accelerator, which was just + a signal handler function to stop accelerator addition. + added gtk_widget_freeze_accelerators and gtk_widget_thaw_accelerators + which will prevent (undo) any accelerators from being added to or + removed from a widget. + Wed Jun 17 21:59:09 1998 Stefan Jeske * gtkspinbutton.h gtkspinbutton.c testgtk.c: diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 7b6bd69c6e..df694dbdb3 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,37 @@ +Thu Jun 18 03:30:06 1998 Tim Janik + + * gtk/gtkaccellabel.h: + * gtk/gtkaccellabel.c: new function gtk_accel_label_accelerator_width to + request the size of the accelerator portion of an accel label. + (gtk_accel_label_size_request): don't request for the accelerators size. + (gtk_accel_label_expose_event): only draw the accelerator if we got + enough extra space. + + * gtk/gtkmenuitem.c (gtk_menu_item_size_request): request accelerator + width from children. + + * gtk/gtkmenu.c (gtk_menu_key_press): when adding an accelerator to an + object (after removal has been requested) check if there is still an + accelerator remaining to avoid adding two accelerators on an object. + this can happen for locked accelerators (or accelerator-frozen widgets). + (gtk_menu_size_request): feature childrens accelerator width in size + requests. + + * gtk/gtknotebook.c (gtk_notebook_menu_item_create): use + gtk_widget_freeze_accelerators() for dynamically created menu items. + + * gtk/gtksignal.h: + * gtk/gtksignal.c: new function gtk_signal_handler_pending_by_func() + which will return a handler_id > 0 if the specified function is pending + for `signal_id'. + + * gtk/gtkwidget.h: + * gtk/gtkwidget.c: remove gtk_widget_stop_accelerator, which was just + a signal handler function to stop accelerator addition. + added gtk_widget_freeze_accelerators and gtk_widget_thaw_accelerators + which will prevent (undo) any accelerators from being added to or + removed from a widget. + Wed Jun 17 21:59:09 1998 Stefan Jeske * gtkspinbutton.h gtkspinbutton.c testgtk.c: diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 7b6bd69c6e..df694dbdb3 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,37 @@ +Thu Jun 18 03:30:06 1998 Tim Janik + + * gtk/gtkaccellabel.h: + * gtk/gtkaccellabel.c: new function gtk_accel_label_accelerator_width to + request the size of the accelerator portion of an accel label. + (gtk_accel_label_size_request): don't request for the accelerators size. + (gtk_accel_label_expose_event): only draw the accelerator if we got + enough extra space. + + * gtk/gtkmenuitem.c (gtk_menu_item_size_request): request accelerator + width from children. + + * gtk/gtkmenu.c (gtk_menu_key_press): when adding an accelerator to an + object (after removal has been requested) check if there is still an + accelerator remaining to avoid adding two accelerators on an object. + this can happen for locked accelerators (or accelerator-frozen widgets). + (gtk_menu_size_request): feature childrens accelerator width in size + requests. + + * gtk/gtknotebook.c (gtk_notebook_menu_item_create): use + gtk_widget_freeze_accelerators() for dynamically created menu items. + + * gtk/gtksignal.h: + * gtk/gtksignal.c: new function gtk_signal_handler_pending_by_func() + which will return a handler_id > 0 if the specified function is pending + for `signal_id'. + + * gtk/gtkwidget.h: + * gtk/gtkwidget.c: remove gtk_widget_stop_accelerator, which was just + a signal handler function to stop accelerator addition. + added gtk_widget_freeze_accelerators and gtk_widget_thaw_accelerators + which will prevent (undo) any accelerators from being added to or + removed from a widget. + Wed Jun 17 21:59:09 1998 Stefan Jeske * gtkspinbutton.h gtkspinbutton.c testgtk.c: diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 7b6bd69c6e..df694dbdb3 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,37 @@ +Thu Jun 18 03:30:06 1998 Tim Janik + + * gtk/gtkaccellabel.h: + * gtk/gtkaccellabel.c: new function gtk_accel_label_accelerator_width to + request the size of the accelerator portion of an accel label. + (gtk_accel_label_size_request): don't request for the accelerators size. + (gtk_accel_label_expose_event): only draw the accelerator if we got + enough extra space. + + * gtk/gtkmenuitem.c (gtk_menu_item_size_request): request accelerator + width from children. + + * gtk/gtkmenu.c (gtk_menu_key_press): when adding an accelerator to an + object (after removal has been requested) check if there is still an + accelerator remaining to avoid adding two accelerators on an object. + this can happen for locked accelerators (or accelerator-frozen widgets). + (gtk_menu_size_request): feature childrens accelerator width in size + requests. + + * gtk/gtknotebook.c (gtk_notebook_menu_item_create): use + gtk_widget_freeze_accelerators() for dynamically created menu items. + + * gtk/gtksignal.h: + * gtk/gtksignal.c: new function gtk_signal_handler_pending_by_func() + which will return a handler_id > 0 if the specified function is pending + for `signal_id'. + + * gtk/gtkwidget.h: + * gtk/gtkwidget.c: remove gtk_widget_stop_accelerator, which was just + a signal handler function to stop accelerator addition. + added gtk_widget_freeze_accelerators and gtk_widget_thaw_accelerators + which will prevent (undo) any accelerators from being added to or + removed from a widget. + Wed Jun 17 21:59:09 1998 Stefan Jeske * gtkspinbutton.h gtkspinbutton.c testgtk.c: diff --git a/gtk/gtk.defs b/gtk/gtk.defs index 2f325360b0..df970658a5 100644 --- a/gtk/gtk.defs +++ b/gtk/gtk.defs @@ -274,10 +274,9 @@ ; enumerations from "./gtkspinbutton.h" -(define-flags GtkSpinButtonUpdatePolicy +(define-enum GtkSpinButtonUpdatePolicy (always GTK_UPDATE_ALWAYS) - (if-valid GTK_UPDATE_IF_VALID) - (snap-to-ticks GTK_UPDATE_SNAP_TO_TICKS)) + (if-valid GTK_UPDATE_IF_VALID)) ; enumerations from "./gtktoolbar.h" diff --git a/gtk/gtkaccellabel.c b/gtk/gtkaccellabel.c index ac005a3dd6..7244f82fba 100644 --- a/gtk/gtkaccellabel.c +++ b/gtk/gtkaccellabel.c @@ -194,6 +194,15 @@ gtk_accel_label_finalize (GtkObject *object) GTK_OBJECT_CLASS (parent_class)->finalize (object); } +guint +gtk_accel_label_accelerator_width (GtkAccelLabel *accel_label) +{ + g_return_if_fail (accel_label != NULL); + g_return_if_fail (GTK_IS_ACCEL_LABEL (accel_label)); + + return accel_label->accel_padding + accel_label->accel_string_width; +} + static void gtk_accel_label_size_request (GtkWidget *widget, GtkRequisition *requisition) @@ -211,7 +220,6 @@ gtk_accel_label_size_request (GtkWidget *widget, accel_label->accel_string_width = gdk_string_width (GTK_WIDGET (accel_label)->style->font, accel_label->accel_string); - requisition->width += accel_label->accel_padding + accel_label->accel_string_width; } static gint @@ -232,9 +240,9 @@ gtk_accel_label_expose_event (GtkWidget *widget, { guint ac_width; - ac_width = accel_label->accel_padding + accel_label->accel_string_width; + ac_width = gtk_accel_label_accelerator_width (accel_label); - if (widget->allocation.width > ac_width + misc->xpad * 2) + if (widget->allocation.width >= widget->requisition.width + ac_width) { guint x; guint y; diff --git a/gtk/gtkaccellabel.h b/gtk/gtkaccellabel.h index c0233bf7e2..b384f01807 100644 --- a/gtk/gtkaccellabel.h +++ b/gtk/gtkaccellabel.h @@ -50,7 +50,7 @@ struct _GtkAccelLabel guint accel_padding; GtkWidget *accel_widget; gchar *accel_string; - guint accel_string_width : 16; + guint16 accel_string_width; }; struct _GtkAccelLabelClass @@ -68,11 +68,12 @@ struct _GtkAccelLabelClass }; -GtkType gtk_accel_label_get_type (void); -GtkWidget* gtk_accel_label_new (const gchar *string); -void gtk_accel_label_set_accel_widget (GtkAccelLabel *accel_label, - GtkWidget *accel_widget); -gboolean gtk_accel_label_refetch (GtkAccelLabel *accel_label); +GtkType gtk_accel_label_get_type (void); +GtkWidget* gtk_accel_label_new (const gchar *string); +guint gtk_accel_label_accelerator_width (GtkAccelLabel *accel_label); +void gtk_accel_label_set_accel_widget (GtkAccelLabel *accel_label, + GtkWidget *accel_widget); +gboolean gtk_accel_label_refetch (GtkAccelLabel *accel_label); #ifdef __cplusplus diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index 475e3576b8..94db57efe4 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -567,7 +567,8 @@ gtk_menu_size_request (GtkWidget *widget, GtkMenuShell *menu_shell; GtkWidget *child; GList *children; - gint max_toggle_size; + guint max_toggle_size; + guint max_accel_width; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_MENU (widget)); @@ -580,6 +581,7 @@ gtk_menu_size_request (GtkWidget *widget, requisition->height = 0; max_toggle_size = 0; + max_accel_width = 0; children = menu_shell->children; while (children) @@ -596,10 +598,11 @@ gtk_menu_size_request (GtkWidget *widget, requisition->height += child->requisition.height; max_toggle_size = MAX (max_toggle_size, MENU_ITEM_CLASS (child)->toggle_size); + max_accel_width = MAX (max_accel_width, GTK_MENU_ITEM (child)->accelerator_width); } } - requisition->width += max_toggle_size; + requisition->width += max_toggle_size + max_accel_width; requisition->width += (GTK_CONTAINER (menu)->border_width + widget->style->klass->xthickness) * 2; requisition->height += (GTK_CONTAINER (menu)->border_width + @@ -821,16 +824,34 @@ gtk_menu_key_press (GtkWidget *widget, TRUE); if (!delete && - gtk_widget_accelerator_signal (GTK_WIDGET (menu_item), - accel_group, - event->keyval, - event->state) == 0) - gtk_widget_add_accelerator (GTK_WIDGET (menu_item), - gtk_signal_name (menu_item->accelerator_signal), - accel_group, - event->keyval, - event->state, - GTK_ACCEL_VISIBLE); + 0 == gtk_widget_accelerator_signal (GTK_WIDGET (menu_item), + accel_group, + event->keyval, + event->state)) + { + GSList *slist; + + 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); + } } } diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c index ea76e03a34..55d3991273 100644 --- a/gtk/gtkmenuitem.c +++ b/gtk/gtkmenuitem.c @@ -135,6 +135,7 @@ gtk_menu_item_init (GtkMenuItem *menu_item) menu_item->submenu = NULL; menu_item->accelerator_signal = menu_item_signals[ACTIVATE]; menu_item->toggle_size = 0; + menu_item->accelerator_width = 0; menu_item->show_toggle_indicator = FALSE; menu_item->show_submenu_indicator = FALSE; menu_item->submenu_direction = GTK_DIRECTION_RIGHT; @@ -270,6 +271,24 @@ gtk_menu_item_activate (GtkMenuItem *menu_item) gtk_signal_emit (GTK_OBJECT (menu_item), menu_item_signals[ACTIVATE]); } +static void +gtk_menu_item_accel_width_foreach (GtkWidget *widget, + gpointer data) +{ + guint *width = data; + + if (GTK_IS_ACCEL_LABEL (widget)) + { + guint w; + + w = gtk_accel_label_accelerator_width (GTK_ACCEL_LABEL (widget)); + *width = MAX (*width, w); + } + else if (GTK_IS_CONTAINER (widget)) + gtk_container_foreach (GTK_CONTAINER (widget), + gtk_menu_item_accel_width_foreach, + data); +} static void gtk_menu_item_size_request (GtkWidget *widget, @@ -277,6 +296,7 @@ gtk_menu_item_size_request (GtkWidget *widget, { GtkMenuItem *menu_item; GtkBin *bin; + guint accel_width; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_MENU_ITEM (widget)); @@ -298,8 +318,15 @@ gtk_menu_item_size_request (GtkWidget *widget, requisition->width += bin->child->requisition.width; requisition->height += bin->child->requisition.height; } + if (menu_item->submenu && menu_item->show_submenu_indicator) requisition->width += 21; + + accel_width = 0; + gtk_container_foreach (GTK_CONTAINER (menu_item), + gtk_menu_item_accel_width_foreach, + &accel_width); + menu_item->accelerator_width = accel_width; } static void diff --git a/gtk/gtkmenuitem.h b/gtk/gtkmenuitem.h index 55529f2d87..82a9244fe0 100644 --- a/gtk/gtkmenuitem.h +++ b/gtk/gtkmenuitem.h @@ -48,6 +48,7 @@ struct _GtkMenuItem guint accelerator_signal; guint16 toggle_size; + guint16 accelerator_width; guint show_toggle_indicator : 1; guint show_submenu_indicator : 1; diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index acaeaf90ec..deb98e5638 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -2998,10 +2998,7 @@ gtk_notebook_menu_item_create (GtkNotebook *notebook, } gtk_widget_show (page->menu_label); menu_item = gtk_menu_item_new (); - gtk_signal_connect (GTK_OBJECT (menu_item), - "add_accelerator", - GTK_SIGNAL_FUNC (gtk_widget_stop_accelerator), - NULL); + gtk_widget_freeze_accelerators (menu_item); gtk_container_add (GTK_CONTAINER (menu_item), page->menu_label); gtk_menu_insert (GTK_MENU (notebook->menu), menu_item, position); gtk_signal_connect (GTK_OBJECT (menu_item), "activate", diff --git a/gtk/gtksignal.c b/gtk/gtksignal.c index 45330e84f1..edd7858e05 100644 --- a/gtk/gtksignal.c +++ b/gtk/gtksignal.c @@ -1501,7 +1501,44 @@ gtk_signal_handler_pending (GtkObject *object, while (handlers && handlers->signal_id == signal_id) { if (handlers->id > 0 && - (may_be_blocked || handlers->blocked == 0)) + (may_be_blocked || handlers->blocked == FALSE)) + { + handler_id = handlers->id; + break; + } + + handlers = handlers->next; + } + + return handler_id; +} + +guint +gtk_signal_handler_pending_by_func (GtkObject *object, + guint signal_id, + gboolean may_be_blocked, + GtkSignalFunc func, + gpointer data) +{ + GtkHandler *handlers; + guint handler_id; + + g_return_val_if_fail (object != NULL, 0); + g_return_val_if_fail (func != NULL, 0); + g_return_val_if_fail (signal_id >= 1, 0); + + if (GTK_OBJECT_CONNECTED (object)) + handlers = gtk_signal_get_handlers (object, signal_id); + else + return 0; + + handler_id = 0; + while (handlers && handlers->signal_id == signal_id) + { + if (handlers->id > 0 && + handlers->func == func && + handlers->func_data == data && + (may_be_blocked || handlers->blocked == FALSE)) { handler_id = handlers->id; break; diff --git a/gtk/gtksignal.h b/gtk/gtksignal.h index affaebb35e..28a31e6a49 100644 --- a/gtk/gtksignal.h +++ b/gtk/gtksignal.h @@ -165,6 +165,11 @@ void gtk_signal_handler_unblock_by_data (GtkObject *object, guint gtk_signal_handler_pending (GtkObject *object, guint signal_id, gboolean may_be_blocked); +guint gtk_signal_handler_pending_by_func (GtkObject *object, + guint signal_id, + gboolean may_be_blocked, + GtkSignalFunc func, + gpointer data); void gtk_signal_handlers_destroy (GtkObject *object); void gtk_signal_default_marshaller (GtkObject *object, GtkSignalFunc func, diff --git a/gtk/gtktypebuiltins_evals.c b/gtk/gtktypebuiltins_evals.c index 11c4e722e8..33ee6aff6a 100644 --- a/gtk/gtktypebuiltins_evals.c +++ b/gtk/gtktypebuiltins_evals.c @@ -300,7 +300,6 @@ static GtkEnumValue _gtk_private_flags_values[] = { static GtkEnumValue _gtk_spin_button_update_policy_values[] = { { GTK_UPDATE_ALWAYS, "GTK_UPDATE_ALWAYS", "always" }, { GTK_UPDATE_IF_VALID, "GTK_UPDATE_IF_VALID", "if-valid" }, - { GTK_UPDATE_SNAP_TO_TICKS, "GTK_UPDATE_SNAP_TO_TICKS", "snap-to-ticks" }, { 0, NULL, NULL } }; static GtkEnumValue _gtk_toolbar_child_type_values[] = { diff --git a/gtk/gtktypebuiltins_ids.c b/gtk/gtktypebuiltins_ids.c index 090e030983..52e9e9f6e2 100644 --- a/gtk/gtktypebuiltins_ids.c +++ b/gtk/gtktypebuiltins_ids.c @@ -85,7 +85,7 @@ { "GtkPrivateFlags", >K_TYPE_PRIVATE_FLAGS, GTK_TYPE_FLAGS, _gtk_private_flags_values }, { "GtkSpinButtonUpdatePolicy", >K_TYPE_SPIN_BUTTON_UPDATE_POLICY, - GTK_TYPE_FLAGS, _gtk_spin_button_update_policy_values }, + GTK_TYPE_ENUM, _gtk_spin_button_update_policy_values }, { "GtkToolbarChildType", >K_TYPE_TOOLBAR_CHILD_TYPE, GTK_TYPE_ENUM, _gtk_toolbar_child_type_values }, { "GtkTreeViewMode", >K_TYPE_TREE_VIEW_MODE, diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index d428ce96ee..2d20cc3e4e 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -1847,6 +1847,68 @@ gtk_widget_size_allocate (GtkWidget *widget, gtk_signal_emit (GTK_OBJECT (widget), widget_signals[SIZE_ALLOCATE], &real_allocation); } +static void +gtk_widget_stop_add_accelerator (GtkWidget *widget) +{ + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_WIDGET (widget)); + + gtk_signal_emit_stop (GTK_OBJECT (widget), widget_signals[ADD_ACCELERATOR]); +} + +static void +gtk_widget_stop_remove_accelerator (GtkWidget *widget) +{ + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_WIDGET (widget)); + + gtk_signal_emit_stop (GTK_OBJECT (widget), widget_signals[REMOVE_ACCELERATOR]); +} + +void +gtk_widget_freeze_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) + { + gtk_signal_connect (GTK_OBJECT (widget), + "add_accelerator", + GTK_SIGNAL_FUNC (gtk_widget_stop_add_accelerator), + NULL); + gtk_signal_connect (GTK_OBJECT (widget), + "remove_accelerator", + GTK_SIGNAL_FUNC (gtk_widget_stop_remove_accelerator), + NULL); + } +} + +void +gtk_widget_thaw_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) + { + gtk_signal_disconnect_by_func (GTK_OBJECT (widget), + GTK_SIGNAL_FUNC (gtk_widget_stop_add_accelerator), + NULL); + gtk_signal_disconnect_by_func (GTK_OBJECT (widget), + GTK_SIGNAL_FUNC (gtk_widget_stop_remove_accelerator), + NULL); + } +} + void gtk_widget_add_accelerator (GtkWidget *widget, const gchar *accel_signal, @@ -1867,15 +1929,6 @@ gtk_widget_add_accelerator (GtkWidget *widget, accel_signal); } -void -gtk_widget_stop_accelerator (GtkWidget *widget) -{ - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_WIDGET (widget)); - - gtk_signal_emit_stop (GTK_OBJECT (widget), widget_signals[ADD_ACCELERATOR]); -} - void gtk_widget_remove_accelerator (GtkWidget *widget, GtkAccelGroup *accel_group, diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 2aa7ec8b94..9f75a4b1cd 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -403,7 +403,6 @@ void gtk_widget_add_accelerator (GtkWidget *widget, guint accel_key, guint accel_mods, GtkAccelFlags accel_flags); -void gtk_widget_stop_accelerator (GtkWidget *widget); void gtk_widget_remove_accelerator (GtkWidget *widget, GtkAccelGroup *accel_group, guint accel_key, @@ -415,6 +414,8 @@ guint gtk_widget_accelerator_signal (GtkWidget *widget, GtkAccelGroup *accel_group, guint accel_key, guint accel_mods); +void gtk_widget_freeze_accelerators (GtkWidget *widget); +void gtk_widget_thaw_accelerators (GtkWidget *widget); gint gtk_widget_event (GtkWidget *widget, GdkEvent *event); diff --git a/gtk/testgtk.c b/gtk/testgtk.c index c3c24e421d..3288d2887c 100644 --- a/gtk/testgtk.c +++ b/gtk/testgtk.c @@ -23,6 +23,7 @@ #include "gtk.h" #include "../gdk/gdk.h" #include "../gdk/gdkx.h" +#include "../gdk/gdkkeysyms.h" #include "circles.xbm" @@ -2056,64 +2057,104 @@ create_menus (void) GtkWidget *box1; GtkWidget *box2; GtkWidget *button; - GtkWidget *menu; - GtkWidget *menubar; - GtkWidget *menuitem; GtkWidget *optionmenu; GtkWidget *separator; - + if (!window) { + GtkWidget *menubar; + GtkWidget *menu; + GtkWidget *menuitem; + GtkAccelGroup *accel_group; + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - + gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &window); gtk_signal_connect (GTK_OBJECT (window), "delete-event", GTK_SIGNAL_FUNC (gtk_true), NULL); - + gtk_window_set_title (GTK_WINDOW (window), "menus"); gtk_container_border_width (GTK_CONTAINER (window), 0); - - + + box1 = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (window), box1); gtk_widget_show (box1); - - + + menubar = gtk_menu_bar_new (); gtk_box_pack_start (GTK_BOX (box1), menubar, FALSE, TRUE, 0); gtk_widget_show (menubar); - + menu = create_menu (2); - + menuitem = gtk_menu_item_new_with_label ("test\nline2"); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu); gtk_menu_bar_append (GTK_MENU_BAR (menubar), menuitem); gtk_widget_show (menuitem); - + menuitem = gtk_menu_item_new_with_label ("foo"); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (3)); gtk_menu_bar_append (GTK_MENU_BAR (menubar), menuitem); gtk_widget_show (menuitem); - + menuitem = gtk_menu_item_new_with_label ("bar"); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (4)); gtk_menu_item_right_justify (GTK_MENU_ITEM (menuitem)); gtk_menu_bar_append (GTK_MENU_BAR (menubar), menuitem); gtk_widget_show (menuitem); - - + + box2 = gtk_vbox_new (FALSE, 10); gtk_container_border_width (GTK_CONTAINER (box2), 10); gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0); gtk_widget_show (box2); + + menu = create_menu (1); + accel_group = gtk_accel_group_get_default (); + gtk_menu_set_accel_group (GTK_MENU (menu), accel_group); - + menuitem = gtk_check_menu_item_new_with_label ("Accelerate Me"); + gtk_menu_append (GTK_MENU (menu), menuitem); + gtk_widget_show (menuitem); + gtk_widget_add_accelerator (menuitem, + "activate", + accel_group, + GDK_F1, + 0, + GTK_ACCEL_VISIBLE | GTK_ACCEL_SIGNAL_VISIBLE); + menuitem = gtk_check_menu_item_new_with_label ("Accelerator Locked"); + gtk_menu_append (GTK_MENU (menu), menuitem); + gtk_widget_show (menuitem); + gtk_widget_add_accelerator (menuitem, + "activate", + accel_group, + GDK_F2, + 0, + GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED); + menuitem = gtk_check_menu_item_new_with_label ("Accelerators Frozen"); + gtk_menu_append (GTK_MENU (menu), menuitem); + gtk_widget_show (menuitem); + gtk_widget_add_accelerator (menuitem, + "activate", + accel_group, + GDK_F2, + 0, + GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (menuitem, + "activate", + accel_group, + GDK_F3, + 0, + GTK_ACCEL_VISIBLE); + gtk_widget_freeze_accelerators (menuitem); + optionmenu = gtk_option_menu_new (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), create_menu (1)); - gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu), 4); + gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), menu); + gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu), 3); gtk_box_pack_start (GTK_BOX (box2), optionmenu, TRUE, TRUE, 0); gtk_widget_show (optionmenu); diff --git a/tests/testgtk.c b/tests/testgtk.c index c3c24e421d..3288d2887c 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -23,6 +23,7 @@ #include "gtk.h" #include "../gdk/gdk.h" #include "../gdk/gdkx.h" +#include "../gdk/gdkkeysyms.h" #include "circles.xbm" @@ -2056,64 +2057,104 @@ create_menus (void) GtkWidget *box1; GtkWidget *box2; GtkWidget *button; - GtkWidget *menu; - GtkWidget *menubar; - GtkWidget *menuitem; GtkWidget *optionmenu; GtkWidget *separator; - + if (!window) { + GtkWidget *menubar; + GtkWidget *menu; + GtkWidget *menuitem; + GtkAccelGroup *accel_group; + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - + gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &window); gtk_signal_connect (GTK_OBJECT (window), "delete-event", GTK_SIGNAL_FUNC (gtk_true), NULL); - + gtk_window_set_title (GTK_WINDOW (window), "menus"); gtk_container_border_width (GTK_CONTAINER (window), 0); - - + + box1 = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (window), box1); gtk_widget_show (box1); - - + + menubar = gtk_menu_bar_new (); gtk_box_pack_start (GTK_BOX (box1), menubar, FALSE, TRUE, 0); gtk_widget_show (menubar); - + menu = create_menu (2); - + menuitem = gtk_menu_item_new_with_label ("test\nline2"); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu); gtk_menu_bar_append (GTK_MENU_BAR (menubar), menuitem); gtk_widget_show (menuitem); - + menuitem = gtk_menu_item_new_with_label ("foo"); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (3)); gtk_menu_bar_append (GTK_MENU_BAR (menubar), menuitem); gtk_widget_show (menuitem); - + menuitem = gtk_menu_item_new_with_label ("bar"); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (4)); gtk_menu_item_right_justify (GTK_MENU_ITEM (menuitem)); gtk_menu_bar_append (GTK_MENU_BAR (menubar), menuitem); gtk_widget_show (menuitem); - - + + box2 = gtk_vbox_new (FALSE, 10); gtk_container_border_width (GTK_CONTAINER (box2), 10); gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0); gtk_widget_show (box2); + + menu = create_menu (1); + accel_group = gtk_accel_group_get_default (); + gtk_menu_set_accel_group (GTK_MENU (menu), accel_group); - + menuitem = gtk_check_menu_item_new_with_label ("Accelerate Me"); + gtk_menu_append (GTK_MENU (menu), menuitem); + gtk_widget_show (menuitem); + gtk_widget_add_accelerator (menuitem, + "activate", + accel_group, + GDK_F1, + 0, + GTK_ACCEL_VISIBLE | GTK_ACCEL_SIGNAL_VISIBLE); + menuitem = gtk_check_menu_item_new_with_label ("Accelerator Locked"); + gtk_menu_append (GTK_MENU (menu), menuitem); + gtk_widget_show (menuitem); + gtk_widget_add_accelerator (menuitem, + "activate", + accel_group, + GDK_F2, + 0, + GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED); + menuitem = gtk_check_menu_item_new_with_label ("Accelerators Frozen"); + gtk_menu_append (GTK_MENU (menu), menuitem); + gtk_widget_show (menuitem); + gtk_widget_add_accelerator (menuitem, + "activate", + accel_group, + GDK_F2, + 0, + GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (menuitem, + "activate", + accel_group, + GDK_F3, + 0, + GTK_ACCEL_VISIBLE); + gtk_widget_freeze_accelerators (menuitem); + optionmenu = gtk_option_menu_new (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), create_menu (1)); - gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu), 4); + gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), menu); + gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu), 3); gtk_box_pack_start (GTK_BOX (box2), optionmenu, TRUE, TRUE, 0); gtk_widget_show (optionmenu);