Commit f83d57e9 authored by Tim Janik's avatar Tim Janik Committed by Tim Janik

yeppers, accelerator changes to fix the gimp. commit message dedicated to


yeppers, accelerator changes to fix the gimp.
commit message dedicated to sopwith ;)

Thu Jun 18 03:30:06 1998  Tim Janik  <timj@gtk.org>

        * 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.
parent 85adae97
Thu Jun 18 03:30:06 1998 Tim Janik <timj@gtk.org>
* 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 <stefan@gtk.org>
* gtkspinbutton.h gtkspinbutton.c testgtk.c:
......
Thu Jun 18 03:30:06 1998 Tim Janik <timj@gtk.org>
* 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 <stefan@gtk.org>
* gtkspinbutton.h gtkspinbutton.c testgtk.c:
......
Thu Jun 18 03:30:06 1998 Tim Janik <timj@gtk.org>
* 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 <stefan@gtk.org>
* gtkspinbutton.h gtkspinbutton.c testgtk.c:
......
Thu Jun 18 03:30:06 1998 Tim Janik <timj@gtk.org>
* 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 <stefan@gtk.org>
* gtkspinbutton.h gtkspinbutton.c testgtk.c:
......
Thu Jun 18 03:30:06 1998 Tim Janik <timj@gtk.org>
* 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 <stefan@gtk.org>
* gtkspinbutton.h gtkspinbutton.c testgtk.c:
......
Thu Jun 18 03:30:06 1998 Tim Janik <timj@gtk.org>
* 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 <stefan@gtk.org>
* gtkspinbutton.h gtkspinbutton.c testgtk.c:
......
Thu Jun 18 03:30:06 1998 Tim Janik <timj@gtk.org>
* 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 <stefan@gtk.org>
* gtkspinbutton.h gtkspinbutton.c testgtk.c:
......
......@@ -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"
......
......@@ -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;
......
......@@ -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
......
......@@ -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);
}
}
}
......
......@@ -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
......
......@@ -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;
......
......@@ -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",
......
......@@ -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;
......
......@@ -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,
......
......@@ -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[] = {
......
......@@ -85,7 +85,7 @@
{ "GtkPrivateFlags", &GTK_TYPE_PRIVATE_FLAGS,
GTK_TYPE_FLAGS, _gtk_private_flags_values },
{ "GtkSpinButtonUpdatePolicy", &GTK_TYPE_SPIN_BUTTON_UPDATE_POLICY,
GTK_TYPE_FLAGS, _gtk_spin_button_update_policy_values },
GTK_TYPE_ENUM, _gtk_spin_button_update_policy_values },
{ "GtkToolbarChildType", &GTK_TYPE_TOOLBAR_CHILD_TYPE,
GTK_TYPE_ENUM, _gtk_toolbar_child_type_values },
{ "GtkTreeViewMode", &GTK_TYPE_TREE_VIEW_MODE,
......
......@@ -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,
......
......@@ -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);
......
......@@ -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);