diff --git a/NEWS.rst b/NEWS.rst index 66056c4..c0054c8 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -23,6 +23,9 @@ Added Changed ------- +- CLI argument to hide close button `#174 + `_ + - The exposed action ``update-library`` now takes a parameter to specify the URI of the directory to update `#149 `_ diff --git a/README.rst b/README.rst index aa25e0e..1d79108 100644 --- a/README.rst +++ b/README.rst @@ -170,7 +170,7 @@ user that will run Argos. Changes can be made using `Dconf Editor Some CLI options are provided (complete list can be obtained with ``argos --help``):: - $ argos --no-tooltips --hide-search-button + $ argos --no-tooltips --hide-search-button --hide-close-button Style ----- diff --git a/argos/app.py b/argos/app.py index ed39426..6ea4418 100644 --- a/argos/app.py +++ b/argos/app.py @@ -52,6 +52,7 @@ class Application(Gtk.Application): start_fullscreen = GObject.Property(type=bool, default=False) disable_tooltips = GObject.Property(type=bool, default=False) hide_search_button = GObject.Property(type=bool, default=False) + hide_close_button = GObject.Property(type=bool, default=False) version = GObject.Property(type=str) def __init__(self, *args, **kwargs): @@ -144,6 +145,14 @@ def _exception_handler( _("Hide search button"), None, ) + self.add_main_option( + "hide-close-button", + 0, + GLib.OptionFlags.NONE, + GLib.OptionArg.NONE, + _("Hide close button"), + None, + ) self.props.start_fullscreen = self._settings.get_boolean("start-fullscreen") @@ -236,6 +245,7 @@ def do_command_line(self, command_line: Gio.ApplicationCommandLine): self.props.disable_tooltips = "no-tooltips" in options self.props.hide_search_button = "hide-search-button" in options + self.props.hide_close_button = "hide-close-button" in options if "maximized" in options: LOGGER.warning("The maximized command line option is deprecated!") diff --git a/argos/widgets/titlebar.py b/argos/widgets/titlebar.py index d9d3887..ef68e4c 100644 --- a/argos/widgets/titlebar.py +++ b/argos/widgets/titlebar.py @@ -65,19 +65,25 @@ def __init__(self, application: Gtk.Application, *, window: Gtk.ApplicationWindo self.remove(self.search_button) self.search_button = None - self.set_decoration_layout(":close") - self.set_show_close_button(True) - # On LXDE with Openbox window manager, showing close - # button also decorate title bar with minimize, maximize - # buttons whatever the Openbox configuration for the - # application is... - self.search_button_toggled_handler_id = ( self.search_button.connect("toggled", self.on_search_button_toggled) if self.search_button else None ) - self._window.connect("notify::is-fullscreen", self.on_is_fullscreen_changed) + + if application.props.hide_close_button: + self.set_decoration_layout("") + self.set_show_close_button(False) + else: + self.set_decoration_layout(":close") + self.set_show_close_button(True) + + # On LXDE with Openbox window manager, showing close + # button also decorate title bar with minimize, maximize + # buttons whatever the Openbox configuration for the + # application is... + + self._window.connect("notify::is-fullscreen", self.on_is_fullscreen_changed) def toggle_search_entry_focus_maybe(self) -> None: if not self.search_button: