[nanny] Update UI
- From: Roberto Majadas <telemaco src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nanny] Update UI
- Date: Sun, 23 Jan 2011 18:07:23 +0000 (UTC)
commit d4329b07eac4645f41989d20fb8cc6e42e628ca1
Author: Roberto Majadas <roberto majadas openshine com>
Date: Sun Jan 16 14:49:21 2011 +0100
Update UI
client/gnome/admin/data/ui/nac_wcf_dialog.ui | 105 ++++++++++++++++--------
client/gnome/admin/src/BlacklistManager.py | 54 +++++++------
client/gnome/admin/src/ConfigureProxyDialog.py | 100 ++++++++++++++++++++++
3 files changed, 199 insertions(+), 60 deletions(-)
---
diff --git a/client/gnome/admin/data/ui/nac_wcf_dialog.ui b/client/gnome/admin/data/ui/nac_wcf_dialog.ui
index 65884d3..5ff636d 100644
--- a/client/gnome/admin/data/ui/nac_wcf_dialog.ui
+++ b/client/gnome/admin/data/ui/nac_wcf_dialog.ui
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
@@ -41,7 +41,6 @@
<child>
<object class="GtkVButtonBox" id="vbuttonbox1">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
<property name="spacing">5</property>
<property name="layout_style">start</property>
<child>
@@ -137,7 +136,6 @@
<child>
<object class="GtkVButtonBox" id="vbuttonbox2">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
<property name="spacing">5</property>
<property name="layout_style">start</property>
<child>
@@ -212,30 +210,14 @@
<property name="left_padding">5</property>
<property name="right_padding">5</property>
<child>
- <object class="GtkVBox" id="vbox1">
+ <object class="GtkHPaned" id="hpaned1">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">10</property>
+ <property name="can_focus">True</property>
+ <property name="position">300</property>
+ <property name="position_set">True</property>
<child>
- <object class="GtkLabel" id="label4">
+ <object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="label" translatable="yes">Here you can apply the available blacklists for the selected user. If you want to add new blacklists please go to System > Administration > Blacklists.</property>
- <property name="justify">fill</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkHPaned" id="hpaned1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="position">300</property>
- <property name="position_set">True</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow3">
<property name="visible">True</property>
@@ -252,33 +234,84 @@
</child>
</object>
<packing>
- <property name="resize">False</property>
- <property name="shrink">True</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow4">
+ <object class="GtkHButtonBox" id="hbuttonbox1">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">never</property>
- <property name="vscrollbar_policy">automatic</property>
- <property name="shadow_type">etched-in</property>
<child>
- <object class="GtkTreeView" id="wcfd_packaged_blacklist_categories_treeview">
+ <object class="GtkButton" id="wcfd_add_bl_button">
+ <property name="label">gtk-add</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="headers_visible">False</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="wcfd_del_bl_button">
+ <property name="label">gtk-remove</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="wcfd_update_bl_button">
+ <property name="label">gtk-refresh</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
</child>
</object>
<packing>
- <property name="resize">True</property>
- <property name="shrink">True</property>
+ <property name="expand">False</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
<packing>
- <property name="position">1</property>
+ <property name="resize">False</property>
+ <property name="shrink">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow4">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">etched-in</property>
+ <child>
+ <object class="GtkTreeView" id="wcfd_packaged_blacklist_categories_treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="headers_visible">False</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">True</property>
</packing>
</child>
</object>
diff --git a/client/gnome/admin/src/BlacklistManager.py b/client/gnome/admin/src/BlacklistManager.py
index e94208c..63411e9 100644
--- a/client/gnome/admin/src/BlacklistManager.py
+++ b/client/gnome/admin/src/BlacklistManager.py
@@ -47,6 +47,7 @@ class BlacklistManager:
self.dialog.get_content_area().add (self.alignment)
self.blacklist_import_button.connect ('clicked', self.__on_blacklist_import_button_clicked)
+ self.blacklist_update_button.connect ('clicked', self.__on_blacklist_update_button_clicked)
self.blacklist_remove_button.connect ('clicked', self.__on_blacklist_remove_button_clicked)
self.unlock_button.connect('clicked', self.__on_unlock_button_clicked)
@@ -95,6 +96,7 @@ class BlacklistManager:
self.unlock_area.show()
self.blacklist_import_button.set_sensitive(lock_status)
+ self.blacklist_update_button.set_sensitive(lock_status)
self.blacklist_remove_button.set_sensitive(lock_status)
@@ -112,32 +114,36 @@ class BlacklistManager:
model.append ((read_only, filter_id, "<b>%s</b>\n %s" % (filter_name, filter_description)))
def __on_blacklist_import_button_clicked (self, widget, data=None):
- file_selection_dialog = gtk.FileChooserDialog (_("Select file to import"), self.dialog,
- buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
- gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
- file_selection_dialog.set_select_multiple (False)
-
- file_filter = gtk.FileFilter ()
- file_filter.add_pattern ("*.nbl")
+ dialog = gtk.MessageDialog(
+ None,
+ gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+ gtk.MESSAGE_QUESTION,
+ gtk.BUTTONS_OK,
+ None)
+
+ def responseToDialog(entry, dialog, response):
+ dialog.response(response)
+
+ dialog.set_markup('Introduce the nannycentral repository url')
+ entry = gtk.Entry()
+ entry.connect("activate", responseToDialog, dialog, gtk.RESPONSE_OK)
+ hbox = gtk.HBox()
+ hbox.pack_start(gtk.Label("Url:"), False, 5, 5)
+ hbox.pack_end(entry)
+ dialog.format_secondary_markup("It's something like http://www.nannycentral.info/blacklist/blacklist.json ...")
+ dialog.vbox.pack_end(hbox, True, True, 0)
+ dialog.show_all()
+ dialog.run()
+ text = entry.get_text()
+ dialog.destroy()
+
+ if not text.startswith("http:/") :
+ text = "http://" + text
- file_selection_dialog.set_filter (file_filter)
- response = file_selection_dialog.run()
+ result = self.dbus_client.add_pkg_filter (text)
- if response == gtk.RESPONSE_ACCEPT:
- filename = file_selection_dialog.get_filename()
- result = self.dbus_client.add_pkg_filter (filename)
-
- if result:
- self.__fill_treeview ()
- else:
- d = gtk.MessageDialog(None, gtk.DIALOG_MODAL, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK)
- d.set_property("icon-name", "nanny")
- d.set_markup(_("<b>Error importing blacklist file</b>"))
- d.format_secondary_markup(_("Some error has occured importing the blacklist file."))
- d.run()
- d.destroy()
-
- file_selection_dialog.destroy()
+ def __on_blacklist_update_button_clicked (self, widget, data=None):
+ pass
def __on_blacklist_remove_button_clicked (self, widget, data=None):
if self.__selected_blacklist == None:
diff --git a/client/gnome/admin/src/ConfigureProxyDialog.py b/client/gnome/admin/src/ConfigureProxyDialog.py
index 0a7f124..5a6fad1 100644
--- a/client/gnome/admin/src/ConfigureProxyDialog.py
+++ b/client/gnome/admin/src/ConfigureProxyDialog.py
@@ -54,6 +54,10 @@ class ConfigureProxyDialog (gtk.Dialog):
self.custom_whitelist_edit_button.connect ('clicked', self.__on_custom_whitelist_edit_button_clicked)
self.custom_whitelist_remove_button.connect ('clicked', self.__on_custom_whitelist_remove_button_clicked)
+ self.add_bl_button.connect("clicked", self.__on_add_bl_button_cb)
+ self.del_bl_button.connect("clicked", self.__on_del_bl_button_cb)
+ self.update_bl_button.connect("clicked", self.__on_update_bl_button_cb)
+
self.__init_custom_treeview (self.custom_blacklist_treeview)
self.__init_custom_treeview (self.custom_whitelist_treeview)
self.__init_pkg_treeview (self.packaged_blacklist_treeview)
@@ -170,6 +174,54 @@ class ConfigureProxyDialog (gtk.Dialog):
filter_name, filter_description = self.dbus_client.get_pkg_filter_metadata(filter_id)
packaged_blacklist_model.append ((filter_id, "<b>%s</b>\n %s" % (filter_name, filter_description)))
+ gobject.timeout_add(1, self.__update_packaged_blacklist_model)
+
+ def __update_packaged_blacklist_model(self):
+ try:
+ list_store = self.packaged_blacklist_treeview.get_model()
+
+ server_list = self.dbus_client.list_pkg_filters ()
+
+
+ for filter_id, ro in server_list:
+ included = False
+ for row in list_store:
+ if row[0] == filter_id :
+ filter_name, filter_description = self.dbus_client.get_pkg_filter_metadata(filter_id)
+ row[1] = "<b>%s</b>\n %s" % (filter_name, filter_description)
+ included = True
+ break
+
+ if included == True:
+ continue
+
+ filter_name, filter_description = self.dbus_client.get_pkg_filter_metadata(filter_id)
+ list_store.append ((filter_id, "<b>%s</b>\n %s" % (filter_name, filter_description)))
+
+ iter = list_store.get_iter_first()
+ while iter :
+ id = list_store.get_value(iter, 0)
+
+ to_remove = True
+ for filter_id, ro in server_list:
+ if filter_id == id :
+ to_remove = False
+ break
+
+ if to_remove == True :
+ tmp_iter = iter
+ iter = list_store.iter_next(tmp_iter)
+ list_store.remove(tmp_iter)
+ continue
+
+ iter = list_store.iter_next(iter)
+
+ gobject.timeout_add(2000, self.__update_packaged_blacklist_model)
+ return False
+ except:
+ return False
+
+
def __on_custom_blacklist_add_button_clicked (self, widget, data=None):
xml = self.__load_dialog ()
self.proxy_rule_dialog = xml.get_object ('wcfed_dialog')
@@ -480,6 +532,54 @@ class ConfigureProxyDialog (gtk.Dialog):
if category_active:
active_categories.append (category_name)
+ def __on_add_bl_button_cb(self, widget):
+ dialog = gtk.MessageDialog(None,
+ gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+ gtk.MESSAGE_QUESTION,
+ gtk.BUTTONS_OK,
+ None)
+ def responseToDialog(entry, dialog, response):
+ dialog.response(response)
+
+ dialog.set_markup(_('Introduce the nannycentral repository url'))
+ entry = gtk.Entry()
+ entry.connect("activate", responseToDialog, dialog, gtk.RESPONSE_OK)
+ hbox = gtk.HBox()
+ hbox.pack_start(gtk.Label("Url:"), False, 5, 5)
+ hbox.pack_end(entry)
+ dialog.format_secondary_markup(_("It's something like http://www.nannycentral.info/blacklist/blacklist.json ..."))
+ dialog.vbox.pack_end(hbox, True, True, 0)
+ dialog.show_all()
+ dialog.run()
+ text = entry.get_text()
+ dialog.destroy()
+
+ if not text.startswith("http:/") :
+ text = "http://" + text
+
+ result = self.dbus_client.add_pkg_filter (text)
+
+ def __on_del_bl_button_cb(self, widget):
+ try:
+ selection = self.packaged_blacklist_treeview.get_selection()
+ model, iter = selection.get_selected()
+ pkg_id = model.get_value(iter, 0)
+ except:
+ return
+
+ d = gtk.MessageDialog(None, gtk.DIALOG_MODAL, type=gtk.MESSAGE_QUESTION, buttons=gtk.BUTTONS_OK_CANCEL)
+ d.set_property("icon-name", "nanny")
+ d.set_markup(_("<b>Are you sure you want to delete this blacklist?</b>"))
+ d.format_secondary_markup(_("This action will remove all the user configuration linked to the blacklist."))
+ response = d.run()
+ if response == gtk.RESPONSE_OK:
+ self.dbus_client.remove_pkg_filter (pkg_id)
+
+ d.destroy()
+
+ def __on_update_bl_button_cb(self, widget):
+ pass
+
def __load_dialog (self):
ui_file = os.path.join (nanny.client.gnome.admin.ui_files_dir, "nac_wcf_edit_dialog.ui")
xml = gtk.Builder ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]