Commit 55694b60 authored by Philipp Hörist's avatar Philipp Hörist

Dont save Gajim settings in bookmarks

- Remove print status from bookmarks
- Remove minimize on join from bookmarks
- Add options to the groupchat menu for both settings

Fixes #9463
parent 4c17b55a
Pipeline #2929 failed with stages
in 3 minutes and 20 seconds
...@@ -1065,24 +1065,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): ...@@ -1065,24 +1065,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
return return
_on_ok(self.contact) _on_ok(self.contact)
def on_minimize_menuitem_toggled(self, widget):
"""
When a groupchat is minimized, unparent the tab, put it in roster etc
"""
old_value = True
non_minimized_gc = app.config.get_per('accounts', self.account,
'non_minimized_gc').split()
if self.contact.jid in non_minimized_gc:
old_value = False
minimize = widget.get_active()
if not minimize and not self.contact.jid in non_minimized_gc:
non_minimized_gc.append(self.contact.jid)
if minimize and self.contact.jid in non_minimized_gc:
non_minimized_gc.remove(self.contact.jid)
if old_value != minimize:
app.config.set_per('accounts', self.account, 'non_minimized_gc',
' '.join(non_minimized_gc))
def on_notify_menuitem_toggled(self, widget): def on_notify_menuitem_toggled(self, widget):
app.config.set_per('rooms', self.contact.jid, 'notify_on_all_messages', app.config.set_per('rooms', self.contact.jid, 'notify_on_all_messages',
widget.get_active()) widget.get_active())
......
...@@ -346,7 +346,6 @@ class Config: ...@@ -346,7 +346,6 @@ class Config:
'no_log_for': [opt_str, '', _('Space separated list of JIDs for which you do not want to store logs. You can also add account name to log nothing for this account.')], 'no_log_for': [opt_str, '', _('Space separated list of JIDs for which you do not want to store logs. You can also add account name to log nothing for this account.')],
'sync_logs_with_server': [opt_bool, True, _('On startup, Gajim will download logs stored on server, provided the server supports XEP-0313')], 'sync_logs_with_server': [opt_bool, True, _('On startup, Gajim will download logs stored on server, provided the server supports XEP-0313')],
'allow_no_log_for': [opt_str, '', _('Space separated list of JIDs for which you accept to not log conversations if he does not want to.')], 'allow_no_log_for': [opt_str, '', _('Space separated list of JIDs for which you accept to not log conversations if he does not want to.')],
'non_minimized_gc': [opt_str, ''],
'attached_gpg_keys': [opt_str, ''], 'attached_gpg_keys': [opt_str, ''],
'keep_alives_enabled': [opt_bool, True, _('Whitespace sent after inactivity')], 'keep_alives_enabled': [opt_bool, True, _('Whitespace sent after inactivity')],
'ping_alives_enabled': [opt_bool, True, _('XMPP ping sent after inactivity')], 'ping_alives_enabled': [opt_bool, True, _('XMPP ping sent after inactivity')],
...@@ -442,6 +441,8 @@ class Config: ...@@ -442,6 +441,8 @@ class Config:
'notify_on_all_messages': [opt_bool, False, _('State whether a notification is created for every message in this room')], 'notify_on_all_messages': [opt_bool, False, _('State whether a notification is created for every message in this room')],
'print_status': [opt_bool, False, _('Show a status message for all status (away, dnd, etc.) changes of users in a group chat')], 'print_status': [opt_bool, False, _('Show a status message for all status (away, dnd, etc.) changes of users in a group chat')],
'print_join_left': [opt_bool, False, _('Show a status message for every join or leave in a group chat')], 'print_join_left': [opt_bool, False, _('Show a status message for every join or leave in a group chat')],
'minimize_on_autojoin': [opt_bool, True, _('If the group chat is minimized into the roster on autojoin')],
'minimize_on_close': [opt_bool, True, _('If the group chat is minimized into the roster on close')],
}, {}), }, {}),
'plugins': ({ 'plugins': ({
'active': [opt_bool, False, _('State whether plugins should be activated on startup (this is saved on Gajim exit). This option SHOULD NOT be used to (de)activate plug-ins. Use GUI instead.')], 'active': [opt_bool, False, _('State whether plugins should be activated on startup (this is saved on Gajim exit). This option SHOULD NOT be used to (de)activate plug-ins. Use GUI instead.')],
......
...@@ -39,8 +39,6 @@ from gajim.common.modules.util import to_xs_boolean ...@@ -39,8 +39,6 @@ from gajim.common.modules.util import to_xs_boolean
log = logging.getLogger('gajim.c.m.bookmarks') log = logging.getLogger('gajim.c.m.bookmarks')
NS_GAJIM_BM = 'xmpp:gajim.org/bookmarks'
class BookmarksData(AbstractPEPData): class BookmarksData(AbstractPEPData):
...@@ -222,18 +220,6 @@ class Bookmarks(AbstractPEPModule): ...@@ -222,18 +220,6 @@ class Bookmarks(AbstractPEPModule):
if not autojoin_val: # not there (it's optional) if not autojoin_val: # not there (it's optional)
autojoin_val = False autojoin_val = False
minimize_val = conf.getTag('minimize', namespace=NS_GAJIM_BM)
if not minimize_val:
minimize_val = False
else:
minimize_val = minimize_val.getData()
print_status = conf.getTag('print_status', namespace=NS_GAJIM_BM)
if not print_status: # not there, try old Gajim behaviour
print_status = None
else:
print_status = print_status.getData()
try: try:
jid = helpers.parse_jid(conf.getAttr('jid')) jid = helpers.parse_jid(conf.getAttr('jid'))
except helpers.InvalidFormat: except helpers.InvalidFormat:
...@@ -245,12 +231,10 @@ class Bookmarks(AbstractPEPModule): ...@@ -245,12 +231,10 @@ class Bookmarks(AbstractPEPModule):
'name': conf.getAttr('name'), 'name': conf.getAttr('name'),
'password': conf.getTagData('password'), 'password': conf.getTagData('password'),
'nick': conf.getTagData('nick'), 'nick': conf.getTagData('nick'),
'print_status': print_status
} }
try: try:
bookmark['autojoin'] = from_xs_boolean(autojoin_val) bookmark['autojoin'] = from_xs_boolean(autojoin_val)
bookmark['minimize'] = from_xs_boolean(minimize_val)
except ValueError as error: except ValueError as error:
log.warning(error) log.warning(error)
continue continue
...@@ -269,8 +253,6 @@ class Bookmarks(AbstractPEPModule): ...@@ -269,8 +253,6 @@ class Bookmarks(AbstractPEPModule):
conf_node.setAttr('jid', jid) conf_node.setAttr('jid', jid)
conf_node.setAttr('autojoin', to_xs_boolean(bm['autojoin'])) conf_node.setAttr('autojoin', to_xs_boolean(bm['autojoin']))
conf_node.setAttr('name', bm['name']) conf_node.setAttr('name', bm['name'])
conf_node.setTag('minimize', namespace=NS_GAJIM_BM).setData(
to_xs_boolean(bm['minimize']))
# Only add optional elements if not empty # Only add optional elements if not empty
# Note: need to handle both None and '' as empty # Note: need to handle both None and '' as empty
# thus shouldn't use "is not None" # thus shouldn't use "is not None"
...@@ -278,10 +260,6 @@ class Bookmarks(AbstractPEPModule): ...@@ -278,10 +260,6 @@ class Bookmarks(AbstractPEPModule):
conf_node.setTagData('nick', bm['nick']) conf_node.setTagData('nick', bm['nick'])
if bm.get('password', None): if bm.get('password', None):
conf_node.setTagData('password', bm['password']) conf_node.setTagData('password', bm['password'])
if bm.get('print_status', None):
conf_node.setTag(
'print_status',
namespace=NS_GAJIM_BM).setData(bm['print_status'])
return storage_node return storage_node
def _build_node(self, _data): def _build_node(self, _data):
...@@ -351,19 +329,21 @@ class Bookmarks(AbstractPEPModule): ...@@ -351,19 +329,21 @@ class Bookmarks(AbstractPEPModule):
if jid not in app.gc_connected[self._account]: if jid not in app.gc_connected[self._account]:
# we are not already connected # we are not already connected
log.info('Autojoin Bookmark: %s', jid) log.info('Autojoin Bookmark: %s', jid)
minimize = app.config.get_per('rooms', jid,
'minimize_on_autojoin', True)
print(minimize)
app.interface.join_gc_room( app.interface.join_gc_room(
self._account, jid, bookmark['nick'], self._account, jid, bookmark['nick'],
bookmark['password'], minimize=bookmark['minimize']) bookmark['password'], minimize=minimize)
def add_bookmark(self, name, jid, autojoin, def add_bookmark(self, name, jid, autojoin, password, nick):
minimize, password, nick):
self.bookmarks[jid] = { self.bookmarks[jid] = {
'name': name, 'name': name,
'autojoin': autojoin, 'autojoin': autojoin,
'minimize': minimize,
'password': password, 'password': password,
'nick': nick, 'nick': nick,
'print_status': None} }
self.store_bookmarks() self.store_bookmarks()
app.nec.push_incoming_event( app.nec.push_incoming_event(
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0 --> <!-- Generated with glade 3.22.1 -->
<interface> <interface>
<requires lib="gtk+" version="3.18"/> <requires lib="gtk+" version="3.18"/>
<object class="GtkListStore" id="liststore1"> <object class="GtkListStore" id="liststore1">
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
<property name="default_height">300</property> <property name="default_height">300</property>
<property name="type_hint">dialog</property> <property name="type_hint">dialog</property>
<signal name="key-press-event" handler="on_key_press_event" swapped="no"/> <signal name="key-press-event" handler="on_key_press_event" swapped="no"/>
<child type="titlebar">
<placeholder/>
</child>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
...@@ -31,7 +34,7 @@ ...@@ -31,7 +34,7 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkScrolledWindow" id="scrolledwindow37"> <object class="GtkScrolledWindow">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="shadow_type">in</property> <property name="shadow_type">in</property>
...@@ -324,95 +327,6 @@ ...@@ -324,95 +327,6 @@
</child> </child>
</object> </object>
</child> </child>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Minimize on Auto Join</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="minimize_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<signal name="state-set" handler="on_minimize_checkbutton_toggled" 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>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Status messages displayed in chat window</property>
<property name="valign">center</property>
<property name="spacing">18</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Status Messages</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="print_status_combobox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="model">liststore1</property>
<signal name="changed" handler="on_print_status_combobox_changed" swapped="no"/>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</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>
</child>
</object>
</child>
<style> <style>
<class name="settings"/> <class name="settings"/>
</style> </style>
...@@ -481,8 +395,5 @@ ...@@ -481,8 +395,5 @@
</child> </child>
</object> </object>
</child> </child>
<child type="titlebar">
<placeholder/>
</child>
</object> </object>
</interface> </interface>
...@@ -375,14 +375,22 @@ class GroupchatControl(ChatControlBase): ...@@ -375,14 +375,22 @@ class GroupchatControl(ChatControlBase):
act.connect("activate", func) act.connect("activate", func)
self.parent_win.window.add_action(act) self.parent_win.window.add_action(act)
non_minimized_gc = app.config.get_per( minimize = app.config.get_per(
'accounts', self.account, 'non_minimized_gc').split() 'rooms', self.contact.jid, 'minimize_on_close', True)
value = self.contact.jid not in non_minimized_gc
act = Gio.SimpleAction.new_stateful( act = Gio.SimpleAction.new_stateful(
'minimize-' + self.control_id, None, 'minimize-on-close-' + self.control_id, None,
GLib.Variant.new_boolean(value)) GLib.Variant.new_boolean(minimize))
act.connect('change-state', self._on_minimize) act.connect('change-state', self._on_minimize_on_close)
self.parent_win.window.add_action(act)
minimize = app.config.get_per(
'rooms', self.contact.jid, 'minimize_on_autojoin', True)
act = Gio.SimpleAction.new_stateful(
'minimize-on-autojoin-' + self.control_id, None,
GLib.Variant.new_boolean(minimize))
act.connect('change-state', self._on_minimize_on_autojoin)
self.parent_win.window.add_action(act) self.parent_win.window.add_action(act)
# Enable notify on all for private rooms # Enable notify on all for private rooms
...@@ -684,7 +692,6 @@ class GroupchatControl(ChatControlBase): ...@@ -684,7 +692,6 @@ class GroupchatControl(ChatControlBase):
con.get_module('Bookmarks').add_bookmark(self.name, con.get_module('Bookmarks').add_bookmark(self.name,
self.room_jid, self.room_jid,
True, True,
True,
password, password,
self.nick) self.nick)
self.update_actions() self.update_actions()
...@@ -696,22 +703,15 @@ class GroupchatControl(ChatControlBase): ...@@ -696,22 +703,15 @@ class GroupchatControl(ChatControlBase):
con = app.connections[self.account] con = app.connections[self.account]
con.get_module('MUC').request_voice(self.room_jid) con.get_module('MUC').request_voice(self.room_jid)
def _on_minimize(self, action, param): def _on_minimize_on_close(self, action, param):
"""
When a groupchat is minimized, unparent the tab, put it in roster etc
"""
action.set_state(param) action.set_state(param)
non_minimized_gc = app.config.get_per( minimize = app.config.set_per(
'accounts', self.account, 'non_minimized_gc').split() 'rooms', self.contact.jid, 'minimize_on_close', param.get_boolean())
minimize = param.get_boolean()
if minimize:
non_minimized_gc.remove(self.contact.jid)
else:
non_minimized_gc.append(self.contact.jid)
app.config.set_per('accounts', self.account, def _on_minimize_on_autojoin(self, action, param):
'non_minimized_gc', ' '.join(non_minimized_gc)) action.set_state(param)
minimize = app.config.set_per(
'rooms', self.contact.jid, 'minimize_on_autojoin', param.get_boolean())
def _on_notify_on_all_messages(self, action, param): def _on_notify_on_all_messages(self, action, param):
action.set_state(param) action.set_state(param)
...@@ -2310,10 +2310,8 @@ class GroupchatControl(ChatControlBase): ...@@ -2310,10 +2310,8 @@ class GroupchatControl(ChatControlBase):
def minimizable(self): def minimizable(self):
if self.force_non_minimizable: if self.force_non_minimizable:
return False return False
if self.contact.jid not in app.config.get_per('accounts', self.account, return app.config.get_per('rooms', self.contact.jid,
'non_minimized_gc').split(' '): 'minimize_on_close', True)
return True
return False
def minimize(self, status='offline'): def minimize(self, status='offline'):
# Minimize it # Minimize it
......
This diff is collapsed.
...@@ -1717,7 +1717,6 @@ class MucBrowser(AgentBrowser): ...@@ -1717,7 +1717,6 @@ class MucBrowser(AgentBrowser):
con.get_module('Bookmarks').add_bookmark(room_jid.split('@')[0], con.get_module('Bookmarks').add_bookmark(room_jid.split('@')[0],
room_jid, room_jid,
False, False,
False,
'' ''
'') '')
......
...@@ -266,7 +266,6 @@ class JoinGroupchatWindow(Gtk.ApplicationWindow): ...@@ -266,7 +266,6 @@ class JoinGroupchatWindow(Gtk.ApplicationWindow):
con.get_module('Bookmarks').add_bookmark(name, con.get_module('Bookmarks').add_bookmark(name,
self.room_jid, self.room_jid,
autojoin, autojoin,
True,
password, password,
nickname) nickname)
......
...@@ -663,7 +663,8 @@ def get_groupchat_menu(control_id, account, jid): ...@@ -663,7 +663,8 @@ def get_groupchat_menu(control_id, account, jid):
('win.print-join-left-', _('Show join/leave')), ('win.print-join-left-', _('Show join/leave')),
('win.print-status-', _('Show status changes')), ('win.print-status-', _('Show status changes')),
('win.notify-on-message-', _('Notify on all messages')), ('win.notify-on-message-', _('Notify on all messages')),
('win.minimize-', _('Minimize on close')), ('win.minimize-on-close-', _('Minimize on close')),
('win.minimize-on-autojoin-', _('Minimize on autojoin')),
]), ]),
(_('Sync Threshold'), []), (_('Sync Threshold'), []),
('win.change-nick-', _('Change Nick')), ('win.change-nick-', _('Change Nick')),
......
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