1#!/usr/local/bin/python3.8 2 3import gi 4gi.require_version('Gtk', '3.0') 5from gi.repository import Gio, Gtk 6 7from SettingsWidgets import SidePage 8from xapp.GSettingsWidgets import * 9 10 11class Module: 12 name = "windows" 13 category = "prefs" 14 comment = _("Manage window preferences") 15 16 def __init__(self, content_box): 17 keywords = _("windows, titlebar, edge, switcher, window list, attention, focus") 18 sidePage = SidePage(_("Windows"), "cs-windows", keywords, content_box, module=self) 19 self.sidePage = sidePage 20 21 def on_module_selected(self): 22 if not self.loaded: 23 print("Loading Windows module") 24 25 self.sidePage.stack = SettingsStack() 26 self.sidePage.add_widget(self.sidePage.stack) 27 28 # Titlebar 29 30 page = SettingsPage() 31 self.sidePage.stack.add_titled(page, "titlebar", _("Titlebar")) 32 33 size_group = Gtk.SizeGroup.new(Gtk.SizeGroupMode.HORIZONTAL) 34 35 settings = page.add_section(_("Buttons")) 36 37 button_options = [] 38 button_options.append([":minimize,maximize,close", _("Right")]) 39 button_options.append(["close,minimize,maximize:", _("Left")]) 40 button_options.append([":close", _("Gnome")]) 41 button_options.append(["close:minimize,maximize", _("Classic Mac")]) 42 43 widget = GSettingsComboBox(_("Buttons layout"), "org.cinnamon.desktop.wm.preferences", "button-layout", button_options, size_group=size_group) 44 settings.add_row(widget) 45 46 settings = page.add_section(_("Actions")) 47 48 action_options = [["toggle-shade", _("Toggle Shade")], ["toggle-maximize", _("Toggle Maximize")], 49 ["toggle-maximize-horizontally", _("Toggle Maximize Horizontally")], ["toggle-maximize-vertically", _("Toggle Maximize Vertically")], 50 ["toggle-stuck", _("Toggle on all workspaces")], ["toggle-above", _("Toggle always on top")], 51 ["minimize", _("Minimize")], ["menu", _("Menu")], ["lower", _("Lower")], ["none", _("None")]] 52 53 widget = GSettingsComboBox(_("Action on title bar double-click"), "org.cinnamon.desktop.wm.preferences", "action-double-click-titlebar", action_options, size_group=size_group) 54 settings.add_row(widget) 55 56 widget = GSettingsComboBox(_("Action on title bar middle-click"), "org.cinnamon.desktop.wm.preferences", "action-middle-click-titlebar", action_options, size_group=size_group) 57 settings.add_row(widget) 58 59 widget = GSettingsComboBox(_("Action on title bar right-click"), "org.cinnamon.desktop.wm.preferences", "action-right-click-titlebar", action_options, size_group=size_group) 60 settings.add_row(widget) 61 62 scroll_options = [["none", _("Nothing")],["shade", _("Shade and unshade")],["opacity", _("Adjust opacity")]] 63 64 widget = GSettingsComboBox(_("Action on title bar with mouse scroll"), "org.cinnamon.desktop.wm.preferences", "action-scroll-titlebar", scroll_options, size_group=size_group) 65 settings.add_row(widget) 66 67 spin = GSettingsSpinButton(_("Minimum opacity"), "org.cinnamon.desktop.wm.preferences", "min-window-opacity", _("%")) 68 settings.add_reveal_row(spin) 69 70 spin.revealer.settings = Gio.Settings("org.cinnamon.desktop.wm.preferences") 71 spin.revealer.settings.bind_with_mapping("action-scroll-titlebar", spin.revealer, "reveal-child", Gio.SettingsBindFlags.GET, lambda x: x == "opacity", None) 72 73 # Behavior 74 75 page = SettingsPage() 76 self.sidePage.stack.add_titled(page, "behavior", _("Behavior")) 77 78 settings = page.add_section(_("Window Focus")) 79 80 focus_options = [["click", _("Click")], ["sloppy", _("Sloppy")], ["mouse", _("Mouse")]] 81 widget = GSettingsComboBox(_("Window focus mode"), "org.cinnamon.desktop.wm.preferences", "focus-mode", focus_options) 82 widget.set_tooltip_text(_("The window focus mode indicates how windows are activated. It has three possible values; \"click\" means windows must be clicked in order to focus them, \"sloppy\" means windows are focused when the mouse enters the window, and \"mouse\" means windows are focused when the mouse enters the window and unfocused when the mouse leaves the window.")) 83 settings.add_row(widget) 84 85 widget = GSettingsSwitch(_("Automatically raise focused windows"), "org.cinnamon.desktop.wm.preferences", "auto-raise") 86 settings.add_reveal_row(widget) 87 88 widget.revealer.settings = Gio.Settings("org.cinnamon.desktop.wm.preferences") 89 widget.revealer.settings.bind_with_mapping("focus-mode", widget.revealer, "reveal-child", Gio.SettingsBindFlags.GET, lambda x: x in ("sloppy", "mouse"), None) 90 91 widget = GSettingsSwitch(_("Bring windows which require attention to the current workspace"), "org.cinnamon", "bring-windows-to-current-workspace") 92 settings.add_row(widget) 93 94 widget = GSettingsSwitch(_("Prevent windows which require attention from stealing focus"), "org.cinnamon", "prevent-focus-stealing") 95 settings.add_row(widget) 96 97 stealing_options = [["smart", _("Smart")], ["strict", _("Strict")]] 98 widget = GSettingsComboBox(_("Focus mode for new windows"), "org.cinnamon.desktop.wm.preferences", "focus-new-windows", stealing_options) 99 widget.set_tooltip_text(_("This option provides additional control over how newly created windows get focus. It has two possible values; 'smart' applies the user's normal focus mode, and 'strict' results in windows started from a terminal not being given focus.")) 100 settings.add_row(widget) 101 102 widget = GSettingsSwitch(_("Attach dialog windows to the parent window"), "org.cinnamon.muffin", "attach-modal-dialogs") 103 settings.add_row(widget) 104 105 settings = page.add_section(_("Moving and Resizing Windows")) 106 107 size_group = Gtk.SizeGroup.new(Gtk.SizeGroupMode.HORIZONTAL) 108 109 placement_options = [["automatic", _("Automatic")], ["pointer", _("Cursor")], ["manual", _("Manual")], ["center", _("Center")]] 110 widget = GSettingsComboBox(_("Location of newly opened windows"), "org.cinnamon.muffin", "placement-mode", placement_options, size_group=size_group) 111 settings.add_row(widget) 112 113 special_key_options = [["", _("Disabled")], ["<Alt>", "<Alt>"],["<Super>", "<Super>"],["<Control>", "<Control>"]] 114 widget = GSettingsComboBox(_("Special key to move and resize windows"), "org.cinnamon.desktop.wm.preferences", "mouse-button-modifier", special_key_options, size_group=size_group) 115 widget.set_tooltip_text(_("While the special key is pressed, windows can be dragged with the left mouse button and resized with the right mouse button.")) 116 settings.add_row(widget) 117 118 widget = GSettingsSpinButton(_("Window drag/resize threshold"), "org.cinnamon.muffin", "resize-threshold", _("Pixels"), 1, 100, size_group=size_group) 119 settings.add_row(widget) 120 121 widget = GSettingsSwitch(_("Edge resistance with other windows and monitor boundaries"), "org.cinnamon.muffin", "edge-resistance-window") 122 widget.set_tooltip_text(_("Make window borders stick when moved or resized near other windows or monitor edges.")) 123 settings.add_row(widget) 124 125 # Alt Tab 126 127 page = SettingsPage() 128 self.sidePage.stack.add_titled(page, "alttab", _("Alt-Tab")) 129 130 settings = page.add_section(_("Alt-Tab")) 131 132 alttab_styles = [ 133 ["icons", _("Icons only")], 134 ["thumbnails", _("Thumbnails only")], 135 ["icons+thumbnails", _("Icons and thumbnails")], 136 ["icons+preview", _("Icons and window preview")], 137 ["preview", _("Window preview (no icons)")], 138 ["coverflow", _("Coverflow (3D)")], 139 ["timeline", _("Timeline (3D)")] 140 ] 141 widget = GSettingsComboBox(_("Alt-Tab switcher style"), "org.cinnamon", "alttab-switcher-style", alttab_styles) 142 settings.add_row(widget) 143 144 widget = GSettingsSwitch(_("Display the alt-tab switcher on the primary monitor instead of the active one"), "org.cinnamon", "alttab-switcher-enforce-primary-monitor") 145 settings.add_row(widget) 146 147 widget = GSettingsSwitch(_("Move minimized windows to the end of the alt-tab switcher"), "org.cinnamon", "alttab-minimized-aware") 148 settings.add_row(widget) 149 150 widget = GSettingsSpinButton(_("Delay before displaying the alt-tab switcher"), "org.cinnamon", "alttab-switcher-delay", units=_("milliseconds"), mini=0, maxi=1000, step=50, page=150) 151 settings.add_row(widget) 152 153 widget = GSettingsSwitch(_("Show windows from all workspaces"), "org.cinnamon", "alttab-switcher-show-all-workspaces") 154 settings.add_row(widget) 155