Skip to content

Commit

Permalink
Add optional close buttons for tabs
Browse files Browse the repository at this point in the history
sem-ver: feature

Signed-off-by: Aleksandr Mezin <mezin.alexander@gmail.com>
  • Loading branch information
amezin authored and gsemet committed Jan 11, 2019
1 parent 805de1e commit e0dba67
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 5 deletions.
5 changes: 5 additions & 0 deletions data/org.guake.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@
<summary>Prefer Dark Theme for GTK</summary>
<description>Prefer the dark theme version of the theme if available</description>
</key>
<key name="tab-close-buttons" type="b">
<default>false</default>
<summary>Show close buttons for tabs</summary>
<description>Show close buttons next to tab titles</description>
</key>
</schema>
<schema id="guake.style" path="/apps/guake/style/">
<key name="cursor-blink-mode" type="i">
Expand Down
15 changes: 15 additions & 0 deletions data/prefs.glade
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,21 @@
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="tab-close-buttons">
<property name="label" translatable="yes">Show close buttons for tabs</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<placeholder/>
</child>
Expand Down
19 changes: 15 additions & 4 deletions guake/boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
gi.require_version('Vte', '2.91') # vte-0.42
gi.require_version('Gtk', '3.0')
from gi.repository import Gdk
from gi.repository import Gio
from gi.repository import Gtk
from gi.repository import Vte

Expand Down Expand Up @@ -328,13 +329,23 @@ def remove_dead_child(self, child):

class TabLabelEventBox(Gtk.EventBox):

def __init__(self, notebook, text):
def __init__(self, notebook, text, settings):
super().__init__()
self.notebook = notebook
self.label = Gtk.Label(text)
self.add(self.label)
self.box = Gtk.Box(Gtk.Orientation.HORIZONTAL, 0, visible=True)
self.label = Gtk.Label(text, visible=True)
self.close_button = Gtk.Button(
image=Gtk.Image.new_from_icon_name("window-close", Gtk.IconSize.MENU),
relief=Gtk.ReliefStyle.NONE
)
self.close_button.connect('clicked', self.on_close)
settings.general.bind(
'tab-close-buttons', self.close_button, 'visible', Gio.SettingsBindFlags.GET
)
self.box.pack_start(self.label, True, True, 0)
self.box.pack_end(self.close_button, False, False, 0)
self.add(self.box)
self.connect("button-press-event", self.on_button_press, self.label)
self.label.show()

def set_text(self, text):
self.label.set_text(text)
Expand Down
2 changes: 1 addition & 1 deletion guake/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def rename_page(self, page_index, new_text, user_set=False):
if isinstance(old_label, TabLabelEventBox):
old_label.set_text(new_text)
else:
label = TabLabelEventBox(self, new_text)
label = TabLabelEventBox(self, new_text, self.guake.settings)
label.add_events(Gdk.EventMask.SCROLL_MASK)
label.connect('scroll-event', self.scroll_callback.on_scroll)

Expand Down
6 changes: 6 additions & 0 deletions guake/prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from gi.repository import GLib
from gi.repository import GObject
from gi.repository import Gdk
from gi.repository import Gio
from gi.repository import Gtk
from gi.repository import Keybinder
from gi.repository import Pango
Expand Down Expand Up @@ -772,6 +773,11 @@ class fake_guake():

self.demo_terminal.pid = pid

self.settings.general.bind(
'tab-close-buttons', self.get_widget('tab-close-buttons'), 'active',
Gio.SettingsBindFlags.DEFAULT
)

self.populate_shell_combo()
self.populate_keys_tree()
self.populate_display_n()
Expand Down
2 changes: 2 additions & 0 deletions releasenotes/notes/tab-close-buttons-1dfe8cb1049ee4dc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
features:
- Optional close buttons for tabs (disabled by default)

0 comments on commit e0dba67

Please sign in to comment.