mirror of
https://github.com/Guake/guake.git
synced 2025-10-26 11:27:13 +00:00
reorder imports
This commit is contained in:
parent
6bc9e53a91
commit
a5893dbd4e
@ -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)
|
||||
|
||||
@ -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
|
||||
[
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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))
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
@ -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):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user