Merge pull request #296 from mattrose/fix-bg-ui
fix background image profile preferences ui
This commit is contained in:
commit
40bd59481b
|
@ -360,11 +360,6 @@
|
|||
<property name="step_increment">0.1</property>
|
||||
<property name="page_increment">0.2</property>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="background_image_shading_adjustment">
|
||||
<property name="upper">1</property>
|
||||
<property name="step_increment">0.1</property>
|
||||
<property name="page_increment">0.01</property>
|
||||
</object>
|
||||
<object class="GtkWindow" id="prefswin">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">6</property>
|
||||
|
@ -2885,6 +2880,60 @@
|
|||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="image_radiobutton">
|
||||
<property name="label" translatable="yes">Background Image</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="group">solid_radiobutton</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Background Image File:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="padding">5</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFileChooserButton" id="background_image_file">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">Choose file</property>
|
||||
<signal name="file-set" handler="on_background_image_file_set" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="darken_background_vbox">
|
||||
<property name="visible">True</property>
|
||||
|
@ -2895,7 +2944,7 @@
|
|||
<object class="GtkLabel" id="darken_background_scale_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">S_hade transparent background:</property>
|
||||
<property name="label" translatable="yes">S_hade background:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">darken_background_scale</property>
|
||||
<property name="xalign">0</property>
|
||||
|
@ -2968,44 +3017,6 @@
|
|||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Background Image:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="padding">5</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFileChooserButton" id="background_image_file">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">Choose file</property>
|
||||
<signal name="file-set" handler="on_background_image_file_set" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
|
@ -3017,62 +3028,22 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Shade Background Image:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="padding">5</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Transparent </property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScale" id="background_image_shading_scale">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="adjustment">background_image_shading_adjustment</property>
|
||||
<property name="round_digits">1</property>
|
||||
<signal name="value-changed" handler="on_background_image_shading_scale_value_changed" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Opaque</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">5</property>
|
||||
<property name="position">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
|
@ -4185,4 +4156,9 @@ Much of the behavior of Terminator is based on GNOME Terminal, and we are adding
|
|||
<widget name="encoding_combobox"/>
|
||||
</widgets>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="background_image_shading_adjustment">
|
||||
<property name="upper">1</property>
|
||||
<property name="step_increment">0.1</property>
|
||||
<property name="page_increment">0.01</property>
|
||||
</object>
|
||||
</interface>
|
||||
|
|
|
@ -633,14 +633,14 @@ class PrefsEditor:
|
|||
guiget('solid_radiobutton').set_active(True)
|
||||
elif self.config['background_type'] == 'transparent':
|
||||
guiget('transparent_radiobutton').set_active(True)
|
||||
elif self.config['background_type'] == 'image':
|
||||
guiget('image_radiobutton').set_active(True)
|
||||
self.update_background_tab()
|
||||
# Background shading
|
||||
widget = guiget('background_darkness_scale')
|
||||
widget.set_value(float(self.config['background_darkness']))
|
||||
widget = guiget('background_image_file')
|
||||
widget.set_filename(self.config['background_image'])
|
||||
widget = guiget('background_image_shading_scale')
|
||||
widget.set_value(float(self.config['background_alpha']))
|
||||
|
||||
## Scrolling tab
|
||||
# Scrollbar position
|
||||
|
@ -945,10 +945,6 @@ class PrefsEditor:
|
|||
self.config['background_image'] = widget.get_filename()
|
||||
self.config.save()
|
||||
|
||||
def on_background_image_shading_scale_value_changed(self,widget):
|
||||
self.config['background_alpha'] = widget.get_value()
|
||||
self.config.save()
|
||||
|
||||
def on_darken_background_scale_value_changed(self, widget):
|
||||
"""Background darkness setting changed"""
|
||||
value = widget.get_value() # This one is rounded according to the UI.
|
||||
|
@ -1507,13 +1503,21 @@ class PrefsEditor:
|
|||
backtype = None
|
||||
imagewidget = guiget('image_radiobutton')
|
||||
transwidget = guiget('transparent_radiobutton')
|
||||
if transwidget.get_active() == True:
|
||||
|
||||
if imagewidget.get_active() == True:
|
||||
backtype = 'image'
|
||||
elif transwidget.get_active() == True:
|
||||
backtype = 'transparent'
|
||||
else:
|
||||
backtype = 'solid'
|
||||
self.config['background_type'] = backtype
|
||||
self.config.save()
|
||||
|
||||
if backtype == 'image':
|
||||
guiget('background_image_file').set_sensitive(True)
|
||||
else:
|
||||
guiget('background_image_file').set_sensitive(False)
|
||||
|
||||
if backtype in ('transparent', 'image'):
|
||||
guiget('darken_background_scale').set_sensitive(True)
|
||||
else:
|
||||
|
|
|
@ -36,6 +36,7 @@ class Overpaint(Vte.Terminal):
|
|||
def __init__(self):
|
||||
Vte.Terminal.__init__(self)
|
||||
self.config = Config()
|
||||
### inactive_color_offset is the opposite of alpha level
|
||||
self.dim_p = float(self.config['inactive_color_offset'])
|
||||
self.dim_l = round(1.0 - self.dim_p,3)
|
||||
def dim(self,b):
|
||||
|
@ -164,15 +165,16 @@ class Terminal(Gtk.VBox):
|
|||
self.queue_draw()
|
||||
self.background_image = None
|
||||
if self.config['background_image'] != '':
|
||||
self.vte.set_clear_background(False)
|
||||
self.vte.connect("draw",self.background_draw)
|
||||
|
||||
try:
|
||||
self.background_image = GdkPixbuf.Pixbuf.new_from_file(self.config['background_image'])
|
||||
except Exception:
|
||||
pass
|
||||
self.vte.set_clear_background(False)
|
||||
self.vte.connect("draw",self.background_draw)
|
||||
except Exception as e:
|
||||
self.background_image = None
|
||||
self.vte.set_clear_background(True)
|
||||
err('error loading background image: %s' % e)
|
||||
|
||||
self.background_alpha = self.config['background_alpha']
|
||||
self.background_alpha = self.config['background_darkness']
|
||||
self.vte.set_allow_hyperlink(True)
|
||||
self.vte._draw_data = None
|
||||
if not hasattr(self.vte, "set_opacity") or \
|
||||
|
@ -753,7 +755,7 @@ class Terminal(Gtk.VBox):
|
|||
self.bgcolor = Gdk.RGBA()
|
||||
self.bgcolor.parse(self.config['background_color'])
|
||||
|
||||
if self.config['background_type'] == 'transparent':
|
||||
if self.config['background_type'] == 'transparent' or self.config['background_type'] == 'image':
|
||||
self.bgcolor.alpha = self.config['background_darkness']
|
||||
else:
|
||||
self.bgcolor.alpha = 1
|
||||
|
@ -1121,10 +1123,10 @@ class Terminal(Gtk.VBox):
|
|||
widget._draw_data = None
|
||||
|
||||
def background_draw(self, widget, cr):
|
||||
if not self.background_image:
|
||||
if not self.config['background_type'] == 'image' or not self.background_image:
|
||||
return(False)
|
||||
over = self.bgcolor
|
||||
over.alpha = self.background_alpha
|
||||
#if not self.background_image:
|
||||
# return(False)
|
||||
rect = self.vte.get_allocation()
|
||||
xratio = float(rect.width) / float(self.background_image.get_width())
|
||||
yratio = float(rect.height) / float(self.background_image.get_height())
|
||||
|
@ -1132,7 +1134,7 @@ class Terminal(Gtk.VBox):
|
|||
cr.scale(xratio,yratio)
|
||||
Gdk.cairo_set_source_pixbuf(cr, self.background_image, 0, 0)
|
||||
cr.paint()
|
||||
Gdk.cairo_set_source_rgba(cr,over)
|
||||
Gdk.cairo_set_source_rgba(cr,self.bgcolor)
|
||||
cr.paint()
|
||||
cr.restore()
|
||||
|
||||
|
|
|
@ -439,7 +439,9 @@ class Terminator(Borg):
|
|||
else:
|
||||
bgcolor = Gdk.RGBA()
|
||||
bgcolor = profiles[profile]['background_color']
|
||||
if profiles[profile]['background_type'] == 'transparent':
|
||||
if profiles[profile]['background_type'] == 'image':
|
||||
backgound_image = profiles[profile]['background_image']
|
||||
if profiles[profile]['background_type'] == 'transparent' or profiles[profile]['background_type'] == 'image':
|
||||
bgalpha = profiles[profile]['background_darkness']
|
||||
else:
|
||||
bgalpha = "1"
|
||||
|
|
Loading…
Reference in New Issue