Appease the folks who demand totally hidden titlebars, by making the titlebars able to totally hide. This does not yet fully address the issue of showing group membership and/or event transmission/reception state while grouped without losing a line of terminal to forced titlebar display. That can come later if it is reasonably possible

This commit is contained in:
Chris Jones 2010-05-15 15:30:13 +02:00
parent 4184acef3c
commit 622604d9b5
2 changed files with 31 additions and 9 deletions

View File

@ -19,11 +19,13 @@ class TerminalPopupMenu(object):
"""Class implementing the Terminal context menu"""
terminal = None
terminator = None
config = None
def __init__(self, terminal):
"""Class initialiser"""
self.terminal = terminal
self.terminator = Terminator()
self.config = Config()
def show(self, widget, event=None):
"""Display the context menu"""
@ -34,6 +36,8 @@ class TerminalPopupMenu(object):
button = None
time = None
self.config.set_profile(terminal.get_profile())
if event:
url = terminal.check_for_url(event)
button = event.button
@ -135,6 +139,14 @@ class TerminalPopupMenu(object):
menu.append(gtk.MenuItem())
if self.config['show_titlebar'] == False:
item = gtk.MenuItem(_('Grouping'))
submenu = self.terminal.populate_group_menu()
submenu.show_all()
item.set_submenu(submenu)
menu.append(item)
menu.append(gtk.MenuItem())
item = gtk.CheckMenuItem(_('Show _scrollbar'))
item.set_active(terminal.scrollbar.get_property('visible'))
item.connect('toggled', lambda x: terminal.do_scrollbar_toggle())
@ -144,8 +156,7 @@ class TerminalPopupMenu(object):
item.connect('activate', lambda x: PrefsEditor(self.terminal))
menu.append(item)
config = Config()
profilelist = config.list_profiles()
profilelist = self.config.list_profiles()
if len(profilelist) > 1:
item = gtk.MenuItem(_('Profiles'))

View File

@ -150,21 +150,30 @@ class Titlebar(gtk.EventBox):
color = term.get_style().bg[gtk.STATE_NORMAL]
else:
color = gtk.gdk.color_parse(title_bg)
self.set_size_request(-1, 2)
self.label.hide()
else:
self.set_size_request(-1, -1)
self.label.show()
self.update_visibility()
self.ebox.modify_bg(gtk.STATE_NORMAL,
gtk.gdk.color_parse(group_bg))
self.set_from_icon_name(icon, gtk.ICON_SIZE_MENU)
def update_visibility(self):
"""Make the titlebar be visible or not"""
if not self.get_desired_visibility():
dbg('hiding titlebar')
self.hide()
self.label.hide()
else:
dbg('showing titlebar')
self.show()
self.label.show()
def get_desired_visibility(self):
"""Returns True if the titlebar is supposed to be visible. False if
not"""
if self.editing() == True:
if self.editing() == True or self.terminal.group:
dbg('implicit desired visibility')
return(True)
else:
dbg('configured visibility: %s' % self.config['show_titlebar'])
return(self.config['show_titlebar'])
def set_from_icon_name(self, name, size = gtk.ICON_SIZE_MENU):
@ -195,10 +204,11 @@ class Titlebar(gtk.EventBox):
self.grouplabel.show()
else:
self.grouplabel.hide()
self.update_visibility()
def on_clicked(self, widget, event):
"""Handle a click on the label"""
self.set_size_request(-1, -1)
self.show()
self.label.show()
self.emit('clicked')
@ -214,6 +224,7 @@ class Titlebar(gtk.EventBox):
"""Create a new group"""
self.groupentry.show()
self.groupentry.grab_focus()
self.update_visibility()
def groupentry_cancel(self, widget, event):
"""Hide the group name entry"""