Group creation is now presented via the titlebar, but still doesn't actually have any backending in functional reality yet.

This commit is contained in:
Chris Jones 2009-10-15 14:17:37 +01:00
parent 5652f104ad
commit e2086578bb
2 changed files with 43 additions and 3 deletions

View File

@ -106,6 +106,7 @@ class Terminal(gtk.VBox):
self.titlebar.connect_icon(self.on_group_button_press)
self.titlebar.connect('edit-done', self.on_edit_done)
self.connect('title-change', self.titlebar.set_terminal_title)
self.titlebar.connect('create-group', self.really_create_group)
self.searchbar = Searchbar()
@ -374,9 +375,13 @@ class Terminal(gtk.VBox):
return(widget_x, menu_y, 1)
def create_group(self, item):
"""Create a new group"""
#FIXME: Make this work
pass
"""Trigger the creation of a group via the titlebar (because popup
windows are really lame)"""
self.titlebar.create_group()
def really_create_group(self, groupname):
"""The titlebar has spoken, let a group be created"""
# FIXME: Actually create the group
def set_groupsend(self, widget, value):
"""Set the groupsend mode"""

View File

@ -7,6 +7,7 @@ import gtk
import gobject
from version import APP_NAME
from util import dbg
from newterminator import Terminator
from editablelabel import EditableLabel
@ -23,10 +24,13 @@ class Titlebar(gtk.EventBox):
ebox = None
groupicon = None
grouplabel = None
groupentry = None
__gsignals__ = {
'clicked': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'edit-done': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'create-group': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_STRING,)),
}
def __init__(self):
@ -43,6 +47,12 @@ class Titlebar(gtk.EventBox):
self.grouplabel = gtk.Label()
self.groupicon = gtk.Image()
self.groupentry = gtk.Entry()
self.groupentry.set_no_show_all(True)
self.groupentry.connect('focus-out-event', self.groupentry_cancel)
self.groupentry.connect('activate', self.groupentry_activate)
self.groupentry.connect('key-press-event', self.groupentry_keypress)
groupsend_type = self.terminator.groupsend_type
if self.terminator.groupsend == groupsend_type['all']:
icon_name = 'all'
@ -55,6 +65,8 @@ class Titlebar(gtk.EventBox):
grouphbox.pack_start(self.groupicon, False, True, 2)
grouphbox.pack_start(self.grouplabel, False, True, 2)
grouphbox.pack_start(self.groupentry, False, True, 2)
self.ebox.add(grouphbox)
self.ebox.show_all()
@ -111,4 +123,27 @@ class Titlebar(gtk.EventBox):
"""Re-emit an edit-done signal from an EditableLabel"""
self.emit('edit-done')
def create_group(self):
"""Create a new group"""
self.groupentry.show()
self.groupentry.grab_focus()
def groupentry_cancel(self, widget, event):
"""Hide the group name entry"""
self.groupentry.set_text('')
self.groupentry.hide()
def groupentry_activate(self, widget):
"""Actually cause a group to be created"""
groupname = self.groupentry.get_text()
dbg('creating group: %s' % groupname)
self.groupentry_cancel(None, None)
self.emit('create-group', groupname)
def groupentry_keypress(self, widget, event):
"""Handle keypresses on the entry widget"""
key = gtk.gdk.keyval_name(event.keyval)
if key == 'Escape':
self.groupentry_cancel(None, None)
gobject.type_register(Titlebar)