bookmarks are now checked thanks to christoph

This commit is contained in:
Yann Leboulanger 2005-06-12 16:39:04 +00:00
parent ac1d22881f
commit a19e89fbfb
2 changed files with 41 additions and 8 deletions

View File

@ -2254,7 +2254,6 @@ class RemoveAccountWindow:
self.window.destroy()
#---------- ManageBookmarksWindow class -------------#
#TODO: Find a good place to check if the input is valid (all neccessary fields filled out?)
class ManageBookmarksWindow:
def __init__(self, plugin):
self.plugin = plugin
@ -2318,7 +2317,17 @@ class ManageBookmarksWindow:
self.xml.signal_autoconnect(self)
self.window.show_all()
def on_manage_bookmarks_window_destroy(self, widget):
def on_bookmarks_treeview_button_press_event(self, widget, event):
(model, iter) = self.selection.get_selected()
if not iter:
#Removed a bookmark before
return
if model.iter_parent(iter):
#The currently selected node is a bookmark
return not self.check_valid_bookmark():
def on_manage_bookmarks_window_destroy(self, widget, event):
del self.plugin.windows['manage_bookmarks']
def on_add_bookmark_button_clicked(self,widget):
@ -2360,11 +2369,35 @@ class ManageBookmarksWindow:
model.remove(iter)
self.clear_fields()
def check_valid_bookmark(self):
'''
Check if all neccessary fields are entered correctly.
'''
(model, iter) = self.selection.get_selected()
if not model.iter_parent(iter):
#Account data can't be changed
return
if self.server_entry.get_text() == '' or self.room_entry.get_text() == '':
dialogs.ErrorDialog(_('This bookmark has invalid data.'),
_('Please be sure to fill out server and room fields \
or remove this bookmark.')).get_response()
return False
return True
def on_ok_button_clicked(self, widget):
'''
Parse the treestore data into our new bookmarks array,
then send the new bookmarks to the server.
'''
(model, iter) = self.selection.get_selected()
if iter and model.iter_parent(iter):
#bookmark selected, check it
if not self.check_valid_bookmark():
return
for account in self.treestore:
gajim.connections[account[1]].bookmarks = []
@ -2379,7 +2412,6 @@ class ManageBookmarksWindow:
gajim.connections[account[1]].bookmarks.append(bmdict)
gajim.connections[account[1]].store_bookmarks()
self.plugin.roster.make_menu()
self.window.destroy()

View File

@ -13540,6 +13540,7 @@ the Jabber network.</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<signal name="button_press_event" handler="on_manage_bookmarks_window_button_press_event" last_modification_time="Sun, 12 Jun 2005 15:52:20 GMT"/>
<child>
<widget class="GtkVBox" id="vbox86">