Skip to content

Commit

Permalink
Add hide tab bar when only one tab option
Browse files Browse the repository at this point in the history
Also tied hide tab bar to some related menu options.
  • Loading branch information
Davidy22 authored and gsemet committed Sep 16, 2021
1 parent 082536f commit 7fe07d4
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 2 deletions.
5 changes: 5 additions & 0 deletions guake/data/org.guake.gschema.xml
Expand Up @@ -111,6 +111,11 @@
<summary>Hide tab bar when fullscreen</summary>
<description>When true, the tab bar will hide when is in fullscreen</description>
</key>
<key name="hide-tabs-if-one-tab" type="b">
<default>true</default>
<summary>Hide tab bar if there is only one tab</summary>
<description>When true, the tab bar will hide when there is only one tab</description>
</key>
<key name="quick-open-enable" type="b">
<default>false</default>
<summary>Enable Quick Open feature.</summary>
Expand Down
16 changes: 16 additions & 0 deletions guake/data/prefs.glade
Expand Up @@ -773,6 +773,7 @@
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_window_tabbar_toggled" swapped="no"/>
<signal name="toggled" handler="toggle_show_tabbar_sensitivity" swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
Expand Down Expand Up @@ -932,6 +933,21 @@
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="hide_tabs_if_one_tab">
<property name="label" translatable="yes">Hide tab bar if there is only one tab</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_hide_tabs_if_one_tab_toggled" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<placeholder/>
</child>
Expand Down
17 changes: 15 additions & 2 deletions guake/gsettings.py
Expand Up @@ -87,6 +87,7 @@ def __init__(self, guake_inst):
settings.general.onChangedValue("custom-command_file", self.custom_command_file_changed)
settings.general.onChangedValue("max-tab-name-length", self.max_tab_name_length_changed)
settings.general.onChangedValue("display-tab-names", self.display_tab_names_changed)
settings.general.onChangedValue("hide-tabs-if-one-tab", self.hide_tabs_if_one_tab_changed)

def custom_command_file_changed(self, settings, key, user_data):
self.guake.load_custom_commands()
Expand Down Expand Up @@ -116,7 +117,10 @@ def tabbar_toggled(self, settings, key, user_data):
called and will show/hide the tabbar.
"""
if settings.get_boolean(key):
self.guake.notebook_manager.set_notebooks_tabbar_visible(True)
if settings.get_boolean(key):
self.guake.get_notebook().hide_if_one_tab()
else:
self.guake.notebook_manager.set_notebooks_tabbar_visible(True)
else:
self.guake.notebook_manager.set_notebooks_tabbar_visible(False)

Expand All @@ -130,7 +134,10 @@ def fullscreen_hide_tabbar_toggled(self, settings, key, user_data):
if settings.get_boolean(key):
self.guake.notebook_manager.set_notebooks_tabbar_visible(False)
else:
self.guake.notebook_manager.set_notebooks_tabbar_visible(True)
if settings.get_boolean(key):
self.guake.get_notebook().hide_if_one_tab()
else:
self.guake.notebook_manager.set_notebooks_tabbar_visible(True)

def alignment_changed(self, settings, key, user_data):
"""If the gconf var window_halignment be changed, this method will
Expand Down Expand Up @@ -423,3 +430,9 @@ def display_tab_names_changed(self, settings, key, user_data):
"""
self.guake.display_tab_names = settings.get_int("display-tab-names")
self.guake.recompute_tabs_titles()

def hide_tabs_if_one_tab_changed(self, settings, key, user_data):
"""If the gconf var hide-tabs-if-one-tab was changed, this method will
be called and will show/hide the tab bar if necessary
"""
self.guake.get_notebook().hide_if_one_tab()
10 changes: 10 additions & 0 deletions guake/notebook.py
Expand Up @@ -323,6 +323,8 @@ def remove_page(self, page_num):
page = self.get_nth_page(self.get_current_page())
if page.get_terminals():
page.get_terminals()[0].grab_focus()

self.hide_if_one_tab()
self.emit("page-deleted")

def delete_page_by_label(self, label, kill=True, prompt=0):
Expand Down Expand Up @@ -350,12 +352,20 @@ def new_page(self, directory=None, position=None):
# this is needed to initially set the last_terminal_focused,
# one could also call terminal.get_parent().on_terminal_focus()
self.terminal_attached(terminal)
self.hide_if_one_tab()

if self.guake:
# Attack background image draw callback to root terminal box
root_terminal_box.connect_after("draw", self.guake.background_image_manager.draw)
return root_terminal_box, page_num, terminal

def hide_if_one_tab(self):
if self.guake.settings.general.get_boolean("window-tabbar"):
if self.guake.settings.general.get_boolean("hide-tabs-if-one-tab"):
self.set_property("show-tabs", self.get_n_pages() != 1)
else:
self.set_property("show-tabs", True)

def terminal_spawn(self, directory=None):
terminal = GuakeTerminal(self.guake)
terminal.grab_focus()
Expand Down
19 changes: 19 additions & 0 deletions guake/prefs.py
Expand Up @@ -349,6 +349,11 @@ def on_fullscreen_hide_tabbar_toggled(self, chk):
"""Changes the activity of fullscreen_hide_tabbar in dconf"""
self.settings.general.set_boolean("fullscreen-hide-tabbar", chk.get_active())

def on_hide_tabs_if_one_tab_toggled(self, chk):
"""Changes the activity of hide_tabs_if_one_tab in dconf
"""
self.settings.general.set_boolean("hide-tabs-if-one-tab", chk.get_active())

def on_start_fullscreen_toggled(self, chk):
"""Changes the activity of start_fullscreen in dconf"""
self.settings.general.set_boolean("start-fullscreen", chk.get_active())
Expand Down Expand Up @@ -538,6 +543,9 @@ def toggle_use_font_background_sensitivity(self, chk):
def toggle_display_n_sensitivity(self, chk):
self.prefDlg.toggle_display_n_sensitivity(chk)

def toggle_show_tabbar_sensitivity(self, chk):
self.prefDlg.toggle_show_tabbar_sensitivity(chk)

def toggle_quick_open_command_line_sensitivity(self, chk):
self.prefDlg.toggle_quick_open_command_line_sensitivity(chk)

Expand Down Expand Up @@ -762,6 +770,13 @@ def toggle_use_font_background_sensitivity(self, chk):
self.get_widget("palette_16").set_sensitive(chk.get_active())
self.get_widget("palette_17").set_sensitive(chk.get_active())

def toggle_show_tabbar_sensitivity(self, chk):
"""If the user chooses to not show the tab bar, it means that they
cannot see the tab bar regardless of what other tab bar options say.
"""
self.get_widget("fullscreen_hide_tabbar").set_sensitive(chk.get_active())
self.get_widget("hide_tabs_if_one_tab").set_sensitive(chk.get_active())

def toggle_display_n_sensitivity(self, chk):
"""When the user unchecks 'on mouse display', the option to select an
alternate display should be enabled.
Expand Down Expand Up @@ -1080,6 +1095,10 @@ def load_configs(self):
value = self.settings.general.get_boolean("fullscreen-hide-tabbar")
self.get_widget("fullscreen_hide_tabbar").set_active(value)

# hide tabbar if only one tab
value = self.settings.general.get_boolean("hide-tabs-if-one-tab")
self.get_widget("hide_tabs_if_one_tab").set_active(value)

# start fullscreen
value = self.settings.general.get_boolean("start-fullscreen")
self.get_widget("start_fullscreen").set_active(value)
Expand Down
40 changes: 40 additions & 0 deletions releasenotes/notes/auto_hide_tabbar-0a20cd95984dfd91.yaml
@@ -0,0 +1,40 @@
release_summary: >
Automatically hide the tab bar when there is only one tab
features:
- |
- Automatically hide the tab bar when there is only one tab #924
known_issues:
- |
- None
upgrade:
- |
If setting is undesired, uncheck the hide tab if one tab option in settings
deprecations:
- |
None
security:
- |
None
fixes:
- |
fixes #924
translations:
- Only put a list of updated 2 letters language code, for example::

translations:
- en

notes_for_package_maintainers:
- |
None
other:
- |
None

0 comments on commit 7fe07d4

Please sign in to comment.