diff --git a/data/shell.ui b/data/shell.ui index d9a88ddb6fceb7b5aae96ac48e1cfad28c1fcc84..cb6a0d192458684bb81b9158fc6a62ac63be706a 100644 --- a/data/shell.ui +++ b/data/shell.ui @@ -1,6 +1,5 @@ -
diff --git a/gnome-tweaks b/gnome-tweaks index a244a85ad085c66ab3b5eccfec3b55af0e1aa9c0..8df2c1b8ec1deed40253e04a8a6458fd5e4e9d18 100755 --- a/gnome-tweaks +++ b/gnome-tweaks @@ -11,8 +11,8 @@ import signal import sys import gi -gi.require_version("Gtk", "3.0") -gi.require_version("Handy", "1") +gi.require_version("Gtk", "4.0") +gi.require_version("Adw", "1") import gtweak from gtweak.defs import VERSION diff --git a/gtweak/app.py b/gtweak/app.py index 742daa124d44a318bf1f6d2a9a3cd0037af170ad..968e7f1d08a1670539b3ab9cc1641af88dd263a7 100644 --- a/gtweak/app.py +++ b/gtweak/app.py @@ -4,6 +4,7 @@ import os.path +from gi.repository import Adw from gi.repository import Gtk from gi.repository import Gio from gi.repository import GLib @@ -49,7 +50,6 @@ class GnomeTweaks(Gtk.Application): if not self.win: model = TweakModel() self.win = Window(self, model) - self.win.show_all() if not self.win.get_titlebar().props.folded: self.win.back_button.props.visible = False self.win.present() @@ -60,6 +60,7 @@ class GnomeTweaks(Gtk.Application): def do_startup(self): Gtk.Application.do_startup(self) + Adw.init() reset_action = Gio.SimpleAction.new("reset", None) reset_action.connect("activate", self.reset_cb) diff --git a/gtweak/tweaks/tweak_group_appearance.py b/gtweak/tweaks/tweak_group_appearance.py index 5caccba89774c4e735b6b2c1002daed825122889..ad1445b32946cabcb1a2bff91dd8cd6661cb85c0 100644 --- a/gtweak/tweaks/tweak_group_appearance.py +++ b/gtweak/tweaks/tweak_group_appearance.py @@ -20,7 +20,8 @@ from gtweak.tweakmodel import Tweak from gtweak.gshellwrapper import GnomeShellFactory from gtweak.gsettings import GSettingsSetting from gtweak.gtksettings import GtkSettingsManager -from gtweak.widgets import ListBoxTweakGroup, GSettingsSwitchTweak, GSettingsComboTweak, GSettingsComboEnumTweak, Title, build_combo_box_text,build_label_beside_widget, FileChooserButton, GSettingsFileChooserButtonTweak +from gtweak.widgets import ListBoxTweakGroup, GSettingsSwitchTweak, GSettingsComboTweak, GSettingsComboEnumTweak, Title, build_combo_box_text,build_label_beside_widget, GSettingsFileChooserButtonTweak # TODO FileChooserButton + _shell = GnomeShellFactory().get_shell() _shell_loaded = _shell is not None @@ -201,13 +202,14 @@ class ShellThemeTweak(Gtk.Box, Tweak): self._combo = cb #a filechooser to install new themes - chooser = FileChooserButton( - _("Select a theme"), - True, - ["application/zip"]) - chooser.connect("file-set", self._on_file_set) - - build_label_beside_widget(self.name, chooser, cb, hbox=self) + # TODO + # chooser = FileChooserButton( + # _("Select a theme"), + # True, + # ["application/zip"]) + # chooser.connect("file-set", self._on_file_set) + + # build_label_beside_widget(self.name, chooser, cb, hbox=self) self.widget_for_size_group = cb def _on_file_set(self, chooser): diff --git a/gtweak/tweaks/tweak_group_font.py b/gtweak/tweaks/tweak_group_font.py index 040571aa97340a9b5ebc7c46e5148901a6eaa355..d96182c220195378ac63bd87ccc13acd35f3c0ba 100644 --- a/gtweak/tweaks/tweak_group_font.py +++ b/gtweak/tweaks/tweak_group_font.py @@ -28,62 +28,60 @@ class FontXSettingsTweak(Gtk.Box, Tweak): self.set_spacing(12) self.props.margin_top = 12 - label = Gtk.Label(_("Hinting")) + label = Gtk.Label(label=_("Hinting")) label.props.yalign = 0.0 label.padding = 10 - self.pack_start(label, False, False, 0) + self.prepend(label) hint_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6) - self.pack_start(hint_box, True, True, 0) + self.prepend(hint_box) - self.btn_full = Gtk.RadioButton.new_from_widget(None) - self.btn_full.set_label(_("Full")) + self.btn_full = Gtk.CheckButton.new_with_label(_("Full")) self.btn_full.set_active(self.settings["font-hinting"] == "full") self.btn_full.connect("toggled", self.on_hint_button_toggled) - hint_box.pack_start(self.btn_full, False, False, 0) + hint_box.prepend(self.btn_full) - self.btn_med = Gtk.RadioButton.new_from_widget(self.btn_full) - self.btn_med.set_label(_("Medium")) + self.btn_med = Gtk.CheckButton.new_with_label(_("Medium")) + self.btn_med.set_group(self.btn_full) self.btn_med.set_active(self.settings["font-hinting"] == "medium") self.btn_med.connect("toggled", self.on_hint_button_toggled) - hint_box.pack_start(self.btn_med, False, False, 0) + hint_box.prepend(self.btn_med) - self.btn_slight = Gtk.RadioButton.new_from_widget(self.btn_full) - self.btn_slight.set_label(_("Slight")) + self.btn_slight = Gtk.CheckButton.new_with_label(_("Slight")) + self.btn_slight.set_group(self.btn_full) self.btn_slight.set_active(self.settings["font-hinting"] == "slight") self.btn_slight.connect("toggled", self.on_hint_button_toggled) - hint_box.pack_start(self.btn_slight, False, False, 0) + hint_box.prepend(self.btn_slight) - self.btn_hnone = Gtk.RadioButton.new_from_widget(self.btn_full) - self.btn_hnone.set_label(_("None")) + self.btn_hnone = Gtk.CheckButton.new_with_label(_("None")) + self.btn_hnone.set_group(self.btn_full) self.btn_hnone.set_active(self.settings["font-hinting"] == "none") self.btn_hnone.connect("toggled", self.on_hint_button_toggled) - hint_box.pack_start(self.btn_hnone, False, False, 0) + hint_box.prepend(self.btn_hnone) - label = Gtk.Label(_("Antialiasing")) + label = Gtk.Label(label=_("Antialiasing")) label.props.yalign = 0.0 - self.pack_start(label, False, False, 0) + self.prepend(label) aa_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6) - self.pack_start(aa_box, False, False, 0) + self.prepend(aa_box) - self.btn_rgba = Gtk.RadioButton.new_from_widget(None) - self.btn_rgba.set_label(_("Subpixel (for LCD screens)")) + self.btn_rgba = Gtk.CheckButton.new_with_label(_("Subpixel (for LCD screens)")) self.btn_rgba.set_active(self.settings["font-antialiasing"] == "rgba") self.btn_rgba.connect("toggled", self.on_aa_button_toggled) - aa_box.pack_start(self.btn_rgba, False, False, 0) + aa_box.prepend(self.btn_rgba) - self.btn_gray = Gtk.RadioButton.new_from_widget(self.btn_rgba) - self.btn_gray.set_label(_("Standard (grayscale)")) + self.btn_gray = Gtk.CheckButton.new_with_label(_("Standard (grayscale)")) + self.btn_gray.set_group(self.btn_rgba) self.btn_gray.set_active(self.settings["font-antialiasing"] == "grayscale") self.btn_gray.connect("toggled", self.on_aa_button_toggled) - aa_box.pack_start(self.btn_gray, False, False, 0) + aa_box.prepend(self.btn_gray) - self.btn_anone = Gtk.RadioButton.new_from_widget(self.btn_rgba) - self.btn_anone.set_label(_("None")) + self.btn_anone = Gtk.CheckButton.new_with_label(_("None")) + self.btn_anone.set_group(self.btn_rgba) self.btn_anone.set_active(self.settings["font-antialiasing"] == "none") self.btn_anone.connect("toggled", self.on_aa_button_toggled) - aa_box.pack_start(self.btn_anone, False, False, 0) + aa_box.prepend(self.btn_anone) def on_hint_button_toggled(self, button): if self.btn_full.get_active(): @@ -106,7 +104,8 @@ class FontXSettingsTweak(Gtk.Box, Tweak): TWEAK_GROUPS = [ ListBoxTweakGroup(_("Fonts"), - GSettingsFontButtonTweak(_("Interface Text"),"org.gnome.desktop.interface", "font-name"), + # TODO + # GSettingsFontButtonTweak(_("Interface Text"),"org.gnome.desktop.interface", "font-name"), GSettingsFontButtonTweak(_("Document Text"), "org.gnome.desktop.interface", "document-font-name"), GSettingsFontButtonTweak(_("Monospace Text"), "org.gnome.desktop.interface", "monospace-font-name"), GSettingsFontButtonTweak(_("Legacy Window Titles"),"org.gnome.desktop.wm.preferences", "titlebar-font"), diff --git a/gtweak/tweaks/tweak_group_keymouse.py b/gtweak/tweaks/tweak_group_keymouse.py index 02da8bc7789cfc240fddb5d7f51a2c74a363a7a6..9e8509890aefd8c50a3b544ff37ea5e4926de1c4 100644 --- a/gtweak/tweaks/tweak_group_keymouse.py +++ b/gtweak/tweaks/tweak_group_keymouse.py @@ -44,8 +44,8 @@ class ComposeDialogLauncher(Gtk.Box, _GSettingsTweak): key_values = ["compose:sclk", "compose:prsc", "compose:menu", "compose:ralt", "compose:rctrl", "compose:rwin", "compose:caps", "compose:lctrl"] key_names = [_("Scroll Lock"), _("PrtScn"), _("Menu"), _("Right Alt"), _("Right Ctrl"), _("Right Super"), _("Caps Lock"), _("Left Ctrl")] - button = Gtk.Button(_("Disabled"), halign=Gtk.Align.END) - button.set_relief(Gtk.ReliefStyle.NONE) + button = Gtk.Button(label=_("Disabled"), halign=Gtk.Align.END) + button.set_has_frame(False) button.connect("clicked", self.on_button_clicked, self.settings) desc = _("Allows entering additional characters.") @@ -53,17 +53,17 @@ class ComposeDialogLauncher(Gtk.Box, _GSettingsTweak): vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) vbox.props.spacing = UI_BOX_SPACING - lbl = Gtk.Label(name) + lbl = Gtk.Label(label=name) lbl.props.xalign = 0.0 lbl_desc = Gtk.Label() - lbl_desc.set_line_wrap(True) + lbl_desc.set_wrap(True) lbl_desc.get_style_context().add_class("dim-label") lbl_desc.set_markup(""+GLib.markup_escape_text(desc)+"") - vbox.pack_start(lbl, False, False, 0) - vbox.pack_start(lbl_desc, False, False, 0) - self.pack_start(vbox, False, False, 0) - self.pack_end(button, True, True, 0) + vbox.prepend(lbl) + vbox.prepend(lbl_desc) + self.prepend(vbox) + self.append(button) for index, item in enumerate(key_values): if self.settings.setting_is_in_list("xkb-options", item): @@ -93,14 +93,23 @@ class ComposeDialog(Gtk.Dialog, Gtk.Button): self.set_transient_for(parent) self.set_size_request(500,-1) - btn_sclk = Gtk.RadioButton.new_with_label_from_widget(None, _("Scroll Lock")) - btn_prsc = Gtk.RadioButton.new_with_label_from_widget(btn_sclk, _("PrtScn")) - btn_menu = Gtk.RadioButton.new_with_label_from_widget(btn_sclk, _("Menu")) - btn_ralt = Gtk.RadioButton.new_with_label_from_widget(btn_sclk, _("Right Alt")) - btn_rctrl = Gtk.RadioButton.new_with_label_from_widget(btn_sclk, _("Right Ctrl")) - btn_rwin = Gtk.RadioButton.new_with_label_from_widget(btn_sclk, _("Right Super")) - btn_caps = Gtk.RadioButton.new_with_label_from_widget(btn_sclk, _("Caps Lock")) - btn_lctrl = Gtk.RadioButton.new_with_label_from_widget(btn_sclk, _("Left Ctrl")) + btn_sclk = Gtk.CheckButton.new_with_label(_("Scroll Lock")) + btn_prsc = Gtk.CheckButton.new_with_label(_("PrtScn")) + btn_menu = Gtk.CheckButton.new_with_label(_("Menu")) + btn_ralt = Gtk.CheckButton.new_with_label(_("Right Alt")) + btn_rctrl = Gtk.CheckButton.new_with_label(_("Right Ctrl")) + btn_rwin = Gtk.CheckButton.new_with_label(_("Right Super")) + btn_caps = Gtk.CheckButton.new_with_label(_("Caps Lock")) + btn_lctrl = Gtk.CheckButton.new_with_label(_("Left Ctrl")) + + btn_prsc.set_group(btn_sclk) + btn_menu.set_group(btn_sclk) + btn_ralt.set_group(btn_sclk) + btn_rctrl.set_group(btn_sclk) + btn_rwin.set_group(btn_sclk) + btn_caps.set_group(btn_sclk) + btn_lctrl.set_group(btn_sclk) + compose_buttons= [btn_sclk, btn_prsc, btn_menu, btn_ralt, btn_rctrl, btn_rwin, btn_caps, btn_lctrl] hb = Gtk.HeaderBar() @@ -122,11 +131,11 @@ class ComposeDialog(Gtk.Dialog, Gtk.Button): grid = Gtk.Grid() grid.props.border_width = 18 - label = Gtk.Label(None) + label = Gtk.Label() label.set_markup(_("The compose key allows a wide variety of characters to be entered. To use it, press the compose key and then a sequence of characters.\n\n" "Many unusual characters can be entered by combining standard ones. For example, compose key followed by C and o will enter ©, a followed by ' will enter á.\n")) - label.set_line_wrap(True) - self.get_content_area().pack_start(grid, True, True, 0) + label.set_wrap(True) + self.get_content_area().prepend(grid) grid.attach(label, 0, 0, 4, 1) grid.attach(btn_sclk, 1, 1, 1, 1) @@ -159,8 +168,6 @@ class ComposeDialog(Gtk.Dialog, Gtk.Button): button.set_sensitive(compose_enabled) button.connect("toggled", self.on_button_toggled, index, parent_button, settings) - self.show_all() - def on_button_toggled(self, button, index, parent_button, settings): for item in self.key_values: settings.setting_remove_from_list("xkb-options", item) @@ -190,23 +197,24 @@ class OverviewShortcutTweak(Gtk.Box, _GSettingsTweak): Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL, spacing=0) _GSettingsTweak.__init__(self, name, "org.gnome.mutter", "overlay-key", loaded=_shell_loaded, **options) - box_btn = Gtk.ButtonBox() - box_btn.set_layout(Gtk.ButtonBoxStyle.EXPAND) + box_btn = Gtk.Box() - btn1 = Gtk.RadioButton.new_with_label_from_widget(None, _("Left Super")) - btn1.set_property("draw-indicator", False) + btn1 = Gtk.CheckButton.new_with_label(_("Left Super")) + # TODO + # btn1.set_property("draw-indicator", False) - btn2 = Gtk.RadioButton.new_from_widget(btn1) - btn2.set_label(_("Right Super")) - btn2.set_property("draw-indicator", False) + btn2 = Gtk.CheckButton.new_with_label(_("Right Super")) + btn2.set_group(btn1) + # TODO + # btn2.set_property("draw-indicator", False) if (self.settings.get_string(self.key_name) == "Super_R"): btn2.set_active(True) btn1.connect("toggled", self.on_button_toggled, "Super_L") btn2.connect("toggled", self.on_button_toggled, "Super_R") - box_btn.pack_start(btn1, True, True, 0) - box_btn.pack_start(btn2, True, True, 0) + box_btn.prepend(btn1) + box_btn.prepend(btn2) build_label_beside_widget(name, box_btn, hbox=self) def on_button_toggled(self, button, key): @@ -222,9 +230,7 @@ class AdditionalLayoutButton(Gtk.Box, Tweak): btn = Gtk.Button(label=_("Additional Layout Options"),halign=Gtk.Align.END) btn.connect("clicked", self._on_browse_clicked) - self.add(btn) - - self.show_all() + self.append(btn) def _on_browse_clicked(self, btn): dialog = Gtk.Window() @@ -243,8 +249,8 @@ class AdditionalLayoutButton(Gtk.Box, Tweak): box = TypingTweakGroup() scrolled_window.add_with_viewport(box) - dialog.add(scrolled_window) - dialog.show_all() + dialog.set_child(scrolled_window) + dialog.show() class ClickMethod(Gtk.ListBox, Tweak): @@ -263,81 +269,87 @@ class ClickMethod(Gtk.ListBox, Tweak): row = Gtk.ListBoxRow() hbox = Gtk.Box() - hbox.props.margin = 10 - row.add(hbox) + hbox.props.margin_top = 10 + hbox.props.margin_bottom = 10 + hbox.props.margin_start = 10 + hbox.props.margin_end = 10 + row.set_child(hbox) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) - lbl = Gtk.Label(_("Fingers"), xalign=0) + lbl = Gtk.Label(label=_("Fingers"), xalign=0) lbl.props.xalign = 0.0 desc = _("Click the touchpad with two fingers for right-click and three fingers for middle-click.") lbl_desc = Gtk.Label() - lbl_desc.set_line_wrap(True) + lbl_desc.set_wrap(True) lbl_desc.get_style_context().add_class("dim-label") lbl_desc.set_markup(""+GLib.markup_escape_text(desc)+"") - self.check_fingers = Gtk.Image.new_from_icon_name("object-select-symbolic", Gtk.IconSize.SMALL_TOOLBAR); - self.check_fingers.set_no_show_all(True) + self.check_fingers = Gtk.Image.new_from_icon_name("object-select-symbolic"); self.check_fingers.set_visible(self.settings[self.key_name] == "fingers") - vbox.pack_start(lbl, False, False, 0) - vbox.pack_start(lbl_desc, False, False, 0) - hbox.pack_start(vbox, False, False, 0) - hbox.pack_end(self.check_fingers, False, False, 0) + vbox.prepend(lbl) + vbox.prepend(lbl_desc) + hbox.prepend(vbox) + hbox.append(self.check_fingers) - self.add(row) + self.append(row) row = Gtk.ListBoxRow() hbox = Gtk.Box() - hbox.props.margin = 10 - row.add(hbox) + hbox.props.margin_top = 10 + hbox.props.margin_bottom = 10 + hbox.props.margin_start = 10 + hbox.props.margin_end = 10 + row.set_child(hbox) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) - lbl = Gtk.Label(_("Area"), xalign=0) + lbl = Gtk.Label(label=_("Area"), xalign=0) lbl.props.xalign = 0.0 desc = _("Click the bottom right of the touchpad for right-click and the bottom middle for middle-click.") lbl_desc = Gtk.Label() - lbl_desc.set_line_wrap(True) + lbl_desc.set_wrap(True) lbl_desc.get_style_context().add_class("dim-label") lbl_desc.set_markup(""+GLib.markup_escape_text(desc)+"") - self.check_area = Gtk.Image.new_from_icon_name("object-select-symbolic", Gtk.IconSize.SMALL_TOOLBAR); - self.check_area.set_no_show_all(True) + self.check_area = Gtk.Image.new_from_icon_name("object-select-symbolic"); self.check_area.set_visible(self.settings[self.key_name] == "areas") - vbox.pack_start(lbl, False, False, 0) - vbox.pack_start(lbl_desc, False, False, 0) - hbox.pack_start(vbox, False, False, 0) - hbox.pack_end(self.check_area, False, False, 0) + vbox.prepend(lbl) + vbox.prepend(lbl_desc) + hbox.prepend(vbox) + hbox.append(self.check_area) - self.add(row) + self.append(row) row = Gtk.ListBoxRow() hbox = Gtk.Box() - hbox.props.margin = 10 - row.add(hbox) + hbox.props.margin_top = 10 + hbox.props.margin_bottom = 10 + hbox.props.margin_start = 10 + hbox.props.margin_end = 10 + row.set_child(hbox) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) - lbl = Gtk.Label(_("Disabled"), xalign=0) + lbl = Gtk.Label(label=_("Disabled"), xalign=0) lbl.props.xalign = 0.0 desc = _("Don’t use mouse click emulation.") lbl_desc = Gtk.Label() - lbl_desc.set_line_wrap(True) + lbl_desc.set_wrap(True) lbl_desc.get_style_context().add_class("dim-label") lbl_desc.set_markup(""+GLib.markup_escape_text(desc)+"") - self.check_disabled = Gtk.Image.new_from_icon_name("object-select-symbolic", Gtk.IconSize.SMALL_TOOLBAR); - self.check_disabled.set_no_show_all(True) + self.check_disabled = Gtk.Image.new_from_icon_name("object-select-symbolic"); self.check_disabled.set_visible(self.settings[self.key_name] == "none") - vbox.pack_start(lbl, False, False, 0) - vbox.pack_start(lbl_desc, False, False, 0) - hbox.pack_start(vbox, False, False, 0) - hbox.pack_end(self.check_disabled, False, False, 0) + vbox.prepend(lbl) + vbox.prepend(lbl_desc) + hbox.prepend(vbox) + hbox.append(self.check_disabled) - self.add(row) + self.append(row) self.connect('row-activated', self.on_row_clicked) def on_row_clicked(self, box, row): diff --git a/gtweak/tweaks/tweak_group_startup.py b/gtweak/tweaks/tweak_group_startup.py index ae7930c3118e0bc113ccef05747e60a1b210beec..007f510962c639b3f45a9ca0026cf2dbde284a9b 100644 --- a/gtweak/tweaks/tweak_group_startup.py +++ b/gtweak/tweaks/tweak_group_startup.py @@ -13,7 +13,7 @@ from gtweak.widgets import ListBoxTweakGroup, UI_BOX_SPACING from gtweak.utils import AutostartManager, AutostartFile def _image_from_gicon(gicon): - image = Gtk.Image.new_from_gicon(gicon, Gtk.IconSize.DIALOG) + image = Gtk.Image.new_from_gicon(gicon) (_, _, h) = Gtk.IconSize.lookup(Gtk.IconSize.DIALOG) image.set_pixel_size(h) return image @@ -30,10 +30,10 @@ class AutostartTitle(Gtk.Box, Tweak): desc = _("Startup applications are automatically started when you log in.") Tweak.__init__(self, _("Startup Applications"), desc, **options) - label = Gtk.Label(desc) + label = Gtk.Label(label=desc) label.get_style_context().add_class("dim-label") self.props.margin_bottom = 10 - self.add(label) + self.append(label) class _AppChooser(Gtk.Dialog): @@ -48,11 +48,12 @@ class _AppChooser(Gtk.Dialog): placeholder_text=_("Search Applications…")) self.entry.set_width_chars(30) self.entry.props.activates_default=True - if (Gtk.check_version(3, 22, 20) == None): - self.entry.set_input_hints(Gtk.InputHints.NO_EMOJI) + # TODO + # if (Gtk.check_version(3, 22, 20) == None): + # self.entry.set_input_hints(Gtk.InputHints.NO_EMOJI) self.searchbar = Gtk.SearchBar() - self.searchbar.add(self.entry) + self.searchbar.set_child(self.entry) self.searchbar.props.hexpand = True # Translators: This is the accelerator for opening the AppChooser search-bar self._search_key, self._search_mods = Gtk.accelerator_parse(_("f")) @@ -77,12 +78,15 @@ class _AppChooser(Gtk.Dialog): if w: self._all[w] = a self._running[w] = running - lb.add(w) + lb.append(w) sw = Gtk.ScrolledWindow() - sw.props.margin = 2 + sw.props.margin_top = 2 + sw.props.margin_bottom = 2 + sw.props.margin_start = 2 + sw.props.margin_end = 2 sw.props.hscrollbar_policy = Gtk.PolicyType.NEVER - sw.add(lb) + sw.set_child(lb) self.add_button(_("_Close"), Gtk.ResponseType.CANCEL) self.add_button(_("_Add"), Gtk.ResponseType.OK) @@ -91,23 +95,21 @@ class _AppChooser(Gtk.Dialog): if self.props.use_header_bar: searchbtn = Gtk.ToggleButton() searchbtn.props.valign = Gtk.Align.CENTER - image = Gtk.Image(icon_name = "edit-find-symbolic", icon_size = Gtk.IconSize.MENU) - searchbtn.add(image) + searchbtn.set_icon_name("edit-find-symbolic") context = searchbtn.get_style_context() - context.add_class("image-button") - context.remove_class("text-button") self.get_header_bar().pack_end(searchbtn) self._binding = searchbtn.bind_property("active", self.searchbar, "search-mode-enabled", GObject.BindingFlags.BIDIRECTIONAL) - self.get_content_area().pack_start(self.searchbar, False, False, 0) - self.get_content_area().pack_start(sw, True, True, 0) + self.get_content_area().prepend(self.searchbar) + self.get_content_area().prepend(sw) self.set_modal(True) self.set_transient_for(main_window) self.set_size_request(400,300) self.listbox = lb - self.connect("key-press-event", self._on_key_press) + # TODO + # self.connect("key-press-event", self._on_key_press) def _sort_apps(self, a, b, user_data): arun = self._running.get(a) @@ -131,7 +133,10 @@ class _AppChooser(Gtk.Dialog): def _build_widget(self, a, extra): row = Gtk.ListBoxRow() g = Gtk.Grid() - g.props.margin = 5 + g.props.margin_top = 10 + g.props.margin_bottom = 10 + g.props.margin_start = 10 + g.props.margin_end = 10 if not a.get_name(): return None @@ -152,7 +157,7 @@ class _AppChooser(Gtk.Dialog): g.attach_next_to( Gtk.Label(label=extra), lbl,Gtk.PositionType.RIGHT,1,1) - row.add(g) + row.set_child(g) #row.get_style_context().add_class('tweak-white') return row @@ -235,7 +240,7 @@ class _StartupTweak(Gtk.ListBoxRow, Tweak): btn.props.vexpand = False btn.props.valign = Gtk.Align.CENTER - self.add(grid) + self.set_child(grid) self.props.margin_start = 1 self.props.margin_end = 1 @@ -243,7 +248,8 @@ class _StartupTweak(Gtk.ListBoxRow, Tweak): self.btn = btn self.app_id = df.get_id() - self.connect("key-press-event", self._on_key_press_event) + # TODO + # self.connect("key-press-event", self._on_key_press_event) def _on_key_press_event(self, row, event): if event.keyval in [Gdk.KEY_Delete, Gdk.KEY_KP_Delete, Gdk.KEY_BackSpace]: @@ -258,11 +264,9 @@ class AddStartupTweak(Gtk.ListBoxRow, Tweak): _("Add a new application to be run at startup"), **options) - img = Gtk.Image() - img.set_from_icon_name("list-add-symbolic", Gtk.IconSize.BUTTON) - self.btn = Gtk.Button(label="", image=img, always_show_image=True) + self.btn = Gtk.Button.new_from_icon_name("list-add-symbolic") self.btn.get_style_context().remove_class("button") - self.add(self.btn) + self.set_child(self.btn) self.get_style_context().add_class('tweak-startup') self.connect("map", self._on_map) self.connect("unmap", self._on_unmap) @@ -322,7 +326,7 @@ class AutostartListBoxTweakGroup(ListBoxTweakGroup): self.main_window, set(self._get_running_executables()), startup_apps) - a.show_all() + a.show() Gio.Application.get_default().unmark_busy() resp = a.run() if resp == Gtk.ResponseType.OK: diff --git a/gtweak/tweaks/tweak_group_test.py b/gtweak/tweaks/tweak_group_test.py index 36a44bb94bd6535bfe144366e23160708e5452af..93afa920f1aabc151255751590914a5f690ed602 100644 --- a/gtweak/tweaks/tweak_group_test.py +++ b/gtweak/tweaks/tweak_group_test.py @@ -23,15 +23,15 @@ class _TestTweak(Gtk.Box, Tweak): def __init__(self, name, description, **options): Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL) Tweak.__init__(self, name, description, **options) - self.add(Gtk.Label("... " + name + " ...")) + self.append(Gtk.Label(label="... " + name + " ...")) class _TestButtonTweak(Gtk.Box, Tweak): def __init__(self, name, description, **options): Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL) Tweak.__init__(self, name, description, **options) - widget = Gtk.Button(name) + widget = Gtk.Button(label=name) widget.connect("clicked", self._on_click) - self.add(widget) + self.append(widget) self._need_action = options.get("_need_action") self._need_logout = options.get("_need_logout") @@ -53,9 +53,9 @@ css_provider.load_from_data(b""" background-color: green; } """) -screen = Gdk.Screen.get_default() +screen = Gdk.Display.get_default() context = Gtk.StyleContext() -context.add_provider_for_screen( +context.add_provider_for_display( screen, css_provider, 1 + Gtk.STYLE_PROVIDER_PRIORITY_USER) diff --git a/gtweak/tweaks/tweak_group_title_bar.py b/gtweak/tweaks/tweak_group_title_bar.py index 08ae606a458cbfe9d2b64ab1ed0af438d1e4771e..79d51ae7d0350d0d6593e59445b8b8d32d01d9a4 100644 --- a/gtweak/tweaks/tweak_group_title_bar.py +++ b/gtweak/tweaks/tweak_group_title_bar.py @@ -63,19 +63,20 @@ class PlaceWindowButtons(Gtk.Box, _GSettingsTweak): "button-layout", **options) - box_btn = Gtk.ButtonBox() - box_btn.set_layout(Gtk.ButtonBoxStyle.EXPAND) + box_btn = Gtk.Box() # Translators: For RTL languages, this is the "Right" direction since the # interface is flipped - btn1 = Gtk.RadioButton.new_with_label_from_widget(None, _("Left")) - btn1.set_property("draw-indicator", False) + btn1 = Gtk.CheckButton.new_with_label(_("Left")) + # TODO + # btn1.set_property("draw-indicator", False) - btn2 = Gtk.RadioButton.new_from_widget(btn1) # Translators: For RTL languages, this is the "Left" direction since the # interface is flipped - btn2.set_label(_("Right")) - btn2.set_property("draw-indicator", False) + btn2 = Gtk.CheckButton.new_with_label(_("Right")) + btn2.set_group(btn1) + # TODO + # btn2.set_property("draw-indicator", False) val = self.settings.get_string(self.key_name) (left, colon, right) = val.partition(":") @@ -83,8 +84,8 @@ class PlaceWindowButtons(Gtk.Box, _GSettingsTweak): btn2.set_active(True) btn2.connect("toggled", self.on_button_toggled) - box_btn.pack_start(btn1, True, True, 0) - box_btn.pack_start(btn2, True, True, 0) + box_btn.prepend(btn1) + box_btn.prepend(btn2) build_label_beside_widget(name, box_btn, hbox=self) diff --git a/gtweak/tweaks/tweak_group_windows.py b/gtweak/tweaks/tweak_group_windows.py index 9de80887e97514479990b3869dce8dd520810fe2..5f551be4c1b994e362ac34ae059af3dcf3064b21 100644 --- a/gtweak/tweaks/tweak_group_windows.py +++ b/gtweak/tweaks/tweak_group_windows.py @@ -28,81 +28,87 @@ class Focus(Gtk.ListBox, Tweak): row = Gtk.ListBoxRow() hbox = Gtk.Box() - hbox.props.margin = 10 - row.add(hbox) + hbox.props.margin_top = 10 + hbox.props.margin_bottom = 10 + hbox.props.margin_start = 10 + hbox.props.margin_end = 10 + row.set_child(hbox) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) - lbl = Gtk.Label(_("Click to Focus"), xalign=0) + lbl = Gtk.Label(label=_("Click to Focus"), xalign=0) lbl.props.xalign = 0.0 desc = _("Windows are focused when they are clicked.") lbl_desc = Gtk.Label() - lbl_desc.set_line_wrap(True) + lbl_desc.set_wrap(True) lbl_desc.get_style_context().add_class("dim-label") lbl_desc.set_markup(""+GLib.markup_escape_text(desc)+"") - self.check_click = Gtk.Image.new_from_icon_name("object-select-symbolic", Gtk.IconSize.SMALL_TOOLBAR); - self.check_click.set_no_show_all(True) + self.check_click = Gtk.Image.new_from_icon_name("object-select-symbolic"); self.check_click.set_visible(self.settings[self.key_name] == "click") - vbox.pack_start(lbl, False, False, 0) - vbox.pack_start(lbl_desc, False, False, 0) - hbox.pack_start(vbox, False, False, 0) - hbox.pack_end(self.check_click, False, False, 0) + vbox.prepend(lbl) + vbox.prepend(lbl_desc) + hbox.prepend(vbox) + hbox.append(self.check_click) - self.add(row) + self.append(row) row = Gtk.ListBoxRow() hbox = Gtk.Box() - hbox.props.margin = 10 - row.add(hbox) + hbox.props.margin_top = 10 + hbox.props.margin_bottom = 10 + hbox.props.margin_start = 10 + hbox.props.margin_end = 10 + row.set_child(hbox) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) - lbl = Gtk.Label(_("Focus on Hover"), xalign=0) + lbl = Gtk.Label(label=_("Focus on Hover"), xalign=0) lbl.props.xalign = 0.0 desc = _("Window is focused when hovered with the pointer. Windows remain focused when the desktop is hovered.") lbl_desc = Gtk.Label() - lbl_desc.set_line_wrap(True) + lbl_desc.set_wrap(True) lbl_desc.get_style_context().add_class("dim-label") lbl_desc.set_markup(""+GLib.markup_escape_text(desc)+"") - self.check_sloppy = Gtk.Image.new_from_icon_name("object-select-symbolic", Gtk.IconSize.SMALL_TOOLBAR); - self.check_sloppy.set_no_show_all(True) + self.check_sloppy = Gtk.Image.new_from_icon_name("object-select-symbolic"); self.check_sloppy.set_visible(self.settings[self.key_name] == "sloppy") - vbox.pack_start(lbl, False, False, 0) - vbox.pack_start(lbl_desc, False, False, 0) - hbox.pack_start(vbox, False, False, 0) - hbox.pack_end(self.check_sloppy, False, False, 0) + vbox.prepend(lbl) + vbox.prepend(lbl_desc) + hbox.prepend(vbox) + hbox.append(self.check_sloppy) - self.add(row) + self.append(row) row = Gtk.ListBoxRow() hbox = Gtk.Box() - hbox.props.margin = 10 - row.add(hbox) + hbox.props.margin_top = 10 + hbox.props.margin_bottom = 10 + hbox.props.margin_start = 10 + hbox.props.margin_end = 10 + row.set_child(hbox) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) - lbl = Gtk.Label(_("Secondary-Click"), xalign=0) + lbl = Gtk.Label(label=_("Secondary-Click"), xalign=0) lbl.props.xalign = 0.0 desc = _("Window is focused when hovered with the pointer. Hovering the desktop removes focus from the previous window.") lbl_desc = Gtk.Label() - lbl_desc.set_line_wrap(True) + lbl_desc.set_wrap(True) lbl_desc.get_style_context().add_class("dim-label") lbl_desc.set_markup(""+GLib.markup_escape_text(desc)+"") - self.check_mouse = Gtk.Image.new_from_icon_name("object-select-symbolic", Gtk.IconSize.SMALL_TOOLBAR); - self.check_mouse.set_no_show_all(True) + self.check_mouse = Gtk.Image.new_from_icon_name("object-select-symbolic"); self.check_mouse.set_visible(self.settings[self.key_name] == "mouse") - vbox.pack_start(lbl, False, False, 0) - vbox.pack_start(lbl_desc, False, False, 0) - hbox.pack_start(vbox, False, False, 0) - hbox.pack_end(self.check_mouse, False, False, 0) + vbox.prepend(lbl) + vbox.prepend(lbl_desc) + hbox.prepend(vbox) + hbox.append(self.check_mouse) - self.add(row) + self.append(row) self.connect('row-activated', self.on_row_clicked) def on_row_clicked(self, box, row): diff --git a/gtweak/tweaks/tweak_group_xkb.py b/gtweak/tweaks/tweak_group_xkb.py index 6ba9195b69ac130062da8ab4c90e056fe7f2432f..308512c232e88c5032808f460e47d6e5f24fee3c 100644 --- a/gtweak/tweaks/tweak_group_xkb.py +++ b/gtweak/tweaks/tweak_group_xkb.py @@ -7,8 +7,8 @@ import logging import gi -gi.require_version("GnomeDesktop", "3.0") -from gi.repository import Gtk, GnomeDesktop +# TODO Removed GnomeDesktop +from gi.repository import Gtk from gtweak.tweakmodel import Tweak, TweakGroup from gtweak.widgets import GSettingsSwitchTweak, build_label_beside_widget, GSettingsComboEnumTweak, GSettingsComboTweak, build_horizontal_sizegroup, ListBoxTweakGroup from gtweak.gsettings import GSettingsSetting, GSettingsMissingError @@ -26,7 +26,7 @@ class _XkbOption(Gtk.Expander, Tweak): self.set_label(self.name) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=3) vbox.set_margin_start(15) - self.add(vbox) + self.append(vbox) self._multiple_selection = not group_id in { 'keypad', 'kpdl', 'caps', 'altwin', 'nbsp', 'esperanto' } self._group_id = group_id @@ -75,16 +75,15 @@ class _XkbOption(Gtk.Expander, Tweak): self._widgets = dict() for (val, name) in model_values: - w = None - if self._multiple_selection: - w = Gtk.CheckButton.new() - else: - w = Gtk.RadioButton.new_from_widget(self._widgets.get(None)) + w = Gtk.CheckButton.new() + if not self._multiple_selection: + w.set_group(self._widgets.get(None)) + self._widgets[val] = w; - vbox.add(w) + vbox.append(w) l = Gtk.Label(label=name) - l.set_line_wrap(True) - w.add(l) + l.set_wrap(True) + w.set_child(l) w._changed_id = w.connect('toggled', self._on_toggled) w._val = val @@ -163,7 +162,7 @@ class TypingTweakGroup(Gtk.Box): obj = _XkbOption(opt, self._kbdsettings, self._xkb_info) self._option_objects.append(obj) self._option_objects.sort(key=lambda item_desc: item_desc.name) - for item in self._option_objects: self.pack_start(item, False, False, 0) + for item in self._option_objects: self.prepend(item) TweakGroup.__init__(self, _("Typing"), *self._option_objects) self.connect("destroy", self._on_destroy) diff --git a/gtweak/tweakview.py b/gtweak/tweakview.py index 94b89a60c0b9dcd5a6553f002cfce41633330f06..e461fbc958ccee4e75de0ae38e35ccb83f34256a 100644 --- a/gtweak/tweakview.py +++ b/gtweak/tweakview.py @@ -4,7 +4,7 @@ import os.path -from gi.repository import Gtk, Gdk, Gio, Handy, GObject +from gi.repository import Adw, Gtk, Gdk, Gio, GObject import gtweak import gtweak.tweakmodel from gtweak.tweakmodel import string_for_search @@ -18,13 +18,12 @@ class Window(Gtk.ApplicationWindow): show_menubar=False) self.set_default_size(980, 640) self.set_size_request(-1, 300) - self.set_position(Gtk.WindowPosition.CENTER) self.set_icon_name("org.gnome.tweaks") self.hsize_group = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL) - self.main_box = Handy.Leaflet() - self.main_box.set_transition_type(Handy.LeafletTransitionType.SLIDE) + self.main_box = Adw.Leaflet() + self.main_box.set_transition_type(Adw.LeafletTransitionType.SLIDE) left_box = self.sidebar() right_box = self.main_content() @@ -36,20 +35,20 @@ class Window(Gtk.ApplicationWindow): self.set_titlebar(titlebar) self._update_decorations() - self.main_box.add(left_box) - self.main_box.child_set(left_box, name="sidebar") - self.main_box.add(separator) - self.main_box.add(right_box) - self.main_box.child_set(right_box, name="content") + self.main_box.append(left_box) + self.main_box.get_page(left_box).set_name("sidebar") + self.main_box.append(separator) + self.main_box.append(right_box) + self.main_box.get_page(right_box).set_name("content") self.main_box.set_visible_child_name("sidebar") self.main_box.bind_property("visible-child-name", titlebar, "visible-child-name", GObject.BindingFlags.SYNC_CREATE) - start_pane_size_group = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL) + start_pane_size_group = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL) start_pane_size_group.add_widget(left_box) start_pane_size_group.add_widget(self._left_header) - end_pane_size_group = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL) + end_pane_size_group = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL) end_pane_size_group.add_widget(right_box) end_pane_size_group.add_widget(self._right_header) @@ -61,21 +60,20 @@ class Window(Gtk.ApplicationWindow): Gtk.Settings.get_default().connect("notify::gtk-decoration-layout", self._update_decorations) - self.connect("key-press-event", self._on_key_press) - self.connect_after("key-press-event", self._after_key_press) - self.add(self.main_box) + # TODO + # self.connect("key-press-event", self._on_key_press) + # self.connect_after("key-press-event", self._after_key_press) + self.set_child(self.main_box) def titlebar(self): - header = Handy.Leaflet() - header.set_transition_type(Handy.LeafletTransitionType.SLIDE) + header = Adw.Leaflet() + header.set_transition_type(Adw.LeafletTransitionType.SLIDE) header.connect("notify::visible-child", self._update_decorations) header.connect("notify::fold", self._update_decorations) left_header = Gtk.HeaderBar() - left_header.props.show_close_button = True right_header = Gtk.HeaderBar() - right_header.props.show_close_button = True right_header.props.hexpand = True self._left_header = left_header @@ -88,27 +86,23 @@ class Window(Gtk.ApplicationWindow): self._group_titlebar_widget = None - self.title = Gtk.Label(label="") - self.title.get_style_context().add_class("title") - right_header.set_custom_title(self.title) + self.title = Adw.WindowTitle.new("", "") + right_header.set_title_widget(self.title) - self.back_button = Gtk.Button.new_from_icon_name("go-previous-symbolic", 1) + self.back_button = Gtk.Button.new_from_icon_name("go-previous-symbolic") self.back_button.connect("clicked", self._on_back_clicked) header.bind_property("folded", self.back_button, "visible") right_header.pack_start(self.back_button) - icon = Gtk.Image() - icon.set_from_icon_name("edit-find-symbolic", Gtk.IconSize.MENU) self.button = Gtk.ToggleButton() - self.button.add(icon) + self.button.set_icon_name("edit-find-symbolic") self.button.connect("toggled", self._on_find_toggled) self.button.props.valign = Gtk.Align.CENTER self.button.get_style_context().add_class("image-button") left_header.pack_start(self.button) - lbl = Gtk.Label(label=_("Tweaks")) - lbl.get_style_context().add_class("title") - left_header.set_custom_title(lbl) + lbl = Adw.WindowTitle.new(_("Tweaks"), "") + left_header.set_title_widget(lbl) self.builder = Gtk.Builder() assert(os.path.exists(gtweak.PKG_DATA_DIR)) @@ -116,21 +110,20 @@ class Window(Gtk.ApplicationWindow): self.builder.add_from_file(filename) appmenu = self.builder.get_object('appmenu') - icon = Gtk.Image.new_from_gicon(Gio.ThemedIcon(name="open-menu-symbolic"), - Gtk.IconSize.BUTTON) - self.menu_btn.set_image(icon) + self.menu_btn.set_icon_name("open-menu-symbolic") self.menu_btn.set_menu_model(appmenu) left_header.pack_end(self.menu_btn) - header.add(left_header) - header.child_set(left_header, name="sidebar") - header.add(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)) - header.add(right_header) - header.child_set(right_header, name="content") + header.append(left_header) + header.get_page(left_header).set_name("sidebar") + header.append(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)) + header.append(right_header) + header.get_page(right_header).set_name("content") - self.header_group = Handy.HeaderGroup() - self.header_group.add_gtk_header_bar(left_header) - self.header_group.add_gtk_header_bar(right_header) + # TODO + # self.header_group = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) + # self.header_group.append(left_header) + # self.header_group.append(right_header) self.hsize_group.add_widget(left_header) @@ -141,12 +134,13 @@ class Window(Gtk.ApplicationWindow): left_box.set_size_request(200, -1) self.entry = Gtk.SearchEntry(placeholder_text=_("Search Tweaks…")) - if (Gtk.check_version(3, 22, 20) is None): - self.entry.set_input_hints(Gtk.InputHints.NO_EMOJI) + # TODO + # if (Gtk.check_version(3, 22, 20) is None): + # self.entry.set_input_hints(Gtk.InputHints.NO_EMOJI) self.entry.connect("search-changed", self._on_search) self.searchbar = Gtk.SearchBar() - self.searchbar.add(self.entry) + self.searchbar.set_child(self.entry) self.searchbar.props.hexpand = False self.listbox = Gtk.ListBox() @@ -154,12 +148,13 @@ class Window(Gtk.ApplicationWindow): self.listbox.connect("row-selected", self._on_select_row) self.listbox.set_header_func(self._list_header_func, None) scroll = Gtk.ScrolledWindow() + scroll.props.vexpand = True scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) - scroll.add(self.listbox) + scroll.set_child(self.listbox) - left_box.pack_start(self.searchbar, False, False, 0) - left_box.pack_start(scroll, True, True, 0) + left_box.prepend(self.searchbar) + left_box.prepend(scroll) self.hsize_group.add_widget(left_box) @@ -170,9 +165,10 @@ class Window(Gtk.ApplicationWindow): right_box.set_size_request(540, -1) self.stack = Gtk.Stack() + self.stack.props.vexpand = True self.stack.get_style_context().add_class("main-container") - right_box.pack_start(self.stack, True, True, 0) + right_box.prepend(self.stack) return right_box @@ -180,9 +176,8 @@ class Window(Gtk.ApplicationWindow): css_provider = Gtk.CssProvider() css_provider.load_from_path( os.path.join(gtweak.PKG_DATA_DIR, 'shell.css')) - screen = Gdk.Screen.get_default() - context = Gtk.StyleContext() - context.add_provider_for_screen(screen, css_provider, + display = Gdk.Display.get_default() + self.get_style_context().add_provider_for_display(display, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_USER) def load_model_data(self): @@ -192,7 +187,7 @@ class Window(Gtk.ApplicationWindow): lbl.set_name('row') row = Gtk.ListBoxRow() row.get_style_context().add_class("tweak-category") - row.add(lbl) + row.set_child(lbl) return row groups = list(self._model._tweak_group_names.keys()) @@ -202,12 +197,12 @@ class Window(Gtk.ApplicationWindow): for g in groups: row = _make_items_listbox(g) - self.listbox.add(row) + self.listbox.append(row) tweakgroup = self._model.get_value( self._model.get_tweakgroup_iter(g), self._model.COLUMN_TWEAK) scroll = Gtk.ScrolledWindow() - scroll.add(tweakgroup) + scroll.set_child(tweakgroup) self.stack.add_named(scroll, g) widget = self.listbox.get_row_at_index(0) @@ -224,10 +219,11 @@ class Window(Gtk.ApplicationWindow): def _update_decorations(self, *_): header = self.get_titlebar() - if header.props.folded: - self.header_group.set_decorate_all(True) - else: - self.header_group.set_decorate_all(False) + # TODO + # if header.props.folded: + # self.header_group.set_show_end_title_buttons(True) + # else: + # self.header_group.set_show_end_title_buttons(False) def _after_key_press(self, widget, event): if not self.button.get_active() or not self.entry.is_focus(): @@ -282,7 +278,7 @@ class Window(Gtk.ApplicationWindow): if row: group = row.get_child().get_text() self.stack.set_visible_child_name(group) - self.title.set_text(group) + self.title.set_title(group) tweakgroup = self._model.get_value( self._model.get_tweakgroup_iter(group), self._model.COLUMN_TWEAK) @@ -307,6 +303,6 @@ class Window(Gtk.ApplicationWindow): def show_only_tweaks(self, tweaks): for t in self._model.tweaks: if t in tweaks: - t.show_all() + t.show() else: t.hide() diff --git a/gtweak/widgets.py b/gtweak/widgets.py index 703ff543469d9a5096ee99166c1309c3e2186ea6..e76f4692133879ad2732c59e820af90c06c8fa11 100644 --- a/gtweak/widgets.py +++ b/gtweak/widgets.py @@ -24,7 +24,7 @@ def build_label_beside_widget(txt, *widget, **kwargs): warning: Warning text to be shown after the label """ def make_image(icon, tip): - image = Gtk.Image.new_from_icon_name(icon, Gtk.IconSize.MENU) + image = Gtk.Image.new_from_icon_name(icon) image.set_tooltip_text(tip) return image @@ -42,24 +42,22 @@ def build_label_beside_widget(txt, *widget, **kwargs): hbox = Gtk.Box() hbox.props.spacing = UI_BOX_SPACING - lbl = Gtk.Label(label=txt) + lbl = Gtk.Label(label=txt, hexpand=True) lbl.props.ellipsize = Pango.EllipsizeMode.END lbl.props.xalign = 0.0 lbl.set_has_tooltip(True) lbl.connect("query-tooltip", show_tooltip_when_ellipsized) - hbox.pack_start(lbl, True, True, 0) + hbox.append(lbl) if kwargs.get("info"): - hbox.pack_start( - make_image("dialog-information-symbolic", kwargs.get("info")), - False, False, 0) + hbox.append( + make_image("dialog-information-symbolic", kwargs.get("info"))) if kwargs.get("warning"): - hbox.pack_start( - make_image("dialog-warning-symbolic", kwargs.get("warning")), - False, False, 0) + hbox.append( + make_image("dialog-warning-symbolic", kwargs.get("warning"))) for w in widget: - hbox.pack_start(w, False, False, 0) + hbox.append(w) # For Atk, indicate that the rightmost widget, usually the switch relates to the # label. By convention this is true in the great majority of cases. Settings that @@ -84,9 +82,10 @@ def build_combo_box_text(selected, *values): selected_iter = _iter combo = Gtk.ComboBox(model=store) - renderer = Gtk.CellRendererText() - combo.pack_start(renderer, True) - combo.add_attribute(renderer, 'markup', 1) + # TODO + # renderer = Gtk.CellRendererText() + # combo.set_child(renderer) + # combo.add_attribute(renderer, 'markup', 1) if selected_iter: combo.set_active_iter(selected_iter) @@ -95,15 +94,16 @@ def build_combo_box_text(selected, *values): def build_horizontal_sizegroup(): sg = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL) - sg.props.ignore_hidden = True + # TODO + # sg.props.ignore_hidden = True return sg def build_tight_button(stock_id): button = Gtk.Button() - button.set_relief(Gtk.ReliefStyle.NONE) + button.set_has_frame(False) button.set_focus_on_click(False) - button.add(Gtk.Image.new_from_stock(stock_id, Gtk.IconSize.MENU)) + button.set_child(Gtk.Image.new_from_stock(stock_id)) data = ".button {\n" \ "-GtkButton-default-border : 0px;\n" \ "-GtkButton-default-outside-border : 0px;\n" \ @@ -191,12 +191,16 @@ class ListBoxTweakGroup(Gtk.ListBox, TweakGroup): name=options['uid']) self.get_style_context().add_class( options.get('css_class', 'tweak-group')) - self.props.margin = 20 + self.props.margin_top = 20 + self.props.margin_bottom = 20 + self.props.margin_start = 20 + self.props.margin_end = 20 self.props.vexpand = False self.props.valign = Gtk.Align.START self._sg = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL) - self._sg.props.ignore_hidden = True + # TODO + # self._sg.props.ignore_hidden = True TweakGroup.__init__(self, name, **options) @@ -215,10 +219,10 @@ class ListBoxTweakGroup(Gtk.ListBox, TweakGroup): row.get_style_context().add_class("tweak") if isinstance(t, Title): row.get_style_context().add_class("title") - row.add(t) + row.set_child(t) row.set_activatable(activatable) if position is None: - self.add(row) + self.append(row) else: self.insert(row, position) if t.widget_for_size_group: @@ -236,7 +240,7 @@ class GSettingsCheckTweak(Gtk.Box, _GSettingsTweak, _DependableMixin): key_name, widget, "active", Gio.SettingsBindFlags.DEFAULT) - self.add(widget) + self.append(widget) self.widget_for_size_group = None self.add_dependency_on_tweak( @@ -258,31 +262,31 @@ class GSettingsSwitchTweak(Gtk.Box, _GSettingsTweak, _DependableMixin): options.get("depends_how") ) - vbox1 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) + vbox1 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, hexpand=True) vbox1.props.spacing = UI_BOX_SPACING lbl = Gtk.Label(label=name) lbl.props.ellipsize = Pango.EllipsizeMode.END lbl.props.xalign = 0.0 - vbox1.pack_start(lbl, True, True, 0) + vbox1.append(lbl) if options.get("desc"): description = options.get("desc") lbl_desc = Gtk.Label() lbl_desc.props.xalign = 0.0 - lbl_desc.set_line_wrap(True) + lbl_desc.set_wrap(True) lbl_desc.get_style_context().add_class("dim-label") lbl_desc.set_markup(""+GLib.markup_escape_text(description)+"") - vbox1.pack_start(lbl_desc, True, True, 0) + vbox1.append(lbl_desc) vbox2 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) vbox2_upper = Gtk.Box() vbox2_lower = Gtk.Box() - vbox2.pack_start(vbox2_upper, True, True, 0) - vbox2.pack_start(w, False, False, 0) - vbox2.pack_start(vbox2_lower, True, True, 0) + vbox2.append(vbox2_upper) + vbox2.append(w) + vbox2.append(vbox2_lower) - self.pack_start(vbox1, True, True, 0) - self.pack_start(vbox2, False, False, 0) + self.append(vbox1) + self.append(vbox2) self.widget_for_size_group = None @@ -293,7 +297,8 @@ class GSettingsFontButtonTweak(Gtk.Box, _GSettingsTweak, _DependableMixin): w = Gtk.FontButton() w.set_use_font(True) - self.settings.bind(key_name, w, "font-name", Gio.SettingsBindFlags.DEFAULT) + # TODO + # self.settings.bind(key_name, w, "font-name", Gio.SettingsBindFlags.DEFAULT) build_label_beside_widget(name, w, hbox=self) self.widget_for_size_group = w @@ -419,19 +424,20 @@ class GSettingsComboTweak(Gtk.Box, _GSettingsTweak, _DependableMixin): return self._extra_info -class FileChooserButton(Gtk.FileChooserButton): - def __init__(self, title, local_only, mimetypes): - Gtk.FileChooserButton.__init__(self, title=title) +# TODO +# class FileChooserButton(Gtk.FileChooserButton): +# def __init__(self, title, local_only, mimetypes): +# Gtk.FileChooserButton.__init__(self, title=title) - if mimetypes: - f = Gtk.FileFilter() - for m in mimetypes: - f.add_mime_type(m) - self.set_filter(f) +# if mimetypes: +# f = Gtk.FileFilter() +# for m in mimetypes: +# f.add_mime_type(m) +# self.set_filter(f) - # self.set_width_chars(15) - self.set_local_only(local_only) - self.set_action(Gtk.FileChooserAction.OPEN) +# # self.set_width_chars(15) +# self.set_local_only(local_only) +# self.set_action(Gtk.FileChooserAction.OPEN) class GSettingsFileChooserButtonTweak(Gtk.Box, _GSettingsTweak, _DependableMixin): @@ -441,12 +447,13 @@ class GSettingsFileChooserButtonTweak(Gtk.Box, _GSettingsTweak, _DependableMixin self.settings.connect('changed::'+self.key_name, self._on_setting_changed) - self.filechooser = FileChooserButton(name, local_only, mimetypes) - self.filechooser.set_uri(self.settings.get_string(self.key_name)) - self.filechooser.connect("file-set", self._on_file_set) + # TODO + # self.filechooser = FileChooserButton(name, local_only, mimetypes) + # self.filechooser.set_uri(self.settings.get_string(self.key_name)) + # self.filechooser.connect("file-set", self._on_file_set) - build_label_beside_widget(name, self.filechooser, hbox=self) - self.widget_for_size_group = self.filechooser + # build_label_beside_widget(name, self.filechooser, hbox=self) + # self.widget_for_size_group = self.filechooser def _values_are_different(self): return self.settings.get_string(self.key_name) != self.filechooser.get_uri() @@ -490,7 +497,7 @@ class Title(Gtk.Box, Tweak): widget.props.xalign = 0.0 if not options.get("top"): widget.set_margin_top(10) - self.add(widget) + self.append(widget) class GSettingsSwitchTweakValue(Gtk.Box, _GSettingsTweak): @@ -508,26 +515,26 @@ class GSettingsSwitchTweakValue(Gtk.Box, _GSettingsTweak): lbl = Gtk.Label(label=name) lbl.props.ellipsize = Pango.EllipsizeMode.END lbl.props.xalign = 0.0 - vbox1.pack_start(lbl, True, True, 0) + vbox1.append(lbl) if options.get("desc"): description = options.get("desc") lbl_desc = Gtk.Label() lbl_desc.props.xalign = 0.0 - lbl_desc.set_line_wrap(True) + lbl_desc.set_wrap(True) lbl_desc.get_style_context().add_class("dim-label") lbl_desc.set_markup(""+GLib.markup_escape_text(description)+"") - vbox1.pack_start(lbl_desc, True, True, 0) + vbox1.prepend(lbl_desc) vbox2 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) vbox2_upper = Gtk.Box() vbox2_lower = Gtk.Box() - vbox2.pack_start(vbox2_upper, True, True, 0) - vbox2.pack_start(sw, False, False, 0) - vbox2.pack_start(vbox2_lower, True, True, 0) + vbox2.prepend(vbox2_upper) + vbox2.prepend(sw) + vbox2.prepend(vbox2_lower) - self.pack_start(vbox1, True, True, 0) - self.pack_start(vbox2, False, False, 0) + self.prepend(vbox1) + self.prepend(vbox2) self.widget_for_size_group = None def _on_toggled(self, sw, pspec):