Tweak zooming behaviour so it doesn't lose fractional font sizes

This commit is contained in:
Chris Jones 2008-01-06 14:33:35 +00:00
commit 41dfad77cd
1 changed files with 24 additions and 24 deletions

View File

@ -85,6 +85,7 @@ class TerminatorTerm:
'link_userchars' : '-A-Za-z0-9',
'link_passchars' : '-A-Za-z0-9,?;.:/!%$^*&~"#\'',
'_palette' : '%s/palette',
'default_palette' : '',
'word_chars' : '-A-Za-z0-9,./?%&#:_',
'mouse_autohide' : True,
}
@ -98,23 +99,23 @@ class TerminatorTerm:
self.term = term
self.gconf_client = gconf.client_get_default ()
self.profile = None
self.profile = ""
profiles = self.gconf_client.get_list (self.defaults['gt_dir'] + '/global/profile_list', 'string')
for item in profiles:
if item == profile:
self.profile = '%s/%s'%(self.defaults['profile_dir'], item)
break
if profile in profiles:
self.profile = '%s/%s'%(self.defaults['profile_dir'], profile)
if self.profile == None:
print "Error, unable to find profile " + profile
# FIXME: This absolutely should not be an exit, the terminal should fail to spawn. If they all fail, it should exit from the mainloop or something.
sys.exit (2)
if not self.profile:
print >> sys.stderr, _("Warning: unable to find profile %s. Continue with default values...") % profile
self.defaults['palette'] = self.defaults['_palette']%(self.profile)
if self.profile:
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.add_dir ('/apps/metacity/general', gconf.CLIENT_PRELOAD_RECURSIVE)
self.gconf_client.notify_add ('/apps/metacity/general/focus_mode', self.on_gconf_notification)
self.clipboard = gtk.clipboard_get (gtk.gdk.SELECTION_CLIPBOARD)
@ -131,9 +132,6 @@ class TerminatorTerm:
self._box.pack_start (self._vte)
self._box.pack_start (self._scrollbar, False)
self.gconf_client.notify_add (self.profile, self.on_gconf_notification)
self.gconf_client.notify_add ('/apps/metacity/general/focus_mode', self.on_gconf_notification)
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 ("popup-menu", self.on_vte_popup_menu)
@ -172,7 +170,7 @@ class TerminatorTerm:
self._vte.set_emulation (self.defaults['emulation'])
# Set our wordchars
word_chars = self.gconf_client.get_string (self.profile + "/word_chars" or self.defaults['word_chars'])
word_chars = self.gconf_client.get_string (self.profile + "/word_chars") or self.defaults['word_chars']
self._vte.set_word_chars (word_chars)
# Set our mouselation
@ -215,8 +213,8 @@ class TerminatorTerm:
self._vte.set_allow_bold (self.gconf_client.get_bool (self.profile + "/allow_bold") or self.defaults['allow_bold'])
# Set our color scheme, preferably from gconf settings
palette = self.gconf_client.get_string (self.profile + "/palette") or self.defaults['palette']
if self.gconf_client.get_bool (self.profile + "/use_theme_colors") == True:
palette = self.gconf_client.get_string (self.profile + "/palette") or self.defaults['default_palette']
if (not self.profile) or self.gconf_client.get_bool (self.profile + "/use_theme_colors"):
fg_color = self._vte.get_style ().text[gtk.STATE_NORMAL]
bg_color = self._vte.get_style ().base[gtk.STATE_NORMAL]
else:
@ -240,6 +238,7 @@ class TerminatorTerm:
colors = palette.split (':')
palette = []
for color in colors:
if color:
palette.append (gtk.gdk.color_parse (color))
self._vte.set_colors (fg_color, bg_color, palette)
@ -315,8 +314,9 @@ class TerminatorTerm:
self.zoom (True)
return (True)
mask = gtk.gdk.CONTROL_MASK
if keyname and (keyname == 'minus'):
if event.state == gtk.gdk.CONTROL_MASK:
if (event.state & mask) == mask:
self.zoom (False)
if keyname and (keyname == 'Tab' or keyname.endswith('_Tab')):
@ -331,14 +331,14 @@ class TerminatorTerm:
def zoom (self, zoom_in):
pangodesc = self._vte.get_font ()
fontsize = pango.PIXELS (pangodesc.get_size ())
fontsize = pangodesc.get_size ()
if fontsize > 1 and not zoom_in:
fontsize -= 1
if fontsize > pango.SCALE and not zoom_in:
fontsize -= pango.SCALE
elif zoom_in:
fontsize += 1
fontsize += pango.SCALE
pangodesc.set_size (fontsize * pango.SCALE)
pangodesc.set_size (fontsize)
self._vte.set_font (pangodesc)
def on_vte_popup_menu (self, term):