Make the titlebar presence configurable by config file and context menu. If it's missing, draw a frame around the Terminal, to indicae colour

This commit is contained in:
Chris Jones 2010-02-09 00:23:21 +00:00
parent eb7fcf5189
commit 79a340539b
6 changed files with 59 additions and 4 deletions

View File

@ -166,6 +166,7 @@ DEFAULTS = {
'emulation' : 'xterm',
'font' : 'Mono 10',
'foreground_color' : '#aaaaaaaaaaaa',
'show_titlebar' : True,
'scrollbar_position' : "right",
'scroll_background' : True,
'scroll_on_keystroke' : True,

View File

@ -864,6 +864,20 @@
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="show_titlebar">
<property name="label" translatable="yes">Show titlebar</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">6</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox136">
<property name="visible">True</property>
@ -896,7 +910,7 @@
</object>
<packing>
<property name="expand">False</property>
<property name="position">6</property>
<property name="position">7</property>
</packing>
</child>
<child>
@ -1024,7 +1038,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">7</property>
<property name="position">8</property>
</packing>
</child>
</object>

View File

@ -318,6 +318,9 @@ class PrefsEditor:
# WM_URGENT terminal bell
widget = guiget('urgent-bell-checkbutton')
widget.set_active(self.config['urgent_bell'])
# Show titlebar
widget = guiget('show_titlebar')
widget.set_active(self.config['show_titlebar'])
# Word chars
widget = guiget('word-chars-entry')
widget.set_text(self.config['word_chars'])
@ -486,6 +489,9 @@ class PrefsEditor:
# Urgent Bell
widget = guiget('urgent-bell-checkbutton')
self.config['urgent_bell'] = widget.get_active()
# Show titlebar
widget = guiget('show_titlebar')
self.config['show_titlebar'] = widget.get_active()
# Word chars
widget = guiget('word-chars-entry')
self.config['word_chars'] = widget.get_text()

View File

@ -74,6 +74,7 @@ class Terminal(gtk.VBox):
scrollbar_position = None
titlebar = None
searchbar = None
border_boxes = None
group = None
cwd = None
@ -178,6 +179,9 @@ class Terminal(gtk.VBox):
def create_terminalbox(self):
"""Create a GtkHBox containing the terminal and a scrollbar"""
ebox1 = gtk.EventBox()
ebox2 = gtk.EventBox()
ebox1.add(ebox2)
terminalbox = gtk.HBox()
self.scrollbar = gtk.VScrollbar(self.vte.get_adjustment())
self.scrollbar.set_no_show_all(True)
@ -193,9 +197,19 @@ class Terminal(gtk.VBox):
func(self.vte)
func(self.scrollbar, False)
terminalbox.show()
ebox2.add(terminalbox)
ebox1.show_all()
return(terminalbox)
self.border_boxes = (ebox1, ebox2)
return(ebox1)
def terminal_border(self, width, colour=None):
"""Show a border around the terminal and optionally colour it in"""
ebox1, ebox2 = self.border_boxes
ebox2.set_border_width(width)
if colour:
ebox1.modify_bg(gtk.STATE_NORMAL, colour)
def update_url_matches(self, posix = True):
"""Update the regexps used to match URLs"""
@ -728,6 +742,10 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
"""Show or hide the terminal scrollbar"""
self.toggle_widget_visibility(self.scrollbar)
def do_titlebar_toggle(self):
"""Show or hide the terminal titlebar"""
self.toggle_widget_visibility(self.titlebar)
def toggle_widget_visibility(self, widget):
"""Show or hide a widget"""
if widget.get_property('visible'):

View File

@ -128,6 +128,11 @@ class TerminalPopupMenu(object):
item.connect('toggled', lambda x: terminal.do_scrollbar_toggle())
menu.append(item)
item = gtk.CheckMenuItem(_('Show _titlebar'))
item.set_active(terminal.titlebar.get_property('visible'))
item.connect('toggled', lambda x: terminal.do_titlebar_toggle())
menu.append(item)
item = gtk.MenuItem(_('_Preferences'))
item.connect('activate', lambda x: PrefsEditor(self.terminal))
menu.append(item)

View File

@ -90,6 +90,7 @@ class Titlebar(gtk.EventBox):
def update(self, other=None):
"""Update our contents"""
default_bg = False
self.label.set_text("%s %s" % (self.termtext, self.sizetext))
if other:
@ -100,6 +101,7 @@ class Titlebar(gtk.EventBox):
title_fg = self.config['title_inactive_fg_color']
title_bg = self.config['title_inactive_bg_color']
icon = '_receive_off'
default_bg = True
else:
title_fg = self.config['title_receive_fg_color']
title_bg = self.config['title_receive_bg_color']
@ -115,6 +117,7 @@ class Titlebar(gtk.EventBox):
title_fg = self.config['title_inactive_fg_color']
title_bg = self.config['title_inactive_bg_color']
icon = '_receive_off'
default_bg = True
group_fg = self.config['title_inactive_fg_color']
group_bg = self.config['title_inactive_bg_color']
else:
@ -135,6 +138,14 @@ class Titlebar(gtk.EventBox):
gtk.gdk.color_parse(group_fg))
self.modify_bg(gtk.STATE_NORMAL,
gtk.gdk.color_parse(title_bg))
if not self.get_property('visible'):
if default_bg == True:
color = term.get_style().bg[gtk.STATE_NORMAL]
else:
color = gtk.gdk.color_parse(title_bg)
term.terminal_border(2, color)
else:
term.terminal_border(0)
self.ebox.modify_bg(gtk.STATE_NORMAL,
gtk.gdk.color_parse(group_bg))
self.set_from_icon_name(icon, gtk.ICON_SIZE_MENU)