From ae172f84ddb9ff9c2fc26dd5ee16c1edd38d08ba Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Mon, 12 Mar 2018 08:33:31 +0100 Subject: =?UTF-8?q?Add=20a=20=E2=80=9Cname=E2=80=9D=20column=20to=20/bookm?= =?UTF-8?q?arks.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- poezio/tabs/bookmarkstab.py | 8 +++++--- poezio/windows/bookmark_forms.py | 33 ++++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/poezio/tabs/bookmarkstab.py b/poezio/tabs/bookmarkstab.py index 498d2f00..ceccc99d 100644 --- a/poezio/tabs/bookmarkstab.py +++ b/poezio/tabs/bookmarkstab.py @@ -25,7 +25,7 @@ class BookmarksTab(Tab): self.new_bookmarks = [] self.removed_bookmarks = [] self.header_win = windows.ColumnHeaderWin( - ('room@server/nickname', 'password', 'autojoin', 'storage')) + ('name', 'room@server/nickname', 'password', 'autojoin', 'storage')) self.bookmarks_win = windows.BookmarksWin( self.bookmarks, self.height - 4, self.width, 1, 0) self.help_win = windows.HelpText('Ctrl+Y: save, Ctrl+G: cancel, ' @@ -107,10 +107,12 @@ class BookmarksTab(Tab): def resize(self): self.need_resize = False self.header_win.resize_columns({ + 'name': + self.width // 4, 'room@server/nickname': - self.width // 3, + self.width // 4, 'password': - self.width // 3, + self.width // 6, 'autojoin': self.width // 6, 'storage': diff --git a/poezio/windows/bookmark_forms.py b/poezio/windows/bookmark_forms.py index 74135e54..25d4055d 100644 --- a/poezio/windows/bookmark_forms.py +++ b/poezio/windows/bookmark_forms.py @@ -11,6 +11,21 @@ from poezio.theming import to_curses_attr, get_theme from poezio.common import safeJID +class BookmarkNameInput(FieldInput, Input): + def __init__(self, field): + FieldInput.__init__(self, field) + Input.__init__(self) + self.text = field.name + self.pos = len(self.text) + self.color = get_theme().COLOR_NORMAL_TEXT + + def save(self): + self._field.name = self.get_text() + + def get_help_message(self): + return 'Edit the text' + + class BookmarkJIDInput(FieldInput, Input): def __init__(self, field): FieldInput.__init__(self, field) @@ -24,7 +39,6 @@ class BookmarkJIDInput(FieldInput, Input): def save(self): jid = safeJID(self.get_text()) self._field.jid = jid.bare - self._field.name = jid.bare self._field.nick = jid.resource def get_help_message(self): @@ -143,7 +157,8 @@ class BookmarksWin(Win): self._bookmarks = list(bookmarks) self.lines = [] for bookmark in sorted(self._bookmarks, key=lambda x: x.jid): - self.lines.append((BookmarkJIDInput(bookmark), + self.lines.append((BookmarkNameInput(bookmark), + BookmarkJIDInput(bookmark), BookmarkPasswordInput(bookmark), BookmarkAutojoinWin(bookmark), BookmarkMethodInput(bookmark))) @@ -164,7 +179,8 @@ class BookmarksWin(Win): self._current_input = 0 def add_bookmark(self, bookmark): - self.lines.append((BookmarkJIDInput(bookmark), + self.lines.append((BookmarkNameInput(bookmark), + BookmarkJIDInput(bookmark), BookmarkPasswordInput(bookmark), BookmarkAutojoinWin(bookmark), BookmarkMethodInput(bookmark))) @@ -318,12 +334,11 @@ class BookmarksWin(Win): self._win.erase() y = -self.scroll_pos for i in range(len(self.lines)): - self.lines[i][0].resize(1, self.width // 3, y + 1, 0) - self.lines[i][1].resize(1, self.width // 3, y + 1, self.width // 3) - self.lines[i][2].resize(1, self.width // 6, y + 1, - 2 * self.width // 3) - self.lines[i][3].resize(1, self.width // 6, y + 1, - 5 * self.width // 6) + self.lines[i][0].resize(1, self.width // 4, y + 1, 0) + self.lines[i][1].resize(1, self.width // 4, y + 1, self.width // 4) + self.lines[i][2].resize(1, self.width // 6, y + 1, 3 * self.width // 6) + self.lines[i][3].resize(1, self.width // 6, y + 1, 4 * self.width // 6) + self.lines[i][4].resize(1, self.width // 6, y + 1, 5 * self.width // 6) y += 1 self._refresh() for i, inp in enumerate(self.lines): -- cgit v1.2.3