diff --git a/guake/callbacks.py b/guake/callbacks.py index ab4201e7..8f416d4a 100644 --- a/guake/callbacks.py +++ b/guake/callbacks.py @@ -1,14 +1,14 @@ import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk -from guake.utils import FullscreenManager -from guake.utils import TabNameUtils +from guake.about import AboutDialog from guake.dialogs import RenameDialog from guake.dialogs import SaveTerminalDialog -from guake.about import AboutDialog from guake.prefs import PrefsDialog -from urllib.parse import quote_plus +from guake.utils import FullscreenManager +from guake.utils import TabNameUtils from guake.utils import get_server_time +from urllib.parse import quote_plus class TerminalContextMenuCallbacks(): @@ -45,9 +45,7 @@ class TerminalContextMenuCallbacks(): pass def on_new_tab(self, *args): - self.notebook.new_page_with_focus( - directory=self.terminal.get_current_directory() - ) + self.notebook.new_page_with_focus(directory=self.terminal.get_current_directory()) def on_rename_tab(self, *args): page_num = self.notebook.find_page_index_by_terminal(self.terminal) diff --git a/guake/customcommands.py b/guake/customcommands.py index 595881ed..04b25fe2 100644 --- a/guake/customcommands.py +++ b/guake/customcommands.py @@ -1,12 +1,15 @@ -import os import json +import os + +import gi from locale import gettext as _ -import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk + class CustomCommands(): + """ Example for a custom commands file [ diff --git a/guake/dialogs.py b/guake/dialogs.py index f340b5d5..5699b0c8 100644 --- a/guake/dialogs.py +++ b/guake/dialogs.py @@ -8,8 +8,7 @@ class RenameDialog(Gtk.Dialog): def __init__(self, window, current_name): super().__init__( - _("Rename tab"), window, - Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, + _("Rename tab"), window, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT) ) self.entry = Gtk.Entry() @@ -31,6 +30,7 @@ class RenameDialog(Gtk.Dialog): def get_text(self): return self.entry.get_text() + class PromptQuitDialog(Gtk.MessageDialog): """Prompts the user whether to quit/close a tab. @@ -81,19 +81,13 @@ class PromptQuitDialog(Gtk.MessageDialog): # self.window.present() return response + class SaveTerminalDialog(Gtk.FileChooserDialog): def __init__(self, terminal, window): super().__init__( - _("Save to..."), - window, - Gtk.FileChooserAction.SAVE, - ( - Gtk.STOCK_CANCEL, - Gtk.ResponseType.CANCEL, - Gtk.STOCK_SAVE, - Gtk.ResponseType.OK - ) + _("Save to..."), window, Gtk.FileChooserAction.SAVE, + (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_SAVE, Gtk.ResponseType.OK) ) self.set_default_response(Gtk.ResponseType.OK) self.terminal = terminal diff --git a/guake/menus.py b/guake/menus.py index a3e1962c..9ab50901 100644 --- a/guake/menus.py +++ b/guake/menus.py @@ -30,6 +30,7 @@ def TabContextMenu(callback_object): SEARCH_SELECTION_LENGTH = 20 FILE_SELECTION_LENGTH = 30 + def TerminalContextMenu(terminal, window, settings, callback_object): """Create the context menu for a terminal """ @@ -81,7 +82,7 @@ def TerminalContextMenu(terminal, window, settings, callback_object): # implementation does not support this at the moment if link: if len(link) >= FILE_SELECTION_LENGTH: - mi.set_label(_("Open Link: {!s}...").format(link[:FILE_SELECTION_LENGTH-3])) + mi.set_label(_("Open Link: {!s}...").format(link[:FILE_SELECTION_LENGTH - 3])) else: mi.set_label(_("Open Link: {!s}").format(link)) mi.set_sensitive(True) @@ -94,7 +95,7 @@ def TerminalContextMenu(terminal, window, settings, callback_object): if selection: search_text = selection.rstrip() if len(search_text) > SEARCH_SELECTION_LENGTH: - search_text = search_text[:SEARCH_SELECTION_LENGTH-3] + "..." + search_text = search_text[:SEARCH_SELECTION_LENGTH - 3] + "..." mi.set_label(_("Search on Web: '%s'") % search_text) mi.set_sensitive(True) else: @@ -108,9 +109,7 @@ def TerminalContextMenu(terminal, window, settings, callback_object): filename_str = str(filename) if len(filename_str) > FILE_SELECTION_LENGTH: mi.set_label( - _("Quick Open: {!s}...").format( - filename_str[:FILE_SELECTION_LENGTH-3] - ) + _("Quick Open: {!s}...").format(filename_str[:FILE_SELECTION_LENGTH - 3]) ) else: mi.set_label(_("Quick Open: {!s}").format(filename_str)) diff --git a/guake/terminal.py b/guake/terminal.py index c4598f29..7cc473c3 100644 --- a/guake/terminal.py +++ b/guake/terminal.py @@ -138,10 +138,7 @@ class GuakeTerminal(Vte.Terminal): super(GuakeTerminal, self).copy_clipboard() elif self.matched_value: guake_clipboard = Gtk.Clipboard.get_default(self.guake.window.get_display()) - guake_clipboard.set_text( - self.matched_value, - len(self.matched_value) - ) + guake_clipboard.set_text(self.matched_value, len(self.matched_value)) def configure_terminal(self): """Sets all customized properties on the terminal diff --git a/guake/theme.py b/guake/theme.py index 1479c156..c77cf7e2 100644 --- a/guake/theme.py +++ b/guake/theme.py @@ -7,11 +7,10 @@ from pathlib import Path import gi gi.require_version('Gtk', '3.0') from gi.repository import GLib -from gi.repository import Gtk from gi.repository import Gdk +from gi.repository import Gtk from textwrap import dedent - from guake.paths import GUAKE_THEME_DIR log = logging.getLogger(__name__) @@ -62,6 +61,7 @@ def get_gtk_theme(settings): prefer_dark_theme = settings.general.get_boolean('gtk-prefer-dark-theme') return (gtk_theme_name, "dark" if prefer_dark_theme else None) + def patch_gtk_theme(style_context, settings): theme_name, variant = get_gtk_theme(settings) diff --git a/guake/utils.py b/guake/utils.py index b73d6655..e900c69f 100644 --- a/guake/utils.py +++ b/guake/utils.py @@ -36,7 +36,9 @@ def get_server_time(widget): ts = time.time() return ts + class TabNameUtils(): + @classmethod def shorten(cls, text, settings): use_vte_titles = settings.general.get_boolean('use-vte-titles') @@ -47,6 +49,7 @@ class TabNameUtils(): text = "..." + text[-max_name_length:] return text + class FullscreenManager(): def __init__(self, window):