From 97aef098bc5f861fe207d56de1831ece5078b664 Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Fri, 13 May 2005 16:53:30 +0000 Subject: [PATCH] fixes/cleanups allover: Basically a traceback a traceback with present() replace some menuitem strings to be more HIG introducing /clear and that is all I think --- src/chat.py | 25 +++++++++-------- src/dialogs.py | 4 +-- src/groupchat_window.py | 11 ++++---- src/gtkgui.glade | 58 +++++++++++++++++++++++++++++---------- src/history_window.py | 11 +++++--- src/roster_window.py | 48 ++++++++++++++++---------------- src/systray.py | 5 ++-- src/tabbed_chat_window.py | 28 +++++++++---------- 8 files changed, 113 insertions(+), 77 deletions(-) diff --git a/src/chat.py b/src/chat.py index 83c3b9386..19fefafba 100644 --- a/src/chat.py +++ b/src/chat.py @@ -139,7 +139,7 @@ class Chat: return active_jid def on_close_button_clicked(self, button, jid): - """When close button is pressed : close a tab""" + """When close button is pressed: close a tab""" self.remove_tab(jid) def on_chat_window_focus_in_event(self, widget, event): @@ -167,8 +167,8 @@ class Chat: new_jid = jid break - conversation_textview = self.xmls[new_jid].\ - get_widget('conversation_textview') + conversation_textview = self.xmls[new_jid].get_widget( + 'conversation_textview') conversation_buffer = conversation_textview.get_buffer() end_iter = conversation_buffer.get_end_iter() end_rect = conversation_textview.get_iter_location(end_iter) @@ -225,8 +225,8 @@ class Chat: self.nb_unread[jid] = 0 self.last_message_time[jid] = 0 - conversation_textview = \ - self.xmls[jid].get_widget('conversation_textview') + conversation_textview = self.xmls[jid].get_widget( + 'conversation_textview') conversation_buffer = conversation_textview.get_buffer() end_iter = conversation_buffer.get_end_iter() @@ -268,7 +268,7 @@ class Chat: self.xmls[jid].signal_autoconnect(self) conversation_scrolledwindow = self.xmls[jid].get_widget( - 'conversation_scrolledwindow') + 'conversation_scrolledwindow') conversation_scrolledwindow.get_vadjustment().connect('value-changed', self.on_conversation_vadjustment_value_changed) @@ -411,18 +411,19 @@ class Chat: x, y = widget.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT, x, y) tags = widget.get_iter_at_location(x, y).get_tags() if self.change_cursor: - widget.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor(\ + widget.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor( gtk.gdk.Cursor(gtk.gdk.XTERM)) self.change_cursor = None tag_table = widget.get_buffer().get_tag_table() for tag in tags: if tag == tag_table.lookup('url') or tag == tag_table.lookup('mail'): - widget.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor(\ + widget.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor( gtk.gdk.Cursor(gtk.gdk.HAND2)) self.change_cursor = tag return False def on_clear(self, widget, textview): + '''clear text found in the given textview''' buffer = textview.get_buffer() start, end = buffer.get_bounds() buffer.delete(start, end) @@ -489,15 +490,15 @@ class Chat: def make_link_menu(self, event, kind, text): menu = gtk.Menu() if kind == 'mail': - item = gtk.MenuItem(_('_Open email composer')) + item = gtk.MenuItem(_('_Open Email Composer')) else: - item = gtk.MenuItem(_('_Open link')) + item = gtk.MenuItem(_('_Open Link')) item.connect('activate', self.on_open_link_activated, kind, text) menu.append(item) if kind == 'mail': - item = gtk.MenuItem(_('_Copy email address')) + item = gtk.MenuItem(_('_Copy Email Address')) else: # It's an url - item = gtk.MenuItem(_('_Copy link address')) + item = gtk.MenuItem(_('_Copy Link Address')) item.connect('activate', self.on_copy_link_activated, text) menu.append(item) diff --git a/src/dialogs.py b/src/dialogs.py index 2756f53d3..e37ecae38 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -179,8 +179,8 @@ class Change_status_message_dialog: def __init__(self, plugin, status): self.xml = gtk.glade.XML(GTKGUI_GLADE, 'change_status_message_dialog', APP) self.window = self.xml.get_widget('change_status_message_dialog') - ui_status = plugin.roster.get_ui_status(status) - self.window.set_title(ui_status + ' Status Message') + uf_status = plugin.roster.get_uf_status(status) + self.window.set_title(uf_status + ' Status Message') message_textview = self.xml.get_widget('message_textview') self.message_buffer = message_textview.get_buffer() diff --git a/src/groupchat_window.py b/src/groupchat_window.py index 43bccdd4b..49f174e09 100644 --- a/src/groupchat_window.py +++ b/src/groupchat_window.py @@ -337,9 +337,9 @@ class Groupchat_window(chat.Chat): return False def print_conversation(self, text, room_jid, contact = '', tim = None): - """Print a line in the conversation : - if contact is set : it's a message from someone - if contact is not set : it's a message from the server""" + """Print a line in the conversation: + if contact is set: it's a message from someone + if contact is not set: it's a message from the server""" other_tags_for_name = [] if contact: if contact == self.nicks[room_jid]: @@ -412,11 +412,10 @@ class Groupchat_window(chat.Chat): def on_info(self, widget, jid): """Call vcard_information_window class to display user's information""" if self.plugin.windows[self.account]['infos'].has_key(jid): - self.plugin.windows[self.account]['infos'][jid].present() + self.plugin.windows[self.account]['infos'][jid].window.present() else: self.plugin.windows[self.account]['infos'][jid] = \ - dialogs.Vcard_window(jid, self.plugin, - self.account, True) + dialogs.Vcard_window(jid, self.plugin, self.account, True) # FIXME: when we'll have a user for each contact, this won't be needed # cause we'll user real information window vcard_xml = self.plugin.windows[self.account]['infos'][jid].xml diff --git a/src/gtkgui.glade b/src/gtkgui.glade index 34c18ac40..54b604883 100644 --- a/src/gtkgui.glade +++ b/src/gtkgui.glade @@ -9767,7 +9767,7 @@ send a chat message to True - Free for chat + Free for Chat True @@ -9845,7 +9845,7 @@ send a chat message to True - New message + New Message True @@ -10114,7 +10114,7 @@ send a chat message to 4 - 490 + 510 250 New version of Gajim available GTK_WINDOW_TOPLEVEL @@ -10166,18 +10166,48 @@ send a chat message to - + True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 + False + 0 + + + + True + gtk-dialog-info + 6 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + True + + + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + 0 diff --git a/src/history_window.py b/src/history_window.py index f8edd64bf..74d4fdb08 100644 --- a/src/history_window.py +++ b/src/history_window.py @@ -139,15 +139,18 @@ class History_window: _('Status is now: ') + data[0] + ': ' + msg, 'status') - def __init__(self, plugin, account, jid): + def __init__(self, plugin, jid, account=None): self.plugin = plugin self.jid = jid self.nb_line = gajim.logger.get_nb_line(jid) xml = gtk.glade.XML(GTKGUI_GLADE, 'history_window', APP) self.window = xml.get_widget('history_window') - list_users = self.plugin.roster.contacts[account][self.jid] - user = list_users[0] - title = 'Conversation History with ' + user.name + if account: + list_users = self.plugin.roster.contacts[account][self.jid] + user = list_users[0] + title = 'Conversation History with ' + user.name + else: + title = 'Conversation History with ' + jid self.window.set_title(title) self.history_buffer = xml.get_widget('history_textview').get_buffer() self.earliest_button = xml.get_widget('earliest_button') diff --git a/src/roster_window.py b/src/roster_window.py index 282267f7c..0305c77f0 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -454,10 +454,12 @@ class Roster_window: dlg.run() def on_history(self, widget, user): - '''When history button is pressed: call log window''' - if not self.plugin.windows['logs'].has_key(user.jid): + '''When history menuitem is activated: call log window''' + if self.plugin.windows['logs'].has_key(user.jid): + self.plugin.windows['logs'][user.jid].window.present() + else: self.plugin.windows['logs'][user.jid] = history_window.\ - History_window(self.plugin, self.account, user.jid) + History_window(self.plugin, user.jid) def mk_menu_user(self, event, iter): '''Make user's popup menu''' @@ -475,7 +477,7 @@ class Roster_window: menu.append(item) item.connect('activate', self.on_rename, iter, path) if not 'not in the roster' in user.groups: - item = gtk.MenuItem(_('Edit groups')) + item = gtk.MenuItem(_('Edit Groups')) menu.append(item) item.connect('activate', self.on_edit_groups, user, account) item = gtk.MenuItem() @@ -485,17 +487,17 @@ class Roster_window: sub_menu = gtk.Menu() item.set_submenu(sub_menu) - item = gtk.MenuItem(_('Resend authorization to')) + item = gtk.MenuItem(_('Resend Authorization to')) sub_menu.append(item) item.connect('activate', self.authorize, jid, account) - item = gtk.MenuItem(_('Rerequest authorization from')) + item = gtk.MenuItem(_('Rerequest Authorization from')) sub_menu.append(item) item.connect('activate', self.req_sub, jid, _('I would like to add you to my contact list.'), account) else: item = gtk.MenuItem() menu.append(item) - item = gtk.MenuItem(_('Add to roster')) + item = gtk.MenuItem(_('Add to Roster')) menu.append(item) item.connect('activate', self.on_add_to_roster, user, account) @@ -589,7 +591,7 @@ class Roster_window: item = gtk.MenuItem(_('Away')) sub_menu.append(item) item.connect('activate', self.change_status, account, 'away') - item = gtk.MenuItem(_('XA')) + item = gtk.MenuItem(_('Not Available')) sub_menu.append(item) item.connect('activate', self.change_status, account, 'xa') item = gtk.MenuItem(_('Busy')) @@ -607,19 +609,19 @@ class Roster_window: item = gtk.MenuItem() menu.append(item) - item = gtk.MenuItem(_('_Edit account')) + item = gtk.MenuItem(_('_Edit Account')) menu.append(item) item.connect('activate', self.on_edit_account, account) - item = gtk.MenuItem(_('_Service discovery')) + item = gtk.MenuItem(_('_Service Discovery')) menu.append(item) item.connect('activate', self.on_service_disco_menuitem_activate, account) - item = gtk.MenuItem(_('_Add contact')) + item = gtk.MenuItem(_('_Add Contact')) menu.append(item) item.connect('activate', self.on_add_new_contact, account) - item = gtk.MenuItem(_('Join _groupchat')) + item = gtk.MenuItem(_('Join _Groupchat')) menu.append(item) item.connect('activate', self.on_join_gc_activate, account) - item = gtk.MenuItem(_('_New message')) + item = gtk.MenuItem(_('_New Message')) menu.append(item) item.connect('activate', self.on_new_message_menuitem_activate, account) @@ -1168,8 +1170,6 @@ class Roster_window: model.set_value(iter, 5, False) def on_service_disco_menuitem_activate(self, widget, account): - '''When Service Discovery is selected: - Call browse class''' if self.plugin.windows[account].has_key('disco'): self.plugin.windows[account]['disco'].window.present() else: @@ -1395,16 +1395,18 @@ class Roster_window: start = '* ' self.window.set_title(start + 'Gajim') - def get_ui_status(self, status): + def get_uf_status(self, status, capitalize=True): + '''returns a userfriendly string for dnd/xa/chat + and capitalize()s the rest''' if status == 'dnd': - ui_status = 'Busy' + uf_status = 'Busy' elif status == 'xa': - ui_status = 'Extended Away' + uf_status = 'Not Available' elif status == 'chat': - ui_status = 'Free for chat' + uf_status = 'Free or Chat' else: - ui_status = status.capitalize() - return ui_status + uf_status = status.capitalize() + return uf_status def __init__(self, plugin): self.xml = gtk.glade.XML(GTKGUI_GLADE, 'roster_window', APP) @@ -1466,8 +1468,8 @@ class Roster_window: for status in ['online', 'chat', 'away', 'xa', 'dnd', 'invisible', 'offline']: - ui_status = self.get_ui_status(status) - iter = liststore.append([ui_status, self.jabber_state_images[status], status]) + uf_status = self.get_uf_status(status) + iter = liststore.append([uf_status, self.jabber_state_images[status], status]) self.status_combobox.show_all() self.status_combobox.set_model(liststore) self.status_combobox.set_active(6) # default to offline diff --git a/src/systray.py b/src/systray.py index 90eda8c4c..12e88e26d 100644 --- a/src/systray.py +++ b/src/systray.py @@ -161,7 +161,7 @@ class Systray: for group in self.plugin.roster.groups[account].keys(): if group == 'Transports': continue - # at least one not offline or with errors in this group + # at least one 'not offline' or 'without errors' in this group at_least_one = False item = gtk.MenuItem(group) groups_menu.append(item) @@ -172,7 +172,8 @@ class Systray: if group in user.groups and user.show != 'offline' and \ user.show != 'error': at_least_one = True - s = user.name.replace('_', '__') + ' (' + user.show + ')' + status = self.plugin.roster.get_uf_status(user.show) + s = user.name.replace('_', '__') + ' (' + status + ')' item = gtk.MenuItem(s) item.connect('activate', self.start_chat, account,\ user.jid) diff --git a/src/tabbed_chat_window.py b/src/tabbed_chat_window.py index d7aabdac0..2abf1d3ce 100644 --- a/src/tabbed_chat_window.py +++ b/src/tabbed_chat_window.py @@ -128,22 +128,19 @@ class Tabbed_chat_window(chat.Chat): chat.Chat.on_chat_notebook_key_press_event(self, widget, event) def on_clear_button_clicked(self, widget): - """When clear button is pressed: - clear the conversation""" + """When clear button is pressed: clear the conversation""" jid = self.get_active_jid() - conversation_buffer = self.xmls[jid].get_widget('conversation_textview').\ - get_buffer() - start, end = conversation_buffer.get_bounds() - conversation_buffer.delete(start, end) + textview = self.xmls[jid].get_widget('conversation_textview') + self.on_clear(None, textview) def on_history_button_clicked(self, widget): """When history button is pressed: call history window""" jid = self.get_active_jid() if self.plugin.windows['logs'].has_key(jid): - self.plugin.windows['logs'][jid].present() + self.plugin.windows['logs'][jid].window.present() else: self.plugin.windows['logs'][jid] = history_window.\ - History_window(self.plugin, self.account, jid) + History_window(self.plugin, jid, self.account) def remove_tab(self, jid): if time.time() - self.last_message_time[jid] < 2: @@ -193,7 +190,7 @@ class Tabbed_chat_window(chat.Chat): and printed in the conversation""" jid = self.get_active_jid() conversation_textview = self.xmls[jid].get_widget('conversation_textview') - if event.hardware_keycode == 23: # TAB + if event.hardware_keycode == 23: # TAB (do not make it .Tab ==> fails) if (event.state & gtk.gdk.CONTROL_MASK) and \ (event.state & gtk.gdk.SHIFT_MASK): # CTRL + SHIFT + TAB self.notebook.emit('key_press_event', event) @@ -221,6 +218,10 @@ class Tabbed_chat_window(chat.Chat): end_iter = message_buffer.get_end_iter() message = message_buffer.get_text(start_iter, end_iter, 0) if message != '': + if message == '/clear': + self.on_clear(None, conversation_textview) # clear conversation + self.on_clear(None, widget) # clear message textview too + return True keyID = '' if self.xmls[jid].get_widget('gpg_togglebutton').get_active(): keyID = self.users[jid].keyID @@ -231,7 +232,6 @@ class Tabbed_chat_window(chat.Chat): return False def on_contact_button_clicked(self, widget): - """When button contact is clicked""" jid = self.get_active_jid() user = self.users[jid] self.plugin.roster.on_info(widget, user, self.account) @@ -256,10 +256,10 @@ class Tabbed_chat_window(chat.Chat): self.plugin.roster.really_remove_user(user, self.account) def print_conversation(self, text, jid, contact = '', tim = None): - """Print a line in the conversation : - if contact is set to status : it's a status message - if contact is set to another value : it's an outgoing message - if contact is not set : it's an incomming message""" + """Print a line in the conversation: + if contact is set to status: it's a status message + if contact is set to another value: it's an outgoing message + if contact is not set: it's an incomming message""" user = self.users[jid] if contact == 'status': kind = 'status'