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
This commit is contained in:
Nikos Kouremenos 2005-05-13 16:53:30 +00:00
parent 2737236f48
commit 97aef098bc
8 changed files with 113 additions and 77 deletions

View file

@ -139,7 +139,7 @@ class Chat:
return active_jid return active_jid
def on_close_button_clicked(self, button, 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) self.remove_tab(jid)
def on_chat_window_focus_in_event(self, widget, event): def on_chat_window_focus_in_event(self, widget, event):
@ -167,8 +167,8 @@ class Chat:
new_jid = jid new_jid = jid
break break
conversation_textview = self.xmls[new_jid].\ conversation_textview = self.xmls[new_jid].get_widget(
get_widget('conversation_textview') 'conversation_textview')
conversation_buffer = conversation_textview.get_buffer() conversation_buffer = conversation_textview.get_buffer()
end_iter = conversation_buffer.get_end_iter() end_iter = conversation_buffer.get_end_iter()
end_rect = conversation_textview.get_iter_location(end_iter) end_rect = conversation_textview.get_iter_location(end_iter)
@ -225,8 +225,8 @@ class Chat:
self.nb_unread[jid] = 0 self.nb_unread[jid] = 0
self.last_message_time[jid] = 0 self.last_message_time[jid] = 0
conversation_textview = \ conversation_textview = self.xmls[jid].get_widget(
self.xmls[jid].get_widget('conversation_textview') 'conversation_textview')
conversation_buffer = conversation_textview.get_buffer() conversation_buffer = conversation_textview.get_buffer()
end_iter = conversation_buffer.get_end_iter() end_iter = conversation_buffer.get_end_iter()
@ -411,18 +411,19 @@ class Chat:
x, y = widget.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT, x, y) x, y = widget.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT, x, y)
tags = widget.get_iter_at_location(x, y).get_tags() tags = widget.get_iter_at_location(x, y).get_tags()
if self.change_cursor: 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)) gtk.gdk.Cursor(gtk.gdk.XTERM))
self.change_cursor = None self.change_cursor = None
tag_table = widget.get_buffer().get_tag_table() tag_table = widget.get_buffer().get_tag_table()
for tag in tags: for tag in tags:
if tag == tag_table.lookup('url') or tag == tag_table.lookup('mail'): 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)) gtk.gdk.Cursor(gtk.gdk.HAND2))
self.change_cursor = tag self.change_cursor = tag
return False return False
def on_clear(self, widget, textview): def on_clear(self, widget, textview):
'''clear text found in the given textview'''
buffer = textview.get_buffer() buffer = textview.get_buffer()
start, end = buffer.get_bounds() start, end = buffer.get_bounds()
buffer.delete(start, end) buffer.delete(start, end)
@ -489,15 +490,15 @@ class Chat:
def make_link_menu(self, event, kind, text): def make_link_menu(self, event, kind, text):
menu = gtk.Menu() menu = gtk.Menu()
if kind == 'mail': if kind == 'mail':
item = gtk.MenuItem(_('_Open email composer')) item = gtk.MenuItem(_('_Open Email Composer'))
else: else:
item = gtk.MenuItem(_('_Open link')) item = gtk.MenuItem(_('_Open Link'))
item.connect('activate', self.on_open_link_activated, kind, text) item.connect('activate', self.on_open_link_activated, kind, text)
menu.append(item) menu.append(item)
if kind == 'mail': if kind == 'mail':
item = gtk.MenuItem(_('_Copy email address')) item = gtk.MenuItem(_('_Copy Email Address'))
else: # It's an url 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) item.connect('activate', self.on_copy_link_activated, text)
menu.append(item) menu.append(item)

View file

@ -179,8 +179,8 @@ class Change_status_message_dialog:
def __init__(self, plugin, status): def __init__(self, plugin, status):
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'change_status_message_dialog', APP) self.xml = gtk.glade.XML(GTKGUI_GLADE, 'change_status_message_dialog', APP)
self.window = self.xml.get_widget('change_status_message_dialog') self.window = self.xml.get_widget('change_status_message_dialog')
ui_status = plugin.roster.get_ui_status(status) uf_status = plugin.roster.get_uf_status(status)
self.window.set_title(ui_status + ' Status Message') self.window.set_title(uf_status + ' Status Message')
message_textview = self.xml.get_widget('message_textview') message_textview = self.xml.get_widget('message_textview')
self.message_buffer = message_textview.get_buffer() self.message_buffer = message_textview.get_buffer()

View file

@ -337,9 +337,9 @@ class Groupchat_window(chat.Chat):
return False return False
def print_conversation(self, text, room_jid, contact = '', tim = None): def print_conversation(self, text, room_jid, contact = '', tim = None):
"""Print a line in the conversation : """Print a line in the conversation:
if contact is set : it's a message from someone if contact is set: it's a message from someone
if contact is not set : it's a message from the server""" if contact is not set: it's a message from the server"""
other_tags_for_name = [] other_tags_for_name = []
if contact: if contact:
if contact == self.nicks[room_jid]: if contact == self.nicks[room_jid]:
@ -412,11 +412,10 @@ class Groupchat_window(chat.Chat):
def on_info(self, widget, jid): def on_info(self, widget, jid):
"""Call vcard_information_window class to display user's information""" """Call vcard_information_window class to display user's information"""
if self.plugin.windows[self.account]['infos'].has_key(jid): 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: else:
self.plugin.windows[self.account]['infos'][jid] = \ self.plugin.windows[self.account]['infos'][jid] = \
dialogs.Vcard_window(jid, self.plugin, dialogs.Vcard_window(jid, self.plugin, self.account, True)
self.account, True)
# FIXME: when we'll have a user for each contact, this won't be needed # FIXME: when we'll have a user for each contact, this won't be needed
# cause we'll user real information window # cause we'll user real information window
vcard_xml = self.plugin.windows[self.account]['infos'][jid].xml vcard_xml = self.plugin.windows[self.account]['infos'][jid].xml

View file

@ -9767,7 +9767,7 @@ send a chat message to</property>
<child> <child>
<widget class="GtkMenuItem" id="free_for_chat_menuitem"> <widget class="GtkMenuItem" id="free_for_chat_menuitem">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">Free for chat</property> <property name="label" translatable="yes">Free for Chat</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<signal name="activate" handler="on_free_for_chat_menuitem_activate" last_modification_time="Mon, 18 Apr 2005 22:28:10 GMT"/> <signal name="activate" handler="on_free_for_chat_menuitem_activate" last_modification_time="Mon, 18 Apr 2005 22:28:10 GMT"/>
</widget> </widget>
@ -9845,7 +9845,7 @@ send a chat message to</property>
<child> <child>
<widget class="GtkImageMenuItem" id="new_message_menuitem"> <widget class="GtkImageMenuItem" id="new_message_menuitem">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">New message</property> <property name="label" translatable="yes">New Message</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child internal-child="image"> <child internal-child="image">
@ -10114,7 +10114,7 @@ send a chat message to</property>
<widget class="GtkDialog" id="new_version_available_dialog"> <widget class="GtkDialog" id="new_version_available_dialog">
<property name="border_width">4</property> <property name="border_width">4</property>
<property name="width_request">490</property> <property name="width_request">510</property>
<property name="height_request">250</property> <property name="height_request">250</property>
<property name="title" translatable="yes">New version of Gajim available</property> <property name="title" translatable="yes">New version of Gajim available</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="type">GTK_WINDOW_TOPLEVEL</property>
@ -10165,6 +10165,29 @@ send a chat message to</property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkHBox" id="hbox2959">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkImage" id="image506">
<property name="visible">True</property>
<property name="stock">gtk-dialog-info</property>
<property name="icon_size">6</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child> <child>
<widget class="GtkLabel" id="information_label"> <widget class="GtkLabel" id="information_label">
<property name="visible">True</property> <property name="visible">True</property>
@ -10185,6 +10208,13 @@ send a chat message to</property>
<property name="fill">False</property> <property name="fill">False</property>
</packing> </packing>
</child> </child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child> <child>
<widget class="GtkFrame" id="frame28"> <widget class="GtkFrame" id="frame28">

View file

@ -139,15 +139,18 @@ class History_window:
_('Status is now: ') + data[0] _('Status is now: ') + data[0]
+ ': ' + msg, 'status') + ': ' + msg, 'status')
def __init__(self, plugin, account, jid): def __init__(self, plugin, jid, account=None):
self.plugin = plugin self.plugin = plugin
self.jid = jid self.jid = jid
self.nb_line = gajim.logger.get_nb_line(jid) self.nb_line = gajim.logger.get_nb_line(jid)
xml = gtk.glade.XML(GTKGUI_GLADE, 'history_window', APP) xml = gtk.glade.XML(GTKGUI_GLADE, 'history_window', APP)
self.window = xml.get_widget('history_window') self.window = xml.get_widget('history_window')
if account:
list_users = self.plugin.roster.contacts[account][self.jid] list_users = self.plugin.roster.contacts[account][self.jid]
user = list_users[0] user = list_users[0]
title = 'Conversation History with ' + user.name title = 'Conversation History with ' + user.name
else:
title = 'Conversation History with ' + jid
self.window.set_title(title) self.window.set_title(title)
self.history_buffer = xml.get_widget('history_textview').get_buffer() self.history_buffer = xml.get_widget('history_textview').get_buffer()
self.earliest_button = xml.get_widget('earliest_button') self.earliest_button = xml.get_widget('earliest_button')

View file

@ -454,10 +454,12 @@ class Roster_window:
dlg.run() dlg.run()
def on_history(self, widget, user): def on_history(self, widget, user):
'''When history button is pressed: call log window''' '''When history menuitem is activated: call log window'''
if not self.plugin.windows['logs'].has_key(user.jid): 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.\ 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): def mk_menu_user(self, event, iter):
'''Make user's popup menu''' '''Make user's popup menu'''
@ -475,7 +477,7 @@ class Roster_window:
menu.append(item) menu.append(item)
item.connect('activate', self.on_rename, iter, path) item.connect('activate', self.on_rename, iter, path)
if not 'not in the roster' in user.groups: if not 'not in the roster' in user.groups:
item = gtk.MenuItem(_('Edit groups')) item = gtk.MenuItem(_('Edit Groups'))
menu.append(item) menu.append(item)
item.connect('activate', self.on_edit_groups, user, account) item.connect('activate', self.on_edit_groups, user, account)
item = gtk.MenuItem() item = gtk.MenuItem()
@ -485,17 +487,17 @@ class Roster_window:
sub_menu = gtk.Menu() sub_menu = gtk.Menu()
item.set_submenu(sub_menu) item.set_submenu(sub_menu)
item = gtk.MenuItem(_('Resend authorization to')) item = gtk.MenuItem(_('Resend Authorization to'))
sub_menu.append(item) sub_menu.append(item)
item.connect('activate', self.authorize, jid, account) item.connect('activate', self.authorize, jid, account)
item = gtk.MenuItem(_('Rerequest authorization from')) item = gtk.MenuItem(_('Rerequest Authorization from'))
sub_menu.append(item) sub_menu.append(item)
item.connect('activate', self.req_sub, jid, item.connect('activate', self.req_sub, jid,
_('I would like to add you to my contact list.'), account) _('I would like to add you to my contact list.'), account)
else: else:
item = gtk.MenuItem() item = gtk.MenuItem()
menu.append(item) menu.append(item)
item = gtk.MenuItem(_('Add to roster')) item = gtk.MenuItem(_('Add to Roster'))
menu.append(item) menu.append(item)
item.connect('activate', self.on_add_to_roster, user, account) item.connect('activate', self.on_add_to_roster, user, account)
@ -589,7 +591,7 @@ class Roster_window:
item = gtk.MenuItem(_('Away')) item = gtk.MenuItem(_('Away'))
sub_menu.append(item) sub_menu.append(item)
item.connect('activate', self.change_status, account, 'away') item.connect('activate', self.change_status, account, 'away')
item = gtk.MenuItem(_('XA')) item = gtk.MenuItem(_('Not Available'))
sub_menu.append(item) sub_menu.append(item)
item.connect('activate', self.change_status, account, 'xa') item.connect('activate', self.change_status, account, 'xa')
item = gtk.MenuItem(_('Busy')) item = gtk.MenuItem(_('Busy'))
@ -607,19 +609,19 @@ class Roster_window:
item = gtk.MenuItem() item = gtk.MenuItem()
menu.append(item) menu.append(item)
item = gtk.MenuItem(_('_Edit account')) item = gtk.MenuItem(_('_Edit Account'))
menu.append(item) menu.append(item)
item.connect('activate', self.on_edit_account, account) item.connect('activate', self.on_edit_account, account)
item = gtk.MenuItem(_('_Service discovery')) item = gtk.MenuItem(_('_Service Discovery'))
menu.append(item) menu.append(item)
item.connect('activate', self.on_service_disco_menuitem_activate, account) item.connect('activate', self.on_service_disco_menuitem_activate, account)
item = gtk.MenuItem(_('_Add contact')) item = gtk.MenuItem(_('_Add Contact'))
menu.append(item) menu.append(item)
item.connect('activate', self.on_add_new_contact, account) item.connect('activate', self.on_add_new_contact, account)
item = gtk.MenuItem(_('Join _groupchat')) item = gtk.MenuItem(_('Join _Groupchat'))
menu.append(item) menu.append(item)
item.connect('activate', self.on_join_gc_activate, account) item.connect('activate', self.on_join_gc_activate, account)
item = gtk.MenuItem(_('_New message')) item = gtk.MenuItem(_('_New Message'))
menu.append(item) menu.append(item)
item.connect('activate', self.on_new_message_menuitem_activate, account) item.connect('activate', self.on_new_message_menuitem_activate, account)
@ -1168,8 +1170,6 @@ class Roster_window:
model.set_value(iter, 5, False) model.set_value(iter, 5, False)
def on_service_disco_menuitem_activate(self, widget, account): 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'): if self.plugin.windows[account].has_key('disco'):
self.plugin.windows[account]['disco'].window.present() self.plugin.windows[account]['disco'].window.present()
else: else:
@ -1395,16 +1395,18 @@ class Roster_window:
start = '* ' start = '* '
self.window.set_title(start + 'Gajim') 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': if status == 'dnd':
ui_status = 'Busy' uf_status = 'Busy'
elif status == 'xa': elif status == 'xa':
ui_status = 'Extended Away' uf_status = 'Not Available'
elif status == 'chat': elif status == 'chat':
ui_status = 'Free for chat' uf_status = 'Free or Chat'
else: else:
ui_status = status.capitalize() uf_status = status.capitalize()
return ui_status return uf_status
def __init__(self, plugin): def __init__(self, plugin):
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'roster_window', APP) 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', for status in ['online', 'chat', 'away', 'xa', 'dnd', 'invisible',
'offline']: 'offline']:
ui_status = self.get_ui_status(status) uf_status = self.get_uf_status(status)
iter = liststore.append([ui_status, self.jabber_state_images[status], status]) iter = liststore.append([uf_status, self.jabber_state_images[status], status])
self.status_combobox.show_all() self.status_combobox.show_all()
self.status_combobox.set_model(liststore) self.status_combobox.set_model(liststore)
self.status_combobox.set_active(6) # default to offline self.status_combobox.set_active(6) # default to offline

View file

@ -161,7 +161,7 @@ class Systray:
for group in self.plugin.roster.groups[account].keys(): for group in self.plugin.roster.groups[account].keys():
if group == 'Transports': if group == 'Transports':
continue 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 at_least_one = False
item = gtk.MenuItem(group) item = gtk.MenuItem(group)
groups_menu.append(item) groups_menu.append(item)
@ -172,7 +172,8 @@ class Systray:
if group in user.groups and user.show != 'offline' and \ if group in user.groups and user.show != 'offline' and \
user.show != 'error': user.show != 'error':
at_least_one = True 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 = gtk.MenuItem(s)
item.connect('activate', self.start_chat, account,\ item.connect('activate', self.start_chat, account,\
user.jid) user.jid)

View file

@ -128,22 +128,19 @@ class Tabbed_chat_window(chat.Chat):
chat.Chat.on_chat_notebook_key_press_event(self, widget, event) chat.Chat.on_chat_notebook_key_press_event(self, widget, event)
def on_clear_button_clicked(self, widget): def on_clear_button_clicked(self, widget):
"""When clear button is pressed: """When clear button is pressed: clear the conversation"""
clear the conversation"""
jid = self.get_active_jid() jid = self.get_active_jid()
conversation_buffer = self.xmls[jid].get_widget('conversation_textview').\ textview = self.xmls[jid].get_widget('conversation_textview')
get_buffer() self.on_clear(None, textview)
start, end = conversation_buffer.get_bounds()
conversation_buffer.delete(start, end)
def on_history_button_clicked(self, widget): def on_history_button_clicked(self, widget):
"""When history button is pressed: call history window""" """When history button is pressed: call history window"""
jid = self.get_active_jid() jid = self.get_active_jid()
if self.plugin.windows['logs'].has_key(jid): if self.plugin.windows['logs'].has_key(jid):
self.plugin.windows['logs'][jid].present() self.plugin.windows['logs'][jid].window.present()
else: else:
self.plugin.windows['logs'][jid] = history_window.\ 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): def remove_tab(self, jid):
if time.time() - self.last_message_time[jid] < 2: if time.time() - self.last_message_time[jid] < 2:
@ -193,7 +190,7 @@ class Tabbed_chat_window(chat.Chat):
and printed in the conversation""" and printed in the conversation"""
jid = self.get_active_jid() jid = self.get_active_jid()
conversation_textview = self.xmls[jid].get_widget('conversation_textview') 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 \ if (event.state & gtk.gdk.CONTROL_MASK) and \
(event.state & gtk.gdk.SHIFT_MASK): # CTRL + SHIFT + TAB (event.state & gtk.gdk.SHIFT_MASK): # CTRL + SHIFT + TAB
self.notebook.emit('key_press_event', event) self.notebook.emit('key_press_event', event)
@ -221,6 +218,10 @@ class Tabbed_chat_window(chat.Chat):
end_iter = message_buffer.get_end_iter() end_iter = message_buffer.get_end_iter()
message = message_buffer.get_text(start_iter, end_iter, 0) message = message_buffer.get_text(start_iter, end_iter, 0)
if message != '': 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 = '' keyID = ''
if self.xmls[jid].get_widget('gpg_togglebutton').get_active(): if self.xmls[jid].get_widget('gpg_togglebutton').get_active():
keyID = self.users[jid].keyID keyID = self.users[jid].keyID
@ -231,7 +232,6 @@ class Tabbed_chat_window(chat.Chat):
return False return False
def on_contact_button_clicked(self, widget): def on_contact_button_clicked(self, widget):
"""When button contact is clicked"""
jid = self.get_active_jid() jid = self.get_active_jid()
user = self.users[jid] user = self.users[jid]
self.plugin.roster.on_info(widget, user, self.account) 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) self.plugin.roster.really_remove_user(user, self.account)
def print_conversation(self, text, jid, contact = '', tim = None): def print_conversation(self, text, jid, contact = '', tim = None):
"""Print a line in the conversation : """Print a line in the conversation:
if contact is set to status : it's a status message 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 set to another value: it's an outgoing message
if contact is not set : it's an incomming message""" if contact is not set: it's an incomming message"""
user = self.users[jid] user = self.users[jid]
if contact == 'status': if contact == 'status':
kind = 'status' kind = 'status'