Commit ada96215 authored by Fabián Orccón's avatar Fabián Orccón Committed by Alexandru Băluț

plugins: Close the developer console on ESC and Ctrl+D

parent f6cdd1ad
......@@ -75,6 +75,7 @@ class Console(GObject.GObject, Peas.Activatable):
namespace = {"app":}
self.window = Gtk.Window()
self.terminal = ConsoleWidget(namespace)
self.terminal.connect("eof", self.__eof_cb)
self.window.set_default_size(600, 400)
self.window.set_title(_("Pitivi Console"))
......@@ -85,5 +86,9 @@ class Console(GObject.GObject, Peas.Activatable):
def __eof_cb(self, unused_widget):
return True
def __delete_event_cb(self, unused_widget, unused_data):
return self.window.hide_on_delete()
......@@ -19,6 +19,7 @@
"""The developer console widget:"""
from gi.repository import Gdk
from gi.repository import GLib
from gi.repository import GObject
from gi.repository import Gtk
from consolebuffer import ConsoleBuffer
......@@ -33,6 +34,10 @@ class ConsoleWidget(Gtk.ScrolledWindow):
it is integrated with.
__gsignals__ = {
"eof": (GObject.SignalFlags.RUN_LAST, None, ()),
def __init__(self, namespace):
self._view = Gtk.TextView()
......@@ -52,21 +57,30 @@ class ConsoleWidget(Gtk.ScrolledWindow):
xalign=0, yalign=0)
return False
def __key_press_event_cb(cls, view, event):
def __key_press_event_cb(self, view, event):
buf = view.get_buffer()
state = event.state & Gtk.accelerator_get_default_mod_mask()
ctrl = state & Gdk.ModifierType.CONTROL_MASK
if event.keyval == Gdk.KEY_Return:
return True
if event.keyval in (Gdk.KEY_KP_Down, Gdk.KEY_Down):
return True
if event.keyval in (Gdk.KEY_KP_Up, Gdk.KEY_Up):
return True
if event.keyval in (Gdk.KEY_KP_Left, Gdk.KEY_Left, Gdk.KEY_BackSpace):
return buf.is_cursor(at=True)
if event.keyval in (Gdk.KEY_KP_Home, Gdk.KEY_Home):
return True
if (ctrl and event.keyval == Gdk.KEY_d) or event.keyval == Gdk.KEY_Escape:
return self.emit("eof")
return False
def __mark_set_cb(self, buf, unused_iter, mark):
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment