make pep work, move config options per account, make publish_tune configurable in account context menu. fixes #3954
This commit is contained in:
parent
ac8faf47ca
commit
533e955cf1
5 changed files with 57 additions and 40 deletions
|
@ -248,14 +248,6 @@ class Config:
|
|||
'use_latex': [opt_bool, False, _('If True, Gajim will convert string between $$ and $$ to an image using dvips and convert before insterting it in chat window.')],
|
||||
'change_status_window_timeout': [opt_int, 15, _('Time of inactivity needed before the change status window closes down.')],
|
||||
'max_conversation_lines': [opt_int, 500, _('Maximum number of lines that are printed in conversations. Oldest lines are cleared.')],
|
||||
'publish_mood': [opt_bool, False],
|
||||
'publish_activity': [opt_bool, False],
|
||||
'publish_tune': [opt_bool, False],
|
||||
'publish_nick': [opt_bool, True],
|
||||
'subscribe_mood': [opt_bool, True],
|
||||
'subscribe_activity': [opt_bool, True],
|
||||
'subscribe_tune': [opt_bool, True],
|
||||
'subscribe_nick': [opt_bool, True],
|
||||
'attach_notifications_to_systray': [opt_bool, False, _('If True, notification windows from notification-daemon will be attached to systray icon.')],
|
||||
'check_idle_every_foo_seconds': [opt_int, 2, _('Choose interval between 2 checks of idleness.')],
|
||||
}
|
||||
|
@ -319,6 +311,14 @@ class Config:
|
|||
'zeroconf_email': [ opt_str, '', '', True ],
|
||||
'use_env_http_proxy' : [opt_bool, False],
|
||||
'otr_flags': [opt_int, 58 ],
|
||||
'publish_mood': [opt_bool, True],
|
||||
'publish_activity': [opt_bool, True],
|
||||
'publish_tune': [opt_bool, True],
|
||||
'publish_nick': [opt_bool, True],
|
||||
'subscribe_mood': [opt_bool, True],
|
||||
'subscribe_activity': [opt_bool, True],
|
||||
'subscribe_tune': [opt_bool, True],
|
||||
'subscribe_nick': [opt_bool, True],
|
||||
}, {}),
|
||||
'statusmsg': ({
|
||||
'message': [ opt_str, '' ],
|
||||
|
|
|
@ -819,7 +819,8 @@ class ConnectionDisco:
|
|||
if dbus_support.supported:
|
||||
listener = MusicTrackListener.get()
|
||||
track = listener.get_playing_track()
|
||||
if gajim.config.get('publish_tune'):
|
||||
if gajim.config.get_per('accounts', self.name,
|
||||
'publish_tune'):
|
||||
gajim.interface.roster.music_track_changed(listener,
|
||||
track, self.name)
|
||||
break
|
||||
|
|
|
@ -254,7 +254,7 @@ def user_nickname(items, name, jid):
|
|||
contact.contact_name = ''
|
||||
|
||||
def user_send_mood(account, mood, message = ''):
|
||||
if not gajim.config.get('publish_mood'):
|
||||
if not gajim.config.get_per('accounts', account, 'publish_mood'):
|
||||
return
|
||||
item = xmpp.Node('mood', {'xmlns': xmpp.NS_MOOD})
|
||||
if mood != '':
|
||||
|
@ -266,7 +266,7 @@ def user_send_mood(account, mood, message = ''):
|
|||
gajim.connections[account].send_pb_publish('', xmpp.NS_MOOD, item, '0')
|
||||
|
||||
def user_send_activity(account, activity, subactivity = '', message = ''):
|
||||
if not gajim.config.get('publish_activity'):
|
||||
if not gajim.config.get_per('accounts', account, 'publish_activity'):
|
||||
return
|
||||
item = xmpp.Node('activity', {'xmlns': xmpp.NS_ACTIVITY})
|
||||
if activity != '':
|
||||
|
@ -280,7 +280,7 @@ def user_send_activity(account, activity, subactivity = '', message = ''):
|
|||
gajim.connections[account].send_pb_publish('', xmpp.NS_ACTIVITY, item, '0')
|
||||
|
||||
def user_send_tune(account, artist = '', title = '', source = '', track = 0,length = 0, items = None):
|
||||
if not (gajim.config.get('publish_tune') and \
|
||||
if not (gajim.config.get_per('accounts', account, 'publish_tune') and \
|
||||
gajim.connections[account].pep_supported):
|
||||
return
|
||||
item = xmpp.Node('tune', {'xmlns': xmpp.NS_TUNE})
|
||||
|
@ -305,7 +305,7 @@ def user_send_tune(account, artist = '', title = '', source = '', track = 0,leng
|
|||
gajim.connections[account].send_pb_publish('', xmpp.NS_TUNE, item, '0')
|
||||
|
||||
def user_send_nickname(account, nick):
|
||||
if not (gajim.config.get('publish_nick') and \
|
||||
if not (gajim.config.get_per('accounts', account, 'publish_nick') and \
|
||||
gajim.connections[account].pep_supported):
|
||||
return
|
||||
item = xmpp.Node('nick', {'xmlns': xmpp.NS_NICK})
|
||||
|
|
|
@ -3260,8 +3260,6 @@ class Interface:
|
|||
if gajim.config.get('autodetect_browser_mailer') or not cfg_was_read:
|
||||
gtkgui_helpers.autodetect_browser_mailer()
|
||||
|
||||
helpers.update_optional_features()
|
||||
|
||||
if gajim.verbose:
|
||||
gajim.log.setLevel(gajim.logging.DEBUG)
|
||||
else:
|
||||
|
@ -3317,6 +3315,8 @@ class Interface:
|
|||
gajim.gajim_optional_features[a] = []
|
||||
gajim.caps_hash[a] = ''
|
||||
|
||||
helpers.update_optional_features()
|
||||
|
||||
if gajim.config.get('remote_control'):
|
||||
try:
|
||||
import remote_control
|
||||
|
|
|
@ -3161,23 +3161,31 @@ class RosterWindow:
|
|||
else:
|
||||
gajim.interface.instances['preferences'] = config.PreferencesWindow()
|
||||
|
||||
def on_publish_tune_checkbutton_toggled(self, widget, account):
|
||||
if widget.get_active():
|
||||
listener = MusicTrackListener.get()
|
||||
self.music_track_changed_signal = listener.connect(
|
||||
'music-track-changed', gajim.interface.roster.music_track_changed)
|
||||
track = listener.get_playing_track()
|
||||
self.music_track_changed(listener, track)
|
||||
def on_publish_tune_toggled(self, widget, account):
|
||||
act = widget.get_active()
|
||||
gajim.config.set_per('accounts', account, 'publish_tune', act)
|
||||
if act:
|
||||
if not self.music_track_changed_signal:
|
||||
listener = MusicTrackListener.get()
|
||||
self.music_track_changed_signal = listener.connect(
|
||||
'music-track-changed', self.music_track_changed)
|
||||
track = listener.get_playing_track()
|
||||
self.music_track_changed(listener, track)
|
||||
else:
|
||||
self.music_track_changed_signal = None
|
||||
# disable it only if no other account use it
|
||||
for acct in gajim.connections:
|
||||
if gajim.config.get_per('accounts', acct, 'publish_tune'):
|
||||
break
|
||||
else:
|
||||
listener = MusicTrackListener.get()
|
||||
listener.disconnect(self.music_track_changed_signal)
|
||||
self.music_track_changed_signal = None
|
||||
|
||||
for account in gajim.connections:
|
||||
if gajim.connections[account].pep_supported:
|
||||
# As many implementations don't support retracting items, we send a "Stopped" event first
|
||||
pep.user_send_tune(account, '')
|
||||
pep.user_retract_tune(account)
|
||||
#TODO:
|
||||
#self.on_checkbutton_toggled(widget, 'publish_tune')
|
||||
if gajim.connections[account].pep_supported:
|
||||
# As many implementations don't support retracting items, we send a
|
||||
# "Stopped" event first
|
||||
pep.user_send_tune(account, '')
|
||||
pep.user_retract_tune(account)
|
||||
helpers.update_optional_features(account)
|
||||
|
||||
def on_pep_services_menuitem_activate(self, widget, account):
|
||||
|
@ -4533,11 +4541,18 @@ class RosterWindow:
|
|||
|
||||
pep_menuitem = xml.get_widget('pep_menuitem')
|
||||
if gajim.connections[account].pep_supported:
|
||||
have_mood = gajim.config.get('publish_mood')
|
||||
have_activity = gajim.config.get('publish_activity')
|
||||
have_tune = gajim.config.get('publish_tune')
|
||||
have_mood = gajim.config.get_per('accounts', account,
|
||||
'publish_mood')
|
||||
have_activity = gajim.config.get_per('accounts', account,
|
||||
'publish_activity')
|
||||
have_tune = gajim.config.get_per('accounts', account,
|
||||
'publish_tune')
|
||||
pep_submenu = gtk.Menu()
|
||||
pep_menuitem.set_submenu(pep_submenu)
|
||||
item = gtk.CheckMenuItem(_('Publish Tune'))
|
||||
pep_submenu.append(item)
|
||||
item.set_active(have_tune)
|
||||
item.connect('toggled', self.on_publish_tune_toggled, account)
|
||||
if have_mood:
|
||||
item = gtk.MenuItem(_('Mood'))
|
||||
pep_submenu.append(item)
|
||||
|
@ -5933,13 +5948,14 @@ class RosterWindow:
|
|||
self.tooltip = tooltips.RosterTooltip()
|
||||
self.draw_roster()
|
||||
|
||||
publish_tune = gajim.config.get('publish_tune')
|
||||
if publish_tune:
|
||||
listener = MusicTrackListener.get()
|
||||
self.music_track_changed_signal = listener.connect(
|
||||
'music-track-changed', self.music_track_changed)
|
||||
track = listener.get_playing_track()
|
||||
self.music_track_changed(listener, track)
|
||||
for account in gajim.connections:
|
||||
if gajim.config.get_per('accounts', account, 'publish_tune'):
|
||||
listener = MusicTrackListener.get()
|
||||
self.music_track_changed_signal = listener.connect(
|
||||
'music-track-changed', self.music_track_changed)
|
||||
track = listener.get_playing_track()
|
||||
self.music_track_changed(listener, track)
|
||||
break
|
||||
|
||||
if gajim.config.get('show_roster_on_startup'):
|
||||
self.window.show_all()
|
||||
|
|
Loading…
Add table
Reference in a new issue