Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/terminal.py
diff options
context:
space:
mode:
authorRafael Ortiz <rafael@activitycentral.com>2011-06-04 16:17:48 (GMT)
committer Rafael Ortiz <rafael@activitycentral.com>2011-06-04 16:17:48 (GMT)
commitb18fa2cff8c1818f89981223193d321314d94486 (patch)
treea049d5b814040dc6121c4870f4dab3e2157feeb4 /terminal.py
parent6be2d921aae00abe7870d6f05f5f239ba630a165 (diff)
adds a zoom out and zoom in button, with accelerators, which change
text font size of the terminal area. Same accelerators as used by GNOME Terminal. From:"manuel quiƱones" <manuel.por.aca@gmail.com>
Diffstat (limited to 'terminal.py')
-rw-r--r--terminal.py32
1 files changed, 31 insertions, 1 deletions
diff --git a/terminal.py b/terminal.py
index f54da21..6316eea 100644
--- a/terminal.py
+++ b/terminal.py
@@ -45,6 +45,8 @@ log = logging.getLogger('Terminal')
log.setLevel(logging.DEBUG)
logging.basicConfig()
+ZOOM_STEP = 2000
+
class TerminalActivity(activity.Activity):
@@ -139,6 +141,21 @@ class TerminalActivity(activity.Activity):
def _create_view_toolbar(self):
view_toolbar = gtk.Toolbar()
+
+ zoom_out_button = ToolButton('zoom-out')
+ zoom_out_button.set_tooltip(_('Zoom out'))
+ zoom_out_button.props.accelerator = '<Ctrl>-'
+ zoom_out_button.connect('clicked', self.__zoom_out_cb)
+ view_toolbar.insert(zoom_out_button, -1)
+ zoom_out_button.show()
+
+ zoom_in_button = ToolButton('zoom-in')
+ zoom_in_button.set_tooltip(_('Zoom in'))
+ zoom_in_button.props.accelerator = '<Ctrl>+'
+ zoom_in_button.connect('clicked', self.__zoom_in_cb)
+ view_toolbar.insert(zoom_in_button, -1)
+ zoom_in_button.show()
+
fullscreen_button = ToolButton('view-fullscreen')
fullscreen_button.set_tooltip(_("Fullscreen"))
fullscreen_button.props.accelerator = '<Alt>Return'
@@ -147,6 +164,19 @@ class TerminalActivity(activity.Activity):
fullscreen_button.show()
return view_toolbar
+ def _zoom(self, step):
+ current_page = self._notebook.get_current_page()
+ vt = self._notebook.get_nth_page(current_page).vt
+ font_desc = vt.get_font()
+ font_desc.set_size(font_desc.get_size() + step)
+ vt.set_font(font_desc)
+
+ def __zoom_out_cb(self, button):
+ self._zoom(ZOOM_STEP * -1)
+
+ def __zoom_in_cb(self, button):
+ self._zoom(ZOOM_STEP)
+
def __fullscreen_cb(self, button):
self.fullscreen()
@@ -321,6 +351,7 @@ class TerminalActivity(activity.Activity):
vt = self._notebook.get_nth_page(self._notebook.get_current_page()).vt
vt.feed('\r\n')
vt.fork_command("/bin/su", ('/bin/su', '-'))
+ vt.fork_command("/bin/sudo", ('/bin/sudo', '-i'))
def __key_press_cb(self, window, event):
# Escape keypresses are routed directly to the vte and then dropped.
@@ -425,7 +456,6 @@ class TerminalActivity(activity.Activity):
font = self._get_conf(conf, 'font', 'Monospace')
vt.set_font(pango.FontDescription(font))
-
fg_color = self._get_conf(conf, 'fg_color', '#000000')
bg_color = self._get_conf(conf, 'bg_color', '#FFFFFF')
vt.set_colors(gtk.gdk.color_parse(fg_color),