add account combobox to join groupchat dialog when we try to join a groupchat from another chat / groupchat. Fixes #3344

This commit is contained in:
Yann Leboulanger 2009-09-02 23:45:16 +02:00
parent a2ca911d80
commit 682d6f838a
4 changed files with 318 additions and 397 deletions

View File

@ -1,365 +1,259 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> <?xml version="1.0"?>
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface> <glade-interface>
<!-- interface-requires gtk+ 2.12 -->
<widget class="GtkWindow" id="join_groupchat_window"> <!-- interface-naming-policy toplevel-contextual -->
<property name="border_width">6</property> <widget class="GtkWindow" id="join_groupchat_window">
<property name="title" translatable="yes">Join Group Chat</property> <property name="border_width">6</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="title" translatable="yes">Join Group Chat</property>
<property name="window_position">GTK_WIN_POS_NONE</property> <signal name="destroy" handler="on_join_groupchat_window_destroy"/>
<property name="modal">False</property> <signal name="key_press_event" handler="on_join_groupchat_window_key_press_event"/>
<property name="resizable">True</property> <child>
<property name="destroy_with_parent">False</property> <widget class="GtkVBox" id="vbox28">
<property name="decorated">True</property> <property name="visible">True</property>
<property name="skip_taskbar_hint">False</property> <property name="spacing">12</property>
<property name="skip_pager_hint">False</property> <child>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> <widget class="GtkTable" id="table15">
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="visible">True</property>
<property name="focus_on_map">True</property> <property name="n_rows">6</property>
<property name="urgency_hint">False</property> <property name="n_columns">2</property>
<signal name="destroy" handler="on_join_groupchat_window_destroy" last_modification_time="Wed, 02 Mar 2005 12:20:14 GMT"/> <property name="column_spacing">12</property>
<signal name="key_press_event" handler="on_join_groupchat_window_key_press_event" last_modification_time="Tue, 05 Apr 2005 13:13:40 GMT"/> <property name="row_spacing">6</property>
<child>
<child> <widget class="GtkEntry" id="room_jid_entry">
<widget class="GtkVBox" id="vbox28"> <property name="visible">True</property>
<property name="visible">True</property> <property name="can_focus">True</property>
<property name="homogeneous">False</property> <property name="has_focus">True</property>
<property name="spacing">12</property> <property name="activates_default">True</property>
<signal name="changed" handler="on_required_entry_changed"/>
<child> </widget>
<widget class="GtkTable" id="table15"> <packing>
<property name="visible">True</property> <property name="left_attach">1</property>
<property name="n_rows">5</property> <property name="right_attach">2</property>
<property name="n_columns">2</property> <property name="top_attach">3</property>
<property name="homogeneous">False</property> <property name="bottom_attach">4</property>
<property name="row_spacing">6</property> <property name="y_options"></property>
<property name="column_spacing">12</property> </packing>
</child>
<child> <child>
<widget class="GtkEntry" id="room_jid_entry"> <widget class="GtkEntry" id="nickname_entry">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="has_focus">True</property> <property name="activates_default">True</property>
<property name="editable">True</property> <signal name="changed" handler="on_required_entry_changed"/>
<property name="visibility">True</property> </widget>
<property name="max_length">0</property> <packing>
<property name="text" translatable="yes"></property> <property name="left_attach">1</property>
<property name="has_frame">True</property> <property name="right_attach">2</property>
<property name="activates_default">True</property> <property name="top_attach">2</property>
<signal name="changed" handler="on_required_entry_changed" last_modification_time="Sat, 14 Jan 2006 21:51:39 GMT"/> <property name="bottom_attach">3</property>
</widget> <property name="y_options"></property>
<packing> </packing>
<property name="left_attach">1</property> </child>
<property name="right_attach">2</property> <child>
<property name="top_attach">2</property> <widget class="GtkLabel" id="label143">
<property name="bottom_attach">3</property> <property name="visible">True</property>
<property name="y_options"></property> <property name="xalign">0</property>
</packing> <property name="label" translatable="yes">Room:</property>
</child> </widget>
<packing>
<child> <property name="top_attach">3</property>
<widget class="GtkEntry" id="nickname_entry"> <property name="bottom_attach">4</property>
<property name="visible">True</property> <property name="x_options">GTK_FILL</property>
<property name="can_focus">True</property> <property name="y_options"></property>
<property name="editable">True</property> </packing>
<property name="visibility">True</property> </child>
<property name="max_length">0</property> <child>
<property name="text" translatable="yes"></property> <widget class="GtkLabel" id="label142">
<property name="has_frame">True</property> <property name="visible">True</property>
<property name="activates_default">True</property> <property name="xalign">0</property>
<signal name="changed" handler="on_required_entry_changed" last_modification_time="Sat, 14 Jan 2006 21:51:24 GMT"/> <property name="label" translatable="yes">Nickname:</property>
</widget> </widget>
<packing> <packing>
<property name="left_attach">1</property> <property name="top_attach">2</property>
<property name="right_attach">2</property> <property name="bottom_attach">3</property>
<property name="top_attach">1</property> <property name="x_options">GTK_FILL</property>
<property name="bottom_attach">2</property> <property name="y_options"></property>
<property name="y_options"></property> </packing>
</packing> </child>
</child> <child>
<widget class="GtkLabel" id="label225">
<child> <property name="visible">True</property>
<widget class="GtkLabel" id="label143"> <property name="xalign">0</property>
<property name="visible">True</property> <property name="label" translatable="yes">Recently:</property>
<property name="label" translatable="yes">Room:</property> </widget>
<property name="use_underline">False</property> <packing>
<property name="use_markup">False</property> <property name="top_attach">1</property>
<property name="justify">GTK_JUSTIFY_LEFT</property> <property name="bottom_attach">2</property>
<property name="wrap">False</property> <property name="x_options">GTK_FILL</property>
<property name="selectable">False</property> <property name="y_options"></property>
<property name="xalign">0</property> </packing>
<property name="yalign">0.5</property> </child>
<property name="xpad">0</property> <child>
<property name="ypad">0</property> <widget class="GtkComboBox" id="recently_combobox">
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> <property name="visible">True</property>
<property name="width_chars">-1</property> <signal name="changed" handler="on_recently_combobox_changed"/>
<property name="single_line_mode">False</property> </widget>
<property name="angle">0</property> <packing>
</widget> <property name="left_attach">1</property>
<packing> <property name="right_attach">2</property>
<property name="left_attach">0</property> <property name="top_attach">1</property>
<property name="right_attach">1</property> <property name="bottom_attach">2</property>
<property name="top_attach">2</property> <property name="x_options">GTK_FILL</property>
<property name="bottom_attach">3</property> <property name="y_options">GTK_FILL</property>
<property name="x_options">fill</property> </packing>
<property name="y_options"></property> </child>
</packing> <child>
</child> <widget class="GtkLabel" id="label145">
<property name="visible">True</property>
<child> <property name="xalign">0</property>
<widget class="GtkLabel" id="label142"> <property name="label" translatable="yes">Password:</property>
<property name="visible">True</property> </widget>
<property name="label" translatable="yes">Nickname:</property> <packing>
<property name="use_underline">False</property> <property name="top_attach">4</property>
<property name="use_markup">False</property> <property name="bottom_attach">5</property>
<property name="justify">GTK_JUSTIFY_LEFT</property> <property name="x_options">GTK_FILL</property>
<property name="wrap">False</property> <property name="y_options"></property>
<property name="selectable">False</property> </packing>
<property name="xalign">0</property> </child>
<property name="yalign">0.5</property> <child>
<property name="xpad">0</property> <widget class="GtkEntry" id="password_entry">
<property name="ypad">0</property> <property name="visible">True</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> <property name="can_focus">True</property>
<property name="width_chars">-1</property> <property name="visibility">False</property>
<property name="single_line_mode">False</property> <property name="activates_default">True</property>
<property name="angle">0</property> </widget>
</widget> <packing>
<packing> <property name="left_attach">1</property>
<property name="left_attach">0</property> <property name="right_attach">2</property>
<property name="right_attach">1</property> <property name="top_attach">4</property>
<property name="top_attach">1</property> <property name="bottom_attach">5</property>
<property name="bottom_attach">2</property> <property name="y_options"></property>
<property name="x_options">fill</property> </packing>
<property name="y_options"></property> </child>
</packing> <child>
</child> <widget class="GtkCheckButton" id="auto_join_checkbutton">
<property name="label" translatable="yes">Join this room automatically when I connect</property>
<child> <property name="visible">True</property>
<widget class="GtkLabel" id="label225"> <property name="can_focus">True</property>
<property name="visible">True</property> <property name="receives_default">False</property>
<property name="label" translatable="yes">Recently:</property> <property name="use_underline">True</property>
<property name="use_underline">False</property> <property name="draw_indicator">True</property>
<property name="use_markup">False</property> </widget>
<property name="justify">GTK_JUSTIFY_LEFT</property> <packing>
<property name="wrap">False</property> <property name="right_attach">2</property>
<property name="selectable">False</property> <property name="top_attach">5</property>
<property name="xalign">0</property> <property name="bottom_attach">6</property>
<property name="yalign">0.5</property> <property name="x_options">GTK_FILL</property>
<property name="xpad">0</property> <property name="y_options"></property>
<property name="ypad">0</property> </packing>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> </child>
<property name="width_chars">-1</property> <child>
<property name="single_line_mode">False</property> <widget class="GtkLabel" id="account_label">
<property name="angle">0</property> <property name="no_show_all">True</property>
</widget> <property name="xalign">0</property>
<packing> <property name="label" translatable="yes">Account</property>
<property name="left_attach">0</property> </widget>
<property name="right_attach">1</property> <packing>
<property name="top_attach">0</property> <property name="x_options">GTK_FILL</property>
<property name="bottom_attach">1</property> <property name="y_options"></property>
<property name="x_options">fill</property> </packing>
<property name="y_options"></property> </child>
</packing> <child>
</child> <widget class="GtkComboBox" id="account_combobox">
<property name="no_show_all">True</property>
<child> <signal name="changed" handler="on_account_combobox_changed"/>
<widget class="GtkComboBox" id="recently_combobox"> </widget>
<property name="visible">True</property> <packing>
<property name="add_tearoffs">False</property> <property name="left_attach">1</property>
<property name="focus_on_click">True</property> <property name="right_attach">2</property>
<signal name="changed" handler="on_recently_combobox_changed" last_modification_time="Wed, 06 Apr 2005 22:25:35 GMT"/> <property name="x_options">GTK_FILL</property>
</widget> <property name="y_options">GTK_FILL</property>
<packing> </packing>
<property name="left_attach">1</property> </child>
<property name="right_attach">2</property> </widget>
<property name="top_attach">0</property> <packing>
<property name="bottom_attach">1</property> <property name="position">0</property>
<property name="x_options">fill</property> </packing>
<property name="y_options">fill</property> </child>
</packing> <child>
</child> <widget class="GtkHButtonBox" id="hbuttonbox12">
<property name="visible">True</property>
<child> <property name="spacing">12</property>
<widget class="GtkLabel" id="label145"> <property name="layout_style">end</property>
<property name="visible">True</property> <child>
<property name="label" translatable="yes">Password:</property> <widget class="GtkButton" id="cancel_button">
<property name="use_underline">False</property> <property name="label">gtk-cancel</property>
<property name="use_markup">False</property> <property name="visible">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property> <property name="can_focus">True</property>
<property name="wrap">False</property> <property name="can_default">True</property>
<property name="selectable">False</property> <property name="receives_default">False</property>
<property name="xalign">0</property> <property name="use_stock">True</property>
<property name="yalign">0.5</property> <signal name="clicked" handler="on_cancel_button_clicked"/>
<property name="xpad">0</property> </widget>
<property name="ypad">0</property> <packing>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> <property name="expand">False</property>
<property name="width_chars">-1</property> <property name="fill">False</property>
<property name="single_line_mode">False</property> <property name="position">0</property>
<property name="angle">0</property> </packing>
</widget> </child>
<packing> <child>
<property name="left_attach">0</property> <widget class="GtkButton" id="join_button">
<property name="right_attach">1</property> <property name="visible">True</property>
<property name="top_attach">3</property> <property name="can_focus">True</property>
<property name="bottom_attach">4</property> <property name="can_default">True</property>
<property name="x_options">fill</property> <property name="has_default">True</property>
<property name="y_options"></property> <property name="receives_default">False</property>
</packing> <signal name="clicked" handler="on_join_button_clicked"/>
</child> <child>
<widget class="GtkAlignment" id="alignment25">
<child> <property name="visible">True</property>
<widget class="GtkEntry" id="password_entry"> <property name="xscale">0</property>
<property name="visible">True</property> <property name="yscale">0</property>
<property name="can_focus">True</property> <child>
<property name="editable">True</property> <widget class="GtkHBox" id="hbox37">
<property name="visibility">False</property> <property name="visible">True</property>
<property name="max_length">0</property> <property name="spacing">2</property>
<property name="text" translatable="yes"></property> <child>
<property name="has_frame">True</property> <widget class="GtkImage" id="image148">
<property name="activates_default">True</property> <property name="visible">True</property>
</widget> <property name="stock">gtk-apply</property>
<packing> </widget>
<property name="left_attach">1</property> <packing>
<property name="right_attach">2</property> <property name="expand">False</property>
<property name="top_attach">3</property> <property name="fill">False</property>
<property name="bottom_attach">4</property> <property name="position">0</property>
<property name="y_options"></property> </packing>
</packing> </child>
</child> <child>
<widget class="GtkLabel" id="label146">
<child> <property name="visible">True</property>
<widget class="GtkCheckButton" id="auto_join_checkbutton"> <property name="label" translatable="yes">_Join</property>
<property name="visible">True</property> <property name="use_underline">True</property>
<property name="can_focus">True</property> </widget>
<property name="label" translatable="yes">Join this room automatically when I connect</property> <packing>
<property name="use_underline">True</property> <property name="expand">False</property>
<property name="relief">GTK_RELIEF_NORMAL</property> <property name="fill">False</property>
<property name="focus_on_click">True</property> <property name="position">1</property>
<property name="active">False</property> </packing>
<property name="inconsistent">False</property> </child>
<property name="draw_indicator">True</property> </widget>
</widget> </child>
<packing> </widget>
<property name="left_attach">0</property> </child>
<property name="right_attach">2</property> </widget>
<property name="top_attach">4</property> <packing>
<property name="bottom_attach">5</property> <property name="expand">False</property>
<property name="x_options">fill</property> <property name="fill">False</property>
<property name="y_options"></property> <property name="position">1</property>
</packing> </packing>
</child> </child>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="expand">False</property>
<property name="expand">True</property> <property name="position">1</property>
<property name="fill">True</property> </packing>
</packing> </child>
</child> </widget>
</child>
<child> </widget>
<widget class="GtkHButtonBox" id="hbuttonbox12">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<property name="spacing">12</property>
<child>
<widget class="GtkButton" id="cancel_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_cancel_button_clicked" last_modification_time="Fri, 04 Mar 2005 13:40:16 GMT"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="join_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_join_button_clicked" last_modification_time="Wed, 02 Mar 2005 12:19:22 GMT"/>
<child>
<widget class="GtkAlignment" id="alignment25">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox37">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image148">
<property name="visible">True</property>
<property name="stock">gtk-apply</property>
<property name="icon_size">4</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">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label146">
<property name="visible">True</property>
<property name="label" translatable="yes">_Join</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface> </glade-interface>

View File

@ -827,8 +827,7 @@ class ConversationTextview(gobject.GObject):
gajim.interface.instances[self.account]['join_gc'].window.present() gajim.interface.instances[self.account]['join_gc'].window.present()
else: else:
try: try:
gajim.interface.instances[self.account]['join_gc'] = \ dialogs.JoinGroupchatWindow(account=None, room_jid=room_jid)
dialogs.JoinGroupchatWindow(self.account, room_jid)
except GajimGeneralException: except GajimGeneralException:
pass pass

View File

@ -1893,28 +1893,42 @@ class SubscriptionRequestWindow:
class JoinGroupchatWindow: class JoinGroupchatWindow:
def __init__(self, account, room_jid='', nick='', password='', def __init__(self, account=None, room_jid='', nick='', password='',
automatic=False): automatic=False):
'''automatic is a dict like {'invities': []} '''automatic is a dict like {'invities': []}
If automatic is not empty, this means room must be automaticaly configured If automatic is not empty, this means room must be automaticaly configured
and when done, invities must be automatically invited''' and when done, invities must be automatically invited'''
if room_jid != '': self.xml = gtkgui_helpers.get_glade('join_groupchat_window.glade')
if room_jid in gajim.gc_connected[account] and\ if account:
gajim.gc_connected[account][room_jid]: if room_jid != '' and room_jid in gajim.gc_connected[account] and\
gajim.gc_connected[account][room_jid]:
ErrorDialog(_('You are already in group chat %s') % room_jid) ErrorDialog(_('You are already in group chat %s') % room_jid)
raise GajimGeneralException, 'You are already in this group chat' raise GajimGeneralException, 'You are already in this group chat'
if nick == '':
nick = gajim.nicks[account]
if gajim.connections[account].connected < 2:
ErrorDialog(_('You are not connected to the server'),
_('You can not join a group chat unless you are connected.'))
raise GajimGeneralException, 'You must be connected to join a groupchat'
else:
account_label = self.xml.get_widget('account_label')
account_combobox = self.xml.get_widget('account_combobox')
account_label.set_no_show_all(False)
account_combobox.set_no_show_all(False)
liststore = gtk.ListStore(str)
account_combobox.set_model(liststore)
cell = gtk.CellRendererText()
account_combobox.pack_start(cell, True)
account_combobox.add_attribute(cell, 'text', 0)
for acct in [a for a in gajim.connections if \
gajim.account_is_connected(a)]:
account_combobox.append_text(acct)
account_combobox.set_active(-1)
self.account = account self.account = account
self.automatic = automatic self.automatic = automatic
if nick == '':
nick = gajim.nicks[self.account]
if gajim.connections[account].connected < 2:
ErrorDialog(_('You are not connected to the server'),
_('You can not join a group chat unless you are connected.'))
raise GajimGeneralException, 'You must be connected to join a groupchat'
self._empty_required_widgets = [] self._empty_required_widgets = []
self.xml = gtkgui_helpers.get_glade('join_groupchat_window.glade')
self.window = self.xml.get_widget('join_groupchat_window') self.window = self.xml.get_widget('join_groupchat_window')
self._room_jid_entry = self.xml.get_widget('room_jid_entry') self._room_jid_entry = self.xml.get_widget('room_jid_entry')
self._nickname_entry = self.xml.get_widget('nickname_entry') self._nickname_entry = self.xml.get_widget('nickname_entry')
@ -1925,11 +1939,13 @@ class JoinGroupchatWindow:
if password: if password:
self._password_entry.set_text(password) self._password_entry.set_text(password)
self.xml.signal_autoconnect(self) self.xml.signal_autoconnect(self)
# now add us to open windows title = None
gajim.interface.instances[account]['join_gc'] = self if account:
if len(gajim.connections) > 1: # now add us to open windows
title = _('Join Group Chat with account %s') % account gajim.interface.instances[account]['join_gc'] = self
else: if len(gajim.connections) > 1:
title = _('Join Group Chat with account %s') % account
if title is None:
title = _('Join Group Chat') title = _('Join Group Chat')
self.window.set_title(title) self.window.set_title(title)
@ -1957,15 +1973,16 @@ class JoinGroupchatWindow:
if len(self._empty_required_widgets): if len(self._empty_required_widgets):
self.xml.get_widget('join_button').set_sensitive(False) self.xml.get_widget('join_button').set_sensitive(False)
if not gajim.connections[account].private_storage_supported: if account and not gajim.connections[account].private_storage_supported:
self.xml.get_widget('auto_join_checkbutton').set_sensitive(False) self.xml.get_widget('auto_join_checkbutton').set_sensitive(False)
self.window.show_all() self.window.show_all()
def on_join_groupchat_window_destroy(self, widget): def on_join_groupchat_window_destroy(self, widget):
'''close window''' '''close window'''
# remove us from open windows if self.account and 'join_gc' in gajim.interface.instances[self.account]:
del gajim.interface.instances[self.account]['join_gc'] # remove us from open windows
del gajim.interface.instances[self.account]['join_gc']
def on_join_groupchat_window_key_press_event(self, widget, event): def on_join_groupchat_window_key_press_event(self, widget, event):
if event.keyval == gtk.keysyms.Escape: # ESCAPE if event.keyval == gtk.keysyms.Escape: # ESCAPE
@ -1978,8 +1995,14 @@ class JoinGroupchatWindow:
else: else:
if widget in self._empty_required_widgets: if widget in self._empty_required_widgets:
self._empty_required_widgets.remove(widget) self._empty_required_widgets.remove(widget)
if len(self._empty_required_widgets) == 0: if len(self._empty_required_widgets) == 0 and self.account:
self.xml.get_widget('join_button').set_sensitive(True) self.xml.get_widget('join_button').set_sensitive(True)
def on_account_combobox_changed(self, widget):
model = widget.get_model()
iter_ = widget.get_active_iter()
self.account = model[iter_][0].decode('utf-8')
self.on_required_entry_changed(self._nickname_entry)
def on_recently_combobox_changed(self, widget): def on_recently_combobox_changed(self, widget):
model = widget.get_model() model = widget.get_model()
@ -1993,6 +2016,11 @@ class JoinGroupchatWindow:
def on_join_button_clicked(self, widget): def on_join_button_clicked(self, widget):
'''When Join button is clicked''' '''When Join button is clicked'''
if not self.account:
ErrorDialog(_('Invalid Account'),
_('You have to choose an account from which you want to join the '
'groupchat.'))
return
nickname = self._nickname_entry.get_text().decode('utf-8') nickname = self._nickname_entry.get_text().decode('utf-8')
room_jid = self._room_jid_entry.get_text().decode('utf-8') room_jid = self._room_jid_entry.get_text().decode('utf-8')
password = self._password_entry.get_text().decode('utf-8') password = self._password_entry.get_text().decode('utf-8')
@ -2000,25 +2028,26 @@ class JoinGroupchatWindow:
nickname = helpers.parse_resource(nickname) nickname = helpers.parse_resource(nickname)
except Exception: except Exception:
ErrorDialog(_('Invalid Nickname'), ErrorDialog(_('Invalid Nickname'),
_('The nickname has not allowed characters.')) _('The nickname has not allowed characters.'))
return return
user, server, resource = helpers.decompose_jid(room_jid) user, server, resource = helpers.decompose_jid(room_jid)
if not user or not server or resource: if not user or not server or resource:
ErrorDialog(_('Invalid group chat Jabber ID'), ErrorDialog(_('Invalid group chat Jabber ID'),
_('The group chat Jabber ID has not allowed characters.')) _('The group chat Jabber ID has not allowed characters.'))
return return
try: try:
room_jid = helpers.parse_jid(room_jid) room_jid = helpers.parse_jid(room_jid)
except Exception: except Exception:
ErrorDialog(_('Invalid group chat Jabber ID'), ErrorDialog(_('Invalid group chat Jabber ID'),
_('The group chat Jabber ID has not allowed characters.')) _('The group chat Jabber ID has not allowed characters.'))
return return
if gajim.interface.msg_win_mgr.has_window(room_jid, self.account): if gajim.interface.msg_win_mgr.has_window(room_jid, self.account):
ctrl = gajim.interface.msg_win_mgr.get_gc_control(room_jid, self.account) ctrl = gajim.interface.msg_win_mgr.get_gc_control(room_jid,
self.account)
if ctrl.type_id != message_control.TYPE_GC: if ctrl.type_id != message_control.TYPE_GC:
ErrorDialog(_('This is not a group chat'), ErrorDialog(_('This is not a group chat'),
_('%s is not the name of a group chat.') % room_jid) _('%s is not the name of a group chat.') % room_jid)
return return
if room_jid in self.recently_groupchat: if room_jid in self.recently_groupchat:
self.recently_groupchat.remove(room_jid) self.recently_groupchat.remove(room_jid)
@ -2026,13 +2055,13 @@ class JoinGroupchatWindow:
if len(self.recently_groupchat) > 10: if len(self.recently_groupchat) > 10:
self.recently_groupchat = self.recently_groupchat[0:10] self.recently_groupchat = self.recently_groupchat[0:10]
gajim.config.set('recently_groupchat', gajim.config.set('recently_groupchat',
' '.join(self.recently_groupchat)) ' '.join(self.recently_groupchat))
if self.xml.get_widget('auto_join_checkbutton').get_active(): if self.xml.get_widget('auto_join_checkbutton').get_active():
# Add as bookmark, with autojoin and not minimized # Add as bookmark, with autojoin and not minimized
name = gajim.get_nick_from_jid(room_jid) name = gajim.get_nick_from_jid(room_jid)
gajim.interface.add_gc_bookmark(self.account, name, room_jid, '1', \ gajim.interface.add_gc_bookmark(self.account, name, room_jid, '1', \
'0', password, nickname) '0', password, nickname)
if self.automatic: if self.automatic:
gajim.automatic_rooms[self.account][room_jid] = self.automatic gajim.automatic_rooms[self.account][room_jid] = self.automatic

View File

@ -1592,9 +1592,8 @@ class GroupchatControl(ChatControlBase):
window.present() window.present()
else: else:
try: try:
gajim.interface.instances[self.account]['join_gc'] =\ dialogs.JoinGroupchatWindow(account=None, room_jid=room_jid,
dialogs.JoinGroupchatWindow(self.account, nick=nick)
room_jid = room_jid, nick=nick)
except GajimGeneralException: except GajimGeneralException:
pass pass
self.clear(self.msg_textview) self.clear(self.msg_textview)