Skip to content

Commit

Permalink
Merge pull request #884 from mattrose/ask_before_close_gui
Browse files Browse the repository at this point in the history
Ask before close gui
  • Loading branch information
mattrose authored Feb 9, 2024
2 parents b47f7d0 + aa03c23 commit 9a3b899
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 10 deletions.
65 changes: 56 additions & 9 deletions terminatorlib/preferences.glade
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 -->
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkListStore" id="AskBeforeCloseListStore">
<columns>
<!-- column-name askwhenclose -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Never</col>
</row>
<row>
<col id="0" translatable="yes">Multiple Terminals</col>
</row>
<row>
<col id="0" translatable="yes">Always</col>
</row>
</data>
</object>
<object class="GtkListStore" id="BackspaceKeyListStore">
<columns>
<!-- column-name Result -->
Expand Down Expand Up @@ -473,7 +490,7 @@
<property name="spacing">36</property>
<property name="homogeneous">True</property>
<child>
<!-- n-columns=2 n-rows=8 -->
<!-- n-columns=2 n-rows=9 -->
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can-focus">False</property>
Expand Down Expand Up @@ -524,7 +541,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
<property name="top-attach">2</property>
<property name="width">2</property>
</packing>
</child>
Expand All @@ -541,7 +558,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
<property name="top-attach">3</property>
<property name="width">2</property>
</packing>
</child>
Expand All @@ -558,7 +575,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
<property name="top-attach">4</property>
<property name="width">2</property>
</packing>
</child>
Expand All @@ -575,7 +592,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
<property name="top-attach">5</property>
<property name="width">2</property>
</packing>
</child>
Expand All @@ -592,7 +609,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">5</property>
<property name="top-attach">6</property>
<property name="width">2</property>
</packing>
</child>
Expand All @@ -609,7 +626,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">6</property>
<property name="top-attach">7</property>
<property name="width">2</property>
</packing>
</child>
Expand All @@ -626,10 +643,40 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">7</property>
<property name="top-attach">8</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="askbeforeclose">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="model">AskBeforeCloseListStore</property>
<property name="active">1</property>
<signal name="changed" handler="on_askbeforeclose_changed" swapped="no"/>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Ask Before Closing:</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
Expand Down
27 changes: 26 additions & 1 deletion terminatorlib/prefseditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,18 @@ def set_values(self):
active = 0
widget = guiget('winstatecombo')
widget.set_active(active)
# Ask Before Closing
option = self.config['ask_before_closing']
if option == 'never':
active = 0
elif option == 'multiple_terminals':
active = 1
elif option == 'always':
active = 2
else:
active = 1
widget = guiget('askbeforeclose')
widget.set_active(active)
# Window borders
widget = guiget('winbordercheck')
widget.set_active(not self.config['borderless'])
Expand Down Expand Up @@ -1497,7 +1509,20 @@ def on_winstatecombo_changed(self, widget):
value = 'normal'
self.config['window_state'] = value
self.config.save()

def on_askbeforeclose_changed(self, widget):
"""Ask Before Close changed"""
selected = widget.get_active()
if selected == 0:
value = 'Never'
elif selected == 1:
value = 'Multiple Terminals'
elif selected == 2:
value = 'Always'
else:
value = 'Multiple Terminals'
configval = value.lower().replace(" ","_")
self.config['ask_before_closing'] = configval
self.config.save()
# helper function, not a signal
def addprofile(self, name, toclone):
"""Add a profile"""
Expand Down

0 comments on commit 9a3b899

Please sign in to comment.