diff --git a/src/dialogs.py b/src/dialogs.py index e1bc94da0..d92698a16 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -850,3 +850,69 @@ class SendSingleMessageDialog: keyID = None, type = 'normal', subject=subject) self.message_tv_buffer.set_text('') # we sent ok, clear the textview + +class XMLConsoleWindow: + def __init__(self, plugin, account): + self.plugin = plugin + self.account = account + + self.xml = gtk.glade.XML(GTKGUI_GLADE, 'xml_console_window', APP) + self.window = self.xml.get_widget('xml_console_window') + self.input_textview = self.xml.get_widget('input_textview') + self.stanzas_log_textview = self.xml.get_widget('stanzas_log_textview') + self.input_tv_buffer = self.input_textview.get_buffer() + + print self.xml.get_widget('expander').set_resize_mode(gtk.RESIZE_IMMEDIATE) + + self.input_textview.modify_base( + gtk.STATE_NORMAL, gtk.gdk.color_parse('black')) + self.input_textview.modify_text( + gtk.STATE_NORMAL, gtk.gdk.color_parse('green')) + + self.stanzas_log_textview.modify_base( + gtk.STATE_NORMAL, gtk.gdk.color_parse('black')) + self.stanzas_log_textview.modify_text( + gtk.STATE_NORMAL, gtk.gdk.color_parse('green')) + + if len(gajim.connections) > 1: + title = _('XML Console for %s')\ + % gajim.config.get_per('accounts', self.account, 'name') + else: + title = _('XML Console') + + self.window.set_title(title) + + self.input_textview.grab_focus() + + self.xml.signal_autoconnect(self) + self.window.show_all() + + def on_send_button_clicked(self, widget): + begin_iter, end_iter = self.input_tv_buffer.get_bounds() + stanza = self.input_tv_buffer.get_text(begin_iter, end_iter) + if stanza: + gajim.connections[self.account].send_stanza(stanza) + self.input_tv_buffer.set_text('') # we sent ok, clear the textview + + def on_presence_button_clicked(self, widget): + self.input_tv_buffer.set_text( + '' + ) + + def on_iq_button_clicked(self, widget): + self.input_tv_buffer.set_text( + '' + ) + + def on_message_button_clicked(self, widget): + self.input_tv_buffer.set_text( + '' + ) + + def on_expander_size_request(self, widget, req): + pass + + def on_xml_console_window_destroy(self, widget): + # remove us from open windows + del self.plugin.windows[self.account]['xml_console'] + widget.destroy() diff --git a/src/gtkgui.glade b/src/gtkgui.glade index 1f2624c14..0fa9f7637 100644 --- a/src/gtkgui.glade +++ b/src/gtkgui.glade @@ -11864,7 +11864,6 @@ JID: whatever@jabber.org 6 - True GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE @@ -15182,7 +15181,7 @@ the Jabber network. True - + True gtk-jump-to 1 @@ -15209,7 +15208,7 @@ the Jabber network. True - + True gtk-refresh 1 @@ -15242,7 +15241,7 @@ the Jabber network. - + True gtk-dialog-authentication 1 @@ -15267,7 +15266,7 @@ the Jabber network. True - + True gtk-dialog-question 1 @@ -15284,11 +15283,11 @@ the Jabber network. True - Re_send Authorization to + Send Authorization to True - + True gtk-go-up 1 @@ -15304,11 +15303,11 @@ the Jabber network. True - Rere_quest Authorization from + Re_quest Authorization from True - + True gtk-go-down 1 @@ -15331,7 +15330,7 @@ the Jabber network. True - + True gtk-add 1 @@ -15350,7 +15349,7 @@ the Jabber network. True - + True gtk-remove 1 @@ -15382,7 +15381,7 @@ the Jabber network. True - + True gtk-justify-fill 1 @@ -15777,26 +15776,62 @@ the Jabber network. - + True _Information True + + + + True + gtk-justify-fill + 1 + 0.5 + 0.5 + 0 + 0 + + - + True _Add to Roster True + + + + True + gtk-add + 1 + 0.5 + 0.5 + 0 + 0 + + - + True _Send Private Message True + + + + True + gtk-jump-to + 1 + 0.5 + 0.5 + 0 + 0 + + @@ -16086,7 +16121,7 @@ Maybe I'll refactor later True - + True gtk-network 1 @@ -16112,7 +16147,7 @@ Maybe I'll refactor later True - + True gtk-dialog-warning 1 @@ -16133,7 +16168,7 @@ Maybe I'll refactor later True - + True gtk-execute 1 @@ -16157,7 +16192,7 @@ Maybe I'll refactor later True - + True gtk-preferences 1 @@ -16177,7 +16212,7 @@ Maybe I'll refactor later True - + True gtk-find 1 @@ -16197,7 +16232,7 @@ Maybe I'll refactor later True - + True gtk-add 1 @@ -16217,7 +16252,7 @@ Maybe I'll refactor later True - + True gtk-connect 1 @@ -16237,7 +16272,7 @@ Maybe I'll refactor later True - + True gtk-new 1 @@ -16251,4 +16286,296 @@ Maybe I'll refactor later + + 12 + + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 550 + 450 + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + + + + + True + True + 390 + + + + True + False + 6 + + + + True + <b>Jabber Traffic</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + False + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_CHAR + True + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0 + True + True + + + + + True + True + + + + + + True + True + False + 6 + + + + + True + False + 6 + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_CHAR + True + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_END + 6 + + + + True + True + _IQ + True + GTK_RELIEF_NORMAL + True + + + + + + + True + True + _Presence + True + GTK_RELIEF_NORMAL + True + + + + + + + True + True + _Message + True + GTK_RELIEF_NORMAL + True + + + + + + + True + True + True + GTK_RELIEF_NORMAL + True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-apply + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Send + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + 0 + False + False + + + + + + + + True + <b>XML Input</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + label_item + + + + + True + True + + + + + + diff --git a/src/roster_window.py b/src/roster_window.py index 034ae565d..ea6fe6b9e 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -643,7 +643,6 @@ class RosterWindow: roster_contact_context_menu.popup(None, None, None, event.button, event.time) roster_contact_context_menu.show_all() - roster_contact_context_menu.reposition() def mk_menu_g(self, event, iter): '''Make group's popup menu''' @@ -665,7 +664,6 @@ class RosterWindow: menu.popup(None, None, None, event.button, event.time) menu.show_all() - menu.reposition() def mk_menu_agent(self, event, iter): '''Make agent's popup menu''' @@ -676,66 +674,52 @@ class RosterWindow: user = self.contacts[account][jid][0] menu = gtk.Menu() - item = gtk.MenuItem() + item = gtk.ImageMenuItem(_('_Log on')) icon = gtk.Image() icon.set_from_stock(gtk.STOCK_YES, gtk.ICON_SIZE_MENU) - label = gtk.Label(_('_Log on')) - label.set_use_underline(True) - hbox = gtk.HBox(False, 3) - hbox.pack_start(icon, False, False) - hbox.pack_start(label, False, False) - item.add(hbox) + item.set_image(icon) menu.append(item) show = self.contacts[account][jid][0].show if show != 'offline' and show != 'error': item.set_sensitive(False) item.connect('activate', self.on_agent_logging, jid, None, account) - item = gtk.MenuItem() + item = gtk.ImageMenuItem(_('Log _off')) icon = gtk.Image() icon.set_from_stock(gtk.STOCK_NO, gtk.ICON_SIZE_MENU) - label = gtk.Label(_('Log _off')) - label.set_use_underline(True) - hbox = gtk.HBox(False, 3) - hbox.pack_start(icon, False, False) - hbox.pack_start(label, False, False) - item.add(hbox) + item.set_image(icon) menu.append(item) if show == 'offline' or show == 'error': item.set_sensitive(False) item.connect('activate', self.on_agent_logging, jid, 'unavailable', account) - item = gtk.MenuItem() + item = gtk.MenuItem() # seperator menu.append(item) - item = gtk.MenuItem() + item = gtk.ImageMenuItem(_('Edit')) icon = gtk.Image() - icon.set_from_stock(gtk.STOCK_EDIT, gtk.ICON_SIZE_MENU) - label = gtk.Label(_('Edit')) - label.set_use_underline(True) - hbox = gtk.HBox(False, 3) - hbox.pack_start(icon, False, False) - hbox.pack_start(label, False, False) - item.add(hbox) + icon.set_from_stock(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_MENU) + item.set_image(icon) menu.append(item) item.connect('activate', self.on_edit_agent, user, account) - item = gtk.MenuItem() + item = gtk.ImageMenuItem(_('_Remove from Roster')) icon = gtk.Image() icon.set_from_stock(gtk.STOCK_REMOVE, gtk.ICON_SIZE_MENU) - label = gtk.Label(_('_Remove from Roster')) - label.set_use_underline(True) - hbox = gtk.HBox(False, 3) - hbox.pack_start(icon, False, False) - hbox.pack_start(label, False, False) - item.add(hbox) + item.set_image(icon) menu.append(item) item.connect('activate', self.on_remove_agent, user, account) menu.popup(None, None, None, event.button, event.time) menu.show_all() - menu.reposition() + + def on_xml_console(self, widget, account): + if self.plugin.windows[account].has_key('xml_console'): + self.plugin.windows[account]['xml_console'].window.present() + else: + self.plugin.windows[account]['xml_console'] = \ + dialogs.XMLConsoleWindow(self.plugin, account) def on_edit_account(self, widget, account): if self.plugin.windows[account].has_key('account_modification'): @@ -766,6 +750,8 @@ class RosterWindow: status_menuitem = childs[0] #sep advanced_actions_menuitem = childs[2] + xml_console_menuitem =\ + advanced_actions_menuitem.get_submenu().get_children()[0] edit_account_menuitem = childs[3] service_discovery_menuitem = childs[4] add_contact_menuitem = childs[5] @@ -788,6 +774,8 @@ class RosterWindow: sub_menu.append(item) item.connect('activate', self.change_status, account, show) + + xml_console_menuitem.connect('activate', self.on_xml_console, account) edit_account_menuitem.connect('activate', self.on_edit_account, account) service_discovery_menuitem.connect('activate', self.on_service_disco_menuitem_activate, account) @@ -799,7 +787,6 @@ class RosterWindow: account_context_menu.popup(None, None, None, event.button, event.time) account_context_menu.show_all() - account_context_menu.reposition() def on_add_to_roster(self, widget, user, account): dialogs.AddNewContactWindow(self.plugin, account, user.jid) @@ -808,7 +795,7 @@ class RosterWindow: '''Authorize a user (by re-sending auth menuitem)''' gajim.connections[account].send_authorization(jid) dialogs.InformationDialog(_('Authorization has been sent'), - _('Now "%s" will know when your status.') %jid).get_response() + _('Now "%s" will know your status.') %jid).get_response() def req_sub(self, widget, jid, txt, account, group=None, pseudo=None): '''Request subscription to a user'''