Commit 990a35f9 authored by Philipp Hörist's avatar Philipp Hörist

MUC: Add option for showing the subject on join

parent fd232ce6
......@@ -296,6 +296,7 @@ class Config:
'threshold_options': [opt_str, '1, 2, 4, 10, 0', _('Options in days which can be chosen in the sync threshold menu'), True],
'public_room_sync_threshold': [opt_int, 1, _('Maximum history in days we request from a public room archive. 0: As much as possible')],
'private_room_sync_threshold': [opt_int, 0, _('Maximum history in days we request from a private room archive. 0: As much as possible')],
'show_subject_on_join': [opt_bool, True, _('If the room subject is shown in chat on join')],
}, {}) # type: Tuple[Dict[str, List[Any]], Dict[Any, Any]]
__options_per_key = {
......
......@@ -401,7 +401,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>
......@@ -498,6 +498,21 @@
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="subject_on_join">
<property name="label" translatable="yes">Show subject after joining a group chat</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_subject_on_join_toggled" swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
<property name="width">2</property>
</packing>
</child>
</object>
</child>
<child type="label">
......
......@@ -297,6 +297,7 @@ class GroupchatControl(ChatControlBase):
self.force_non_minimizable = False
self.is_continued = is_continued
self.is_anonymous = True
self.join_time = 0
# Controls the state of autorejoin.
# None - autorejoin is neutral.
......@@ -1546,7 +1547,10 @@ class GroupchatControl(ChatControlBase):
date = time.strftime('%d-%m-%Y %H:%M:%S',
time.localtime(event.timestamp))
text = '%s - %s' % (text, date)
self.print_conversation(text)
just_joined = self.join_time > time.time() - 10
if app.config.get('show_subject_on_join') or not just_joined:
self.print_conversation(text)
if event.subject == '':
self.subject_button.hide()
......@@ -1643,6 +1647,7 @@ class GroupchatControl(ChatControlBase):
app.gc_connected[self.account][self.room_jid] = value
def got_connected(self):
self.join_time = time.time()
# Make autorejoin stop.
if self.autorejoin:
GLib.source_remove(self.autorejoin)
......
......@@ -142,6 +142,9 @@ class Preferences(Gtk.ApplicationWindow):
st = app.config.get('positive_184_ack')
self.xml.get_object('positive_184_ack_checkbutton').set_active(st)
st = app.config.get('show_subject_on_join')
self.xml.get_object('subject_on_join').set_active(st)
# Show avatar in tabs
st = app.config.get('show_avatar_in_tabs')
self.xml.get_object('show_avatar_in_tabs_checkbutton').set_active(st)
......@@ -500,6 +503,9 @@ class Preferences(Gtk.ApplicationWindow):
return 'mixed'
return val
def on_subject_on_join_toggled(self, widget):
app.config.set('show_subject_on_join', widget.get_active())
def on_checkbutton_toggled(self, widget, config_name,
change_sensitivity_widgets=None):
app.config.set(config_name, widget.get_active())
......
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