diff --git a/gajim/common/config.py b/gajim/common/config.py index ba49e256cf6a9554fc2eb8d8084a88da369d0f7e..41627bccc10423b00e549e025799095d81055233 100644 --- a/gajim/common/config.py +++ b/gajim/common/config.py @@ -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 = { diff --git a/gajim/data/gui/preferences_window.ui b/gajim/data/gui/preferences_window.ui index 9a09bef9a29869c1dd83824cc1e1e0bc3695f920..075f57f29326968ac2494fd5e48cf392b6c2a17c 100644 --- a/gajim/data/gui/preferences_window.ui +++ b/gajim/data/gui/preferences_window.ui @@ -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"> diff --git a/gajim/groupchat_control.py b/gajim/groupchat_control.py index bef332682fbd31345e973a6c3faa0ec68a26e01a..e87a5b077ba1b19d7d87fad02677454b7764604b 100644 --- a/gajim/groupchat_control.py +++ b/gajim/groupchat_control.py @@ -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) diff --git a/gajim/gtk/preferences.py b/gajim/gtk/preferences.py index 723f97d4a9ded4194204bef6cf3a349b72538b83..f16f98255374bc763c997b10dcedf5453fe6095c 100644 --- a/gajim/gtk/preferences.py +++ b/gajim/gtk/preferences.py @@ -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())