Tweak zooming behaviour so it doesn't lose fractional font sizes
This commit is contained in:
commit
41dfad77cd
48
terminator
48
terminator
|
@ -85,6 +85,7 @@ class TerminatorTerm:
|
||||||
'link_userchars' : '-A-Za-z0-9',
|
'link_userchars' : '-A-Za-z0-9',
|
||||||
'link_passchars' : '-A-Za-z0-9,?;.:/!%$^*&~"#\'',
|
'link_passchars' : '-A-Za-z0-9,?;.:/!%$^*&~"#\'',
|
||||||
'_palette' : '%s/palette',
|
'_palette' : '%s/palette',
|
||||||
|
'default_palette' : '',
|
||||||
'word_chars' : '-A-Za-z0-9,./?%&#:_',
|
'word_chars' : '-A-Za-z0-9,./?%&#:_',
|
||||||
'mouse_autohide' : True,
|
'mouse_autohide' : True,
|
||||||
}
|
}
|
||||||
|
@ -98,24 +99,24 @@ class TerminatorTerm:
|
||||||
self.term = term
|
self.term = term
|
||||||
self.gconf_client = gconf.client_get_default ()
|
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')
|
profiles = self.gconf_client.get_list (self.defaults['gt_dir'] + '/global/profile_list', 'string')
|
||||||
|
|
||||||
for item in profiles:
|
if profile in profiles:
|
||||||
if item == profile:
|
self.profile = '%s/%s'%(self.defaults['profile_dir'], profile)
|
||||||
self.profile = '%s/%s'%(self.defaults['profile_dir'], item)
|
|
||||||
break
|
|
||||||
|
|
||||||
if self.profile == None:
|
if not self.profile:
|
||||||
print "Error, unable to find profile " + profile
|
print >> sys.stderr, _("Warning: unable to find profile %s. Continue with default values...") % 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)
|
|
||||||
|
|
||||||
self.defaults['palette'] = self.defaults['_palette']%(self.profile)
|
self.defaults['palette'] = self.defaults['_palette']%(self.profile)
|
||||||
|
|
||||||
self.gconf_client.add_dir (self.profile, gconf.CLIENT_PRELOAD_RECURSIVE)
|
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.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)
|
self.clipboard = gtk.clipboard_get (gtk.gdk.SELECTION_CLIPBOARD)
|
||||||
|
|
||||||
self._vte = vte.Terminal ()
|
self._vte = vte.Terminal ()
|
||||||
|
@ -131,9 +132,6 @@ class TerminatorTerm:
|
||||||
self._box.pack_start (self._vte)
|
self._box.pack_start (self._vte)
|
||||||
self._box.pack_start (self._scrollbar, False)
|
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 ("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)
|
||||||
|
@ -172,7 +170,7 @@ class TerminatorTerm:
|
||||||
self._vte.set_emulation (self.defaults['emulation'])
|
self._vte.set_emulation (self.defaults['emulation'])
|
||||||
|
|
||||||
# Set our wordchars
|
# 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)
|
self._vte.set_word_chars (word_chars)
|
||||||
|
|
||||||
# Set our mouselation
|
# 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'])
|
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
|
# Set our color scheme, preferably from gconf settings
|
||||||
palette = self.gconf_client.get_string (self.profile + "/palette") or self.defaults['palette']
|
palette = self.gconf_client.get_string (self.profile + "/palette") or self.defaults['default_palette']
|
||||||
if self.gconf_client.get_bool (self.profile + "/use_theme_colors") == True:
|
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]
|
fg_color = self._vte.get_style ().text[gtk.STATE_NORMAL]
|
||||||
bg_color = self._vte.get_style ().base[gtk.STATE_NORMAL]
|
bg_color = self._vte.get_style ().base[gtk.STATE_NORMAL]
|
||||||
else:
|
else:
|
||||||
|
@ -240,7 +238,8 @@ class TerminatorTerm:
|
||||||
colors = palette.split (':')
|
colors = palette.split (':')
|
||||||
palette = []
|
palette = []
|
||||||
for color in colors:
|
for color in colors:
|
||||||
palette.append (gtk.gdk.color_parse (color))
|
if color:
|
||||||
|
palette.append (gtk.gdk.color_parse (color))
|
||||||
self._vte.set_colors (fg_color, bg_color, palette)
|
self._vte.set_colors (fg_color, bg_color, palette)
|
||||||
|
|
||||||
# Set our cursor blinkiness
|
# Set our cursor blinkiness
|
||||||
|
@ -315,8 +314,9 @@ class TerminatorTerm:
|
||||||
self.zoom (True)
|
self.zoom (True)
|
||||||
return (True)
|
return (True)
|
||||||
|
|
||||||
|
mask = gtk.gdk.CONTROL_MASK
|
||||||
if keyname and (keyname == 'minus'):
|
if keyname and (keyname == 'minus'):
|
||||||
if event.state == gtk.gdk.CONTROL_MASK:
|
if (event.state & mask) == mask:
|
||||||
self.zoom (False)
|
self.zoom (False)
|
||||||
|
|
||||||
if keyname and (keyname == 'Tab' or keyname.endswith('_Tab')):
|
if keyname and (keyname == 'Tab' or keyname.endswith('_Tab')):
|
||||||
|
@ -331,14 +331,14 @@ class TerminatorTerm:
|
||||||
|
|
||||||
def zoom (self, zoom_in):
|
def zoom (self, zoom_in):
|
||||||
pangodesc = self._vte.get_font ()
|
pangodesc = self._vte.get_font ()
|
||||||
fontsize = pango.PIXELS (pangodesc.get_size ())
|
fontsize = pangodesc.get_size ()
|
||||||
|
|
||||||
if fontsize > 1 and not zoom_in:
|
if fontsize > pango.SCALE and not zoom_in:
|
||||||
fontsize -= 1
|
fontsize -= pango.SCALE
|
||||||
elif zoom_in:
|
elif zoom_in:
|
||||||
fontsize += 1
|
fontsize += pango.SCALE
|
||||||
|
|
||||||
pangodesc.set_size (fontsize * pango.SCALE)
|
pangodesc.set_size (fontsize)
|
||||||
self._vte.set_font (pangodesc)
|
self._vte.set_font (pangodesc)
|
||||||
|
|
||||||
def on_vte_popup_menu (self, term):
|
def on_vte_popup_menu (self, term):
|
||||||
|
|
Loading…
Reference in New Issue