1
0
Fork 0

keybindings: Use a GSettings object rather than a schema, to support extensions

If we want to support keybindings from extensions installed in the user's
directory, we can't take a schema, as the GSettings object needs to have
a special GSettingsSchemaSource.

https://bugzilla.gnome.org/show_bug.cgi?id=673014
This commit is contained in:
Jasper St. Pierre 2012-03-27 11:42:42 -03:00
parent 65390e50a4
commit 68321d9bf4
5 changed files with 113 additions and 110 deletions

View file

@ -29,6 +29,7 @@
#ifndef META_KEYBINDINGS_PRIVATE_H
#define META_KEYBINDINGS_PRIVATE_H
#include <gio/gio.h>
#include <meta/keybindings.h>
struct _MetaKeyHandler
@ -73,7 +74,7 @@ void meta_display_process_mapping_event (MetaDisplay *display,
XEvent *event);
gboolean meta_prefs_add_keybinding (const char *name,
const char *schema,
GSettings *settings,
MetaKeyBindingAction action,
MetaKeyBindingFlags flags);

View file

@ -53,7 +53,7 @@ static gboolean all_bindings_disabled = FALSE;
static gboolean add_builtin_keybinding (MetaDisplay *display,
const char *name,
const char *schema,
GSettings *settings,
MetaKeyBindingFlags flags,
MetaKeyBindingAction action,
MetaKeyHandlerFunc handler,
@ -546,7 +546,7 @@ display_get_keybinding (MetaDisplay *display,
static gboolean
add_keybinding_internal (MetaDisplay *display,
const char *name,
const char *schema,
GSettings *settings,
MetaKeyBindingFlags flags,
MetaKeyBindingAction action,
MetaKeyHandlerFunc func,
@ -556,7 +556,7 @@ add_keybinding_internal (MetaDisplay *display,
{
MetaKeyHandler *handler;
if (!meta_prefs_add_keybinding (name, schema, action, flags))
if (!meta_prefs_add_keybinding (name, settings, action, flags))
return FALSE;
handler = g_new0 (MetaKeyHandler, 1);
@ -576,13 +576,13 @@ add_keybinding_internal (MetaDisplay *display,
static gboolean
add_builtin_keybinding (MetaDisplay *display,
const char *name,
const char *schema,
GSettings *settings,
MetaKeyBindingFlags flags,
MetaKeyBindingAction action,
MetaKeyHandlerFunc handler,
int handler_arg)
{
return add_keybinding_internal (display, name, schema,
return add_keybinding_internal (display, name, settings,
flags | META_KEY_BINDING_BUILTIN,
action, handler, handler_arg, NULL, NULL);
}
@ -591,7 +591,7 @@ add_builtin_keybinding (MetaDisplay *display,
* meta_display_add_keybinding:
* @display: a #MetaDisplay
* @name: the binding's name
* @schema: the #GSettings schema where @name is stored
* @settings: the #GSettings object where @name is stored
* @flags: flags to specify binding details
* @handler: function to run when the keybinding is invoked
* @user_data: the data to pass to @handler
@ -617,13 +617,13 @@ add_builtin_keybinding (MetaDisplay *display,
gboolean
meta_display_add_keybinding (MetaDisplay *display,
const char *name,
const char *schema,
GSettings *settings,
MetaKeyBindingFlags flags,
MetaKeyHandlerFunc handler,
gpointer user_data,
GDestroyNotify free_data)
{
return add_keybinding_internal (display, name, schema, flags,
return add_keybinding_internal (display, name, settings, flags,
META_KEYBINDING_ACTION_NONE,
handler, 0, user_data, free_data);
}
@ -3644,104 +3644,106 @@ init_builtin_key_bindings (MetaDisplay *display)
{
#define REVERSES_AND_REVERSED (META_KEY_BINDING_REVERSES | \
META_KEY_BINDING_IS_REVERSED)
GSettings *common_keybindings = g_settings_new (SCHEMA_COMMON_KEYBINDINGS);
GSettings *mutter_keybindings = g_settings_new (SCHEMA_MUTTER_KEYBINDINGS);
add_builtin_keybinding (display,
"switch-to-workspace-1",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_WORKSPACE_1,
handle_switch_to_workspace, 0);
add_builtin_keybinding (display,
"switch-to-workspace-2",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_WORKSPACE_2,
handle_switch_to_workspace, 1);
add_builtin_keybinding (display,
"switch-to-workspace-3",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_WORKSPACE_3,
handle_switch_to_workspace, 2);
add_builtin_keybinding (display,
"switch-to-workspace-4",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_WORKSPACE_4,
handle_switch_to_workspace, 3);
add_builtin_keybinding (display,
"switch-to-workspace-5",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_WORKSPACE_5,
handle_switch_to_workspace, 4);
add_builtin_keybinding (display,
"switch-to-workspace-6",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_WORKSPACE_6,
handle_switch_to_workspace, 5);
add_builtin_keybinding (display,
"switch-to-workspace-7",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_WORKSPACE_7,
handle_switch_to_workspace, 6);
add_builtin_keybinding (display,
"switch-to-workspace-8",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_WORKSPACE_8,
handle_switch_to_workspace, 7);
add_builtin_keybinding (display,
"switch-to-workspace-9",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_WORKSPACE_9,
handle_switch_to_workspace, 8);
add_builtin_keybinding (display,
"switch-to-workspace-10",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_WORKSPACE_10,
handle_switch_to_workspace, 9);
add_builtin_keybinding (display,
"switch-to-workspace-11",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_WORKSPACE_11,
handle_switch_to_workspace, 10);
add_builtin_keybinding (display,
"switch-to-workspace-12",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_WORKSPACE_12,
handle_switch_to_workspace, 11);
add_builtin_keybinding (display,
"switch-to-workspace-left",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_WORKSPACE_LEFT,
handle_switch_to_workspace, META_MOTION_LEFT);
add_builtin_keybinding (display,
"switch-to-workspace-right",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_WORKSPACE_RIGHT,
handle_switch_to_workspace, META_MOTION_RIGHT);
add_builtin_keybinding (display,
"switch-to-workspace-up",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_WORKSPACE_UP,
handle_switch_to_workspace, META_MOTION_UP);
add_builtin_keybinding (display,
"switch-to-workspace-down",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_WORKSPACE_DOWN,
handle_switch_to_workspace, META_MOTION_DOWN);
@ -3759,84 +3761,84 @@ init_builtin_key_bindings (MetaDisplay *display)
add_builtin_keybinding (display,
"switch-group",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_REVERSES,
META_KEYBINDING_ACTION_SWITCH_GROUP,
handle_switch, META_TAB_LIST_GROUP);
add_builtin_keybinding (display,
"switch-group-backward",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
REVERSES_AND_REVERSED,
META_KEYBINDING_ACTION_SWITCH_GROUP_BACKWARD,
handle_switch, META_TAB_LIST_GROUP);
add_builtin_keybinding (display,
"switch-windows",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_REVERSES,
META_KEYBINDING_ACTION_SWITCH_WINDOWS,
handle_switch, META_TAB_LIST_NORMAL);
add_builtin_keybinding (display,
"switch-windows-backward",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
REVERSES_AND_REVERSED,
META_KEYBINDING_ACTION_SWITCH_WINDOWS_BACKWARD,
handle_switch, META_TAB_LIST_NORMAL);
add_builtin_keybinding (display,
"switch-panels",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_REVERSES,
META_KEYBINDING_ACTION_SWITCH_PANELS,
handle_switch, META_TAB_LIST_DOCKS);
add_builtin_keybinding (display,
"switch-panels-backward",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
REVERSES_AND_REVERSED,
META_KEYBINDING_ACTION_SWITCH_PANELS_BACKWARD,
handle_switch, META_TAB_LIST_DOCKS);
add_builtin_keybinding (display,
"cycle-group",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_REVERSES,
META_KEYBINDING_ACTION_CYCLE_GROUP,
handle_cycle, META_TAB_LIST_GROUP);
add_builtin_keybinding (display,
"cycle-group-backward",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
REVERSES_AND_REVERSED,
META_KEYBINDING_ACTION_CYCLE_GROUP_BACKWARD,
handle_cycle, META_TAB_LIST_GROUP);
add_builtin_keybinding (display,
"cycle-windows",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_REVERSES,
META_KEYBINDING_ACTION_CYCLE_WINDOWS,
handle_cycle, META_TAB_LIST_NORMAL);
add_builtin_keybinding (display,
"cycle-windows-backward",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
REVERSES_AND_REVERSED,
META_KEYBINDING_ACTION_CYCLE_WINDOWS_BACKWARD,
handle_cycle, META_TAB_LIST_NORMAL);
add_builtin_keybinding (display,
"cycle-panels",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_REVERSES,
META_KEYBINDING_ACTION_CYCLE_PANELS,
handle_cycle, META_TAB_LIST_DOCKS);
add_builtin_keybinding (display,
"cycle-panels-backward",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
REVERSES_AND_REVERSED,
META_KEYBINDING_ACTION_CYCLE_PANELS_BACKWARD,
handle_cycle, META_TAB_LIST_DOCKS);
@ -3849,14 +3851,14 @@ init_builtin_key_bindings (MetaDisplay *display)
*/
add_builtin_keybinding (display,
"tab-popup-select",
SCHEMA_MUTTER_KEYBINDINGS,
mutter_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_TAB_POPUP_SELECT,
handle_tab_popup_select, 0);
add_builtin_keybinding (display,
"tab-popup-cancel",
SCHEMA_MUTTER_KEYBINDINGS,
mutter_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_TAB_POPUP_CANCEL,
handle_tab_popup_cancel, 0);
@ -3865,35 +3867,35 @@ init_builtin_key_bindings (MetaDisplay *display)
add_builtin_keybinding (display,
"show-desktop",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_SHOW_DESKTOP,
handle_show_desktop, 0);
add_builtin_keybinding (display,
"panel-main-menu",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_PANEL_MAIN_MENU,
handle_panel, META_KEYBINDING_ACTION_PANEL_MAIN_MENU);
add_builtin_keybinding (display,
"panel-run-dialog",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_PANEL_RUN_DIALOG,
handle_panel, META_KEYBINDING_ACTION_PANEL_RUN_DIALOG);
add_builtin_keybinding (display,
"toggle-recording",
SCHEMA_MUTTER_KEYBINDINGS,
mutter_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_TOGGLE_RECORDING,
handle_toggle_recording, 0);
add_builtin_keybinding (display,
"set-spew-mark",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_NONE,
META_KEYBINDING_ACTION_SET_SPEW_MARK,
handle_set_spew_mark, 0);
@ -3908,311 +3910,314 @@ init_builtin_key_bindings (MetaDisplay *display)
add_builtin_keybinding (display,
"activate-window-menu",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_ACTIVATE_WINDOW_MENU,
handle_activate_window_menu, 0);
add_builtin_keybinding (display,
"toggle-fullscreen",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_TOGGLE_FULLSCREEN,
handle_toggle_fullscreen, 0);
add_builtin_keybinding (display,
"toggle-maximized",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_TOGGLE_MAXIMIZED,
handle_toggle_maximized, 0);
add_builtin_keybinding (display,
"toggle-tiled-left",
SCHEMA_MUTTER_KEYBINDINGS,
mutter_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_TOGGLE_TILED_LEFT,
handle_toggle_tiled, META_TILE_LEFT);
add_builtin_keybinding (display,
"toggle-tiled-right",
SCHEMA_MUTTER_KEYBINDINGS,
mutter_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_TOGGLE_TILED_RIGHT,
handle_toggle_tiled, META_TILE_RIGHT);
add_builtin_keybinding (display,
"toggle-above",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_TOGGLE_ABOVE,
handle_toggle_above, 0);
add_builtin_keybinding (display,
"maximize",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MAXIMIZE,
handle_maximize, 0);
add_builtin_keybinding (display,
"unmaximize",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_UNMAXIMIZE,
handle_unmaximize, 0);
add_builtin_keybinding (display,
"toggle-shaded",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_TOGGLE_SHADED,
handle_toggle_shaded, 0);
add_builtin_keybinding (display,
"minimize",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MINIMIZE,
handle_minimize, 0);
add_builtin_keybinding (display,
"close",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_CLOSE,
handle_close, 0);
add_builtin_keybinding (display,
"begin-move",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_BEGIN_MOVE,
handle_begin_move, 0);
add_builtin_keybinding (display,
"begin-resize",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_BEGIN_RESIZE,
handle_begin_resize, 0);
add_builtin_keybinding (display,
"toggle-on-all-workspaces",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_TOGGLE_ON_ALL_WORKSPACES,
handle_toggle_on_all_workspaces, 0);
add_builtin_keybinding (display,
"move-to-workspace-1",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_1,
handle_move_to_workspace, 0);
add_builtin_keybinding (display,
"move-to-workspace-2",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_2,
handle_move_to_workspace, 1);
add_builtin_keybinding (display,
"move-to-workspace-3",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_3,
handle_move_to_workspace, 2);
add_builtin_keybinding (display,
"move-to-workspace-4",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_4,
handle_move_to_workspace, 3);
add_builtin_keybinding (display,
"move-to-workspace-5",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_5,
handle_move_to_workspace, 4);
add_builtin_keybinding (display,
"move-to-workspace-6",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_6,
handle_move_to_workspace, 5);
add_builtin_keybinding (display,
"move-to-workspace-7",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_7,
handle_move_to_workspace, 6);
add_builtin_keybinding (display,
"move-to-workspace-8",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_8,
handle_move_to_workspace, 7);
add_builtin_keybinding (display,
"move-to-workspace-9",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_9,
handle_move_to_workspace, 8);
add_builtin_keybinding (display,
"move-to-workspace-10",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_10,
handle_move_to_workspace, 9);
add_builtin_keybinding (display,
"move-to-workspace-11",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_11,
handle_move_to_workspace, 10);
add_builtin_keybinding (display,
"move-to-workspace-12",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_12,
handle_move_to_workspace, 11);
add_builtin_keybinding (display,
"move-to-workspace-left",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_LEFT,
handle_move_to_workspace, META_MOTION_LEFT);
add_builtin_keybinding (display,
"move-to-workspace-right",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_RIGHT,
handle_move_to_workspace, META_MOTION_RIGHT);
add_builtin_keybinding (display,
"move-to-workspace-up",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_UP,
handle_move_to_workspace, META_MOTION_UP);
add_builtin_keybinding (display,
"move-to-workspace-down",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_DOWN,
handle_move_to_workspace, META_MOTION_DOWN);
add_builtin_keybinding (display,
"raise-or-lower",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_RAISE_OR_LOWER,
handle_raise_or_lower, 0);
add_builtin_keybinding (display,
"raise",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_RAISE,
handle_raise, 0);
add_builtin_keybinding (display,
"lower",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_LOWER,
handle_lower, 0);
add_builtin_keybinding (display,
"maximize-vertically",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MAXIMIZE_VERTICALLY,
handle_maximize_vertically, 0);
add_builtin_keybinding (display,
"maximize-horizontally",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MAXIMIZE_HORIZONTALLY,
handle_maximize_horizontally, 0);
add_builtin_keybinding (display,
"move-to-corner-nw",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_CORNER_NW,
handle_move_to_corner_nw, 0);
add_builtin_keybinding (display,
"move-to-corner-ne",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_CORNER_NE,
handle_move_to_corner_ne, 0);
add_builtin_keybinding (display,
"move-to-corner-sw",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_CORNER_SW,
handle_move_to_corner_sw, 0);
add_builtin_keybinding (display,
"move-to-corner-se",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_CORNER_SE,
handle_move_to_corner_se, 0);
add_builtin_keybinding (display,
"move-to-side-n",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_SIDE_N,
handle_move_to_side_n, 0);
add_builtin_keybinding (display,
"move-to-side-s",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_SIDE_S,
handle_move_to_side_s, 0);
add_builtin_keybinding (display,
"move-to-side-e",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_SIDE_E,
handle_move_to_side_e, 0);
add_builtin_keybinding (display,
"move-to-side-w",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_SIDE_W,
handle_move_to_side_w, 0);
add_builtin_keybinding (display,
"move-to-center",
SCHEMA_COMMON_KEYBINDINGS,
common_keybindings,
META_KEY_BINDING_PER_WINDOW,
META_KEYBINDING_ACTION_MOVE_TO_CENTER,
handle_move_to_center, 0);
g_object_unref (common_keybindings);
g_object_unref (mutter_keybindings);
}
void

View file

@ -1660,7 +1660,7 @@ meta_key_pref_free (MetaKeyPref *pref)
update_binding (pref, NULL);
g_free (pref->name);
g_free (pref->schema);
g_object_unref (pref->settings);
g_free (pref);
}
@ -1920,13 +1920,13 @@ meta_prefs_get_visual_bell_type (void)
gboolean
meta_prefs_add_keybinding (const char *name,
const char *schema,
GSettings *settings,
MetaKeyBindingAction action,
MetaKeyBindingFlags flags)
{
MetaKeyPref *pref;
GSettings *settings;
char **strokes;
guint id;
if (g_hash_table_lookup (key_bindings, name))
{
@ -1934,19 +1934,9 @@ meta_prefs_add_keybinding (const char *name,
return FALSE;
}
settings = SETTINGS (schema);
if (settings == NULL)
{
settings = g_settings_new (schema);
if ((flags & META_KEY_BINDING_BUILTIN) != 0)
g_signal_connect (settings, "changed",
G_CALLBACK (bindings_changed), NULL);
g_hash_table_insert (settings_schemas, g_strdup (schema), settings);
}
pref = g_new0 (MetaKeyPref, 1);
pref->name = g_strdup (name);
pref->schema = g_strdup (schema);
pref->settings = g_object_ref (settings);
pref->action = action;
pref->bindings = NULL;
pref->add_shift = (flags & META_KEY_BINDING_REVERSES) != 0;
@ -1959,9 +1949,17 @@ meta_prefs_add_keybinding (const char *name,
g_hash_table_insert (key_bindings, g_strdup (name), pref);
if (!pref->builtin)
if (pref->builtin)
{
if (g_object_get_data (G_OBJECT (settings), "changed-signal") == NULL)
{
id = g_signal_connect (settings, "changed",
G_CALLBACK (bindings_changed), NULL);
g_object_set_data (G_OBJECT (settings), "changed-signal", GUINT_TO_POINTER (id));
}
}
else
{
guint id;
char *changed_signal = g_strdup_printf ("changed::%s", name);
id = g_signal_connect (settings, changed_signal,
G_CALLBACK (bindings_changed), NULL);
@ -1979,7 +1977,6 @@ gboolean
meta_prefs_remove_keybinding (const char *name)
{
MetaKeyPref *pref;
GSettings *settings;
guint id;
pref = g_hash_table_lookup (key_bindings, name);
@ -1995,9 +1992,8 @@ meta_prefs_remove_keybinding (const char *name)
return FALSE;
}
settings = SETTINGS (pref->schema);
id = GPOINTER_TO_UINT (g_object_steal_data (G_OBJECT (settings), name));
g_signal_handler_disconnect (settings, id);
id = GPOINTER_TO_UINT (g_object_steal_data (G_OBJECT (pref->settings), name));
g_signal_handler_disconnect (pref->settings, id);
g_hash_table_remove (key_bindings, name);

View file

@ -129,7 +129,7 @@ MetaGrabOp meta_display_get_grab_op (MetaDisplay *display);
gboolean meta_display_add_keybinding (MetaDisplay *display,
const char *name,
const char *schema,
GSettings *settings,
MetaKeyBindingFlags flags,
MetaKeyHandlerFunc handler,
gpointer user_data,

View file

@ -30,6 +30,7 @@
#include <meta/types.h>
#include <pango/pango-font.h>
#include <gdesktop-enums.h>
#include <gio/gio.h>
/* Keep in sync with GSettings schemas! */
typedef enum
@ -271,7 +272,7 @@ typedef struct _MetaKeyHandler MetaKeyHandler;
typedef struct
{
char *name;
char *schema;
GSettings *settings;
MetaKeyBindingAction action;