accel activation on invisible pages

hey owen, james.

afaik, we still have the problem of activating accelerators
on invisible notebook pages (and maybe even hidden widgets, iirc).
while the accel mechanism generally allows for selective activation,
the current implementation in gtkwidget.c doesn't make use of
that yet:

static void
closure_accel_activate (GClosure     *closure,
                        GValue       *return_value,
                        guint         n_param_values,
                        const GValue *param_values,
                        gpointer      invocation_hint,
                        gpointer      marshal_data)
  AccelClosure *aclosure = (AccelClosure*) closure;

  if (GTK_WIDGET_IS_SENSITIVE (closure->data))
    g_signal_emit (closure->data, aclosure->signal_id, 0);

  /* we handled the accelerator */
  g_value_set_boolean (return_value, TRUE);

i'd like to refine the implementation of that function to:

  gboolean can_activate = FALSE;
  g_signal_emit (closure->data, signals[CAN_ACCEL_ACTIVATE], 0, aclosure->signal_id, &can_activate);

  if (can_activate)
    g_signal_emit (closure->data, aclosure->signal_id, 0);

  /* wether accelerator was handled */
  g_value_set_boolean (return_value, can_activate);

by introducing a new signal on GtkWidget:

	gboolean (*can_activate_accel) (GtkWidget *widget, guint signal_id);

with a GtkWidget class handler of:

static gboolean
widget_can_activate_accel (GtkWidget *widget, guint signal_id)
  return GTK_WIDGET_IS_SENSITIVE (widget) && gdk_window_is_viewable (widget->window);

and a GtkMenuItem class handler of:

static gboolean
menu_item_can_activate_accel (GtkWidget *widget, guint signal_id)
  return GTK_WIDGET_IS_SENSITIVE (widget);

the later is neccessary because ordinary widgets now need to
be viewable (have all their parent windows mapped => be on a visible
notebook page) to have their accelerators activated. however for
menu items, we actually want activation while their menus are hidden.

i'd apprechiate comments, especially if you can think of any
problems with this approach.
also, i'm pondering whether this change would be suitable for 2.2.
though an extra signal is an API addition, it does fix the
accel-activation-on-invisible-pages bug.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]