Skip to content

Commit

Permalink
feat: Add tiling options
Browse files Browse the repository at this point in the history
  • Loading branch information
mmstick committed Jul 12, 2021
1 parent efa75dd commit dafcac6
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
12 changes: 10 additions & 2 deletions i18n/en/pop_desktop_widget.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ multi-monitor-behavior = Multi-monitor Behavior
page-appearance = Appearance
page-dock = Dock
page-main = General
page-tiling = Tiling
page-workspaces = Workspaces
position-bottom = Bottom of the screen
Expand All @@ -78,6 +79,14 @@ size-small = Small
super-key-action = Super Key Action
tiling-active-hint = Show active window hint
tiling-gap-inner = Inner
tiling-gap-outer = Outer
tiling-gaps = Gaps
tiling-show-title = Show window title decorations
tiling-smart-gaps = Smart
tiling-snap-to-grid = Snap floating windows to grid
top-bar = Top Bar
window-controls = Window Controls
Expand All @@ -90,5 +99,4 @@ workspaces-dynamic-description = Automatically removes empty workspaces.
workspaces-fixed = Fixed Number of Workspaces
workspaces-fixed-description = Specify a number of workspaces
workspaces-primary = Workspaces on Primary Display Only
workspaces-span-displays = Workspaces Span Displays
workspaces-span-displays = Workspaces Span Displays
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ extern crate gtk_extras;

pub mod gis;
pub mod gresource;
mod gst_video;
pub mod localize;

mod gst_video;
mod tiling;

use gio::{Settings, SettingsBindFlags, SettingsExt};
use glib::clone;
use gtk::prelude::*;
Expand Down Expand Up @@ -827,6 +829,7 @@ impl PopDesktopWidget {
appearance_page(&stack);
dock_page(&stack);
workspaces_page(&stack);
tiling::view(&stack);

stack.show_all();

Expand Down
35 changes: 35 additions & 0 deletions src/tiling.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use gio::prelude::*;
use gtk::prelude::*;
use gtk_extras::settings;
use gio::SettingsBindFlags;
use crate::fl;

pub fn view(stack: &gtk::Stack) {
let page = crate::settings_page(stack, "tiling", &fl!("page-tiling"));

if let Some(settings) = settings::new_checked("org.gnome.shell.extensions.pop-shell") {
let toggle_switch = |list: &gtk::ListBox, description: &str, property: &str| {
let switch = crate::switch_row(list, description);
settings.bind(property, &switch, "active", SettingsBindFlags::DEFAULT);
};

let spin_button = |list: &gtk::ListBox, description: &str, property: &str| {
let spin = crate::spin_row(list, description, 0.0, 64.0, 1.0);
settings.bind(property, &spin, "value", SettingsBindFlags::DEFAULT);
};

let list = crate::framed_list_box();

toggle_switch(&list, &fl!("tiling-show-title"), "show-title");
toggle_switch(&list, &fl!("tiling-active-hint"), "active-hint");
toggle_switch(&list, &fl!("tiling-snap-to-grid"), "snap-to-grid");

page.add(&list);

let list = crate::settings_list_box(&page, &fl!("tiling-gaps"));

spin_button(&list, &fl!("tiling-gap-outer"), "gap-outer");
spin_button(&list, &fl!("tiling-gap-inner"), "gap-inner");
toggle_switch(&list, &fl!("tiling-smart-gaps"), "smart-gaps");
}
}

0 comments on commit dafcac6

Please sign in to comment.