Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pin button to temporarily prevent hiding when losing focus #2138

Merged
merged 1 commit into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion guake/guake_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,6 @@ def hide_window_callback():
if visible and value:
log.info("Hiding on focus lose")
self.hide()
return False

def losefocus_callback(sleep_time):
sleep(sleep_time)
Expand Down
22 changes: 21 additions & 1 deletion guake/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from guake.globals import PROMPT_PROCESSES
from guake.menus import mk_notebook_context_menu
from guake.prefs import PrefsDialog
from guake.utils import HidePrevention
from guake.utils import gdk_is_x11_display
from guake.utils import get_process_name
from guake.utils import save_tabs_when_changed
Expand Down Expand Up @@ -91,6 +92,11 @@ def __init__(self, *args, **kwargs):
)

# Action box
self.pin_button = Gtk.ToggleButton(
image=Gtk.Image.new_from_icon_name("view-pin-symbolic", Gtk.IconSize.MENU),
visible=False,
)
self.pin_button.connect("clicked", self.on_pin_clicked)
self.new_page_button = Gtk.Button(
image=Gtk.Image.new_from_icon_name("tab-new-symbolic", Gtk.IconSize.MENU),
visible=True,
Expand All @@ -106,13 +112,17 @@ def __init__(self, *args, **kwargs):
self.tab_selection_button.connect("clicked", self.on_tab_selection)

self.action_box = Gtk.Box(visible=True)
self.action_box.pack_start(self.pin_button, 0, 0, 0)
self.action_box.pack_start(self.new_page_button, 0, 0, 0)
self.action_box.pack_end(self.tab_selection_button, 0, 0, 0)
self.action_box.pack_start(self.tab_selection_button, 0, 0, 0)
self.set_action_widget(self.action_box, Gtk.PackType.END)

def attach_guake(self, guake):
self.guake = guake

self.guake.settings.general.onChangedValue("window-losefocus", self.on_lose_focus_toggled)
self.pin_button.set_visible(self.guake.settings.general.get_boolean("window-losefocus"))

def on_button_press(self, target, event, user_data):
if event.button == 3:
menu = mk_notebook_context_menu(self)
Expand All @@ -133,6 +143,16 @@ def on_button_press(self, target, event, user_data):

return False

def on_pin_clicked(self, user_data=None):
hide_prevention = HidePrevention(self.guake.window)
if self.pin_button.get_active():
hide_prevention.prevent()
else:
hide_prevention.allow()

def on_lose_focus_toggled(self, settings, key, user_data=None):
self.pin_button.set_visible(settings.get_boolean(key))

@save_tabs_when_changed
def on_new_tab(self, user_data):
self.new_page_with_focus()
Expand Down
3 changes: 3 additions & 0 deletions releasenotes/notes/pin-button-8b85a8fd0392c3d0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
features:
- |
- Add a pin button to temporarily prevent hiding when losing focus, closes #2089.