gnome-scan r655 - in trunk: . lib
- From: bersace svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-scan r655 - in trunk: . lib
- Date: Thu, 11 Dec 2008 21:03:44 +0000 (UTC)
Author: bersace
Date: Thu Dec 11 21:03:44 2008
New Revision: 655
URL: http://svn.gnome.org/viewvc/gnome-scan?rev=655&view=rev
Log:
Implemented option widget destruction.
Modified:
trunk/ChangeLog
trunk/lib/gnome-scan-option-box.vala
trunk/lib/gnome-scan-option-page.vala
Modified: trunk/lib/gnome-scan-option-box.vala
==============================================================================
--- trunk/lib/gnome-scan-option-box.vala (original)
+++ trunk/lib/gnome-scan-option-box.vala Thu Dec 11 21:03:44 2008
@@ -31,6 +31,8 @@
int child_count = 0;
int child_visible_count = 0;
int child_expanding_count = 0;
+ HashTable<Gnome.Scan.Option,OptionWidget> children;
+ HashTable<Gnome.Scan.Option,Gtk.Label> labels;
construct {
this.spacing = 6;
@@ -46,6 +48,9 @@
this.table.set_col_spacings(6);
this.table.set_row_spacings(4);
alignment.add(this.table);
+
+ children = new HashTable<Gnome.Scan.Option, OptionWidget>(GLib.direct_hash, GLib.direct_equal);
+ labels = new HashTable<Gnome.Scan.Option, Gtk.Label>(GLib.direct_hash, GLib.direct_equal);
}
public OptionBox(string label)
@@ -86,15 +91,42 @@
// locale typographic rules.
Label label = new Label(_("%s:").printf(option.title));
label.set_alignment((float)0, (float)0);
+ this.labels.insert(option, label);
this.table.attach(label, 0, 1, this.child_count-1, this.child_count,
AttachOptions.FILL, AttachOptions.FILL, 0, 0);
this.table.attach(widget, 1, 2, this.child_count-1, this.child_count,opts, opts, 0, 0);
}
+ this.children.insert(option, widget);
this.on_option_widget_visibility_changed(widget);
}
- public void on_option_widget_visibility_changed(OptionWidget widget)
+ // return whether the box is empty
+ public bool unpack_option(Option option)
+ {
+ var widget = this.children.lookup(option);
+ if (widget == null)
+ return false;
+
+ // hide widget
+ widget.no_show_all = true;
+ widget.hide();
+
+ // destroy widget
+ this.table.remove(widget);
+ this.children.remove(option);
+
+ // destroy label
+ var label = this.labels.lookup(option);
+ if (label != null) {
+ this.table.remove(label);
+ this.labels.remove(option);
+ }
+
+ return this.table.get_children().length() == 0;
+ }
+
+ private void on_option_widget_visibility_changed(OptionWidget widget)
{
if (widget.expand) {
this.child_expanding_count += widget.visible ? +1 : -1;
Modified: trunk/lib/gnome-scan-option-page.vala
==============================================================================
--- trunk/lib/gnome-scan-option-page.vala (original)
+++ trunk/lib/gnome-scan-option-page.vala Thu Dec 11 21:03:44 2008
@@ -50,6 +50,15 @@
box.pack_option(option);
}
+ public void unpack_option(Option option)
+ {
+ OptionBox box = this.boxes.lookup(option.group);
+ if (box.unpack_option(option)) {
+ this.container.remove(box);
+ this.boxes.remove(option.group);
+ }
+ }
+
private void on_box_visibility_changed(OptionBox box)
{
if (box.expand) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]