Skip to content

Commit

Permalink
Hide close button when window is maximized
Browse files Browse the repository at this point in the history
Refs: #174
  • Loading branch information
orontee committed Jun 4, 2024
1 parent aced8b9 commit 13ae882
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
3 changes: 3 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Added
Changed
-------

- CLI argument to hide close button `#174
<https://github.com/orontee/argos/issues/174>`_

- The exposed action ``update-library`` now takes a parameter to
specify the URI of the directory to update `#149
<https://github.com/orontee/argos/issues/149>`_
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----
Expand Down
10 changes: 10 additions & 0 deletions argos/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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!")
Expand Down
22 changes: 14 additions & 8 deletions argos/widgets/titlebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 13ae882

Please sign in to comment.