all the options in preferences window now apply instantly

This commit is contained in:
Yann Leboulanger 2005-03-09 10:26:57 +00:00
parent 396b6a9eb1
commit be74122555
2 changed files with 122 additions and 104 deletions

View File

@ -249,9 +249,15 @@ class preferences_window:
self.plugin.config['print_time'] = 'always' self.plugin.config['print_time'] = 'always'
self.update_print_time() self.update_print_time()
def on_use_emoticons_checkbutton_function(self): def on_use_emoticons_checkbutton_toggled(self, widget):
""" self.on_checkbutton_toggled(widget, 'useemoticons',\
model = self.emot_tree.get_model() [self.xml.get_widget('button_new_emoticon'),\
self.xml.get_widget('button_remove_emoticon'),\
self.xml.get_widget('treeview_emoticons'),\
self.xml.get_widget('set_image_button'),\
self.xml.get_widget('emoticons_image')])
def on_emoticons_treemodel_row_deleted(self, model, path, iter):
iter = model.get_iter_first() iter = model.get_iter_first()
emots = [] emots = []
while iter: while iter:
@ -259,72 +265,72 @@ class preferences_window:
emots.append(model.get_value(iter, 1)) emots.append(model.get_value(iter, 1))
iter = model.iter_next(iter) iter = model.iter_next(iter)
self.plugin.config['emoticons'] = '\t'.join(emots) self.plugin.config['emoticons'] = '\t'.join(emots)
"""
self.plugin.roster.mkemoticons() self.plugin.roster.mkemoticons()
def on_emoticons_treeview_row_changed(self, model, path, iter): def on_emoticons_treemodel_row_changed(self, model, path, iter):
print 'row-changed' iter = model.get_iter_first()
emots = []
while iter:
emots.append(model.get_value(iter, 0))
emots.append(model.get_value(iter, 1))
iter = model.iter_next(iter)
self.plugin.config['emoticons'] = '\t'.join(emots)
self.plugin.roster.mkemoticons()
def on_auto_pop_up_checkbox_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'autopopup', None,\
[self.auto_pp_away_checkbutton])
def on_auto_pop_up_away_checkbox_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'autopopupaway')
def on_soundplayer_entry_changed(self, widget):
self.plugin.config['soundplayer'] = widget.get_text()
def on_prompt_online_status_message_checkbutton_toggled(self, widget): def on_prompt_online_status_message_checkbutton_toggled(self, widget):
"""On Prompt Online Status Message Checkbutton Toggled""" """On Prompt Online Status Message Checkbutton Toggled"""
if widget.get_active(): self.on_checkbutton_toggled(widget, 'ask_online_status')
self.plugin.config['ask_online_status'] = 1
else:
self.plugin.config['ask_online_status'] = 0
def on_prompt_offline_status_message_checkbutton_toggled(self, widget): def on_prompt_offline_status_message_checkbutton_toggled(self, widget):
"""On Prompt Offline Status Message Checkbutton Toggled""" """On Prompt Offline Status Message Checkbutton Toggled"""
if widget.get_active(): self.on_checkbutton_toggled(widget, 'ask_ofline_status')
self.plugin.config['ask_offline_status'] = 1
else:
self.plugin.config['ask_offline_status'] = 0
def write_cfg(self): #FIXME: (nk) instant apply def on_sounds_treemodel_row_changed(self, model, path, iter):
"""Save preferences in config File and apply them"""
#sound player
self.plugin.config['soundplayer'] = \
self.xml.get_widget('entry_soundplayer').get_text()
#sounds
model = self.sound_tree.get_model()
iter = model.get_iter_first() iter = model.get_iter_first()
while iter: while iter:
path = model.get_path(iter) path = model.get_path(iter)
sound_event = model.get_value(iter, 0)
if model[path][1]: if model[path][1]:
self.plugin.config['sound_' + model.get_value(iter, 0)] = 1 self.plugin.config['sound_' + sound_event] = 1
else: else:
self.plugin.config['sound_' + model.get_value(iter, 0)] = 0 self.plugin.config['sound_' + sound_event] = 0
self.plugin.config['sound_' + model.get_value(iter, 0) + '_file'] = \ self.plugin.config['sound_' + sound_event + '_file'] = \
model.get_value(iter, 2) model.get_value(iter, 2)
iter = model.iter_next(iter) iter = model.iter_next(iter)
#autopopup
if self.auto_pp_checkbutton.get_active(): def on_auto_away_checkbutton_toggled(self, widget):
self.plugin.config['autopopup'] = 1 self.on_checkbutton_toggled(widget, 'autoaway', None,\
else: [self.auto_away_time_spinbutton])
self.plugin.config['autopopup'] = 0
#autopopupaway def on_auto_away_time_spinbutton_value_changed(self, widget):
if self.auto_pp_away_checkbutton.get_active(): aat = widget.get_value_as_int()
self.plugin.config['autopopupaway'] = 1
else:
self.plugin.config['autopopupaway'] = 0
#autoaway
if self.auto_away_checkbutton.get_active():
self.plugin.config['autoaway'] = 1
else:
self.plugin.config['autoaway'] = 0
aat = self.auto_away_time_spinbutton.get_value_as_int()
self.plugin.config['autoawaytime'] = aat self.plugin.config['autoawaytime'] = aat
#autoxa self.plugin.sleeper = common.sleepy.Sleepy(\
if self.auto_xa_checkbutton.get_active(): self.plugin.config['autoawaytime']*60, \
self.plugin.config['autoxa'] = 1 self.plugin.config['autoxatime']*60)
else:
self.plugin.config['autoxa'] = 0 def on_auto_xa_checkbutton_toggled(self, widget):
axt = self.auto_xa_time_spinbutton.get_value_as_int() self.on_checkbutton_toggled(widget, 'autoxa', None,\
[self.auto_xa_time_spinbutton])
def on_auto_xa_time_spinbutton_value_changed(self, widget):
axt = widget.get_value_as_int()
self.plugin.config['autoxatime'] = axt self.plugin.config['autoxatime'] = axt
self.plugin.sleeper = common.sleepy.Sleepy(\ self.plugin.sleeper = common.sleepy.Sleepy(\
self.plugin.config['autoawaytime']*60, \ self.plugin.config['autoawaytime']*60, \
self.plugin.config['autoxatime']*60) self.plugin.config['autoxatime']*60)
#Status messages
model = self.msg_tree.get_model() def on_msg_treemodel_row_changed(self, model, path, iter):
iter = model.get_iter_first() iter = model.get_iter_first()
i = 0 i = 0
while iter: while iter:
@ -337,13 +343,45 @@ class preferences_window:
del self.plugin.config['msg%i' % i] del self.plugin.config['msg%i' % i]
i += 1 i += 1
#log presences in user file def on_msg_treemodel_row_deleted(self, model, path, iter):
if self.xml.get_widget('chk_log_pres_usr').get_active(): iter = model.get_iter_first()
i = 0
while iter:
self.plugin.config['msg%i_name' % i] = model.get_value(iter, 0)
self.plugin.config['msg%i' % i] = model.get_value(iter, 1)
iter = model.iter_next(iter)
i += 1
while self.plugin.config.has_key('msg%s_name' % i):
del self.plugin.config['msg%i_name' % i]
del self.plugin.config['msg%i' % i]
i += 1
def on_links_open_with_combobox_changed(self, widget):
if widget.get_active() == 2:
self.xml.get_widget('custom_apps_frame').set_sensitive(True)
self.plugin.config['openwith'] = 'custom'
else:
if widget.get_active() == 0:
self.plugin.config['openwith'] = 'gnome-open'
if widget.get_active() == 1:
self.plugin.config['openwith'] = 'kfmclient exec'
self.xml.get_widget('custom_apps_frame').set_sensitive(False)
def on_custom_browser_entry_changed(self, widget):
self.plugin.config['custombrowser'] = widget.get_text()
def on_custom_mail_client_entry_changed(self, widget):
self.plugin.config['custommailapp'] = widget.get_text()
def on_log_in_contact_checkbutton_toggled(self, widget):
if widget.get_active():
self.config_logger['lognotusr'] = 1 self.config_logger['lognotusr'] = 1
else: else:
self.config_logger['lognotusr'] = 0 self.config_logger['lognotusr'] = 0
#log presences in external file self.plugin.send('CONFIG', None, ('Logger', self.config_logger, 'GtkGui'))
if self.xml.get_widget('chk_log_pres_ext').get_active():
def on_log_in_extern_checkbutton_toggled(self, widget):
if widget.get_active():
self.config_logger['lognotsep'] = 1 self.config_logger['lognotsep'] = 1
else: else:
self.config_logger['lognotsep'] = 0 self.config_logger['lognotsep'] = 0
@ -606,23 +644,6 @@ class preferences_window:
model.set_value(iter, 2, file) model.set_value(iter, 2, file)
model.set_value(iter, 1, 1) model.set_value(iter, 1, 1)
def on_links_open_with_combobox_changed(self, widget):
if widget.get_active() == 2:
self.xml.get_widget('custom_apps_frame').set_sensitive(True)
self.plugin.config['openwith'] = 'custom'
else:
if widget.get_active() == 0:
self.plugin.config['openwith'] = 'gnome-open'
if widget.get_active() == 1:
self.plugin.config['openwith'] = 'kfmclient exec'
self.xml.get_widget('custom_apps_frame').set_sensitive(False)
def on_custom_browser_entry_changed(self, widget):
self.plugin.config['custombrowser'] = widget.get_text()
def on_custom_mail_client_entry_changed(self, widget):
self.plugin.config['custommailapp'] = widget.get_text()
def __init__(self, plugin): def __init__(self, plugin):
"""Initialize Preference window""" """Initialize Preference window"""
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'preferences_window', APP) self.xml = gtk.glade.XML(GTKGUI_GLADE, 'preferences_window', APP)
@ -779,11 +800,11 @@ class preferences_window:
self.auto_pp_away_checkbutton.set_sensitive(self.plugin.config['autopopup']) self.auto_pp_away_checkbutton.set_sensitive(self.plugin.config['autopopup'])
#sound player #sound player
self.xml.get_widget('entry_soundplayer').set_text(\ self.xml.get_widget('soundplayer_entry').set_text(\
self.plugin.config['soundplayer']) self.plugin.config['soundplayer'])
#sounds #sounds
self.sound_tree = self.xml.get_widget('treeview_sounds') self.sound_tree = self.xml.get_widget('sounds_treeview')
model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN, \ model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN, \
gobject.TYPE_STRING) gobject.TYPE_STRING)
self.sound_tree.set_model(model) self.sound_tree.set_model(model)
@ -810,10 +831,10 @@ class preferences_window:
self.fill_sound_treeview() self.fill_sound_treeview()
if not os.name == 'posix': if not os.name == 'posix':
self.xml.get_widget('entry_soundplayer').set_sensitive(False) self.xml.get_widget('soundplayer_entry').set_sensitive(False)
self.sound_tree.set_sensitive(False) self.sound_tree.set_sensitive(False)
self.xml.get_widget('entry_sounds').set_sensitive(False) self.xml.get_widget('sounds_entry').set_sensitive(False)
self.xml.get_widget('button_sounds').set_sensitive(False) self.xml.get_widget('sounds_button').set_sensitive(False)
#Autoaway #Autoaway
st = self.plugin.config['autoaway'] st = self.plugin.config['autoaway']
@ -856,24 +877,6 @@ class preferences_window:
buf = self.xml.get_widget('msg_textview').get_buffer() buf = self.xml.get_widget('msg_textview').get_buffer()
buf.connect('changed', self.on_msg_textview_changed) buf.connect('changed', self.on_msg_textview_changed)
self.xml.signal_connect('on_auto_pop_up_checkbox_toggled', \
self.on_checkbutton_toggled, 'autopopup', None,\
[self.auto_pp_away_checkbutton])
self.xml.signal_connect('on_auto_away_checkbutton_toggled', \
self.on_checkbutton_toggled, 'autopopupaway', None,\
[self.auto_away_time_spinbutton])
self.xml.signal_connect('on_auto_xa_checkbutton_toggled', \
self.on_checkbutton_toggled, 'autoxa', None,\
[self.auto_xa_time_spinbutton])
self.xml.signal_connect('on_use_emoticons_checkbutton_toggled', \
self.on_checkbutton_toggled, 'useemoticons', \
self.on_use_emoticons_checkbutton_function, \
[self.xml.get_widget('button_new_emoticon'),
self.xml.get_widget('button_remove_emoticon'),
self.xml.get_widget('treeview_emoticons'),
self.xml.get_widget('set_image_button'),
self.xml.get_widget('emoticons_image')])
self.plugin.send('ASK_CONFIG', None, ('GtkGui', 'Logger', {'lognotsep':1,\ self.plugin.send('ASK_CONFIG', None, ('GtkGui', 'Logger', {'lognotsep':1,\
'lognotusr':1})) 'lognotusr':1}))
self.config_logger = self.plugin.wait('CONFIG') self.config_logger = self.plugin.wait('CONFIG')
@ -894,14 +897,22 @@ class preferences_window:
#log presences in user file #log presences in user file
st = self.config_logger['lognotusr'] st = self.config_logger['lognotusr']
self.xml.get_widget('chk_log_pres_usr').set_active(st) self.xml.get_widget('log_in_contact_checkbutton').set_active(st)
#log presences in external file #log presences in external file
st = self.config_logger['lognotsep'] st = self.config_logger['lognotsep']
self.xml.get_widget('chk_log_pres_ext').set_active(st) self.xml.get_widget('log_in_extern_checkbutton').set_active(st)
self.emot_tree.get_model().connect('row-changed', \ self.emot_tree.get_model().connect('row-changed', \
self.on_emoticons_treeview_row_changed) self.on_emoticons_treemodel_row_changed)
self.emot_tree.get_model().connect('row-deleted', \
self.on_emoticons_treemodel_row_deleted)
self.sound_tree.get_model().connect('row-changed', \
self.on_sounds_treemodel_row_changed)
self.msg_tree.get_model().connect('row-changed', \
self.on_msg_treemodel_row_changed)
self.msg_tree.get_model().connect('row-deleted', \
self.on_msg_treemodel_row_deleted)
self.xml.signal_autoconnect(self) self.xml.signal_autoconnect(self)

View File

@ -4424,6 +4424,7 @@ on the server as a vCard</property>
<property name="active">False</property> <property name="active">False</property>
<property name="inconsistent">False</property> <property name="inconsistent">False</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<signal name="toggled" handler="on_auto_pop_up_away_checkbutton_toggled" last_modification_time="Tue, 08 Mar 2005 22:51:08 GMT"/>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>
@ -4435,6 +4436,7 @@ on the server as a vCard</property>
<child> <child>
<widget class="GtkCheckButton" id="ignore_events_from_contacts_not_in_roster_checkbutton"> <widget class="GtkCheckButton" id="ignore_events_from_contacts_not_in_roster_checkbutton">
<property name="visible">True</property> <property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="label" translatable="yes">_Ignore events from contacts not in your roster</property> <property name="label" translatable="yes">_Ignore events from contacts not in your roster</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
@ -4482,7 +4484,7 @@ on the server as a vCard</property>
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
<property name="xpad">0</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
<property name="mnemonic_widget">entry_soundplayer</property> <property name="mnemonic_widget">soundplayer_entry</property>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>
@ -4492,7 +4494,7 @@ on the server as a vCard</property>
</child> </child>
<child> <child>
<widget class="GtkEntry" id="entry_soundplayer"> <widget class="GtkEntry" id="soundplayer_entry">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="editable">True</property> <property name="editable">True</property>
@ -4502,6 +4504,7 @@ on the server as a vCard</property>
<property name="has_frame">True</property> <property name="has_frame">True</property>
<property name="invisible_char">*</property> <property name="invisible_char">*</property>
<property name="activates_default">False</property> <property name="activates_default">False</property>
<signal name="changed" handler="on_soundplayer_entry_changed" last_modification_time="Tue, 08 Mar 2005 22:59:53 GMT"/>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>
@ -4527,7 +4530,7 @@ on the server as a vCard</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property> <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child> <child>
<widget class="GtkTreeView" id="treeview_sounds"> <widget class="GtkTreeView" id="sounds_treeview">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="headers_visible">True</property> <property name="headers_visible">True</property>
@ -4552,7 +4555,7 @@ on the server as a vCard</property>
<property name="spacing">5</property> <property name="spacing">5</property>
<child> <child>
<widget class="GtkEntry" id="entry_sounds"> <widget class="GtkEntry" id="sounds_entry">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="editable">True</property> <property name="editable">True</property>
@ -4571,7 +4574,7 @@ on the server as a vCard</property>
</child> </child>
<child> <child>
<widget class="GtkButton" id="button_sounds"> <widget class="GtkButton" id="sounds_button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="label" translatable="yes">...</property> <property name="label" translatable="yes">...</property>
@ -4784,6 +4787,7 @@ on the server as a vCard</property>
<property name="snap_to_ticks">False</property> <property name="snap_to_ticks">False</property>
<property name="wrap">False</property> <property name="wrap">False</property>
<property name="adjustment">12 1 100 1 10 10</property> <property name="adjustment">12 1 100 1 10 10</property>
<signal name="value_changed" handler="on_auto_away_time_spinbutton_value_changed" last_modification_time="Wed, 09 Mar 2005 09:46:53 GMT"/>
</widget> </widget>
</child> </child>
</widget> </widget>
@ -4821,6 +4825,7 @@ on the server as a vCard</property>
<property name="snap_to_ticks">False</property> <property name="snap_to_ticks">False</property>
<property name="wrap">False</property> <property name="wrap">False</property>
<property name="adjustment">20 1 100 1 10 10</property> <property name="adjustment">20 1 100 1 10 10</property>
<signal name="value_changed" handler="on_auto_xa_time_spinbutton_value_changed" last_modification_time="Wed, 09 Mar 2005 09:46:59 GMT"/>
</widget> </widget>
</child> </child>
</widget> </widget>
@ -5459,7 +5464,7 @@ Custom</property>
<property name="spacing">0</property> <property name="spacing">0</property>
<child> <child>
<widget class="GtkCheckButton" id="chk_log_pres_usr"> <widget class="GtkCheckButton" id="log_in_contact_checkbutton">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="label" translatable="yes">Log presences in _contact's log file</property> <property name="label" translatable="yes">Log presences in _contact's log file</property>
@ -5469,6 +5474,7 @@ Custom</property>
<property name="active">False</property> <property name="active">False</property>
<property name="inconsistent">False</property> <property name="inconsistent">False</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<signal name="toggled" handler="on_log_in_contact_checkbutton_toggled" last_modification_time="Tue, 08 Mar 2005 23:21:11 GMT"/>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>
@ -5478,7 +5484,7 @@ Custom</property>
</child> </child>
<child> <child>
<widget class="GtkCheckButton" id="chk_log_pres_ext"> <widget class="GtkCheckButton" id="log_in_extern_checkbutton">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="label" translatable="yes">Log presences in an _external file</property> <property name="label" translatable="yes">Log presences in an _external file</property>
@ -5488,6 +5494,7 @@ Custom</property>
<property name="active">False</property> <property name="active">False</property>
<property name="inconsistent">False</property> <property name="inconsistent">False</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<signal name="toggled" handler="on_log_in_extern_checkbutton_toggled" last_modification_time="Tue, 08 Mar 2005 23:27:49 GMT"/>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>