Skip to content

Commit

Permalink
add GUI controls for background image
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrose committed Sep 30, 2020
1 parent e06003e commit 8db142d
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 3 deletions.
116 changes: 114 additions & 2 deletions terminatorlib/preferences.glade
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,11 @@
<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>
Expand Down Expand Up @@ -1434,6 +1439,12 @@
<property name="top_attach">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
Expand Down Expand Up @@ -2860,7 +2871,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">1</property>
<property name="padding">5</property>
<property name="position">0</property>
</packing>
</child>
Expand Down Expand Up @@ -2928,7 +2939,108 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</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>
<property name="position">4</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">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>
</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>
</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>
</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>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
</object>
Expand Down
15 changes: 14 additions & 1 deletion terminatorlib/prefseditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,11 @@ def on_palette_click(event, data, widget=widget):
# 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
widget = guiget('scrollbar_position_combobox')
Expand Down Expand Up @@ -931,6 +935,15 @@ def on_scrollbar_position_combobox_changed(self, widget):
self.config['scrollbar_position'] = value
self.config.save()

def on_background_image_file_set(self,widget):
print(widget.get_filename())
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.
Expand Down

0 comments on commit 8db142d

Please sign in to comment.