Adapt to mutter moving to GSettings

https://bugzilla.gnome.org/show_bug.cgi?id=663429
This commit is contained in:
Florian Müllner 2011-06-27 03:54:26 +02:00
parent de5b00fd52
commit a9ab8784c4
11 changed files with 97 additions and 187 deletions

View File

@ -36,10 +36,6 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
PKG_PROG_PKG_CONFIG([0.22]) PKG_PROG_PKG_CONFIG([0.22])
# GConf stuff
AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
AM_GCONF_SOURCE_2
GLIB_GSETTINGS GLIB_GSETTINGS
# Get a value to substitute into gnome-shell.in # Get a value to substitute into gnome-shell.in

View File

@ -60,23 +60,14 @@ gschemas.compiled: $(gsettings_SCHEMAS:.xml=.valid)
all-local: gschemas.compiled all-local: gschemas.compiled
# GConf schemas: provide defaults for keys from Metacity we are overriding
gconfschemadir = @GCONF_SCHEMA_FILE_DIR@
gconfschema_DATA = gnome-shell.schemas
shadersdir = $(pkgdatadir)/shaders shadersdir = $(pkgdatadir)/shaders
shaders_DATA = \ shaders_DATA = \
shaders/dim-window.glsl shaders/dim-window.glsl
install-data-local:
GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(srcdir)/$(gconfschema_DATA)
EXTRA_DIST = \ EXTRA_DIST = \
gnome-shell.desktop.in.in \ gnome-shell.desktop.in.in \
$(menu_DATA) \ $(menu_DATA) \
$(gconfschema_DATA) \
$(shaders_DATA) \ $(shaders_DATA) \
org.gnome.shell.gschema.xml.in org.gnome.shell.gschema.xml.in

View File

@ -1,100 +0,0 @@
<gconfschemafile>
<schemalist>
<!-- Metacity overrides -->
<schema>
<key>/schemas/desktop/gnome/shell/windows/attach_modal_dialogs</key>
<applyto>/desktop/gnome/shell/windows/attach_modal_dialogs</applyto>
<owner>gnome-shell</owner>
<type>bool</type>
<default>true</default>
<locale name="C">
<short>Attach modal dialog to the parent window</short>
<long>
This key overrides /apps/mutter/general/attach_modal_dialogs when
running GNOME Shell.
</long>
</locale>
</schema>
<schema>
<key>/schemas/desktop/gnome/shell/windows/button_layout</key>
<applyto>/desktop/gnome/shell/windows/button_layout</applyto>
<owner>gnome-shell</owner>
<type>string</type>
<default>:close</default>
<locale name="C">
<short>Arrangement of buttons on the titlebar</short>
<long>
Arrangement of buttons on the titlebar. The
value should be a string, such as
"menu:minimize,maximize,spacer,close"; the colon separates the
left corner of the window from the right corner, and
the button names are comma-separated. Duplicate buttons
are not allowed. Unknown button names are silently ignored
so that buttons can be added in future gnome-shell versions
without breaking older versions.
A special spacer tag can be used to insert some space between
two adjacent buttons.
This key overrides /apps/metacity/general/button_layout when
running GNOME Shell.
</long>
</locale>
</schema>
<schema>
<key>/schemas/desktop/gnome/shell/windows/edge_tiling</key>
<applyto>/desktop/gnome/shell/windows/edge_tiling</applyto>
<owner>gnome-shell</owner>
<type>bool</type>
<default>true</default>
<locale name="C">
<short>enable edge tiling when dropping windows on screen edges</short>
<long>
If enabled, dropping windows on vertical screen edges maximizes them
vertically and resizes them horizontally to cover half of the
available area. Dropping windows on the top screen edge maximizes them
completely.
This key overrides /apps/metacity/general/edge_tiling when
running GNOME Shell.
</long>
</locale>
</schema>
<schema>
<key>/schemas/desktop/gnome/shell/windows/theme</key>
<applyto>/desktop/gnome/shell/windows/theme</applyto>
<owner>gnome-shell</owner>
<type>string</type>
<default>Adwaita</default>
<locale name="C">
<short>Current theme</short>
<long>
The theme determines the appearance of window borders,
titlebar, and so forth.
This key overrides /apps/metacity/general/theme when
running GNOME Shell.
</long>
</locale>
</schema>
<schema>
<key>/schemas/desktop/gnome/shell/windows/workspaces_only_on_primary</key>
<applyto>/desktop/gnome/shell/windows/workspaces_only_on_primary</applyto>
<owner>gnome-shell</owner>
<type>bool</type>
<default>true</default>
<locale name="C">
<short>Workspaces only on primary monitor</short>
<long>
This key overrides /apps/mutter/general/workspaces_only_on_primary when
running GNOME Shell.
</long>
</locale>
</schema>
</schemalist>
</gconfschemafile>

View File

@ -142,4 +142,40 @@
</_description> </_description>
</key> </key>
</schema> </schema>
<schema id="org.gnome.shell.overrides" path="/org/gnome/shell/overrides/">
<key name="attach-modal-dialogs" type="b">
<default>true</default>
<summary>Attach modal dialog to the parent window</summary>
<description>
This key overrides the key in org.gnome.mutter when running
GNOME Shell.
</description>
</key>
<key name="button-layout" type="s">
<default>":close"</default>
<summary>Arrangement of buttons on the titlebar</summary>
<description>
This key overrides the key in org.gnome.desktop.wm.preferences when
running GNOME Shell.
</description>
</key>
<key name="edge-tiling" type="b">
<default>true</default>
<summary>Enable edge tiling when dropping windows on screen edges</summary>
<description>
This key overrides the key in org.gnome.mutter when running GNOME Shell.
</description>
</key>
<key name="workspaces-only-on-primary" type="b">
<default>true</default>
<summary>Workspaces only on primary monitor</summary>
<description>
This key overrides the key in org.gnome.mutter when running GNOME Shell.
</description>
</key>
</schema>
</schemalist> </schemalist>

View File

@ -199,7 +199,7 @@ AltTabPopup.prototype = {
this.actor.get_allocation_box(); this.actor.get_allocation_box();
// Make the initial selection // Make the initial selection
if (binding == 'switch_group') { if (binding == 'switch-group') {
if (backward) { if (backward) {
this._select(0, this._appIcons[0].cachedWindows.length - 1); this._select(0, this._appIcons[0].cachedWindows.length - 1);
} else { } else {
@ -208,9 +208,9 @@ AltTabPopup.prototype = {
else else
this._select(0, 0); this._select(0, 0);
} }
} else if (binding == 'switch_group_backward') { } else if (binding == 'switch-group-backward') {
this._select(0, this._appIcons[0].cachedWindows.length - 1); this._select(0, this._appIcons[0].cachedWindows.length - 1);
} else if (binding == 'switch_windows_backward') { } else if (binding == 'switch-windows-backward') {
this._select(this._appIcons.length - 1); this._select(this._appIcons.length - 1);
} else if (this._appIcons.length == 1) { } else if (this._appIcons.length == 1) {
this._select(0); this._select(0);

View File

@ -2,7 +2,6 @@
const Clutter = imports.gi.Clutter; const Clutter = imports.gi.Clutter;
const Cogl = imports.gi.Cogl; const Cogl = imports.gi.Cogl;
const GConf = imports.gi.GConf;
const GLib = imports.gi.GLib; const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio; const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk; const Gtk = imports.gi.Gtk;

View File

@ -4,7 +4,6 @@ const Clutter = imports.gi.Clutter;
const Gdk = imports.gi.Gdk; const Gdk = imports.gi.Gdk;
const Gio = imports.gi.Gio; const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib; const GLib = imports.gi.GLib;
const GConf = imports.gi.GConf;
const Lang = imports.lang; const Lang = imports.lang;
const Mainloop = imports.mainloop; const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta; const Meta = imports.gi.Meta;
@ -135,13 +134,13 @@ function _initUserSession() {
let shellwm = global.window_manager; let shellwm = global.window_manager;
shellwm.takeover_keybinding('panel_run_dialog'); shellwm.takeover_keybinding('panel-run-dialog');
shellwm.connect('keybinding::panel_run_dialog', function () { shellwm.connect('keybinding::panel-run-dialog', function () {
getRunDialog().open(); getRunDialog().open();
}); });
shellwm.takeover_keybinding('panel_main_menu'); shellwm.takeover_keybinding('panel-main-menu');
shellwm.connect('keybinding::panel_main_menu', function () { shellwm.connect('keybinding::panel-main-menu', function () {
overview.toggle(); overview.toggle();
}); });
@ -577,16 +576,6 @@ function _globalKeyPressHandler(actor, event) {
// This relies on the fact that Clutter.ModifierType is the same as Gdk.ModifierType // This relies on the fact that Clutter.ModifierType is the same as Gdk.ModifierType
let action = global.display.get_keybinding_action(keyCode, modifierState); let action = global.display.get_keybinding_action(keyCode, modifierState);
// The screenshot action should always be available (even if a
// modal dialog is present)
if (action == Meta.KeyBindingAction.COMMAND_SCREENSHOT) {
let gconf = GConf.Client.get_default();
let command = gconf.get_string('/apps/metacity/keybinding_commands/command_screenshot');
if (command != null && command != '')
Util.spawnCommandLine(command);
return true;
}
// Other bindings are only available to the user session when the overview is up and // Other bindings are only available to the user session when the overview is up and
// no modal dialog is present. // no modal dialog is present.
if (global.session_type == Shell.SessionType.USER && (!overview.visible || modalCount > 1)) if (global.session_type == Shell.SessionType.USER && (!overview.visible || modalCount > 1))

View File

@ -1,6 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const GConf = imports.gi.GConf; const DBus = imports.dbus;
const GDesktopEnums = imports.gi.GDesktopEnums;
const Gio = imports.gi.Gio; const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk; const Gtk = imports.gi.Gtk;
const Lang = imports.lang; const Lang = imports.lang;
@ -29,8 +30,8 @@ const DPI_FACTOR_LARGE = 1.25;
const DPI_FACTOR_LARGER = 1.5; const DPI_FACTOR_LARGER = 1.5;
const DPI_FACTOR_LARGEST = 2.0; const DPI_FACTOR_LARGEST = 2.0;
const KEY_META_DIR = '/apps/metacity/general'; const WM_SCHEMA = 'org.gnome.desktop.wm.preferences';
const KEY_VISUAL_BELL = KEY_META_DIR + '/visual_bell'; const KEY_VISUAL_BELL_TYPE = 'visual-bell-type';
const DESKTOP_INTERFACE_SCHEMA = 'org.gnome.desktop.interface'; const DESKTOP_INTERFACE_SCHEMA = 'org.gnome.desktop.interface';
const KEY_GTK_THEME = 'gtk-theme'; const KEY_GTK_THEME = 'gtk-theme';
@ -49,10 +50,6 @@ ATIndicator.prototype = {
_init: function() { _init: function() {
PanelMenu.SystemStatusButton.prototype._init.call(this, 'preferences-desktop-accessibility', null); PanelMenu.SystemStatusButton.prototype._init.call(this, 'preferences-desktop-accessibility', null);
let client = GConf.Client.get_default();
client.add_dir(KEY_META_DIR, GConf.ClientPreloadType.PRELOAD_ONELEVEL, null);
client.notify_add(KEY_META_DIR, Lang.bind(this, this._keyChanged), null, null);
let highContrast = this._buildHCItem(); let highContrast = this._buildHCItem();
this.menu.addMenuItem(highContrast); this.menu.addMenuItem(highContrast);
@ -71,7 +68,7 @@ ATIndicator.prototype = {
'screen-keyboard-enabled'); 'screen-keyboard-enabled');
this.menu.addMenuItem(screenKeyboard); this.menu.addMenuItem(screenKeyboard);
let visualBell = this._buildItemGConf(_("Visual Alerts"), client, KEY_VISUAL_BELL); let visualBell = this._buildVisualBellItem();
this.menu.addMenuItem(visualBell); this.menu.addMenuItem(visualBell);
let stickyKeys = this._buildItem(_("Sticky Keys"), A11Y_SCHEMA, KEY_STICKY_KEYS_ENABLED); let stickyKeys = this._buildItem(_("Sticky Keys"), A11Y_SCHEMA, KEY_STICKY_KEYS_ENABLED);
@ -101,22 +98,6 @@ ATIndicator.prototype = {
return widget; return widget;
}, },
_buildItemGConf: function(string, client, key) {
function on_get() {
return client.get_bool(key);
}
let widget = this._buildItemExtended(string,
client.get_bool(key),
client.key_is_writable(key),
function(enabled) {
client.set_bool(key, enabled);
});
this.connect('gconf-changed', function() {
widget.setToggleState(client.get_bool(key));
});
return widget;
},
_buildItem: function(string, schema, key) { _buildItem: function(string, schema, key) {
let settings = new Gio.Settings({ schema: schema }); let settings = new Gio.Settings({ schema: schema });
let widget = this._buildItemExtended(string, let widget = this._buildItemExtended(string,
@ -131,6 +112,27 @@ ATIndicator.prototype = {
return widget; return widget;
}, },
_buildVisualBellItem: function() {
let settings = new Gio.Settings({ schema: WM_SCHEMA });
let currentValue = settings.get_enum(KEY_VISUAL_BELL_TYPE);
let visualBellItem = this._buildItemExtended(
_("Visual Alerts"),
currentValue != GDesktopEnums.VisualBellType.NONE,
settings.is_writable(KEY_VISUAL_BELL_TYPE),
function(enabled) {
if (enabled)
settings.set_enum(KEY_VISUAL_BELL_TYPE,
GDesktopEnums.VisualBellType.FULLSCREEN_FLASH);
else
settings.reset(KEY_VISUAL_BELL_TYPE);
});
settings.connect('changed::' + KEY_VISUAL_BELL_TYPE, function() {
let value = settings.get_enum(KEY_VISUAL_BELL_TYPE);
visualBellItem.setToggleState(value != GDesktopEnums.VisualBellType.NONE);
});
return visualBellItem;
},
_buildHCItem: function() { _buildHCItem: function() {
let settings = new Gio.Settings({ schema: DESKTOP_INTERFACE_SCHEMA }); let settings = new Gio.Settings({ schema: DESKTOP_INTERFACE_SCHEMA });
let gtkTheme = settings.get_string(KEY_GTK_THEME); let gtkTheme = settings.get_string(KEY_GTK_THEME);
@ -190,10 +192,6 @@ ATIndicator.prototype = {
widget.setToggleState(active); widget.setToggleState(active);
}); });
return widget; return widget;
},
_keyChanged: function() {
this.emit('gconf-changed');
} }
}; };
Signals.addSignalMethods(ATIndicator.prototype); Signals.addSignalMethods(ATIndicator.prototype);

View File

@ -121,15 +121,15 @@ WindowManager.prototype = {
this._shellwm.connect('destroy', Lang.bind(this, this._destroyWindow)); this._shellwm.connect('destroy', Lang.bind(this, this._destroyWindow));
this._workspaceSwitcherPopup = null; this._workspaceSwitcherPopup = null;
this.setKeybindingHandler('switch_to_workspace_left', Lang.bind(this, this._showWorkspaceSwitcher)); this.setKeybindingHandler('switch-to-workspace-left', Lang.bind(this, this._showWorkspaceSwitcher));
this.setKeybindingHandler('switch_to_workspace_right', Lang.bind(this, this._showWorkspaceSwitcher)); this.setKeybindingHandler('switch-to-workspace-right', Lang.bind(this, this._showWorkspaceSwitcher));
this.setKeybindingHandler('switch_to_workspace_up', Lang.bind(this, this._showWorkspaceSwitcher)); this.setKeybindingHandler('switch-to-workspace-up', Lang.bind(this, this._showWorkspaceSwitcher));
this.setKeybindingHandler('switch_to_workspace_down', Lang.bind(this, this._showWorkspaceSwitcher)); this.setKeybindingHandler('switch-to-workspace-down', Lang.bind(this, this._showWorkspaceSwitcher));
this.setKeybindingHandler('switch_windows', Lang.bind(this, this._startAppSwitcher)); this.setKeybindingHandler('switch-windows', Lang.bind(this, this._startAppSwitcher));
this.setKeybindingHandler('switch_group', Lang.bind(this, this._startAppSwitcher)); this.setKeybindingHandler('switch-group', Lang.bind(this, this._startAppSwitcher));
this.setKeybindingHandler('switch_windows_backward', Lang.bind(this, this._startAppSwitcher)); this.setKeybindingHandler('switch-windows-backward', Lang.bind(this, this._startAppSwitcher));
this.setKeybindingHandler('switch_group_backward', Lang.bind(this, this._startAppSwitcher)); this.setKeybindingHandler('switch-group-backward', Lang.bind(this, this._startAppSwitcher));
this.setKeybindingHandler('switch_panels', Lang.bind(this, this._startA11ySwitcher)); this.setKeybindingHandler('switch-panels', Lang.bind(this, this._startA11ySwitcher));
Main.overview.connect('showing', Lang.bind(this, function() { Main.overview.connect('showing', Lang.bind(this, function() {
for (let i = 0; i < this._dimmedWindows.length; i++) for (let i = 0; i < this._dimmedWindows.length; i++)
@ -556,15 +556,15 @@ WindowManager.prototype = {
if (this._workspaceSwitcherPopup == null) if (this._workspaceSwitcherPopup == null)
this._workspaceSwitcherPopup = new WorkspaceSwitcherPopup.WorkspaceSwitcherPopup(); this._workspaceSwitcherPopup = new WorkspaceSwitcherPopup.WorkspaceSwitcherPopup();
if (binding == 'switch_to_workspace_up') if (binding == 'switch-to-workspace-up')
this.actionMoveWorkspaceUp(); this.actionMoveWorkspaceUp();
else if (binding == 'switch_to_workspace_down') else if (binding == 'switch-to-workspace-down')
this.actionMoveWorkspaceDown(); this.actionMoveWorkspaceDown();
// left/right would effectively act as synonyms for up/down if we enabled them; // left/right would effectively act as synonyms for up/down if we enabled them;
// but that could be considered confusing. // but that could be considered confusing.
// else if (binding == 'switch_to_workspace_left') // else if (binding == 'switch-to-workspace-left')
// this.actionMoveWorkspaceLeft(); // this.actionMoveWorkspaceLeft();
// else if (binding == 'switch_to_workspace_right') // else if (binding == 'switch-to-workspace-right')
// this.actionMoveWorkspaceRight(); // this.actionMoveWorkspaceRight();
}, },

View File

@ -1,7 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Clutter = imports.gi.Clutter; const Clutter = imports.gi.Clutter;
const GConf = imports.gi.GConf; const Gio = imports.gi.Gio;
const Lang = imports.lang; const Lang = imports.lang;
const Mainloop = imports.mainloop; const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta; const Meta = imports.gi.Meta;
@ -28,7 +28,8 @@ const CLOSE_BUTTON_FADE_TIME = 0.1;
const DRAGGING_WINDOW_OPACITY = 100; const DRAGGING_WINDOW_OPACITY = 100;
const BUTTON_LAYOUT_KEY = '/desktop/gnome/shell/windows/button_layout'; const BUTTON_LAYOUT_SCHEMA = 'org.gnome.shell.overrides';
const BUTTON_LAYOUT_KEY = 'button-layout';
// Define a layout scheme for small window counts. For larger // Define a layout scheme for small window counts. For larger
// counts we fall back to an algorithm. We need more schemes here // counts we fall back to an algorithm. We need more schemes here
@ -527,8 +528,8 @@ WindowOverlay.prototype = {
let button = this.closeButton; let button = this.closeButton;
let title = this.title; let title = this.title;
let gconf = GConf.Client.get_default(); let settings = new Gio.Settings({ schema: BUTTON_LAYOUT_SCHEMA });
let layout = gconf.get_string(BUTTON_LAYOUT_KEY); let layout = settings.get_string(BUTTON_LAYOUT_KEY);
let rtl = St.Widget.get_default_direction() == St.TextDirection.RTL; let rtl = St.Widget.get_default_direction() == St.TextDirection.RTL;
let split = layout.split(":"); let split = layout.split(":");

View File

@ -33,6 +33,8 @@ extern GType gnome_shell_plugin_get_type (void);
#define SHELL_DBUS_SERVICE "org.gnome.Shell" #define SHELL_DBUS_SERVICE "org.gnome.Shell"
#define MAGNIFIER_DBUS_SERVICE "org.gnome.Magnifier" #define MAGNIFIER_DBUS_SERVICE "org.gnome.Magnifier"
#define OVERRIDES_SCHEMA "org.gnome.shell.overrides"
static gboolean is_gdm_mode = FALSE; static gboolean is_gdm_mode = FALSE;
#define DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER 1 #define DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER 1
@ -309,16 +311,14 @@ shell_fonts_init (void)
static void static void
shell_prefs_init (void) shell_prefs_init (void)
{ {
meta_prefs_override_preference_location ("/apps/mutter/general/attach_modal_dialogs", meta_prefs_override_preference_schema ("attach-modal-dialogs",
"/desktop/gnome/shell/windows/attach_modal_dialogs"); OVERRIDES_SCHEMA);
meta_prefs_override_preference_location ("/apps/mutter/general/workspaces_only_on_primary", meta_prefs_override_preference_schema ("workspaces-only-on-primary",
"/desktop/gnome/shell/windows/workspaces_only_on_primary"); OVERRIDES_SCHEMA);
meta_prefs_override_preference_location ("/apps/metacity/general/button_layout", meta_prefs_override_preference_schema ("button-layout",
"/desktop/gnome/shell/windows/button_layout"); OVERRIDES_SCHEMA);
meta_prefs_override_preference_location ("/apps/metacity/general/edge_tiling", meta_prefs_override_preference_schema ("edge-tiling",
"/desktop/gnome/shell/windows/edge_tiling"); OVERRIDES_SCHEMA);
meta_prefs_override_preference_location ("/apps/metacity/general/theme",
"/desktop/gnome/shell/windows/theme");
} }
/* This is an IBus workaround. The flow of events with IBus is that every time /* This is an IBus workaround. The flow of events with IBus is that every time