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 #Get the account that is currently used
#(the parent of the currently selected item) #(the parent of the currently selected item)
(model, iter) = self.selection.get_selected() (model, iter) = self.selection.get_selected()
if not iter: if not iter: #Nothing selected, do nothing
#Nothing selected, do nothing
return return
#FIXME: ErrorDialog
parent = model.iter_parent(iter) 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. #No parent, so we got an account -> add to this.
add_to = iter 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) account = model.get_value(add_to, 1)
self.treestore.append(add_to, [account,_('New Room'), '', '', '', '']) self.treestore.append(add_to, [account,_('New Room'), '', '', '', ''])
self.view.expand_row(model.get_path(add_to), True) self.view.expand_row(model.get_path(add_to), True)
def on_remove_bookmark_button_clicked(self, widget): def on_remove_bookmark_button_clicked(self, widget):
''' '''
Remove selected bookmark. Remove selected bookmark.
''' '''
(model, iter) = self.selection.get_selected() (model, iter) = self.selection.get_selected()
if not iter: if not iter: #Nothing selected
#Nothing selected
return return
if not model.iter_parent(iter): if not model.iter_parent(iter):
#Don't remove account iters #Don't remove account iters
return return
@ -2411,21 +2407,25 @@ class ManageBookmarksWindow:
then send the new bookmarks to the server. then send the new bookmarks to the server.
''' '''
for account in self.treestore: for account in self.treestore:
gajim.connections[account[1]].bookmarks=[] 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'
#Build and append the bookmark-dict for bm in account.iterchildren():
bmdict = { 'name':bm[1], 'jid':bm[2], print bm[0], bm[1], bm[2], bm[3], bm[4], bm[5]
'autojoin':bm[3], 'password':bm[4], #Convert True/False/None to '1' or '0'
'nick':bm[5] } if bm[3]: #autojoin
if gajim.connections[account[1]].status > 1: 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]].bookmarks.append(bmdict)
gajim.connections[account[1]].store_bookmarks() gajim.connections[account[1]].store_bookmarks()
self.window.destroy() self.window.destroy()
def on_cancel_button_clicked(self, widget): def on_cancel_button_clicked(self, widget):
@ -2442,25 +2442,20 @@ class ManageBookmarksWindow:
#this will be None, so we will just: #this will be None, so we will just:
return return
if not model.iter_parent(iter): widgets = [ self.title_entry, self.nick_entry, self.room_entry,
#Top-level has no data (it's the account fields) self.server_entry, self.pass_entry, self.autojoin_checkbutton ]
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
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)
if model.iter_parent(iter):
#make the fields sensitive
for field in widgets:
field.set_sensitive(True)
else:
#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 #Fill in the data for childs
self.title_entry.set_text(model.get_value(iter, 1)) self.title_entry.set_text(model.get_value(iter, 1))
@ -2473,12 +2468,12 @@ class ManageBookmarksWindow:
server = '' server = ''
self.room_entry.set_text(room) self.room_entry.set_text(room)
self.server_entry.set_text(server) 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) self.autojoin_checkbutton.set_active(True)
else: else:
self.autojoin_checkbutton.set_active(False) self.autojoin_checkbutton.set_active(False)
self.pass_entry.set_text(model.get_value(iter,4)) self.pass_entry.set_text(model.get_value(iter, 4))
self.nick_entry.set_text(model.get_value(iter,5)) self.nick_entry.set_text(model.get_value(iter, 5))
def on_title_entry_changed(self, widget): def on_title_entry_changed(self, widget):
(model, iter) = self.selection.get_selected() (model, iter) = self.selection.get_selected()
@ -2517,9 +2512,8 @@ class ManageBookmarksWindow:
model.set_value(iter, 3, self.autojoin_checkbutton.get_active()) model.set_value(iter, 3, self.autojoin_checkbutton.get_active())
def clear_fields(self): def clear_fields(self):
self.title_entry.set_text('') widgets = [ self.title_entry, self.nick_entry, self.room_entry,
self.room_entry.set_text('') self.server_entry, self.pass_entry ]
self.server_entry.set_text('') for field in widgets:
self.pass_entry.set_text('') field.set_text('')
self.nick_entry.set_text('')
self.autojoin_checkbutton.set_active(False) 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 return message
class Popup_notification_window: class PopupNotificationWindow:
def __init__(self, plugin, event_type, jid, account): def __init__(self, plugin, event_type, jid, account):
self.plugin = plugin self.plugin = plugin
self.account = account self.account = account
@ -765,7 +765,7 @@ class Popup_notification_window:
window_width, self.window_height = self.window.get_size() window_width, self.window_height = self.window.get_size()
self.plugin.roster.popups_notification_height += self.window_height self.plugin.roster.popups_notification_height += self.window_height
self.window.move(gtk.gdk.screen_width() - window_width, 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) xml.signal_autoconnect(self)
self.window.show_all() 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 elif gajim.connections[account].connected in (2, 3): # we're online or chat
show_notification = True show_notification = True
if show_notification: if show_notification:
instance = dialogs.Popup_notification_window(self, instance = dialogs.PopupNotificationWindow(self,
_('Contact Signed In'), jid, account) _('Contact Signed In'), jid, account)
self.roster.popup_notification_windows.append(instance) 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 elif gajim.connections[account].connected in (2, 3): # we're online or chat
show_notification = True show_notification = True
if show_notification: if show_notification:
instance = dialogs.Popup_notification_window(self, instance = dialogs.PopupNotificationWindow(self,
_('Contact Signed Out'), jid, account) _('Contact Signed Out'), jid, account)
self.roster.popup_notification_windows.append(instance) 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 elif gajim.connections[account].connected in (2, 3): # we're online or chat
show_notification = True show_notification = True
if show_notification: if show_notification:
instance = dialogs.Popup_notification_window(self, instance = dialogs.PopupNotificationWindow(self,
_('New Message'), jid, account) _('New Message'), jid, account)
self.roster.popup_notification_windows.append(instance) self.roster.popup_notification_windows.append(instance)
self.roster.on_message(jid, array[1], array[2], account, array[3]) 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) #We received a bookmark item from the server (JEP48)
#Open GC window if neccessary #Open GC window if neccessary
if bm['autojoin'] == "1": if bm['autojoin']:
jid = bm['jid'] jid = bm['jid']
self.roster.new_room(jid, bm['nick'], account) self.roster.new_room(jid, bm['nick'], account)
self.windows[account]['gc'][jid].set_active_tab(jid) self.windows[account]['gc'][jid].set_active_tab(jid)