Author: asterix Date: 2007-04-19 23:23:50 +0200 (Thu, 19 Apr 2007) New Revision: 8087
Modified: trunk/data/glade/chat_control_popup_menu.glade trunk/src/chat_control.py Log: remove ping menuitem and add /help command to chat_window. fixes #2947
Modified: trunk/data/glade/chat_control_popup_menu.glade =================================================================== --- trunk/data/glade/chat_control_popup_menu.glade 2007-04-19 20:54:42 UTC (rev 8086) +++ trunk/data/glade/chat_control_popup_menu.glade 2007-04-19 21:23:50 UTC (rev 8087) @@ -13,7 +13,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image1366"> + <widget class="GtkImage" id="image1370"> <property name="visible">True</property> <property name="stock">gtk-justify-fill</property> <property name="icon_size">1</property> @@ -42,7 +42,7 @@ <signal name="activate" handler="_on_send_file_menuitem_activate" last_modification_time="Tue, 03 Jan 2006 04:26:55 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image1367"> + <widget class="GtkImage" id="image1371"> <property name="visible">True</property> <property name="stock">gtk-file</property> <property name="icon_size">1</property> @@ -83,7 +83,7 @@ <signal name="activate" handler="_on_add_to_roster_menuitem_activate" last_modification_time="Tue, 03 Jan 2006 04:26:37 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image1368"> + <widget class="GtkImage" id="image1372"> <property name="visible">True</property> <property name="stock">gtk-add</property> <property name="icon_size">1</property> @@ -95,15 +95,6 @@ </child> </widget> </child> - - <child> - <widget class="GtkMenuItem" id="ping_menuitem"> - <property name="visible">True</property> - <property name="label" translatable="yes">Ping</property> - <property name="use_underline">True</property> - <signal name="activate" handler="_on_ping_menuitem_activate" last_modification_time="Mon, 16 Apr 2007 18:23:32 GMT"/> - </widget> - </child> </widget>
</glade-interface>
Modified: trunk/src/chat_control.py =================================================================== --- trunk/src/chat_control.py 2007-04-19 20:54:42 UTC (rev 8086) +++ trunk/src/chat_control.py 2007-04-19 21:23:50 UTC (rev 8087) @@ -498,11 +498,6 @@ if message_array == ['']: message_array = []
- if command == 'ping' and not len(message_array): - gajim.connections[self.account].sendPing(self.contact) - self.clear(self.msg_textview) - return True - if command == 'clear' and not len(message_array): self.conv_textview.clear() # clear conversation self.clear(self.msg_textview) # clear message textview too @@ -866,6 +861,7 @@ '''A control for standard 1-1 chat''' TYPE_ID = message_control.TYPE_CHAT old_msg_kind = None # last kind of the printed message + CHAT_CMDS = ['clear', 'compact', 'help', 'ping'] def __init__(self, parent_win, contact, acct, resource = None): ChatControlBase.__init__(self, self.TYPE_ID, parent_win, @@ -1144,6 +1140,49 @@ self.contact.get_shown_name() gtk.Tooltips().set_tip(self.xml.get_widget('gpg_eventbox'), tt)
+ def _process_command(self, message): + if message[0] != '/': + return False + + # Handle common commands + if ChatControlBase._process_command(self, message): + return True + + message = message[1:] + message_array = message.split(' ', 1) + command = message_array.pop(0).lower() + if message_array == ['']: + message_array = [] + + if command == 'help': + if len(message_array): + subcommand = message_array.pop(0) + self.get_command_help(subcommand) + else: + self.get_command_help(command) + self.clear(self.msg_textview) + return True + elif command == 'ping' and not len(message_array): + gajim.connections[self.account].sendPing(self.contact) + self.clear(self.msg_textview) + return True + return False + + def get_command_help(self, command): + if command == 'help': + self.print_conversation(_('Commands: %s') % ChatControl.CHAT_CMDS, + 'info') + elif command == 'clear': + self.print_conversation(_('Usage: /%s, clears the text window.'), + 'info') + elif command == 'compact': + self.print_conversation(_('Usage: /%s, hide the chat buttons.'), + 'info') + elif command == 'ping': + self.print_conversation(_(''), 'info') + else: + self.print_conversation(_('No help info for /%s') % command, 'info') + def send_message(self, message, keyID = '', chatstate = None): '''Send a message to contact''' if message in ('', None, '\n') or self._process_command(message): @@ -1393,7 +1432,6 @@ toggle_gpg_menuitem = xml.get_widget('toggle_gpg_menuitem') add_to_roster_menuitem = xml.get_widget('add_to_roster_menuitem') send_file_menuitem = xml.get_widget('send_file_menuitem') - ping_menuitem = xml.get_widget('ping_menuitem') compact_view_menuitem = xml.get_widget('compact_view_menuitem') information_menuitem = xml.get_widget('information_menuitem') @@ -1434,8 +1472,6 @@ id = history_menuitem.connect('activate', self._on_history_menuitem_activate) self.handlers[id] = history_menuitem - id = ping_menuitem.connect('activate', - self._on_ping_menuitem_activate) id = send_file_menuitem.connect('activate', self._on_send_file_menuitem_activate) self.handlers[id] = send_file_menuitem @@ -1830,9 +1866,6 @@ cursor = gtk.gdk.Cursor(gtk.gdk.LEFT_PTR) self.bigger_avatar_window.window.set_cursor(cursor)
- def _on_ping_menuitem_activate(self, widget): - gajim.connections[self.account].sendPing(self.contact) - def _on_send_file_menuitem_activate(self, widget): gajim.interface.instances['file_transfers'].show_file_send_request( self.account, self.contact)