merge in latest changes from trunk

This commit is contained in:
Chris Jones 2009-09-02 20:39:25 +01:00
commit 9d82f13989
4 changed files with 147 additions and 65 deletions

View File

@ -79,6 +79,7 @@ class Uninstall(Command):
return 'uninstall'
def run(self):
f = None
self.ensure_filename('manifest')
try:
try:
@ -87,7 +88,8 @@ class Uninstall(Command):
except IOError, e:
raise DistutilsFileError("unable to open install manifest: %s", str(e))
finally:
f.close()
if f:
f.close()
for file in files:
if os.path.isfile(file) or os.path.islink(file):

View File

@ -29,38 +29,31 @@ from util import dbg, err, debug
from keybindings import TerminatorKeybindings
from terminatorterm import TerminatorTerm
from prefs_profile import ProfileEditor
from terminatoreditablelabel import TerminatorEditableLabel
import translation
# FIXME: Move to notebook.py
class TerminatorNotebookTabLabel(gtk.HBox):
_terminator = None
_notebook = None
_label = None
_icon = None
_label = None
_button = None
_ebox = None
_autotitle = None
custom = None
def __init__(self, title, notebook, terminator):
gtk.HBox.__init__(self, False)
self._notebook = notebook
self._terminator = terminator
self.custom = False
self._label = gtk.Label(title)
self._label = TerminatorEditableLabel(title)
self.update_angle()
self._ebox = gtk.EventBox ()
self._ebox.set_visible_window (False)
self._ebox.add (self._label)
self.pack_start(self._ebox, True, True)
self.pack_start(self._label, True, True)
self._icon = gtk.Image()
self._icon.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)
self.update_closebut()
self._ebox.connect ("button-press-event", self.on_click_title)
self.show_all()
@ -117,9 +110,7 @@ class TerminatorNotebookTabLabel(gtk.HBox):
break
def set_title(self, title, force=False):
self._autotitle = title
if not self.custom or force:
self._label.set_text(title)
self._label.set_text(title, force)
def get_title(self):
return self._label.get_text()
@ -130,43 +121,6 @@ class TerminatorNotebookTabLabel(gtk.HBox):
def width_request(self):
return self.size_request()[0]
def on_click_title(self, widget, event):
if event.type == gtk.gdk._2BUTTON_PRESS and self._ebox in self.get_children ():
self.remove (self._ebox)
self._entry = gtk.Entry ()
self._entry.set_text (self._label.get_text ())
self._entry.show ()
self.pack_start (self._entry)
self.reorder_child (self._entry, 0)
self._notebook.connect ("switch-page", self.entry_to_label)
self._entry.connect ("activate", self.on_entry_activated)
self._entry.connect ("key-press-event", self.on_entry_keypress)
self._entry.grab_focus ()
def entry_to_label (self, widget, page, page_num):
if (self._entry):
self.remove (self._entry)
self.add (self._ebox)
self._entry = None
self.reorder_child (self._ebox, 0)
self._ebox.show_all ()
def on_entry_activated (self, widget):
entry = self._entry.get_text ()
label = self._label.get_text ()
if entry == '':
self.custom = False
self.set_title (self._autotitle)
elif entry != label:
self.custom = True
self.set_title (self._entry.get_text (), True)
self.entry_to_label (None, None, None)
def on_entry_keypress (self, widget, event):
key = gtk.gdk.keyval_name (event.keyval)
if key == 'Escape':
self.entry_to_label (None, None, None)
class Terminator:
options = None
@ -324,14 +278,17 @@ class Terminator:
term.spawn_child ()
self.save_yourself ()
if hidden or self.conf.hidden:
self.hide()
couldbind = False
try:
bindkey.tomboy_keybinder_bind(self.conf.keybindings['hide_window'],self.cbkeyCloak,term)
couldbind = bindkey.tomboy_keybinder_bind(self.conf.keybindings['hide_window'],self.cbkeyCloak,term)
except:
dbg (_("Unable to bind hide_window key"))
pass
if couldbind:
if hidden or self.conf.hidden:
self.hide()
else:
if hidden or self.conf.hidden:
self.window.iconify()
def set_handle_size (self, size):
if size in xrange (0,6):

View File

@ -0,0 +1,120 @@
#!/usr/bin/env python
# vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab
#
# Copyright (c) 2009, Emmanuel Bretelle <chantra@debuntu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2 only.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor
# , Boston, MA 02110-1301 USA
# pylint: disable-msg=W0212
''' Editable Label class'''
import gtk
class TerminatorEditableLabel( gtk.EventBox ):
'''
An eventbox that partialy emulate a gtk.Label
On double-click, the label is editable, entering an empty will revert back to automatic text
'''
_label = None
_ebox = None
_autotext = None
_custom = None
_entry = None
_entry_handler_id = []
def __init__(self, text = ""):
''' Class initialiser'''
gtk.EventBox.__init__(self)
self._label = gtk.Label(text)
self._custom = False
self.set_visible_window (False)
self.add (self._label)
self.connect ("button-press-event", self._on_click_text)
def set_angle(self, angle ):
'''set angle of the label'''
self._label.set_angle( angle )
def set_text( self, text, force=False):
'''set the text of the label'''
self._autotext = text
if not self._custom or force:
self._label.set_text(text)
def get_text( self ):
'''get the text from the label'''
return self._label.get_text()
def _on_click_text(self, widget, event):
'''event handling text edition'''
if event.type == gtk.gdk._2BUTTON_PRESS :
self.remove (self._label)
self._entry = gtk.Entry ()
self._entry.set_text (self._label.get_text ())
self._entry.show ()
self.add (self._entry)
sig = self._entry.connect ("focus-out-event", self._entry_to_label)
self._entry_handler_id.append(sig)
sig = self._entry.connect ("activate", self._on_entry_activated)
self._entry_handler_id.append(sig)
sig = self._entry.connect ("key-press-event",
self._on_entry_keypress)
self._entry_handler_id.append(sig)
self._entry.grab_focus ()
return True
# make pylint happy
if 1 or widget or event:
return False
def _entry_to_label (self, widget, event):
'''replace gtk.Entry by the gtk.Label'''
if self._entry and self._entry in self.get_children():
#disconnect signals to avoid segfault :s
for sig in self._entry_handler_id:
if self._entry.handler_is_connected(sig):
self._entry.disconnect(sig)
self._entry_handler_id = []
self.remove (self._entry)
self.add (self._label)
self._entry = None
self.show_all ()
return True
#make pylint happy
if 1 or widget or event:
return False
def _on_entry_activated (self, widget):
'''get the text entered in gtk.Entry'''
entry = self._entry.get_text ()
label = self._label.get_text ()
if entry == '':
self._custom = False
self.set_text (self._autotext)
elif entry != label:
self._custom = True
self._label.set_text (entry)
self._entry_to_label (None, None)
# make pylint happy
if 1 or widget:
return
def _on_entry_keypress (self, widget, event):
'''handle keypressed in gtk.Entry'''
key = gtk.gdk.keyval_name (event.keyval)
if key == 'Escape':
self._entry_to_label (None, None)
# make pylint happy
if 1 or widget or event:
return

View File

@ -30,7 +30,7 @@ from terminatorlib.util import dbg, err, debug
#import encoding list
from terminatorlib.encoding import TerminatorEncoding
from terminatorlib.terminatoreditablelabel import TerminatorEditableLabel
# import translation support
from terminatorlib import translation
@ -62,7 +62,7 @@ class TerminatorTermTitle (gtk.EventBox):
def __init__ (self, terminal, terminator, configwanted = False):
gtk.EventBox.__init__ (self)
self._title = gtk.Label ()
self._title = TerminatorEditableLabel()
self._group = gtk.Label ()
self._separator = gtk.VSeparator ()
self._ebox = gtk.EventBox ()
@ -92,12 +92,12 @@ class TerminatorTermTitle (gtk.EventBox):
self._hbox.pack_start (self._title, True, True)
self.add (self._hbox)
self._title.show ()
self._title.show_all ()
self._hbox.show ()
self.wanted = configwanted
self.connect ("button-release-event", self.on_clicked)
self.connect ("button-press-event", self.on_clicked)
def connect_icon (self, func):
self._ebox.connect ("button-release-event", func)
@ -105,7 +105,7 @@ class TerminatorTermTitle (gtk.EventBox):
def on_clicked (self, widget, event):
if self._parent is not None:
self._parent._vte.grab_focus ()
def set_group_label (self, name):
"""If 'name' is None, hide the group name object, otherwise set it as the group label"""
if name:
@ -382,7 +382,9 @@ class TerminatorTerm (gtk.VBox):
elif match == self.matches['addr_only']:
url = 'http://' + url
elif match == self.matches['launchpad']:
url = 'https://bugs.launchpad.net/bugs/%s' % re.sub (r'[^0-9]+', '', url)
for item in re.findall(r'[0-9]+',url):
url = 'https://bugs.launchpad.net/bugs/%s' % item
return url
return url
@ -625,7 +627,8 @@ text/plain
self.matches['email'] = self._vte.match_add (lboundry + "(mailto:)?[a-zA-Z0-9][a-zA-Z0-9.+-]*@[a-zA-Z0-9][a-zA-Z0-9-]*\.[a-zA-Z0-9][a-zA-Z0-9-]+[.a-zA-Z0-9-]*" + rboundry)
self.matches['nntp'] = self._vte.match_add (lboundry + '''news:[-A-Z\^_a-z{|}~!"#$%&'()*+,./0-9;:=?`]+@[-A-Za-z0-9.]+(:[0-9]+)?''' + rboundry)
# if the url looks like a Launchpad changelog closure entry LP: #92953 - make it a url to http://bugs.launchpad.net
self.matches['launchpad'] = self._vte.match_add ('\\bLP:? #?[0-9]+\\b')
# the regular expression is similar to the perl one specified in the Ubuntu Policy Manual - /lp:\s+\#\d+(?:,\s*\#\d+)*/i
self.matches['launchpad'] = self._vte.match_add ('\\b(lp|LP):?\s?#?[0-9]+(,\s*#?[0-9]+)*\\b')
def _path_lookup(self, command):
if os.path.isabs (command):
@ -808,7 +811,7 @@ text/plain
dbg ('H9TRANS: Configuring background type as: %s' % background_type)
# set background image settings
if background_type == "image":
if background_type == "image" and self.conf.background_image is not None and self.conf.background_image != '':
dbg ('H9TRANS: Setting background image to: %s' % self.conf.background_image)
self._vte.set_background_image_file (self.conf.background_image)
dbg ('H9TRANS: Setting background image scroll to: %s' % self.conf.scroll_background)