mirror of
https://github.com/elementary/gala.git
synced 2024-09-11 15:15:39 +03:00
MaskCorners: Use GLib.Settings (#1046)
This commit is contained in:
parent
fef071bdfb
commit
1aaa95740c
@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (C) 2015 Rory J Sanderson
|
||||
// Copyright 2021 elementary, Inc. (https://elementary.io)
|
||||
// 2015 Rory J Sanderson
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
@ -22,7 +23,8 @@ namespace Gala.Plugins.MaskCorners {
|
||||
public class Main : Gala.Plugin {
|
||||
Gala.WindowManager? wm = null;
|
||||
Display display;
|
||||
Settings settings;
|
||||
|
||||
private GLib.Settings settings;
|
||||
|
||||
List<Actor>[] cornermasks;
|
||||
private const int DEFAULT_CORNER_RADIUS = 6;
|
||||
@ -31,7 +33,8 @@ namespace Gala.Plugins.MaskCorners {
|
||||
public override void initialize (Gala.WindowManager wm) {
|
||||
this.wm = wm;
|
||||
display = wm.get_display ();
|
||||
settings = Settings.get_default ();
|
||||
|
||||
settings = new GLib.Settings (Config.SCHEMA + ".mask-corners");
|
||||
|
||||
setup_cornermasks ();
|
||||
|
||||
@ -42,9 +45,10 @@ namespace Gala.Plugins.MaskCorners {
|
||||
destroy_cornermasks ();
|
||||
}
|
||||
|
||||
void setup_cornermasks () {
|
||||
if (!settings.enable)
|
||||
private void setup_cornermasks () {
|
||||
if (!settings.get_boolean ("enable")) {
|
||||
return;
|
||||
}
|
||||
|
||||
var scale = Utils.get_ui_scaling_factor ();
|
||||
|
||||
@ -52,15 +56,16 @@ namespace Gala.Plugins.MaskCorners {
|
||||
cornermasks = new List<Actor>[n_monitors];
|
||||
corner_radius = DEFAULT_CORNER_RADIUS * scale;
|
||||
|
||||
if (settings.only_on_primary) {
|
||||
if (settings.get_boolean ("only-on-primary")) {
|
||||
add_cornermasks (display.get_primary_monitor ());
|
||||
} else {
|
||||
for (int m = 0; m < n_monitors; m++)
|
||||
add_cornermasks (m);
|
||||
}
|
||||
|
||||
if (settings.disable_on_fullscreen)
|
||||
if (settings.get_boolean ("disable-on-fullscreen")) {
|
||||
display.in_fullscreen_changed.connect (fullscreen_changed);
|
||||
}
|
||||
|
||||
unowned Meta.MonitorManager monitor_manager = Meta.MonitorManager.@get ();
|
||||
monitor_manager.monitors_changed.connect (resetup_cornermasks);
|
||||
|
@ -1,37 +0,0 @@
|
||||
//
|
||||
// Copyright (C) 2015 Rory J Sanderson
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
namespace Gala.Plugins.MaskCorners {
|
||||
class Settings : Granite.Services.Settings {
|
||||
static Settings? instance = null;
|
||||
|
||||
public static unowned Settings get_default () {
|
||||
if (instance == null)
|
||||
instance = new Settings ();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public bool enable { get; set; default = true; }
|
||||
public bool disable_on_fullscreen { get; set; default = true; }
|
||||
public bool only_on_primary { get; set; default = false; }
|
||||
|
||||
Settings () {
|
||||
base (Config.SCHEMA + ".mask-corners");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
gala_maskcorners_sources = [
|
||||
'Main.vala',
|
||||
'Settings.vala',
|
||||
'Main.vala'
|
||||
]
|
||||
|
||||
gala_maskcorners_lib = shared_library(
|
||||
|
Loading…
Reference in New Issue
Block a user