st/settings: Add magnifier activation property and bind to settings
The same code for reading the current magnifier state is repeated in both shell-recorder, shell-screenshot and magnifier itself. So to move this inside a property of st-settings so that we can refer to it all over the places removing duplications. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/473
This commit is contained in:
parent
d7632bbd3d
commit
5357e0a18c
@ -18,9 +18,6 @@ var NO_CHANGE = 0.0;
|
||||
var POINTER_REST_TIME = 1000; // milliseconds
|
||||
|
||||
// Settings
|
||||
const APPLICATIONS_SCHEMA = 'org.gnome.desktop.a11y.applications';
|
||||
const SHOW_KEY = 'screen-magnifier-enabled';
|
||||
|
||||
const MAGNIFIER_SCHEMA = 'org.gnome.desktop.a11y.magnifier';
|
||||
const SCREEN_POSITION_KEY = 'screen-position';
|
||||
const MAG_FACTOR_KEY = 'mag-factor';
|
||||
@ -117,12 +114,16 @@ var Magnifier = class Magnifier {
|
||||
|
||||
let aZoomRegion = new ZoomRegion(this, this._cursorRoot);
|
||||
this._zoomRegions.push(aZoomRegion);
|
||||
let showAtLaunch = this._settingsInit(aZoomRegion);
|
||||
this._settingsInit(aZoomRegion);
|
||||
aZoomRegion.scrollContentsTo(this.xMouse, this.yMouse);
|
||||
|
||||
St.Settings.get().connect('notify::magnifier-active', () => {
|
||||
this.setActive(St.Settings.get().magnifier_active);
|
||||
});
|
||||
|
||||
// Export to dbus.
|
||||
magDBusService = new MagnifierDBus.ShellMagnifier();
|
||||
this.setActive(showAtLaunch);
|
||||
this.setActive(St.Settings.get().magnifier_active);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -501,13 +502,8 @@ var Magnifier = class Magnifier {
|
||||
}
|
||||
|
||||
_settingsInit(zoomRegion) {
|
||||
this._appSettings = new Gio.Settings({ schema_id: APPLICATIONS_SCHEMA });
|
||||
this._settings = new Gio.Settings({ schema_id: MAGNIFIER_SCHEMA });
|
||||
|
||||
this._appSettings.connect('changed::' + SHOW_KEY, () => {
|
||||
this.setActive(this._appSettings.get_boolean(SHOW_KEY));
|
||||
});
|
||||
|
||||
this._settings.connect('changed::' + SCREEN_POSITION_KEY,
|
||||
this._updateScreenPosition.bind(this));
|
||||
this._settings.connect('changed::' + MAG_FACTOR_KEY,
|
||||
@ -614,8 +610,6 @@ var Magnifier = class Magnifier {
|
||||
let showCrosshairs = this._settings.get_boolean(SHOW_CROSS_HAIRS_KEY);
|
||||
this.addCrosshairs();
|
||||
this.setCrosshairsVisible(showCrosshairs);
|
||||
|
||||
return this._appSettings.get_boolean(SHOW_KEY);
|
||||
}
|
||||
|
||||
_updateScreenPosition() {
|
||||
|
@ -17,15 +17,13 @@
|
||||
#include <meta/meta-cursor-tracker.h>
|
||||
#include <meta/display.h>
|
||||
#include <meta/compositor-mutter.h>
|
||||
#include <st/st.h>
|
||||
|
||||
#include "shell-global.h"
|
||||
#include "shell-recorder-src.h"
|
||||
#include "shell-recorder.h"
|
||||
#include "shell-util.h"
|
||||
|
||||
#define A11Y_APPS_SCHEMA "org.gnome.desktop.a11y.applications"
|
||||
#define MAGNIFIER_ACTIVE_KEY "screen-magnifier-enabled"
|
||||
|
||||
typedef enum {
|
||||
RECORDER_STATE_CLOSED,
|
||||
RECORDER_STATE_RECORDING
|
||||
@ -58,7 +56,6 @@ struct _ShellRecorder {
|
||||
int pointer_x;
|
||||
int pointer_y;
|
||||
|
||||
GSettings *a11y_settings;
|
||||
gboolean draw_cursor;
|
||||
MetaCursorTracker *cursor_tracker;
|
||||
cairo_surface_t *cursor_image;
|
||||
@ -213,8 +210,6 @@ shell_recorder_init (ShellRecorder *recorder)
|
||||
|
||||
recorder->memory_target = get_memory_target();
|
||||
|
||||
recorder->a11y_settings = g_settings_new (A11Y_APPS_SCHEMA);
|
||||
|
||||
recorder->state = RECORDER_STATE_CLOSED;
|
||||
recorder->framerate = DEFAULT_FRAMES_PER_SECOND;
|
||||
recorder->draw_cursor = TRUE;
|
||||
@ -239,8 +234,6 @@ shell_recorder_finalize (GObject *object)
|
||||
|
||||
recorder_remove_redraw_timeout (recorder);
|
||||
|
||||
g_clear_object (&recorder->a11y_settings);
|
||||
|
||||
G_OBJECT_CLASS (shell_recorder_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
@ -465,9 +458,16 @@ recorder_record_frame (ShellRecorder *recorder,
|
||||
|
||||
GST_BUFFER_PTS(buffer) = now;
|
||||
|
||||
if (recorder->draw_cursor &&
|
||||
!g_settings_get_boolean (recorder->a11y_settings, MAGNIFIER_ACTIVE_KEY))
|
||||
if (recorder->draw_cursor)
|
||||
{
|
||||
StSettings *settings = st_settings_get ();
|
||||
gboolean magnifier_active = FALSE;
|
||||
|
||||
g_object_get (settings, "magnifier-active", &magnifier_active, NULL);
|
||||
|
||||
if (magnifier_active)
|
||||
recorder_draw_cursor (recorder, buffer);
|
||||
}
|
||||
|
||||
shell_recorder_src_add_buffer (SHELL_RECORDER_SRC (recorder->current_pipeline->src), buffer);
|
||||
gst_buffer_unref (buffer);
|
||||
|
@ -7,14 +7,12 @@
|
||||
#include <meta/meta-plugin.h>
|
||||
#include <meta/meta-shaped-texture.h>
|
||||
#include <meta/meta-cursor-tracker.h>
|
||||
#include <st/st.h>
|
||||
|
||||
#include "shell-global.h"
|
||||
#include "shell-screenshot.h"
|
||||
#include "shell-util.h"
|
||||
|
||||
#define A11Y_APPS_SCHEMA "org.gnome.desktop.a11y.applications"
|
||||
#define MAGNIFIER_ACTIVE_KEY "screen-magnifier-enabled"
|
||||
|
||||
typedef struct _ShellScreenshotPrivate ShellScreenshotPrivate;
|
||||
|
||||
struct _ShellScreenshot
|
||||
@ -271,9 +269,12 @@ should_draw_cursor_image (ShellScreenshotMode mode)
|
||||
{
|
||||
if (mode == SHELL_SCREENSHOT_WINDOW || !meta_is_wayland_compositor ())
|
||||
{
|
||||
g_autoptr (GSettings) settings = g_settings_new (A11Y_APPS_SCHEMA);
|
||||
StSettings *settings = st_settings_get ();
|
||||
gboolean magnifier_active = FALSE;
|
||||
|
||||
if (!g_settings_get_boolean (settings, MAGNIFIER_ACTIVE_KEY))
|
||||
g_object_get (settings, "magnifier-active", &magnifier_active, NULL);
|
||||
|
||||
if (!magnifier_active)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#define KEY_DRAG_THRESHOLD "drag-threshold"
|
||||
#define KEY_GTK_THEME "gtk-theme"
|
||||
#define KEY_GTK_ICON_THEME "icon-theme"
|
||||
#define KEY_MAGNIFIER_ACTIVE "screen-magnifier-enabled"
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
@ -38,6 +39,7 @@ enum {
|
||||
PROP_DRAG_THRESHOLD,
|
||||
PROP_GTK_THEME,
|
||||
PROP_GTK_ICON_THEME,
|
||||
PROP_MAGNIFIER_ACTIVE,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
@ -48,11 +50,13 @@ struct _StSettings
|
||||
GObject parent_object;
|
||||
GSettings *interface_settings;
|
||||
GSettings *mouse_settings;
|
||||
GSettings *a11y_settings;
|
||||
|
||||
gchar *gtk_theme;
|
||||
gchar *gtk_icon_theme;
|
||||
gboolean enable_animations;
|
||||
gboolean primary_paste;
|
||||
gboolean magnifier_active;
|
||||
gint drag_threshold;
|
||||
};
|
||||
|
||||
@ -105,6 +109,9 @@ st_settings_get_property (GObject *object,
|
||||
case PROP_GTK_ICON_THEME:
|
||||
g_value_set_string (value, settings->gtk_icon_theme);
|
||||
break;
|
||||
case PROP_MAGNIFIER_ACTIVE:
|
||||
g_value_set_boolean (value, settings->magnifier_active);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
@ -144,6 +151,11 @@ st_settings_class_init (StSettingsClass *klass)
|
||||
"GTK+ Icon Theme",
|
||||
"",
|
||||
G_PARAM_READABLE);
|
||||
props[PROP_MAGNIFIER_ACTIVE] = g_param_spec_boolean("magnifier-active",
|
||||
"Magnifier is active",
|
||||
"Weather the a11y magnifier is active",
|
||||
FALSE,
|
||||
G_PARAM_READABLE);
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, props);
|
||||
}
|
||||
@ -190,6 +202,18 @@ on_mouse_settings_changed (GSettings *g_settings,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
on_a11y_settings_changed (GSettings *g_settings,
|
||||
const gchar *key,
|
||||
StSettings *settings)
|
||||
{
|
||||
if (g_str_equal (key, KEY_MAGNIFIER_ACTIVE))
|
||||
{
|
||||
settings->magnifier_active = g_settings_get_boolean (g_settings, key);
|
||||
g_object_notify_by_pspec (G_OBJECT (settings), props[PROP_MAGNIFIER_ACTIVE]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
st_settings_init (StSettings *settings)
|
||||
{
|
||||
@ -201,6 +225,10 @@ st_settings_init (StSettings *settings)
|
||||
g_signal_connect (settings->interface_settings, "changed",
|
||||
G_CALLBACK (on_mouse_settings_changed), settings);
|
||||
|
||||
settings->a11y_settings = g_settings_new ("org.gnome.desktop.a11y.applications");
|
||||
g_signal_connect (settings->a11y_settings, "changed",
|
||||
G_CALLBACK (on_a11y_settings_changed), settings);
|
||||
|
||||
settings->enable_animations = g_settings_get_boolean (settings->interface_settings,
|
||||
KEY_ENABLE_ANIMATIONS);
|
||||
settings->primary_paste = g_settings_get_boolean (settings->interface_settings,
|
||||
@ -211,6 +239,8 @@ st_settings_init (StSettings *settings)
|
||||
KEY_GTK_ICON_THEME);
|
||||
settings->drag_threshold = g_settings_get_int (settings->mouse_settings,
|
||||
KEY_DRAG_THRESHOLD);
|
||||
settings->magnifier_active = g_settings_get_boolean (settings->a11y_settings,
|
||||
KEY_MAGNIFIER_ACTIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user