Fixed accelerators stuff

master
Yevgen Muntyan 2006-11-07 06:05:12 -06:00
parent b95ec42ede
commit 4beff880d5
4 changed files with 30 additions and 35 deletions

View File

@ -35,7 +35,7 @@
<kdevautoproject>
<general>
<activetarget>moo/libmoo.la</activetarget>
<useconfiguration>debug</useconfiguration>
<useconfiguration>gtk-cvs</useconfiguration>
</general>
<run>
<mainprogram>tests/medit</mainprogram>
@ -293,16 +293,16 @@
</kdevdoctreeview>
<kdevfilecreate>
<filetypes>
<type icon="source" ext="g" name="GAP source" create="template" >
<type icon="source" ext="g" create="template" name="GAP source" >
<descr>A new empty GAP source file</descr>
</type>
<type icon="source_cpp" ext="cpp" name="C++ Source" create="template" >
<type icon="source_cpp" ext="cpp" create="template" name="C++ Source" >
<descr>A new empty C++ file.</descr>
</type>
<type icon="source_h" ext="h" name="C/C++ Header" create="template" >
<type icon="source_h" ext="h" create="template" name="C/C++ Header" >
<descr>A new empty header file for C/C++.</descr>
</type>
<type icon="source_c" ext="c" name="C Source" create="template" >
<type icon="source_c" ext="c" create="template" name="C Source" >
<descr>A new empty C file.</descr>
</type>
</filetypes>

View File

@ -156,7 +156,6 @@ set_accel (const char *accel_path,
{
guint accel_key = 0;
GdkModifierType accel_mods = 0;
GtkAccelKey old;
const char *old_accel;
g_return_if_fail (accel_path != NULL && accel != NULL);
@ -197,29 +196,9 @@ set_accel (const char *accel_path,
(gpointer) accel_map_changed,
NULL);
if (gtk_accel_map_lookup_entry (accel_path, &old))
{
if (accel_key != old.accel_key || accel_mods != old.accel_mods)
{
if (accel_key || accel_mods)
{
if (!gtk_accel_map_change_entry (accel_path, accel_key, accel_mods, TRUE))
g_warning ("could not set accel '%s' for accel_path '%s'",
accel, accel_path);
}
else
{
gtk_accel_map_change_entry (accel_path, 0, 0, TRUE);
}
}
}
else
{
if (accel_key || accel_mods)
gtk_accel_map_add_entry (accel_path,
accel_key,
accel_mods);
}
if (!gtk_accel_map_change_entry (accel_path, accel_key, accel_mods, TRUE))
g_warning ("could not set accel '%s' for accel_path '%s'",
accel, accel_path);
g_signal_handlers_unblock_by_func (gtk_accel_map_get (),
(gpointer) accel_map_changed,

View File

@ -246,17 +246,33 @@ typedef struct {
static gboolean
key_event (G_GNUC_UNUSED GtkWidget *widget,
key_event (GtkWidget *widget,
GdkEventKey *event,
Stuff *s)
{
if (gtk_accelerator_valid (event->keyval, event->state))
GdkKeymap *keymap;
guint keyval;
GdkModifierType consumed_modifiers;
GdkModifierType mods;
keymap = gdk_keymap_get_for_display (gtk_widget_get_display (widget));
gdk_keymap_translate_keyboard_state (keymap, event->hardware_keycode,
event->state, event->group,
NULL, NULL, NULL, &consumed_modifiers);
keyval = gdk_keyval_to_lower (event->keyval);
mods = event->state & gtk_accelerator_get_default_mod_mask () & ~consumed_modifiers;
if (keyval != event->keyval)
mods |= GDK_SHIFT_MASK;
if (gtk_accelerator_valid (keyval, mods))
{
char *label = gtk_accelerator_get_label (event->keyval, event->state);
char *label = gtk_accelerator_get_label (keyval, mods);
gtk_label_set_text (s->label, label);
g_free (label);
s->key = event->keyval;
s->mods = event->state;
s->key = keyval;
s->mods = mods;
}
return TRUE;

View File

@ -1348,8 +1348,8 @@ moo_window_add_action (MooWindow *window,
char *accel_path;
accel_path = _moo_action_make_accel_path (action);
_moo_action_set_accel_path (action, accel_path);
_moo_accel_register (accel_path, _moo_action_get_default_accel (action));
_moo_action_set_accel_path (action, accel_path);
g_free (accel_path);
}