cleaning up a bit patch of delmonico

This commit is contained in:
Nikos Kouremenos 2005-06-10 18:40:19 +00:00
parent 7da7327369
commit 490e029800
3 changed files with 49 additions and 55 deletions

View File

@ -2368,36 +2368,32 @@ class ManageBookmarksWindow:
'''
#Get the account that is currently used
#(the parent of the currently selected item)
(model, iter) = self.selection.get_selected()
if not iter:
#Nothing selected, do nothing
if not iter: #Nothing selected, do nothing
return
#FIXME: ErrorDialog
parent = model.iter_parent(iter)
if not parent:
if parent:
#We got a bookmark selected, so we add_to the parent
add_to = parent
else:
#No parent, so we got an account -> add to this.
add_to = iter
else:
#We got a bookmark selected, so we add_to the parent:
add_to = parent
account = model.get_value(add_to, 1)
self.treestore.append(add_to, [account,_('New Room'), '', '', '', ''])
self.view.expand_row(model.get_path(add_to), True)
def on_remove_bookmark_button_clicked(self, widget):
'''
Remove selected bookmark.
'''
(model, iter) = self.selection.get_selected()
if not iter:
#Nothing selected
if not iter: #Nothing selected
return
if not model.iter_parent(iter):
#Don't remove account iters
return
@ -2411,21 +2407,25 @@ class ManageBookmarksWindow:
then send the new bookmarks to the server.
'''
for account in self.treestore:
gajim.connections[account[1]].bookmarks=[]
for bm in account.iterchildren():
#Covnert True/False to 0/1 string
if bm[3]:
bm[3]='1'
else:
bm[3]='0'
gajim.connections[account[1]].bookmarks = []
#Build and append the bookmark-dict
bmdict = { 'name':bm[1], 'jid':bm[2],
'autojoin':bm[3], 'password':bm[4],
'nick':bm[5] }
if gajim.connections[account[1]].status > 1:
for bm in account.iterchildren():
print bm[0], bm[1], bm[2], bm[3], bm[4], bm[5]
#Convert True/False/None to '1' or '0'
if bm[3]: #autojoin
bm[3] = '1'
else:
bm[3] = '0'
#create the bookmark-dict
bmdict = { 'name': bm[1], 'jid': bm[2], 'autojoin': bm[3],
'password': bm[4], 'nick': bm[5] }
if gajim.connections[account[1]].status > 1: #if we're connected
gajim.connections[account[1]].bookmarks.append(bmdict)
gajim.connections[account[1]].store_bookmarks()
self.window.destroy()
def on_cancel_button_clicked(self, widget):
@ -2442,25 +2442,20 @@ class ManageBookmarksWindow:
#this will be None, so we will just:
return
if not model.iter_parent(iter):
#Top-level has no data (it's the account fields)
self.clear_fields()
self.title_entry.set_sensitive(False)
self.nick_entry.set_sensitive(False)
self.room_entry.set_sensitive(False)
self.server_entry.set_sensitive(False)
self.pass_entry.set_sensitive(False)
self.autojoin_checkbutton.set_sensitive(False)
return
widgets = [ self.title_entry, self.nick_entry, self.room_entry,
self.server_entry, self.pass_entry, self.autojoin_checkbutton ]
if model.iter_parent(iter):
#make the fields sensitive
for field in widgets:
field.set_sensitive(True)
else:
#Show the fields
self.title_entry.set_sensitive(True)
self.nick_entry.set_sensitive(True)
self.room_entry.set_sensitive(True)
self.server_entry.set_sensitive(True)
self.pass_entry.set_sensitive(True)
self.autojoin_checkbutton.set_sensitive(True)
#Top-level has no data (it's the account fields)
#clear fields & make them insensitive
self.clear_fields()
for field in widgets:
field.set_sensitive(False)
return
#Fill in the data for childs
self.title_entry.set_text(model.get_value(iter, 1))
@ -2473,12 +2468,12 @@ class ManageBookmarksWindow:
server = ''
self.room_entry.set_text(room)
self.server_entry.set_text(server)
if model.get_value(iter,3)=='1':
if model.get_value(iter, 3) == '1':
self.autojoin_checkbutton.set_active(True)
else:
self.autojoin_checkbutton.set_active(False)
self.pass_entry.set_text(model.get_value(iter,4))
self.nick_entry.set_text(model.get_value(iter,5))
self.pass_entry.set_text(model.get_value(iter, 4))
self.nick_entry.set_text(model.get_value(iter, 5))
def on_title_entry_changed(self, widget):
(model, iter) = self.selection.get_selected()
@ -2517,9 +2512,8 @@ class ManageBookmarksWindow:
model.set_value(iter, 3, self.autojoin_checkbutton.get_active())
def clear_fields(self):
self.title_entry.set_text('')
self.room_entry.set_text('')
self.server_entry.set_text('')
self.pass_entry.set_text('')
self.nick_entry.set_text('')
widgets = [ self.title_entry, self.nick_entry, self.room_entry,
self.server_entry, self.pass_entry ]
for field in widgets:
field.set_text('')
self.autojoin_checkbutton.set_active(False)

View File

@ -726,7 +726,7 @@ _('Without a connection, you can not change your password.')).get_response()
return message
class Popup_notification_window:
class PopupNotificationWindow:
def __init__(self, plugin, event_type, jid, account):
self.plugin = plugin
self.account = account
@ -765,7 +765,7 @@ class Popup_notification_window:
window_width, self.window_height = self.window.get_size()
self.plugin.roster.popups_notification_height += self.window_height
self.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)
xml.signal_autoconnect(self)
self.window.show_all()

View File

@ -307,7 +307,7 @@ class Interface:
elif gajim.connections[account].connected in (2, 3): # we're online or chat
show_notification = True
if show_notification:
instance = dialogs.Popup_notification_window(self,
instance = dialogs.PopupNotificationWindow(self,
_('Contact Signed In'), jid, account)
self.roster.popup_notification_windows.append(instance)
@ -325,7 +325,7 @@ class Interface:
elif gajim.connections[account].connected in (2, 3): # we're online or chat
show_notification = True
if show_notification:
instance = dialogs.Popup_notification_window(self,
instance = dialogs.PopupNotificationWindow(self,
_('Contact Signed Out'), jid, account)
self.roster.popup_notification_windows.append(instance)
@ -376,7 +376,7 @@ class Interface:
elif gajim.connections[account].connected in (2, 3): # we're online or chat
show_notification = True
if show_notification:
instance = dialogs.Popup_notification_window(self,
instance = dialogs.PopupNotificationWindow(self,
_('New Message'), jid, account)
self.roster.popup_notification_windows.append(instance)
self.roster.on_message(jid, array[1], array[2], account, array[3])
@ -577,7 +577,7 @@ class Interface:
#We received a bookmark item from the server (JEP48)
#Open GC window if neccessary
if bm['autojoin'] == "1":
if bm['autojoin']:
jid = bm['jid']
self.roster.new_room(jid, bm['nick'], account)
self.windows[account]['gc'][jid].set_active_tab(jid)