diff options
author | mathieui <mathieui@mathieui.net> | 2014-04-28 23:29:21 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2014-04-28 23:29:21 +0200 |
commit | 0caf9417b27a67bd6b78a96d22618ef6dd995937 (patch) | |
tree | f42e0e982faa5a88d590eba45165c2f8951bf0be /src/tabs | |
parent | 069283e349b2e8dd324446aa5c30253a0993f1a3 (diff) | |
download | poezio-0caf9417b27a67bd6b78a96d22618ef6dd995937.tar.gz poezio-0caf9417b27a67bd6b78a96d22618ef6dd995937.tar.bz2 poezio-0caf9417b27a67bd6b78a96d22618ef6dd995937.tar.xz poezio-0caf9417b27a67bd6b78a96d22618ef6dd995937.zip |
Make the size modular, remove small-size lock (also seems to fix #2155)
some stuff is now hidden wen the window size gets too small (might need
some adjustments). The info buffer in the roster tab, the userlist in
mucs, the vertical tab list, the info buffer everywhere, etc…
Diffstat (limited to 'src/tabs')
-rw-r--r-- | src/tabs/__init__.py | 3 | ||||
-rw-r--r-- | src/tabs/basetabs.py | 20 | ||||
-rw-r--r-- | src/tabs/conversationtab.py | 50 | ||||
-rw-r--r-- | src/tabs/muclisttab.py | 33 | ||||
-rw-r--r-- | src/tabs/muctab.py | 58 | ||||
-rw-r--r-- | src/tabs/privatetab.py | 27 | ||||
-rw-r--r-- | src/tabs/rostertab.py | 54 | ||||
-rw-r--r-- | src/tabs/xmltab.py | 27 |
8 files changed, 199 insertions, 73 deletions
diff --git a/src/tabs/__init__.py b/src/tabs/__init__.py index bb9409b0..a0ad089b 100644 --- a/src/tabs/__init__.py +++ b/src/tabs/__init__.py @@ -1,4 +1,5 @@ -from . basetabs import Tab, ChatTab, GapTab, STATE_PRIORITY +from . basetabs import Tab, ChatTab, GapTab +from . basetabs import STATE_PRIORITY from . rostertab import RosterInfoTab from . muctab import MucTab, NS_MUC_USER from . privatetab import PrivateTab diff --git a/src/tabs/basetabs.py b/src/tabs/basetabs.py index 2811ba66..77086ec6 100644 --- a/src/tabs/basetabs.py +++ b/src/tabs/basetabs.py @@ -38,9 +38,6 @@ from theming import get_theme from windows import g_lock -MIN_WIDTH = 42 -MIN_HEIGHT = 6 - # getters for tab colors (lambdas, so that they are dynamic) STATE_COLORS = { 'disconnected': lambda: get_theme().COLOR_TAB_DISCONNECTED, @@ -88,6 +85,7 @@ STATE_PRIORITY = { class Tab(object): tab_core = None + size_manager = None plugin_commands = {} plugin_keys = {} @@ -103,6 +101,12 @@ class Tab(object): @property + def size(self): + if not Tab.size_manager: + Tab.size_manager = self.core.size + return Tab.size_manager + + @property def core(self): if not Tab.tab_core: Tab.tab_core = singleton.Singleton(core.Core) @@ -182,11 +186,7 @@ class Tab(object): @staticmethod def resize(scr): with g_lock: - Tab.size = (Tab.height, Tab.width) = scr.getmaxyx() - if Tab.height < MIN_HEIGHT or Tab.width < MIN_WIDTH: - Tab.visible = False - else: - Tab.visible = True + Tab.height, Tab.width = scr.getmaxyx() windows.Win._tab_win = scr def register_command(self, name, func, *, desc='', shortdesc='', completion=None, usage=''): @@ -283,9 +283,9 @@ class Tab(object): return False def refresh_tab_win(self): - if self.left_tab_win: + if self.left_tab_win and not self.size.core_degrade_x: self.left_tab_win.refresh() - else: + elif not self.size.core_degrade_y: self.tab_win.refresh() def refresh(self): diff --git a/src/tabs/conversationtab.py b/src/tabs/conversationtab.py index 51262db0..d37ba4b7 100644 --- a/src/tabs/conversationtab.py +++ b/src/tabs/conversationtab.py @@ -260,23 +260,44 @@ class ConversationTab(ChatTab): callback=callback) def resize(self): - if self.core.information_win_size >= self.height-3 or not self.visible: - return self.need_resize = False - self.text_win.resize(self.height-3-self.core.information_win_size - Tab.tab_win_height(), self.width, 1, 0) + if self.size.tab_degrade_y: + display_bar = False + info_win_height = 0 + tab_win_height = 0 + bar_height = 0 + else: + display_bar = True + info_win_height = self.core.information_win_size + tab_win_height = Tab.tab_win_height() + bar_height = 1 + + self.text_win.resize(self.height - 2 - bar_height - info_win_height + - tab_win_height, + self.width, bar_height, 0) self.text_win.rebuild_everything(self._text_buffer) - self.upper_bar.resize(1, self.width, 0, 0) - self.info_header.resize(1, self.width, self.height-2-self.core.information_win_size - Tab.tab_win_height(), 0) - self.input.resize(1, self.width, self.height-1, 0) + if display_bar: + self.upper_bar.resize(1, self.width, 0, 0) + self.info_header.resize(1, self.width, + self.height - 2 - bar_height - info_win_height + - tab_win_height, + 0) + self.input.resize(1, self.width, self.height - 1, 0) def refresh(self): if self.need_resize: self.resize() log.debug(' TAB Refresh: %s', self.__class__.__name__) + display_bar = display_info_win = not self.size.tab_degrade_y + self.text_win.refresh() - self.upper_bar.refresh(self.get_dest_jid(), roster[self.get_dest_jid()]) + + if display_bar: + self.upper_bar.refresh(self.get_dest_jid(), roster[self.get_dest_jid()]) self.info_header.refresh(self.get_dest_jid(), roster[self.get_dest_jid()], self.text_win, self.chatstate, ConversationTab.additional_informations) - self.info_win.refresh() + + if display_info_win: + self.info_win.refresh() self.refresh_tab_win() self.input.refresh() @@ -439,14 +460,21 @@ class DynamicConversationTab(ConversationTab): if self.need_resize: self.resize() log.debug(' TAB Refresh: %s', self.__class__.__name__) + display_bar = display_info_win = not self.size.tab_degrade_y + self.text_win.refresh() - self.upper_bar.refresh(self.get_name(), roster[self.get_name()]) + if display_bar: + self.upper_bar.refresh(self.get_name(), roster[self.get_name()]) if self.locked_resource: displayed_jid = "%s/%s" % (self.get_name(), self.locked_resource) else: displayed_jid = self.get_name() - self.info_header.refresh(displayed_jid, roster[self.get_name()], self.text_win, self.chatstate, ConversationTab.additional_informations) - self.info_win.refresh() + self.info_header.refresh(displayed_jid, roster[self.get_name()], + self.text_win, self.chatstate, + ConversationTab.additional_informations) + if display_info_win: + self.info_win.refresh() + self.refresh_tab_win() self.input.refresh() diff --git a/src/tabs/muclisttab.py b/src/tabs/muclisttab.py index 6506d4cf..b8c49e8c 100644 --- a/src/tabs/muclisttab.py +++ b/src/tabs/muclisttab.py @@ -63,26 +63,41 @@ class MucListTab(Tab): if self.need_resize: self.resize() log.debug(' TAB Refresh: %s', self.__class__.__name__) + if self.size.tab_degrade_y: + display_info_win = False + else: + display_info_win = True + self.info_header.refresh(window=self.listview) - self.info_win.refresh() + if display_info_win: + self.info_win.refresh() self.refresh_tab_win() self.list_header.refresh() self.listview.refresh() self.input.refresh() - self.update_commands() def resize(self): - if self.core.information_win_size >= self.height-3 or not self.visible: - return self.need_resize = False - self.info_header.resize(1, self.width, self.height-2-self.core.information_win_size - Tab.tab_win_height(), 0) - column_size = {'node-part': int(self.width*2/8), - 'name': int(self.width*5/8), - 'users': self.width-int(self.width*2/8)-int(self.width*5/8)} + if self.size.tab_degrade_y: + info_win_height = 0 + tab_win_height = 0 + else: + info_win_height = self.core.information_win_size + tab_win_height = Tab.tab_win_height() + + self.info_header.resize(1, self.width, + self.height - 2 - info_win_height + - tab_win_height, + 0) + column_size = {'node-part': int(self.width* 2 / 8), + 'name': int(self.width * 5 / 8), + 'users': self.width - int(self.width * 2 / 8) + - int(self.width * 5 / 8)} self.list_header.resize_columns(column_size) self.list_header.resize(1, self.width, 0, 0) self.listview.resize_columns(column_size) - self.listview.resize(self.height-3-self.core.information_win_size - Tab.tab_win_height(), self.width, 1, 0) + self.listview.resize(self.height - 3 - info_win_height - tab_win_height, + self.width, 1, 0) self.input.resize(1, self.width, self.height-1, 0) def on_slash(self): diff --git a/src/tabs/muctab.py b/src/tabs/muctab.py index ceda58a5..2170e754 100644 --- a/src/tabs/muctab.py +++ b/src/tabs/muctab.py @@ -796,29 +796,42 @@ class MucTab(ChatTab): """ Resize the whole window. i.e. all its sub-windows """ - if not self.visible: - return self.need_resize = False - if config.get("hide_user_list", False): + if config.get("hide_user_list", False) or self.size.tab_degrade_x: + display_user_list = False text_width = self.width else: - text_width = (self.width//10)*9 - self.user_win.resize(self.height - 3 - self.core.information_win_size - - Tab.tab_win_height(), - self.width - (self.width // 10) * 9 - 1, - 1, - (self.width // 10) * 9 + 1) + display_user_list = True + text_width = (self.width // 10) * 9 + + if self.size.tab_degrade_y: + display_info_win = False + tab_win_height = 0 + info_win_height = 0 + else: + display_info_win = True + tab_win_height = Tab.tab_win_height() + info_win_height = self.core.information_win_size + + + if display_user_list: + self.user_win.resize(self.height - 3 - info_win_height + - tab_win_height, + self.width - (self.width // 10) * 9 - 1, + 1, + (self.width // 10) * 9 + 1) + self.v_separator.resize(self.height - 2 - tab_win_height, + 1, 1, 9 * (self.width // 10)) + self.topic_win.resize(1, self.width, 0, 0) - self.v_separator.resize(self.height - 2 - Tab.tab_win_height(), - 1, 1, 9 * (self.width // 10)) - self.text_win.resize(self.height - 3 - self.core.information_win_size - - Tab.tab_win_height(), - text_width, 1, 0) + + self.text_win.resize(self.height - 3 - info_win_height + - tab_win_height, + text_width, 1, 0) self.text_win.rebuild_everything(self._text_buffer) self.info_header.resize(1, self.width, - self.height - 2 - - self.core.information_win_size - - Tab.tab_win_height(), + self.height - 2 - info_win_height + - tab_win_height, 0) self.input.resize(1, self.width, self.height-1, 0) @@ -826,14 +839,21 @@ class MucTab(ChatTab): if self.need_resize: self.resize() log.debug(' TAB Refresh: %s', self.__class__.__name__) + if config.get("hide_user_list", False) or self.size.tab_degrade_x: + display_user_list = False + else: + display_user_list = True + display_info_win = not self.size.tab.degrade_y + self.topic_win.refresh(self.get_single_line_topic()) self.text_win.refresh() - if not config.get("hide_user_list", False): + if display_user_list: self.v_separator.refresh() self.user_win.refresh(self.users) self.info_header.refresh(self, self.text_win) self.refresh_tab_win() - self.info_win.refresh() + if display_info_win: + self.info_win.refresh() self.input.refresh() def on_input(self, key, raw): diff --git a/src/tabs/privatetab.py b/src/tabs/privatetab.py index 7b050769..a88e9060 100644 --- a/src/tabs/privatetab.py +++ b/src/tabs/privatetab.py @@ -237,21 +237,36 @@ class PrivateTab(ChatTab): self.parent_muc.command_info(user) def resize(self): - if self.core.information_win_size >= self.height-3 or not self.visible: - return self.need_resize = False - self.text_win.resize(self.height-2-self.core.information_win_size - Tab.tab_win_height(), self.width, 0, 0) + + if self.size.tab_degrade_y: + info_win_height = 0 + tab_win_height = 0 + else: + info_win_height = self.core.information_win_size + tab_win_height = Tab.tab_win_height() + + self.text_win.resize(self.height - 2 - info_win_height - tab_win_height, + self.width, 0, 0) self.text_win.rebuild_everything(self._text_buffer) - self.info_header.resize(1, self.width, self.height-2-self.core.information_win_size - Tab.tab_win_height(), 0) + self.info_header.resize(1, self.width, + self.height - 2 - info_win_height + - tab_win_height, + 0) self.input.resize(1, self.width, self.height-1, 0) def refresh(self): if self.need_resize: self.resize() log.debug(' TAB Refresh: %s', self.__class__.__name__) + display_info_win = not self.size.tab_degrade_y + self.text_win.refresh() - self.info_header.refresh(self.name, self.text_win, self.chatstate, PrivateTab.additional_informations) - self.info_win.refresh() + self.info_header.refresh(self.name, self.text_win, self.chatstate, + PrivateTab.additional_informations) + if display_info_win: + self.info_win.refresh() + self.refresh_tab_win() self.input.refresh() diff --git a/src/tabs/rostertab.py b/src/tabs/rostertab.py index 42a63545..adc83445 100644 --- a/src/tabs/rostertab.py +++ b/src/tabs/rostertab.py @@ -266,15 +266,40 @@ class RosterInfoTab(Tab): self.core.command_last_activity(jid) def resize(self): - if not self.visible: - return self.need_resize = False - roster_width = self.width//2 - info_width = self.width-roster_width-1 - self.v_separator.resize(self.height-1 - Tab.tab_win_height(), 1, 0, roster_width) - self.information_win.resize(self.height-2-4, info_width, 0, roster_width+1, self.core.information_buffer) - self.roster_win.resize(self.height-1 - Tab.tab_win_height(), roster_width, 0, 0) - self.contact_info_win.resize(5 - Tab.tab_win_height(), info_width, self.height-2-4, roster_width+1) + if self.size.tab_degrade_x: + display_info = False + roster_width = self.width + else: + display_info = True + roster_width = self.width // 2 + if self.size.tab_degrade_y: + display_contact_win = False + contact_win_h = 0 + else: + display_contact_win = True + contact_win_h = 5 + if self.size.tab_degrade_y: + tab_win_height = 0 + else: + tab_win_height = Tab.tab_win_height() + + info_width = self.width - roster_width - 1 + if display_info: + self.v_separator.resize(self.height - 1 - tab_win_height, + 1, 0, roster_width) + self.information_win.resize(self.height - 1 - tab_win_height + - contact_win_h, + info_width, 0, roster_width + 1, + self.core.information_buffer) + if display_contact_win: + self.contact_info_win.resize(contact_win_h - tab_win_height, + info_width, + self.height - tab_win_height + - contact_win_h - 1, + roster_width + 1) + self.roster_win.resize(self.height - 1 - Tab.tab_win_height(), + roster_width, 0, 0) self.input.resize(1, self.width, self.height-1, 0) self.default_help_message.resize(1, self.width, self.height-1, 0) @@ -699,10 +724,17 @@ class RosterInfoTab(Tab): if self.need_resize: self.resize() log.debug(' TAB Refresh: %s', self.__class__.__name__) - self.v_separator.refresh() + + display_info = not self.size.tab_degrade_x + display_contact_win = not self.size.tab_degrade_y + self.roster_win.refresh(roster) - self.contact_info_win.refresh(self.roster_win.get_selected_row()) - self.information_win.refresh() + if display_info: + self.v_separator.refresh() + self.information_win.refresh() + if display_contact_win: + self.contact_info_win.refresh( + self.roster_win.get_selected_row()) self.refresh_tab_win() self.input.refresh() diff --git a/src/tabs/xmltab.py b/src/tabs/xmltab.py index a2728586..7c79da67 100644 --- a/src/tabs/xmltab.py +++ b/src/tabs/xmltab.py @@ -163,23 +163,38 @@ class XMLTab(Tab): self.core.close_tab() def resize(self): - if self.core.information_win_size >= self.height-3 or not self.visible: - return self.need_resize = False - min = 1 if self.left_tab_win else 2 - self.text_win.resize(self.height-self.core.information_win_size - Tab.tab_win_height() - 2, self.width, 0, 0) + if self.size.tab_degrade_y: + info_win_size = 0 + tab_win_height = 0 + else: + info_win_size = self.core.information_win_size + tab_win_height = Tab.tab_win_height() + + self.text_win.resize(self.height - info_win_size - tab_win_height - 2, + self.width, 0, 0) self.text_win.rebuild_everything(self.core.xml_buffer) - self.info_header.resize(1, self.width, self.height-2-self.core.information_win_size - Tab.tab_win_height(), 0) + self.info_header.resize(1, self.width, + self.height - 2 - info_win_size + - tab_win_height, + 0) self.input.resize(1, self.width, self.height-1, 0) def refresh(self): if self.need_resize: self.resize() log.debug(' TAB Refresh: %s', self.__class__.__name__) + + if self.size.tab_degrade_y: + display_info_win = False + else: + display_info_win = True + self.text_win.refresh() self.info_header.refresh(self.filter_type, self.filter, self.text_win) self.refresh_tab_win() - self.info_win.refresh() + if display_info_win: + self.info_win.refresh() self.input.refresh() def on_lose_focus(self): |