advanced actions show account if multiple acocunts

This commit is contained in:
Nikos Kouremenos 2005-07-07 15:41:03 +00:00
parent 47ca86a537
commit 6c9d148e07
4 changed files with 178 additions and 148 deletions

View File

@ -706,10 +706,11 @@ _('Without a connection, you can not change your password.')).get_response()
class PopupNotificationWindow:
def __init__(self, plugin, event_type, jid, account):
def __init__(self, plugin, event_type, jid, account, msg_type = ''):
self.plugin = plugin
self.account = account
self.jid = jid
self.msg_type = msg_type
xml = gtk.glade.XML(GTKGUI_GLADE, 'popup_notification_window', APP)
self.window = xml.get_widget('popup_notification_window')
@ -771,7 +772,7 @@ class PopupNotificationWindow:
window_width, window_height = window_instance.window.get_size()
self.plugin.roster.popups_notification_height += window_height
window_instance.window.move(gtk.gdk.screen_width() - window_width,
gtk.gdk.screen_height() - self.plugin.roster.popups_notification_height)
gtk.gdk.screen_height() - self.plugin.roster.popups_notification_height)
def on_popup_notification_window_button_press_event(self, widget, event):
# use Contact class, new_chat expects it that way
@ -790,10 +791,14 @@ class PopupNotificationWindow:
self.plugin.roster.contacts[self.account][self.jid] = [user]
self.plugin.roster.add_user_to_roster(user.self.jid, self.account)
self.plugin.roster.new_chat(user, self.account)
chats_window = self.plugin.windows[self.account]['chats'][self.jid]
chats_window.set_active_tab(self.jid)
chats_window.window.present()
if msg_type == 'normal': # it's single message
pass
else: # 'chat'
self.plugin.roster.new_chat(user, self.account)
chats_window = self.plugin.windows[self.account]['chats'][self.jid]
chats_window.set_active_tab(self.jid)
chats_window.window.present()
self.adjust_height_and_move_popup_notification_windows()

View File

@ -334,7 +334,7 @@ class Interface:
array[10], array[11], array[12], account)
def handle_event_msg(self, account, array):
#('MSG', account, (contact, msg, time, encrypted, mtype, subject))
#('MSG', account, (contact, msg, time, encrypted, msg_type, subject))
jid = array[0].split('/')[0]
if jid.find('@') <= 0:
jid = jid.replace('@', '')
@ -376,10 +376,10 @@ class Interface:
show_notification = True
if show_notification:
instance = dialogs.PopupNotificationWindow(self,
_('New Message'), jid, account)
_('New Message'), jid, account, array[4]) #[4] is msg_type
self.roster.popup_notification_windows.append(instance)
# array : (contact, msg, time, encrypted, mtype, subject)
# array : (contact, msg, time, encrypted, msg_type, subject)
self.roster.on_message(jid, array[1], array[2], account, array[3],
array[4], array[5])
if gajim.config.get_per('soundevents', 'first_message_received',

View File

@ -131,138 +131,6 @@
<property name="visible">True</property>
<property name="label" translatable="yes">_Advanced</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="advanced_menuitem_menu">
<child>
<widget class="GtkImageMenuItem" id="send_single_message_menuitem">
<property name="visible">True</property>
<property name="label" translatable="yes">_Send Single Message</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_send_single_message_menuitem_activate" last_modification_time="Wed, 06 Jul 2005 13:20:23 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image923">
<property name="visible">True</property>
<property name="stock">gtk-new</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="xml_console_menuitem">
<property name="visible">True</property>
<property name="label" translatable="yes">_XML Console</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_xml_console_menuitem_activate" last_modification_time="Wed, 06 Jul 2005 13:20:23 GMT"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator8">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="administrator_menuitem">
<property name="visible">True</property>
<property name="label" translatable="yes">_Administrator</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="administrator_menuitem_menu">
<child>
<widget class="GtkMenuItem" id="online_users_menuitem">
<property name="visible">True</property>
<property name="label" translatable="yes">_Online Users</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_online_users_menuitem_activate" last_modification_time="Wed, 06 Jul 2005 13:26:25 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="send_server_message_menuitem">
<property name="visible">True</property>
<property name="label" translatable="yes">_Send Server Message</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_send_server_message_menuitem_activate" last_modification_time="Wed, 06 Jul 2005 13:26:25 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image924">
<property name="visible">True</property>
<property name="stock">gtk-new</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator9">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="set_motd_menuitem">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Set Message of the Day</property>
<property name="label" translatable="yes">Set MOTD</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_set_motd_menuitem_activate" last_modification_time="Wed, 06 Jul 2005 13:26:25 GMT"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="update_motd_menuitem">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Update Message of the Day</property>
<property name="label" translatable="yes">Update MOTD</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_update_motd_menuitem_activate" last_modification_time="Wed, 06 Jul 2005 13:26:25 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="delete_motd_menuitem">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Delete Message of the Day</property>
<property name="label" translatable="yes">Delete MOTD</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_delete_motd_menuitem_activate" last_modification_time="Wed, 06 Jul 2005 13:26:25 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image925">
<property name="visible">True</property>
<property name="stock">gtk-clear</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
@ -16989,4 +16857,134 @@ Maybe I'll refactor later</property>
</child>
</widget>
<widget class="GtkMenu" id="advanced_menuitem_menu">
<child>
<widget class="GtkImageMenuItem" id="send_single_message_menuitem">
<property name="visible">True</property>
<property name="label" translatable="yes">_Send Single Message</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_send_single_message_menuitem_activate" last_modification_time="Wed, 06 Jul 2005 13:20:23 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image931">
<property name="visible">True</property>
<property name="stock">gtk-new</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="xml_console_menuitem">
<property name="visible">True</property>
<property name="label" translatable="yes">_XML Console</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_xml_console_menuitem_activate" last_modification_time="Wed, 06 Jul 2005 13:20:23 GMT"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator8">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="administrator_menuitem">
<property name="visible">True</property>
<property name="label" translatable="yes">_Administrator</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="administrator_menuitem_menu">
<child>
<widget class="GtkMenuItem" id="online_users_menuitem">
<property name="visible">True</property>
<property name="label" translatable="yes">_Online Users</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_online_users_menuitem_activate" last_modification_time="Wed, 06 Jul 2005 13:26:25 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="send_server_message_menuitem">
<property name="visible">True</property>
<property name="label" translatable="yes">_Send Server Message</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_send_server_message_menuitem_activate" last_modification_time="Wed, 06 Jul 2005 13:26:25 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image932">
<property name="visible">True</property>
<property name="stock">gtk-new</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator9">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="set_motd_menuitem">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Set Message of the Day</property>
<property name="label" translatable="yes">Set MOTD</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_set_motd_menuitem_activate" last_modification_time="Wed, 06 Jul 2005 13:26:25 GMT"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="update_motd_menuitem">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Update Message of the Day</property>
<property name="label" translatable="yes">Update MOTD</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_update_motd_menuitem_activate" last_modification_time="Wed, 06 Jul 2005 13:26:25 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="delete_motd_menuitem">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Delete Message of the Day</property>
<property name="label" translatable="yes">Delete MOTD</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_delete_motd_menuitem_activate" last_modification_time="Wed, 06 Jul 2005 13:26:25 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image933">
<property name="visible">True</property>
<property name="stock">gtk-clear</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</glade-interface>

View File

@ -273,7 +273,7 @@ class RosterWindow:
widget.set_state(gtk.STATE_NORMAL) #do not allow selected_state
def make_menu(self):
'''create the main_window's menus'''
'''create the main window's menus'''
new_message_menuitem = self.xml.get_widget('new_message_menuitem')
join_gc_menuitem = self.xml.get_widget('join_gc_menuitem')
add_new_contact_menuitem = self.xml.get_widget('add_new_contact_menuitem')
@ -283,23 +283,31 @@ class RosterWindow:
'show_offline_contacts_menuitem')
profile_avatar_menuitem = self.xml.get_widget('profile_avatar_menuitem')
xm = gtk.glade.XML(GTKGUI_GLADE, 'advanced_menuitem_menu', APP)
advanced_menuitem_menu = xm.get_widget('advanced_menuitem_menu')
xm.signal_autoconnect(self)
if self.add_new_contact_handler_id:
add_new_contact_menuitem.handler_disconnect(
self.add_new_contact_handler_id)
self.add_new_contact_handler_id = None
if self.service_disco_handler_id:
service_disco_menuitem.handler_disconnect(
self.service_disco_handler_id)
self.service_disco_handler_id = None
if self.new_message_menuitem_handler_id:
new_message_menuitem.handler_disconnect(
self.new_message_menuitem_handler_id)
self.new_message_menuitem_handler_id = None
#remove the existing submenus
add_new_contact_menuitem.remove_submenu()
service_disco_menuitem.remove_submenu()
join_gc_menuitem.remove_submenu()
new_message_menuitem.remove_submenu()
advanced_menuitem.remove_submenu()
#remove the existing accelerator
if self.have_new_message_accel:
@ -354,17 +362,18 @@ class RosterWindow:
for account in gajim.connections:
if gajim.connections[account].connected <= 1: #if offline or connecting
continue
item = gtk.MenuItem(_('to ') + account + _(' account'))
item = gtk.MenuItem(_('to %s account') % account)
sub_menu.append(item)
item.connect('activate', self.on_add_new_contact, account)
sub_menu.show_all()
#disco
sub_menu = gtk.Menu()
service_disco_menuitem.set_submenu(sub_menu)
for account in gajim.connections:
if gajim.connections[account].connected <= 1: #if offline or connecting
continue
item = gtk.MenuItem(_('using ') + account + _(' account'))
item = gtk.MenuItem(_('using %s account') % account)
sub_menu.append(item)
item.connect('activate', self.on_service_disco_menuitem_activate, account)
sub_menu.show_all()
@ -377,11 +386,25 @@ class RosterWindow:
continue
our_jid = gajim.config.get_per('accounts', account, 'name') + '@' +\
gajim.config.get_per('accounts', account, 'hostname')
item = gtk.MenuItem(_('as ') + our_jid)
item = gtk.MenuItem(_('as %s') % our_jid)
sub_menu.append(item)
item.connect('activate', self.on_new_message_menuitem_activate,
account)
sub_menu.show_all()
#Advanced Actions
for account in gajim.connections:
if gajim.connections[account].connected <= 1: #if offline or connecting
continue
item = gtk.MenuItem(_('for %s ') % account)
item.set_submenu(advanced_menuitem_menu)
sub_menu = gtk.Menu()
sub_menu.append(item)
advanced_menuitem.set_submenu(sub_menu)
sub_menu.show_all()
else:
if len(gajim.connections) == 1: # one account
#add
@ -393,15 +416,19 @@ class RosterWindow:
self.service_disco_handler_id = service_disco_menuitem.connect(
'activate', self.on_service_disco_menuitem_activate,
gajim.connections.keys()[0])
#new msg
if not self.new_message_menuitem_handler_id:
self.new_message_menuitem_handler_id = new_message_menuitem.\
connect('activate', self.on_new_message_menuitem_activate,
gajim.connections.keys()[0])
#new msg accel
if not self.have_new_message_accel:
ag = gtk.accel_groups_from_object(self.window)[0]
new_message_menuitem.add_accelerator('activate', ag,
gtk.keysyms.n, gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
self.have_new_message_accel = True
advanced_menuitem.set_submenu(advanced_menuitem_menu)
if at_least_one_account_connected:
new_message_menuitem.set_sensitive(True)
@ -423,7 +450,6 @@ class RosterWindow:
def draw_roster(self):
'''Clear and draw roster'''
self.make_menu()
self.tree.get_model().clear()
for acct in gajim.connections:
self.add_account_to_roster(acct)
@ -1535,7 +1561,7 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
def on_show_offline_contacts_menuitem_activate(self, widget):
'''when show offline option is changed:
redraw the treeview'''
gajim.config.set('showoffline', 1 - gajim.config.get('showoffline'))
gajim.config.set('showoffline', not gajim.config.get('showoffline'))
self.draw_roster()
def iconCellDataFunc(self, column, renderer, model, iter, data = None):
@ -1777,7 +1803,7 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
gajim.config.get('height'))
self.groups = {}
# contacts[account][jid] is a list of all Contact insatnces:
# contacts[account][jid] is a list of all Contact instances:
# one per resource
self.contacts = {}
self.newly_added = {}
@ -1876,6 +1902,7 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
self.on_status_combobox_changed)
self.collapsed_rows = gajim.config.get('collapsed_rows').split('\t')
self.make_menu()
self.draw_roster()
if len(gajim.connections) == 0: # if no account
self.plugin.windows['account_modification'] = \