Some trouble with default key bindings



Good day,

I would to suggest one thing.

I have been installed 2.0.2 version of GTK+ on my Linux machine.
As I found GtkCombo uses ATL+TAB key binding for entry completion,
and that binding is hardcoded in GTK-2.0 gtkcombo.c file.
I guess, it's obvious - ALT+TAB is "standart" switch btw
applications in most Window servers.

In KDE, for example, I couldn't disable/reserve that binding for
my GTK application, so, I couldn't use ALT+TAB for completion
in combo boxes.

It would be great if such bindings could be adjustable by "USER".
You could organize something like GtkCommonBindings widget:

struct GtkCommonBindings {
  ...
  GList *key_bindings;
/* where key_bindings is
    struct GtkKeyBindings {
      GtkType widget_type; // "guint types;" - bit mask combined from
GtkType
                           // if valid widget type then this binding
                           // will work only for specified widgets
                           // otherwise binding is common for all
widgets
                           // So, you could use same KEY with different
                           // actions for different widgets.
      guint keyval; // they key name from gdk/gdkkeysym.h
      gchar *action;  // sample: "focus-next", "signal-activate"
                      // action name is using to determine action_func()

                      // by default
      guint state; // bit mask combined from GdkModifierType
      void (*action_func)(GtkWidget* widget, gpointer *data);
                            // function to perform when binding is
invoked

                            // widget - widget where binding is invoked
      gpointer *data; // data to pass to action_func()
    }
*/
  ...
};

Initizlize it with default values.
Implement some functions to adjust (add,modify,delete) bindings.
Then recode key_press event handlers in all widgets to use
appropriate values from GtkCommonBindings widget instead of hard
coded key values.

some_user_func()
{
...

GtkWidget *key_binds = gtk_common_bindings_get_default();
GtkKeyBindings *key =
    gtk_common_bindings_get_key_by_action (key_binds, "combo-complete");

key->keyval = GDK_Tab;
key->state = GDK_SHIFT_MASK & GDK_MOD1_MASK;
gtk_common_bindings_set_key_byaction (key_binds, "combo-complete", key);

...
}

.../gtk-2.0/gtk/gtkcombo.c

gtk_combo_entry_key_press(GtkEntry *entry, GdkEventKey *event, GtkCombo
*combo)
{
...

GtkWidget *key_binds = gtk_common_bindings_get_default();
GtkKeyBindings *key =
    gtk_common_bindings_get_key_by_action (key_binds, "combo-complete");

if (event->keyval == key->keyval &&
    event->state == key->state) {
  -> do completion
}

...

}

Thank you,
-Andrew






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