MUC: Add option for showing the subject on join
This commit is contained in:
		
							parent
							
								
									fd232ce616
								
							
						
					
					
						commit
						990a35f9d8
					
				
					 4 changed files with 29 additions and 2 deletions
				
			
		| 
						 | 
					@ -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],
 | 
					        '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')],
 | 
					        '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')],
 | 
					        '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]]
 | 
					    }, {})  # type: Tuple[Dict[str, List[Any]], Dict[Any, Any]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    __options_per_key = {
 | 
					    __options_per_key = {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -401,7 +401,7 @@
 | 
				
			||||||
                  </object>
 | 
					                  </object>
 | 
				
			||||||
                  <packing>
 | 
					                  <packing>
 | 
				
			||||||
                    <property name="left_attach">0</property>
 | 
					                    <property name="left_attach">0</property>
 | 
				
			||||||
                    <property name="top_attach">5</property>
 | 
					                    <property name="top_attach">6</property>
 | 
				
			||||||
                    <property name="width">2</property>
 | 
					                    <property name="width">2</property>
 | 
				
			||||||
                  </packing>
 | 
					                  </packing>
 | 
				
			||||||
                </child>
 | 
					                </child>
 | 
				
			||||||
| 
						 | 
					@ -498,6 +498,21 @@
 | 
				
			||||||
                    <property name="width">2</property>
 | 
					                    <property name="width">2</property>
 | 
				
			||||||
                  </packing>
 | 
					                  </packing>
 | 
				
			||||||
                </child>
 | 
					                </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>
 | 
					              </object>
 | 
				
			||||||
            </child>
 | 
					            </child>
 | 
				
			||||||
            <child type="label">
 | 
					            <child type="label">
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -297,6 +297,7 @@ class GroupchatControl(ChatControlBase):
 | 
				
			||||||
        self.force_non_minimizable = False
 | 
					        self.force_non_minimizable = False
 | 
				
			||||||
        self.is_continued = is_continued
 | 
					        self.is_continued = is_continued
 | 
				
			||||||
        self.is_anonymous = True
 | 
					        self.is_anonymous = True
 | 
				
			||||||
 | 
					        self.join_time = 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Controls the state of autorejoin.
 | 
					        # Controls the state of autorejoin.
 | 
				
			||||||
        # None - autorejoin is neutral.
 | 
					        # None - autorejoin is neutral.
 | 
				
			||||||
| 
						 | 
					@ -1546,7 +1547,10 @@ class GroupchatControl(ChatControlBase):
 | 
				
			||||||
            date = time.strftime('%d-%m-%Y %H:%M:%S',
 | 
					            date = time.strftime('%d-%m-%Y %H:%M:%S',
 | 
				
			||||||
                                 time.localtime(event.timestamp))
 | 
					                                 time.localtime(event.timestamp))
 | 
				
			||||||
            text = '%s - %s' % (text, date)
 | 
					            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 == '':
 | 
					        if event.subject == '':
 | 
				
			||||||
            self.subject_button.hide()
 | 
					            self.subject_button.hide()
 | 
				
			||||||
| 
						 | 
					@ -1643,6 +1647,7 @@ class GroupchatControl(ChatControlBase):
 | 
				
			||||||
        app.gc_connected[self.account][self.room_jid] = value
 | 
					        app.gc_connected[self.account][self.room_jid] = value
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def got_connected(self):
 | 
					    def got_connected(self):
 | 
				
			||||||
 | 
					        self.join_time = time.time()
 | 
				
			||||||
        # Make autorejoin stop.
 | 
					        # Make autorejoin stop.
 | 
				
			||||||
        if self.autorejoin:
 | 
					        if self.autorejoin:
 | 
				
			||||||
            GLib.source_remove(self.autorejoin)
 | 
					            GLib.source_remove(self.autorejoin)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -142,6 +142,9 @@ class Preferences(Gtk.ApplicationWindow):
 | 
				
			||||||
        st = app.config.get('positive_184_ack')
 | 
					        st = app.config.get('positive_184_ack')
 | 
				
			||||||
        self.xml.get_object('positive_184_ack_checkbutton').set_active(st)
 | 
					        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
 | 
					        # Show avatar in tabs
 | 
				
			||||||
        st = app.config.get('show_avatar_in_tabs')
 | 
					        st = app.config.get('show_avatar_in_tabs')
 | 
				
			||||||
        self.xml.get_object('show_avatar_in_tabs_checkbutton').set_active(st)
 | 
					        self.xml.get_object('show_avatar_in_tabs_checkbutton').set_active(st)
 | 
				
			||||||
| 
						 | 
					@ -500,6 +503,9 @@ class Preferences(Gtk.ApplicationWindow):
 | 
				
			||||||
                return 'mixed'
 | 
					                return 'mixed'
 | 
				
			||||||
        return val
 | 
					        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,
 | 
					    def on_checkbutton_toggled(self, widget, config_name,
 | 
				
			||||||
    change_sensitivity_widgets=None):
 | 
					    change_sensitivity_widgets=None):
 | 
				
			||||||
        app.config.set(config_name, widget.get_active())
 | 
					        app.config.set(config_name, widget.get_active())
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue