summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/config.py15
-rw-r--r--src/core.py19
-rw-r--r--src/tabs.py18
3 files changed, 40 insertions, 12 deletions
diff --git a/src/config.py b/src/config.py
index 801d0b38..9661158e 100644
--- a/src/config.py
+++ b/src/config.py
@@ -124,6 +124,18 @@ class Config(RawConfigParser):
return
self.write_in_file(section, option, value)
+ def set(self, option, value, section=DEFSECTION):
+ """
+ Set the value of an option temporarily
+ """
+ try:
+ RawConfigParser.set(self, section, option, value)
+ except NoSectionError:
+ pass
+
+
+firstrun = False
+
# creates the configuration directory if it doesn't exist
# and copy the default config in it
CONFIG_HOME = environ.get("XDG_CONFIG_HOME")
@@ -137,6 +149,7 @@ except OSError:
if not path.isfile(path.join(CONFIG_PATH, 'poezio.cfg')):
copy2(path.join(path.dirname(__file__), '../data/default_config.cfg'), path.join(CONFIG_PATH, 'poezio.cfg'))
+ firstrun = True
parser = OptionParser()
parser.add_option("-f", "--file", dest="filename", default=path.join(CONFIG_PATH, 'poezio.cfg'),
@@ -145,3 +158,5 @@ parser.add_option("-d", "--debug", dest="debug",
help="The file where debug will be written", metavar="DEBUG_FILE")
(options, args) = parser.parse_args()
config = Config(options.filename)
+if firstrun:
+ config.set('firstrun', True)
diff --git a/src/core.py b/src/core.py
index 4a2cc91f..8d1fde3a 100644
--- a/src/core.py
+++ b/src/core.py
@@ -89,6 +89,7 @@ class Core(object):
self.information_buffer = TextBuffer()
self.information_win_size = config.get('info_win_height', 2, 'var')
self.information_win = windows.TextWin(20)
+ self.tab_win = windows.GlobalInfoBar()
self.information_buffer.add_window(self.information_win)
self.tabs = []
self.previous_tab_nb = 0
@@ -182,10 +183,20 @@ class Core(object):
tabs.Tab.resize(self.stdscr)
# resize the information_win to its initial size
self.resize_global_information_win()
+ # resize the global_info_bar to its initial size
+ self.resize_global_info_bar()
default_tab = tabs.RosterInfoTab()
default_tab.on_gain_focus()
self.tabs.append(default_tab)
self.information(_('Welcome to poezio!'))
+ if config.get('firstrun', ''):
+ self.information(_(
+ 'It seems that it is the first time you start poezio.\n' + \
+ 'The configuration help is here: http://dev.louiz.org/project/poezio/doc/HowToConfigure\n' + \
+ 'And the documentation for users is here: http://dev.louiz.org/project/poezio/doc/HowToUse\n' + \
+ 'By default, you are in poezio’s chatroom, where you can ask for help or tell us how great it is.\n' + \
+ 'Just press Ctrl-n.' \
+ ))
self.refresh_window()
def resize_global_information_win(self):
@@ -195,6 +206,13 @@ class Core(object):
self.information_win.resize(self.information_win_size, tabs.Tab.width,
tabs.Tab.height - 2 - self.information_win_size, 0)
+
+ def resize_global_info_bar(self):
+ """
+ Resize the GlobalInfoBar only once at each resize
+ """
+ self.tab_win.resize(1, tabs.Tab.width, tabs.Tab.height - 2, 0)
+
def on_exception(self, typ, value, trace):
"""
When an exception is raised, just reset curses and call
@@ -676,6 +694,7 @@ class Core(object):
"""
tabs.Tab.resize(self.stdscr)
self.resize_global_information_win()
+ self.resize_global_info_bar()
with resize_lock:
for tab in self.tabs:
if config.get('lazy_resize', 'true') == 'true':
diff --git a/src/tabs.py b/src/tabs.py
index d2145d54..c336adcd 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -77,6 +77,12 @@ class Tab(object):
return Tab.tab_core
@property
+ def tab_win(self):
+ if not Tab.tab_core:
+ Tab.tab_core = singleton.Singleton(core.Core)
+ return Tab.tab_core.tab_win
+
+ @property
def info_win(self):
return self.core.information_win
@@ -381,7 +387,6 @@ class MucTab(ChatTab):
self.v_separator = windows.VerticalSeparator()
self.user_win = windows.UserList()
self.info_header = windows.MucInfoWin()
- self.tab_win = windows.GlobalInfoBar()
self.input = windows.MessageInput()
self.ignores = [] # set of Users
# keys
@@ -679,7 +684,6 @@ class MucTab(ChatTab):
self.text_win.rebuild_everything(self._room)
self.user_win.resize(self.height-3-self.core.information_win_size-1, self.width-text_width-1, 1, text_width+1)
self.info_header.resize(1, self.width, self.height-3-self.core.information_win_size, 0)
- self.tab_win.resize(1, self.width, self.height-2, 0)
self.input.resize(1, self.width, self.height-1, 0)
def refresh(self):
@@ -981,7 +985,6 @@ class PrivateTab(ChatTab):
self.text_win = windows.TextWin()
room.add_window(self.text_win)
self.info_header = windows.PrivateInfoWin()
- self.tab_win = windows.GlobalInfoBar()
self.input = windows.MessageInput()
# keys
self.key_func['^I'] = self.completion
@@ -1026,7 +1029,6 @@ class PrivateTab(ChatTab):
self.text_win.resize(self.height-3-self.core.information_win_size, self.width, 0, 0)
self.text_win.rebuild_everything(self._room)
self.info_header.resize(1, self.width, self.height-3-self.core.information_win_size, 0)
- self.tab_win.resize(1, self.width, self.height-2, 0)
self.input.resize(1, self.width, self.height-1, 0)
def refresh(self):
@@ -1141,7 +1143,6 @@ class RosterInfoTab(Tab):
Tab.__init__(self)
self.name = "Roster"
self.v_separator = windows.VerticalSeparator()
- self.tab_win = windows.GlobalInfoBar()
self.information_win = windows.TextWin()
self.core.information_buffer.add_window(self.information_win)
self.roster_win = windows.RosterWin()
@@ -1175,7 +1176,6 @@ class RosterInfoTab(Tab):
roster_width = self.width//2
info_width = self.width-roster_width-1
self.v_separator.resize(self.height-2, 1, 0, roster_width)
- self.tab_win.resize(1, self.width, self.height-2, 0)
self.information_win.resize(self.height-2-4, info_width, 0, roster_width+1, self.core.information_buffer)
self.roster_win.resize(self.height-2, roster_width, 0, 0)
self.contact_info_win.resize(4, info_width, self.height-2-4, roster_width+1)
@@ -1494,7 +1494,6 @@ class ConversationTab(ChatTab):
txt_buff.add_window(self.text_win)
self.upper_bar = windows.ConversationStatusMessageWin()
self.info_header = windows.ConversationInfoWin()
- self.tab_win = windows.GlobalInfoBar()
self.input = windows.MessageInput()
# keys
self.key_func['^I'] = self.completion
@@ -1533,7 +1532,6 @@ class ConversationTab(ChatTab):
self.text_win.rebuild_everything(self._room)
self.upper_bar.resize(1, self.width, 0, 0)
self.info_header.resize(1, self.width, self.height-3-self.core.information_win_size, 0)
- self.tab_win.resize(1, self.width, self.height-2, 0)
self.input.resize(1, self.width, self.height-1, 0)
def refresh(self):
@@ -1622,7 +1620,6 @@ class MucListTab(Tab):
columns = ('node-part', 'name', 'users')
self.list_header = windows.ColumnHeaderWin(columns)
self.listview = windows.ListWin(columns)
- self.tab_win = windows.GlobalInfoBar()
self.default_help_message = windows.HelpText("“j”: join room.")
self.input = self.default_help_message
self.key_func["KEY_DOWN"] = self.listview.move_cursor_down
@@ -1656,7 +1653,6 @@ class MucListTab(Tab):
self.list_header.resize(1, self.width, 1, 0)
self.listview.resize_columns(column_size)
self.listview.resize(self.height-4, self.width, 2, 0)
- self.tab_win.resize(1, self.width, self.height-2, 0)
self.input.resize(1, self.width, self.height-1, 0)
def on_slash(self):
@@ -1749,7 +1745,6 @@ class SimpleTextTab(Tab):
Tab.__init__(self)
self._color_state = theme.COLOR_TAB_NORMAL
self.text_win = windows.SimpleTextWin(text)
- self.tab_win = windows.GlobalInfoBar()
self.default_help_message = windows.HelpText("“Ctrl+q”: close")
self.input = self.default_help_message
self.key_func['^T'] = self.close
@@ -1779,7 +1774,6 @@ class SimpleTextTab(Tab):
if not self.visible:
return
self.text_win.resize(self.height-2, self.width, 0, 0)
- self.tab_win.resize(1, self.width, self.height-2, 0)
self.input.resize(1, self.width, self.height-1, 0)
def refresh(self):