diff --git a/src/dialogs.py b/src/dialogs.py index 7db66fd65..0e14e0fe3 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -417,6 +417,16 @@ class Information_dialog: dialog.connect('response', self.on_response) dialog.show() +class Input_dialog: + '''Class for Input dialog''' + def __init__(self, title, label_str): + xml = gtk.glade.XML(GTKGUI_GLADE, 'input_dialog', APP) + self.dialog = xml.get_widget('input_dialog') + label = xml.get_widget('label') + self.input_entry = xml.get_widget('input_entry') + self.dialog.set_title(title) + label.set_text(label_str) + class Error_dialog: '''Class for error dialog''' def on_response(self, dialog, response_id): diff --git a/src/groupchat_window.py b/src/groupchat_window.py index e03f4ab80..edf5fb7ca 100644 --- a/src/groupchat_window.py +++ b/src/groupchat_window.py @@ -42,24 +42,26 @@ class Groupchat_window(chat.Chat): self.nicks = {} self.list_treeview = {} self.subjects = {} - self.subject_entry = self.xml.get_widget('subject_entry') + self.subject_entry = {} + self.subject_entry_tooltip = {} self.new_room(room_jid, nick) self.show_title() - self.subject_entry_tooltip = gtk.Tooltips() - self.xml.signal_connect('on_groupchat_window_destroy', \ + self.xml.signal_connect('on_groupchat_window_destroy', self.on_groupchat_window_destroy) - self.xml.signal_connect('on_groupchat_window_delete_event', \ + self.xml.signal_connect('on_groupchat_window_delete_event', self.on_groupchat_window_delete_event) - self.xml.signal_connect('on_groupchat_window_focus_in_event', \ + self.xml.signal_connect('on_groupchat_window_focus_in_event', self.on_groupchat_window_focus_in_event) - self.xml.signal_connect('on_chat_notebook_key_press_event', \ + self.xml.signal_connect('on_chat_notebook_key_press_event', self.on_chat_notebook_key_press_event) - self.xml.signal_connect('on_chat_notebook_switch_page', \ + self.xml.signal_connect('on_chat_notebook_switch_page', self.on_chat_notebook_switch_page) - self.xml.signal_connect('on_set_button_clicked', \ - self.on_set_button_clicked) - self.xml.signal_connect('on_configure_button_clicked', \ - self.on_configure_button_clicked) + self.xml.signal_connect('on_change_subject_menuitem_activate', + self.on_change_subject_menuitem_activate) + self.xml.signal_connect('on_configure_room_menuitem_activate', + self.on_configure_room_menuitem_activate) + self.xml.signal_connect('on_close_window_activate', + self.on_close_window_activate) self.window.show_all() def save_var(self, jid): @@ -79,6 +81,10 @@ class Groupchat_window(chat.Chat): self.list_treeview[jid].expand_all() self.set_subject(jid, var['subject']) + def on_close_window_activate(self, widget): + #FIXME: does not work as it should + self.on_groupchat_window_delete_event(widget, None) + def on_groupchat_window_delete_event(self, widget, event): """close window""" for room_jid in self.xmls: @@ -109,8 +115,9 @@ class Groupchat_window(chat.Chat): new_jid = jid break subject = self.subjects[new_jid] - self.subject_entry.set_text(subject) - self.subject_entry_tooltip.set_tip(self.subject_entry, subject) + subject_entry = self.subject_entry[new_jid] + subject_entry.set_text(subject) + self.subject_entry_tooltip[new_jid].set_tip(subject_entry, subject) chat.Chat.on_chat_notebook_switch_page(self, notebook, page, page_num) def get_role_iter(self, room_jid, role): @@ -174,7 +181,7 @@ class Groupchat_window(chat.Chat): return list def remove_user(self, room_jid, nick): - """Remove a user from the roster""" + """Remove a user from the list_users""" model = self.list_treeview[room_jid].get_model() iter = self.get_user_iter(room_jid, nick) if not iter: @@ -224,7 +231,7 @@ class Groupchat_window(chat.Chat): def chg_user_status(self, room_jid, nick, show, status, role, affiliation, \ jid, reason, actor, statusCode, account): - """When a user change his status""" + """When a user changes his status""" if not role: role = 'None' model = self.list_treeview[room_jid].get_model() @@ -254,31 +261,24 @@ class Groupchat_window(chat.Chat): def set_subject(self, room_jid, subject): self.subjects[room_jid] = subject - self.subject_entry.set_text(subject) - self.subject_entry_tooltip.set_tip(self.subject_entry, subject) + subject_entry = self.subject_entry[room_jid] + subject_entry.set_text(subject) + self.subject_entry_tooltip[room_jid].set_tip(subject_entry, subject) - def on_set_button_clicked(self, widget): + def on_change_subject_menuitem_activate(self, widget): room_jid = self.get_active_jid() - subject = self.subject_entry.get_text() - gajim.connections[self.account].send_gc_subject(room_jid, subject) + instance = dialogs.Input_dialog('Changing the Subject', + 'Please specify the new subject:') + response = instance.dialog.run() + instance.dialog.destroy() + if response == gtk.RESPONSE_OK: + subject = instance.input_entry.get_text() + gajim.connections[self.account].send_gc_subject(room_jid, subject) - def on_configure_button_clicked(self, widget): + def on_configure_room_menuitem_activate(self, widget): room_jid = self.get_active_jid() gajim.connections[self.account].request_gc_config(room_jid) - def on_subject_entry_focus_out_event(self, widget): - print 'FIXME: focus out' - return - new_child = notebook.get_nth_page(page_num) - new_jid = '' - for jid in self.xmls: - if self.childs[jid] == new_child: - new_jid = jid - break - subject = self.subjects[new_jid] - self.subject_entry.set_text(subject) - self.subject_entry_tooltip.set_tip(self.subject_entry, subject) - def on_message_textview_key_press_event(self, widget, event): """When a key is pressed: if enter is pressed without the shit key, message (if not empty) is sent @@ -519,6 +519,9 @@ class Groupchat_window(chat.Chat): 'list_treeview') conversation_textview = self.xmls[room_jid].get_widget( 'conversation_textview') + self.subject_entry[room_jid] = self.xmls[room_jid].get_widget( + 'subject_entry') + self.subject_entry_tooltip[room_jid] = gtk.Tooltips() #status_image, nickname, real_jid, status store = gtk.TreeStore(gtk.Image, str, str, str) diff --git a/src/gtkgui.glade b/src/gtkgui.glade index 0104ec212..265cee7ba 100644 --- a/src/gtkgui.glade +++ b/src/gtkgui.glade @@ -7624,7 +7624,6 @@ Custom - 4 Groupchat GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE @@ -7643,100 +7642,104 @@ Custom - + True False - 2 + 0 - + True - False - 5 - + True - Subject: - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - True - True - True - 0 - - True - * - True - - - - 0 - True - True - - - - - - True - Click to set the subject - True - True - True - _Set + _Actions True - GTK_RELIEF_NORMAL - True - - - - 0 - False - False - - - - - True - Click to configure the room options - True - _Configure - True - GTK_RELIEF_NORMAL - True - + + + + + + True + Click to change the subject of the room + Change _Subject + True + + + + + True + gtk-edit + 1 + 0.5 + 0.5 + 0 + 0 + + + + + + + + True + Click to configure the room options + Configure _Room + True + + + + + True + gtk-preferences + 1 + 0.5 + 0.5 + 0 + 0 + + + + + + + + True + + + + + + True + Close _Window + True + + + + + + True + gtk-close + 1 + 0.5 + 0.5 + 0 + 0 + + + + + + - - 0 - False - False - 0 False - True + False @@ -7758,120 +7761,187 @@ Custom 0 - - 4 + True + True + 495 - + True - 100 + False + 0 - - 100 + True - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT + False + 5 - + + True + Subject: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + True True - False - False - True - False - - - - - + False + True + 0 + + True + * + False + + 0 + True + True + - False - False + 0 + False + True - - 200 + True True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - + + 200 True True - False - False - True - GTK_JUSTIFY_LEFT - GTK_WRAP_WORD - False - 0 - 0 - 0 - 0 - 0 - 0 - - - - - + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + False + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_WORD + False + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + False + True + + + + + + 55 + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + GTK_JUSTIFY_LEFT + GTK_WRAP_WORD + True + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + False + False + - False - True + 0 + True + True True - True + False - - 55 + + 100 True - True - GTK_POLICY_AUTOMATIC + GTK_POLICY_NEVER GTK_POLICY_AUTOMATIC GTK_SHADOW_IN GTK_CORNER_TOP_LEFT - + True True - True - False - False - GTK_JUSTIFY_LEFT - GTK_WRAP_WORD - True - 0 - 0 - 0 - 0 - 0 - 0 - - + False + False + False + True + + + + + @@ -10882,4 +10952,152 @@ send a chat message to + + True + + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + False + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + True + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 5 + True + False + 0 + + + + True + False + 10 + + + + True + gtk-dialog-question + 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 + True + True + + + + + 0 + False + True + + + + + + True + True + True + True + 0 + + True + * + True + + + 0 + False + False + + + + + 0 + True + True + + + + + +