merging title-hightlight to dnd

This commit is contained in:
Emmanuel Bretelle 2008-03-02 13:17:56 +00:00
commit d7ca7b3ce3
1 changed files with 91 additions and 36 deletions

View File

@ -96,6 +96,8 @@ class TerminatorTerm:
defaults = { defaults = {
'gt_dir' : '/apps/gnome-terminal', 'gt_dir' : '/apps/gnome-terminal',
'_profile_dir' : '%s/profiles', '_profile_dir' : '%s/profiles',
'titlebars' : True,
'titletips' : False,
'allow_bold' : True, 'allow_bold' : True,
'silent_bell' : True, 'silent_bell' : True,
'background_color' : '#000000', 'background_color' : '#000000',
@ -145,22 +147,28 @@ class TerminatorTerm:
if self.profile: if self.profile:
self.gconf_client.add_dir (self.profile, gconf.CLIENT_PRELOAD_RECURSIVE) self.gconf_client.add_dir (self.profile, gconf.CLIENT_PRELOAD_RECURSIVE)
self.gconf_client.notify_add (self.profile, self.on_gconf_notification) self.gconf_client.notify_add (self.profile, self.on_gconf_notification)
else:
if os.path.exists (pwd.getpwuid(os.getuid ())[5] + "/.terminatorrc"):
f = open (pwd.getpwuid (os.getuid ())[5] + "/.terminatorrc")
config = f.readlines ()
f.close ()
for line in config: if os.path.exists (pwd.getpwuid(os.getuid ())[5] + "/.terminatorrc"):
try: f = open (pwd.getpwuid (os.getuid ())[5] + "/.terminatorrc")
line = line.split("#")[0] config = f.readlines ()
line = line.strip () f.close ()
if line:
(key,value) = line.split ("=") for line in config:
print >> sys.stderr, _('''Overriding setting '%s' from default value '%s' to: '%s' ''') % (key.strip (), self.defaults[key.strip ()], value.strip ()) try:
self.defaults[key.strip ()] = value.strip () line = line.strip ()
except: if line[0] == '#':
pass pass
elif line:
(key,value) = line.split ("=")
print >> sys.stderr, _('''Overriding setting '%s' from value '%s' to: '%s' ''')%(key.strip (), self.defaults[key.strip ()], value.strip ())
if value.strip() == "True":
self.defaults[key.strip ()] = True
elif value.strip() == "False":
self.defaults[key.strip ()] = False
else:
self.defaults[key.strip ()] = value.strip ()
except:
pass
self.gconf_client.add_dir ('/apps/metacity/general', gconf.CLIENT_PRELOAD_RECURSIVE) self.gconf_client.add_dir ('/apps/metacity/general', gconf.CLIENT_PRELOAD_RECURSIVE)
self.gconf_client.notify_add ('/apps/metacity/general/focus_mode', self.on_gconf_notification) self.gconf_client.notify_add ('/apps/metacity/general/focus_mode', self.on_gconf_notification)
@ -174,20 +182,33 @@ class TerminatorTerm:
self.reconfigure_vte () self.reconfigure_vte ()
self._vte.show () self._vte.show ()
self._box = gtk.HBox () self._termbox = gtk.HBox ()
self._box.show () self._termbox.show()
self._title = gtk.Label()
self._title.show()
self._titlebox = gtk.EventBox()
self._titlebox.add(self._title)
self._box = gtk.VBox ()
self._box.show()
self._box.pack_start(self._titlebox, False)
self._box.pack_start(self._termbox)
if self.reconf('titlebars'):
self._titlebox.show()
else:
self._titlebox.hide()
self._scrollbar = gtk.VScrollbar (self._vte.get_adjustment ()) self._scrollbar = gtk.VScrollbar (self._vte.get_adjustment ())
if self.scrollbar_position != "hidden" and self.scrollbar_position != "disabled": if self.scrollbar_position != "hidden" and self.scrollbar_position != "disabled":
self._scrollbar.show () self._scrollbar.show ()
if self.scrollbar_position == 'right': if self.scrollbar_position == 'right':
packfunc = self._box.pack_start packfunc = self._termbox.pack_start
else: else:
packfunc = self._box.pack_end packfunc = self._termbox.pack_end
packfunc (self._vte) packfunc (self._vte)
packfunc (self._scrollbar, False) packfunc (self._scrollbar, False)
self._vte.connect ("key-press-event", self.on_vte_key_press) self._vte.connect ("key-press-event", self.on_vte_key_press)
self._vte.connect ("button-press-event", self.on_vte_button_press) self._vte.connect ("button-press-event", self.on_vte_button_press)
self._vte.connect ("popup-menu", self.on_vte_popup_menu) self._vte.connect ("popup-menu", self.on_vte_popup_menu)
@ -204,7 +225,10 @@ class TerminatorTerm:
self._vte.connect ("composited-changed", self.on_composited_changed) self._vte.connect ("composited-changed", self.on_composited_changed)
# self._vte.connect ("window-title-changed", self.on_vte_title_change) self._vte.connect ("window-title-changed", self.on_vte_title_change)
self._vte.connect ("grab-focus", self.on_vte_focus)
self._vte.connect ("focus-out-event", self.on_vte_focus_out)
self._vte.connect ("focus-in-event", self.on_vte_focus_in)
@ -510,6 +534,11 @@ class TerminatorTerm:
else: else:
self._scrollbar.show () self._scrollbar.show ()
def do_title_toggle (self):
if self._title.get_property ('visible'):
self._title.hide ()
else:
self._title.show ()
#keybindings for the individual splited terminals (affects only the #keybindings for the individual splited terminals (affects only the
#the selected terminal) #the selected terminal)
def on_vte_key_press (self, term, event): def on_vte_key_press (self, term, event):
@ -635,6 +664,11 @@ class TerminatorTerm:
item.set_active (self._scrollbar.get_property ('visible')) item.set_active (self._scrollbar.get_property ('visible'))
item.connect ("toggled", lambda menu_item: self.do_scrollbar_toggle ()) item.connect ("toggled", lambda menu_item: self.do_scrollbar_toggle ())
menu.append (item) menu.append (item)
item = gtk.CheckMenuItem (_("Show Title"))
item.set_active (self._title.get_property ('visible'))
item.connect ("toggled", lambda menu_item: self.do_title_toggle ())
menu.append (item)
item = gtk.MenuItem () item = gtk.MenuItem ()
menu.append (item) menu.append (item)
@ -658,9 +692,27 @@ class TerminatorTerm:
return menu return menu
def on_vte_title_change(self, vte): def on_vte_title_change(self, vte):
vte.set_property ("has-tooltip", True) if self.reconf ('titletips'):
vte.set_property ("tooltip-text", vte.get_window_title ()) vte.set_property ("has-tooltip", True)
vte.set_property ("tooltip-text", vte.get_window_title ())
#set the title anyhow, titlebars setting only show/hide the label
self._title.set_text(vte.get_window_title ())
self.terminator.set_window_title("Terminator: %s" %vte.get_window_title ())
def on_vte_focus_in(self, vte, event):
self._titlebox.modify_bg(gtk.STATE_NORMAL,self.terminator.window.get_style().bg[gtk.STATE_SELECTED])
self._title.modify_fg(gtk.STATE_NORMAL, self.terminator.window.get_style().fg[gtk.STATE_SELECTED])
return
def on_vte_focus_out(self, vte, event):
self._titlebox.modify_bg(gtk.STATE_NORMAL, self.terminator.window.get_style().bg[gtk.STATE_NORMAL])
self._title.modify_fg(gtk.STATE_NORMAL, self.terminator.window.get_style().fg[gtk.STATE_NORMAL])
return
def on_vte_focus(self, vte):
if vte.get_window_title ():
self.terminator.set_window_title("Terminator: %s" %vte.get_window_title ())
def get_box (self): def get_box (self):
return self._box return self._box
@ -669,7 +721,7 @@ class TerminatorTerm:
self._vte.destroy() self._vte.destroy()
class Terminator: class Terminator:
def __init__ (self, profile, command = None): def __init__ (self, profile, command = None, fullscreen = False, maximise = False, borderless = False):
self.profile = profile self.profile = profile
self.gconf_client = gconf.client_get_default () self.gconf_client = gconf.client_get_default ()
self.command = command self.command = command
@ -692,6 +744,15 @@ class Terminator:
self.window.set_property ('allow-shrink', True) self.window.set_property ('allow-shrink', True)
if fullscreen:
self.fullscreen_toggle ()
if maximise:
self.maximize ()
if borderless:
self.window.set_decorated (False)
# Set RGBA colormap if possible so VTE can use real alpha # Set RGBA colormap if possible so VTE can use real alpha
# channels for transparency. # channels for transparency.
screen = self.window.get_screen() screen = self.window.get_screen()
@ -778,8 +839,13 @@ class Terminator:
if keyname == 'Q': if keyname == 'Q':
if not self.on_delete_event (window, gtk.gdk.Event (gtk.gdk.DELETE)): if not self.on_delete_event (window, gtk.gdk.Event (gtk.gdk.DELETE)):
self.on_destroy_event (window, gtk.gdk.Event (gtk.gdk.DESTROY)) self.on_destroy_event (window, gtk.gdk.Event (gtk.gdk.DESTROY))
def set_window_title(self, title):
"""
Modifies Terminator window title
"""
self.window.set_title(title)
def add(self, widget, terminal, pos = "bottom"): def add(self, widget, terminal, pos = "bottom"):
""" """
Add a term to another at position pos Add a term to another at position pos
@ -1024,18 +1090,7 @@ if __name__ == '__main__':
del (gconf) del (gconf)
gconf = fakegconf () gconf = fakegconf ()
term = Terminator (options.profile, command) term = Terminator (options.profile, command, options.fullscreen, options.maximise, options.borderless)
# Set the Terminator in fullscreen state or maximize it.
# Fullscreen and maximise are mutually exclusive, with
# fullscreen taking precedence over maximise.
if options.fullscreen:
term.toggle_fullscreen ()
elif options.maximise:
term.maximize ()
if options.borderless:
term.window.set_decorated (False)
gtk.main () gtk.main ()