From f0f054af6bbd0bfda6555b1b6598f7053d08bfa3 Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Mon, 10 Apr 2006 12:09:05 +0000 Subject: [PATCH] [Geobert] new compact view so important info are not hidden (f.e. chatstates) for maximum adjustment, see hide_* in ACE. fixes #1276 --- src/chat_control.py | 46 ++++++++++++++++------------------------ src/common/config.py | 7 ++++-- src/common/optparser.py | 13 +++++++++--- src/groupchat_control.py | 13 ++++++------ src/message_control.py | 8 +++---- src/message_window.py | 4 ++-- 6 files changed, 46 insertions(+), 45 deletions(-) diff --git a/src/chat_control.py b/src/chat_control.py index f688d8403..f6768408a 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -389,7 +389,7 @@ class ChatControlBase(MessageControl): self.clear(self.msg_textview) # clear message textview too return True elif message == '/compact': - self.set_compact_view(not self.compact_view_current) + self.chat_buttons_set_visible(not self.hide_chat_buttons_current) self.clear(self.msg_textview) return True return False @@ -519,7 +519,7 @@ class ChatControlBase(MessageControl): def _on_compact_view_menuitem_activate(self, widget): isactive = widget.get_active() - self.set_compact_view(isactive) + self.chat_buttons_set_visible(isactive) def set_control_active(self, state): if state: @@ -652,32 +652,22 @@ class ChatControlBase(MessageControl): color.blue = int((color.blue * p) + (mask * (1 - p))) return color - def set_compact_view(self, state): - '''Toggle compact view. state is bool''' - MessageControl.set_compact_view(self, state) + def widget_set_visible(self, widget, state): + '''Show or hide a widget. state is bool''' # make the last message visible, when changing to "full view" if not state: gobject.idle_add(self.conv_textview.scroll_to_end_iter) - - if self.type_id == message_control.TYPE_GC: - widgets = [ - self.xml.get_widget('banner_eventbox'), - self.xml.get_widget('actions_hbox'), - self.xml.get_widget('list_scrolledwindow'), - ] - else: - widgets = [ - self.xml.get_widget('banner_eventbox'), - self.xml.get_widget('actions_hbox'), - ] - for widget in widgets: - if state: - widget.set_no_show_all(True) - widget.hide() - else: - widget.set_no_show_all(False) - widget.show_all() + widget.set_no_show_all(state) + if state: + widget.hide() + else: + widget.show_all() + + def chat_buttons_set_visible(self, state): + '''Toggle chat buttons. state is bool''' + MessageControl.chat_buttons_set_visible(self, state) + self.widget_set_visible(self.xml.get_widget('actions_hbox'), state) def got_connected(self): self.msg_textview.set_sensitive(True) @@ -697,9 +687,9 @@ class ChatControl(ChatControlBase): def __init__(self, parent_win, contact, acct, resource = None): ChatControlBase.__init__(self, self.TYPE_ID, parent_win, 'chat_child_vbox', (_('Chat'), _('Chats')), contact, acct, resource) - self.compact_view_always = gajim.config.get('always_compact_view_chat') - self.set_compact_view(self.compact_view_always) - + self.hide_chat_buttons_always = gajim.config.get('always_hide_chat_buttons') + self.chat_buttons_set_visible(self.hide_chat_buttons_always) + self.widget_set_visible(self.xml.get_widget('banner_eventbox'), gajim.config.get('hide_chat_banner')) # Initialize drag-n-drop self.TARGET_TYPE_URI_LIST = 80 self.dnd_list = [ ( 'text/uri-list', 0, self.TARGET_TYPE_URI_LIST ) ] @@ -1153,7 +1143,7 @@ class ChatControl(ChatControlBase): send_file_menuitem.set_sensitive(False) # compact_view_menuitem - compact_view_menuitem.set_active(self.compact_view_current) + compact_view_menuitem.set_active(self.hide_chat_buttons_current) # add_to_roster_menuitem if _('Not in Roster') in contact.groups: diff --git a/src/common/config.py b/src/common/config.py index da434bac2..3798ae6b4 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -135,8 +135,6 @@ class Config: 'show_roster_on_startup': [opt_bool, True], 'key_up_lines': [opt_int, 25, _('How many lines to store for Ctrl+KeyUP.')], 'version': [ opt_str, '0.10' ], # which version created the config - 'always_compact_view_chat': [opt_bool, False, _('Use compact view when you open a chat window')], - 'always_compact_view_gc': [opt_bool, False, _('Use compact view when you open a group chat window')], 'search_engine': [opt_str, 'http://www.google.com/search?&q=%s&sourceid=gajim'], 'dictionary_url': [opt_str, 'WIKTIONARY', _("Either custom url with %s in it where %s is the word/phrase or 'WIKTIONARY' which means use wiktionary.")], 'always_english_wikipedia': [opt_bool, False], @@ -195,6 +193,11 @@ class Config: _('Controls the window where new messages are placed.\n\'always\' - All messages are sent to a single window.\n\'never\' - All messages get their own window.\n\'peracct\' - Messages for each account are sent to a specific window.\n\'pertype\' - Each message type (e.g., chats vs. groupchats) are sent to a specific window. Note, changing this option requires restarting Gajim before the changes will take effect')], 'show_avatar_in_chat': [opt_bool, True, _('If False, you will no longer see the avatar in the chat window')], 'escape_key_closes': [opt_bool, True, _('If True, pressing the escape key closes a tab/window')], + 'always_hide_groupchat_buttons': [opt_bool, False, _('Hides the buttons when you open a group chat window')], + 'always_hide_chat_buttons': [opt_bool, False, _('Hides the buttons when you open a chat window')], + 'hide_groupchat_banner': [opt_bool, False, _('Hides the banner when you open a group chat window')], + 'hide_chat_banner': [opt_bool, False, _('Hides the banner when you open a chat window')], + 'hide_groupchat_occupants_list': [opt_bool, False, _('Hides the room occupants list in groupchat window')], } __options_per_key = { diff --git a/src/common/optparser.py b/src/common/optparser.py index 9a21049f8..5aab15975 100644 --- a/src/common/optparser.py +++ b/src/common/optparser.py @@ -195,14 +195,21 @@ class OptionsParser: def update_config_09_to_010(self): if self.old_values.has_key('usetabbedchat') and not \ - self.old_values['usetabbedchat']: + self.old_values['usetabbedchat']: gajim.config.set('one_message_window', 'never') if self.old_values.has_key('autodetect_browser_mailer') and \ - self.old_values['autodetect_browser_mailer'] is True: + self.old_values['autodetect_browser_mailer'] is True: gajim.config.set('autodetect_browser_mailer', False) if self.old_values.has_key('useemoticons') and \ - not self.old_values['useemoticons']: + not self.old_values['useemoticons']: gajim.config.set('emoticons_theme', '') + if self.old_values.has_key('always_compact_view_chat') and \ + self.old_values['always_compact_view_chat']: + gajim.config.set('always_hide_chat_buttons', True) + if self.old_values.has_key('always_compact_view_gc') and \ + self.old_values['always_compact_view_gc']: + gajim.config.set('always_hide_groupchat_buttons', True) + for account in gajim.config.get_per('accounts'): proxies_str = gajim.config.get_per('accounts', account, 'file_transfer_proxies') diff --git a/src/groupchat_control.py b/src/groupchat_control.py index 9cab0f3d8..1309163e1 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -102,8 +102,10 @@ class GroupchatControl(ChatControlBase): self.nick = contact.name self.name = self.room_jid.split('@')[0] - self.compact_view_always = gajim.config.get('always_compact_view_gc') - self.set_compact_view(self.compact_view_always) + self.hide_chat_buttons_always = gajim.config.get('always_hide_groupchat_buttons') + self.chat_buttons_set_visible(self.hide_chat_buttons_always) + self.widget_set_visible(self.xml.get_widget('banner_eventbox'), gajim.config.get('hide_groupchat_banner')) + self.widget_set_visible(self.xml.get_widget('list_scrolledwindow'), gajim.config.get('hide_groupchat_occupants_list')) self.gc_refer_to_nick_char = gajim.config.get('gc_refer_to_nick_char') self._last_selected_contact = None # None or holds jid, account tuple @@ -312,8 +314,8 @@ class GroupchatControl(ChatControlBase): sets sensitivity state for configure_room''' menu = self.gc_popup_menu childs = menu.get_children() - # compact_view_menuitem - childs[5].set_active(self.compact_view_current) + # hide chat buttons + childs[5].set_active(self.hide_chat_buttons_current) if gajim.gc_connected[self.account][self.room_jid]: c = gajim.contacts.get_gc_contact(self.account, self.room_jid, self.nick) @@ -1025,8 +1027,7 @@ class GroupchatControl(ChatControlBase): self.print_conversation(_('Usage: /%s [reason], closes the current ' 'window or tab, displaying reason if specified.') % command, 'info') elif command == 'compact': - self.print_conversation(_('Usage: /%s, sets the groupchat window to ' - 'compact mode.') % command, 'info') + self.print_conversation(_('Usage: /%s, hide the chat buttons.') % command, 'info') elif command == 'invite': self.print_conversation(_('Usage: /%s [reason], invites JID to ' 'the current room, optionally providing a reason.') % command, diff --git a/src/message_control.py b/src/message_control.py index e03695b13..daf09e862 100644 --- a/src/message_control.py +++ b/src/message_control.py @@ -42,8 +42,8 @@ class MessageControl: self.display_names = display_names self.contact = contact self.account = account - self.compact_view_always = False - self.compact_view_current = False + self.hide_chat_buttons_always = False + self.hide_chat_buttons_current = False self.nb_unread = 0 self.resource = resource @@ -113,9 +113,9 @@ class MessageControl: # NOTE: Derived classes SHOULD implement this return None - def set_compact_view(self, state): + def chat_buttons_set_visible(self, state): # NOTE: Derived classes MAY implement this - self.compact_view_current = state + self.hide_chat_buttons_current = state def got_connected(self): pass diff --git a/src/message_window.py b/src/message_window.py index 63f677325..b693c80e9 100644 --- a/src/message_window.py +++ b/src/message_window.py @@ -479,8 +479,8 @@ class MessageWindow: elif event.string and event.string in st and \ (event.state & gtk.gdk.MOD1_MASK): # ALT + 1,2,3.. self.notebook.set_current_page(st.index(event.string)) - elif event.keyval == gtk.keysyms.c: # ALT + C toggles compact view - ctrl.set_compact_view(not ctrl.compact_view_current) + elif event.keyval == gtk.keysyms.c: # ALT + C toggles chat buttons + ctrl.chat_buttons_set_visible(not ctrl.hide_chat_buttons_current) # Close tab bindings elif event.keyval == gtk.keysyms.Escape and \ gajim.config.get('escape_key_closes'): # Escape