def __init__(self): Vte.Terminal.__init__(self) self.set_size(self.get_column_count(), 7) self.set_size_request(200, 130) tl = Gtk.TargetList.new([]) tl.add_uri_targets(self.TARGET_URI_LIST) self.drag_dest_set(Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, [], Gdk.DragAction.DEFAULT | Gdk.DragAction.COPY) self.drag_dest_set_target_list(tl) self.profile_settings = self.get_profile_settings() self.profile_settings.connect("changed", self.on_profile_settings_changed) self.system_settings = Gio.Settings.new("org.gnome.desktop.interface") self.system_settings.connect("changed::monospace-font-name", self.font_changed) self.reconfigure_vte() result, pid = self.spawn_sync(Vte.PtyFlags.DEFAULT, None, [Vte.get_user_shell()], None, GLib.SpawnFlags.SEARCH_PATH, None, None, None) self.child_pid = pid self.match_add_regex(self.HIGHLIGHT_VREGEX, 0) self.connect("button-press-event", self.on_button_press) self.connect('text-scrolled', self.on_text_scroll)
def __init__(self): Vte.Terminal.__init__(self) self.set_background_image(None) self.set_background_transparent(False) self.set_size(self.get_column_count(), 5) self.set_size_request(200, 50) tl = Gtk.TargetList.new([]) tl.add_uri_targets(self.TARGET_URI_LIST) self.drag_dest_set(Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, [], Gdk.DragAction.DEFAULT | Gdk.DragAction.COPY) self.drag_dest_set_target_list(tl) self.profile_settings = self.get_profile_settings() self.profile_settings.connect("changed", self.on_profile_settings_changed) self.system_settings = Gio.Settings.new("org.gnome.desktop.interface") self.system_settings.connect("changed::monospace-font-name", self.font_changed) self.reconfigure_vte() self.fork_command_full(Vte.PtyFlags.DEFAULT, None, [Vte.get_user_shell()], None, GLib.SpawnFlags.SEARCH_PATH, None, None)
def __init__(self): Gtk.Box.__init__(self) self.profile_settings = self.get_profile_settings() self.profile_settings.connect("changed", self.on_profile_settings_changed) self.system_settings = Gio.Settings.new("org.gnome.desktop.interface") self.system_settings.connect("changed::monospace-font-name", self.font_changed) self._vte = Vte.Terminal() self.reconfigure_vte() self._vte.set_size(self._vte.get_column_count(), 5) self._vte.set_size_request(200, 50) self._vte.show() self.pack_start(self._vte, True, True, 0) scrollbar = Gtk.Scrollbar.new(Gtk.Orientation.VERTICAL, self._vte.get_vadjustment()) scrollbar.show() self.pack_start(scrollbar, False, False, 0) # we need to reconf colors if the style changes #FIXME: why? #self._vte.connect("style-update", lambda term, oldstyle: self.reconfigure_vte()) self._vte.connect("key-press-event", self.on_vte_key_press) self._vte.connect("button-press-event", self.on_vte_button_press) self._vte.connect("popup-menu", self.on_vte_popup_menu) self._vte.connect("child-exited", self.on_child_exited) #: FIXME: TypeError: on_child_exited() takes exactly 1 argument (2 given) #: self._vte.connect("child-exited", lambda (self2, term2): self2.on_child_exited() ) #: print "Connecting child-exited to _vte, with :" #: print "lambda self2,term2: self2.on_child_exited()" self._accel_base = '<gedit>/plugins/terminal' self._accels = { 'copy-clipboard': [ Gdk.KEY_C, Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.SHIFT_MASK, self.copy_clipboard ], 'paste-clipboard': [ Gdk.KEY_V, Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.SHIFT_MASK, self.paste_clipboard ] } for name in self._accels: path = self._accel_base + '/' + name accel = Gtk.AccelMap.lookup_entry(path) if not accel[0]: Gtk.AccelMap.add_entry(path, self._accels[name][0], self._accels[name][1]) self._vte.fork_command_full(Vte.PtyFlags.DEFAULT, None, [Vte.get_user_shell()], None, GLib.SpawnFlags.SEARCH_PATH, None, None)
def create_term(shell=Vte.get_user_shell(), emulation="xterm", pwd=os.environ['HOME']): term = Vte.Terminal() pid = term.fork_command_full(Vte.PtyFlags.DEFAULT, pwd, [shell], [], GLib.SpawnFlags.DO_NOT_REAP_CHILD, None, None, ) term.set_emulation(emulation) term.watch_child(pid[1]) return term,pid
def on_child_exited(self, term): #: print "on_child_exited have been called (shell is terminated)" print ".:[ Re-launching a shell, on %s, v%s. (c) %s ]:." % ( __app_disp_name__, __version__, __author__) print ".:[ Take a look at %s for more informations, or for the latest version of this piece of software. ]:." % ( __website__) print self._vte.fork_command_full(Vte.PtyFlags.DEFAULT, None, [Vte.get_user_shell()], None, GLib.SpawnFlags.SEARCH_PATH, None, None)
def __init__(self): Vte.Terminal.__init__(self) self.set_size(self.get_column_count(), 5) self.set_size_request(200, 50) tl = Gtk.TargetList.new([]) tl.add_uri_targets(self.TARGET_URI_LIST) self.drag_dest_set(Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, [], Gdk.DragAction.DEFAULT | Gdk.DragAction.COPY) self.drag_dest_set_target_list(tl) self.profile_settings = self.get_profile_settings() self.profile_settings.connect("changed", self.on_profile_settings_changed) self.system_settings = Gio.Settings.new("org.gnome.desktop.interface") self.system_settings.connect("changed::monospace-font-name", self.font_changed) self.reconfigure_vte() self.fork_command_full(Vte.PtyFlags.DEFAULT, None, [Vte.get_user_shell()], None, GLib.SpawnFlags.SEARCH_PATH, None, None)
def get_terminal_cmd(): """Enforce a default value for terminal from GSettings.""" terminal_cmd = settings.get_string("terminal-shell") if not terminal_cmd: terminal_cmd = Vte.get_user_shell() return terminal_cmd
def terminal_or_default(): """Enforce a default value for terminal from GSettings""" terminalcmd = settings.get_string("terminal-shell") if (terminalcmd == "") or (terminalcmd is None): terminalcmd = Vte.get_user_shell() return terminalcmd
#Specific imports for Python 2 and 3 if sys.version_info < (3, 0): from urllib import url2pathname from ConfigParser import RawConfigParser else: from urllib.request import url2pathname from configparser import RawConfigParser from gi.repository import GObject, Nautilus, Gtk, Gdk, Vte, GLib DEFAULT_CONF = { 'general/def_term_height': 5, #lines 'general/def_visible': True, 'general/term_on_top': True, 'terminal/shell': Vte.get_user_shell(), } class Config(object): """Handles the configuration of Nautilus Terminal.""" def __init__(self): """The constructor.""" self._default = DEFAULT_CONF self._confp = RawConfigParser() self.read() def read(self): """Read the configuration from a file.""" #Determine where is stored the configuration
def on_child_exited(self): self._vte.fork_command_full(Vte.PtyFlags.DEFAULT, None, [Vte.get_user_shell()], None, GLib.SpawnFlags.SEARCH_PATH, None, None)
from signal import SIGTERM, SIGKILL #Specific imports for Python 2 and 3 if sys.version_info < (3, 0): from urllib import url2pathname from ConfigParser import RawConfigParser else: from urllib.request import url2pathname from configparser import RawConfigParser from gi.repository import GObject, Nautilus, Gtk, Gdk, Vte, GLib DEFAULT_CONF = { 'general/def_term_height': 5, #lines 'general/def_visible': True, 'general/term_on_top': True, 'terminal/shell': Vte.get_user_shell(), } class Config(object): """Handles the configuration of Nautilus Terminal.""" def __init__(self): """The constructor.""" self._default = DEFAULT_CONF self._confp = RawConfigParser() self.read() def read(self): """Read the configuration from a file.""" #Determine where is stored the configuration config_file = os.path.join(os.environ.get("HOME"), ".%s" % __appname__)
def do_child_exited(self): Vte.Terminal.do_child_exited(self) self._vte.fork_command_full(Vte.PtyFlags.DEFAULT, None, [Vte.get_user_shell()], None, GLib.SpawnFlags.SEARCH_PATH, None, None)