[Xfce4-commits] <design:master> Rework construction of example data.
Jannis Pohlmann
noreply at xfce.org
Tue May 31 22:30:01 CEST 2011
Updating branch refs/heads/master
to 0ddb473a55eb4d19b66fc28ceebb44b5a36b4073 (commit)
from 52f2c69912b5c503f2307a280db32cee23f77529 (commit)
commit 0ddb473a55eb4d19b66fc28ceebb44b5a36b4073
Author: Jannis Pohlmann <jannis at xfce.org>
Date: Tue May 31 22:28:07 2011 +0200
Rework construction of example data.
.../demo-code/custom-view/shortcuts-view.vala | 148 ++++++++++----------
1 files changed, 76 insertions(+), 72 deletions(-)
diff --git a/thunar/shortcuts-pane/demo-code/custom-view/shortcuts-view.vala b/thunar/shortcuts-pane/demo-code/custom-view/shortcuts-view.vala
index a0f2c76..a324a46 100644
--- a/thunar/shortcuts-pane/demo-code/custom-view/shortcuts-view.vala
+++ b/thunar/shortcuts-pane/demo-code/custom-view/shortcuts-view.vala
@@ -22,6 +22,30 @@ using Gtk;
+public class Category : GLib.Object {
+ public string name { get; set; }
+
+ public Category (string name) {
+ this.name = name;
+ }
+}
+
+
+
+public class Shortcut : GLib.Object {
+ public string name { get; set; }
+ public string icon_name { get; set; }
+ public bool connected { get; set; }
+
+ public Shortcut (string name, string icon_name, bool connected) {
+ this.name = name;
+ this.icon_name = icon_name;
+ this.connected = connected;
+ }
+}
+
+
+
public class ShortcutsView : EventBox {
private Alignment alignment { get; set; }
private VBox box { get; set; }
@@ -36,79 +60,59 @@ public class ShortcutsView : EventBox {
alignment.add (box);
box.show ();
- var devices_expander = new Expander ("<span size='medium' weight='bold' color='#353535'>DEVICES</span>");
- devices_expander.set_border_width (0);
- devices_expander.set_use_markup (true);
- devices_expander.set_expanded (true);
- devices_expander.set_spacing (0);
- box.pack_start(devices_expander, false, true, 0);
-
- var devices_box = new VBox (false, 0);
- devices_expander.add (devices_box);
- devices_box.show ();
-
- var filesys = new ShortcutRow ("File System", "harddrive", false);
- devices_box.pack_start (filesys, false, true, 0);
- filesys.show ();
-
- var ipod = new ShortcutRow ("iPod", "multimedia-player", true);
- devices_box.pack_start (ipod, false, true, 0);
- ipod.show ();
-
- var dvdrw = new ShortcutRow ("Blank DVD+RW Disc", "media-optical-dvd", true);
- devices_box.pack_start (dvdrw, false, true, 0);
- dvdrw.show ();
-
- var places_expander = new Expander ("<span size='medium' weight='bold' color='#353535'>PLACES</span>");
- places_expander.set_use_markup (true);
- places_expander.set_expanded (true);
- box.pack_start(places_expander, false, true, 0);
-
- var places_box = new VBox (false, 0);
- places_expander.add (places_box);
- places_box.show ();
-
- var home = new ShortcutRow ("jannis", "user-home", false);
- places_box.pack_start (home, false, true, 0);
- home.show ();
-
- var desktop = new ShortcutRow ("Desktop", "user-desktop", false);
- places_box.pack_start (desktop, false, true, 0);
- desktop.show ();
-
- var trash = new ShortcutRow ("Trash", "user-trash", false);
- places_box.pack_start (trash, false, true, 0);
- trash.show ();
-
- var documents = new ShortcutRow ("Documents", "folder-documents", false);
- places_box.pack_start (documents, false, true, 0);
- documents.show ();
-
- var downloads = new ShortcutRow ("Downloads", "folder", false);
- places_box.pack_start (downloads, false, true, 0);
- downloads.show ();
-
- var thesis = new ShortcutRow ("Thesis", "folder", false);
- places_box.pack_start (thesis, false, true, 0);
- thesis.show ();
-
- var network_expander = new Expander ("<span size='medium' weight='bold' color='#353535'>NETWORK</span>");
- network_expander.set_use_markup (true);
- network_expander.set_expanded (true);
- box.pack_start(network_expander, false, true, 0);
-
- var network_box = new VBox (false, 0);
- network_expander.add (network_box);
- network_box.show ();
-
- var sftpxfce = new ShortcutRow ("sftp at xfce.org", "folder-remote", true);
- network_box.pack_start (sftpxfce, false, true, 0);
- sftpxfce.show ();
-
- var ftpgezeiten = new ShortcutRow ("ftp at gezeiten.org", "folder-remote", false);
- network_box.pack_start (ftpgezeiten, false, true, 0);
- ftpgezeiten.show ();
+ List<GLib.Object> shortcuts = new List<GLib.Object> ();
+
+ shortcuts.append (new Category ("DEVICES"));
+ shortcuts.append (new Shortcut ("File System", "harddrive", false));
+ shortcuts.append (new Shortcut ("iPod", "multimedia-player", true));
+ shortcuts.append (new Shortcut ("Blank DVD+RW Disc", "media-optical-dvd", true));
+
+ shortcuts.append (new Category ("PLACES"));
+ shortcuts.append (new Shortcut ("jannis", "user-home", false));
+ shortcuts.append (new Shortcut ("Desktop", "user-desktop", false));
+ shortcuts.append (new Shortcut ("Trash", "user-trash", false));
+ shortcuts.append (new Shortcut ("Documents", "folder-documents", false));
+ shortcuts.append (new Shortcut ("Downloads", "folder", false));
+ shortcuts.append (new Shortcut ("Thesis", "folder", false));
+
+ shortcuts.append (new Category ("NETWORK"));
+ shortcuts.append (new Shortcut ("sftp at xfce.org", "folder-remote", true));
+ shortcuts.append (new Shortcut ("ftp at gezeiten.org", "folder-remote", false));
+
+ Container? container = null;
+ foreach (var item in shortcuts) {
+ if (item is Category) {
+ Category category = (Category) item;
+
+ var markup = "<span size='medium' weight='bold' color='#353535'>%s</span>";
+
+ var expander = new Expander (GLib.Markup.printf_escaped (markup, category.name));
+ expander.set_border_width (0);
+ expander.set_use_markup (true);
+ expander.set_expanded (true);
+ expander.set_spacing (0);
+ box.pack_start (expander, false, true, 0);
+
+ container = new VBox (false, 0);
+ expander.add (container);
+ container.show ();
+ } else {
+ Shortcut shortcut = (Shortcut) item;
+ var row = new ShortcutRow (shortcut.name, shortcut.icon_name, shortcut.connected);
+ container.add (row);
+ row.show ();
+ }
+ }
show_all ();
}
+
+ public Widget? get_selected_row () {
+ foreach (var child in get_children ()) {
+ if ((child.state & StateType.SELECTED) != 0) {
+ return child;
+ }
+ }
+ return null;
+ }
}
More information about the Xfce4-commits
mailing list