Commit 185e1b93 authored by Philipp Hörist's avatar Philipp Hörist

Preferences: Simplify combobox code

parent e503523c
......@@ -55,7 +55,6 @@ opt_str = ['string', 0]
opt_bool = ['boolean', 0]
opt_color = ['color', r'(#[0-9a-fA-F]{6})|rgb\(\d+,\d+,\d+\)|rgba\(\d+,\d+,\d+,[01]\.?\d*\)']
opt_one_window_types = ['never', 'always', 'always_with_roster', 'peracct', 'pertype']
opt_show_roster_on_startup = ['always', 'never', 'last_state']
opt_treat_incoming_messages = ['', 'chat', 'normal']
......
......@@ -112,18 +112,23 @@
</object>
<object class="GtkListStore" id="show_roster_on_startup_liststore">
<columns>
<!-- column-name item -->
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name setting -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Always</col>
<col id="1">always</col>
</row>
<row>
<col id="0" translatable="yes">Never</col>
<col id="1">never</col>
</row>
<row>
<col id="0" translatable="yes">Last state</col>
<col id="1">last_state</col>
</row>
</data>
</object>
......@@ -275,6 +280,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="model">show_roster_on_startup_liststore</property>
<property name="id_column">1</property>
<signal name="changed" handler="on_show_roster_on_startup_changed" swapped="no"/>
<child>
<object class="GtkCellRendererText"/>
......
......@@ -77,12 +77,8 @@ class Preferences(Gtk.ApplicationWindow):
self._ui.one_window_type_combobox.set_active(0)
# Show roster on startup
choices = c_config.opt_show_roster_on_startup
type_ = app.config.get('show_roster_on_startup')
if type_ in choices:
self._ui.show_roster_on_startup.set_active(choices.index(type_))
else:
self._ui.show_roster_on_startup.set_active(0)
self._ui.show_roster_on_startup.set_active_id(
app.config.get('show_roster_on_startup'))
# Quit on roster x
st = app.config.get('quit_on_roster_x_button')
......@@ -505,10 +501,8 @@ class Preferences(Gtk.ApplicationWindow):
app.config.set('one_message_window', config_type)
app.interface.msg_win_mgr.reconfig()
def on_show_roster_on_startup_changed(self, widget):
active = widget.get_active()
config_type = c_config.opt_show_roster_on_startup[active]
app.config.set('show_roster_on_startup', config_type)
def on_show_roster_on_startup_changed(self, combobox):
app.config.set('show_roster_on_startup', combobox.get_active_id())
def on_quit_on_roster_x_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'quit_on_roster_x_button')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment