[rygel] ui: Implement adding of Folder URIs



commit 493beb203515cc05f985d624b27dd4fe7f87fc8b
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Jun 3 17:38:05 2009 +0300

    ui: Implement adding of Folder URIs
    
    Implement adding of Folder URIs to the treeview using a
    GtkFileChooserDialog.
---
 data/rygel-preferences.ui             |   70 +++++++++++++++++++++++++++++++++
 src/ui/rygel-folder-pref-section.vala |   16 +++++++
 2 files changed, 86 insertions(+), 0 deletions(-)

diff --git a/data/rygel-preferences.ui b/data/rygel-preferences.ui
index a4c70b3..c5207a2 100644
--- a/data/rygel-preferences.ui
+++ b/data/rygel-preferences.ui
@@ -555,6 +555,76 @@
     <property name="page_increment">10</property>
     <property name="page_size">10</property>
   </object>
+  <object class="GtkFileChooserDialog" id="folders-dialog">
+    <property name="can_default">True</property>
+    <property name="has_default">True</property>
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Select folders</property>
+    <property name="modal">True</property>
+    <property name="destroy_with_parent">True</property>
+    <property name="type_hint">dialog</property>
+    <property name="transient_for">preferences-dialog</property>
+    <property name="has_separator">False</property>
+    <property name="select_multiple">True</property>
+    <property name="action">select-folder</property>
+    <property name="local_only">False</property>
+    <child internal-child="vbox">
+      <object class="GtkVBox" id="dialog-vbox2">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child>
+          <placeholder/>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area2">
+            <property name="visible">True</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="button4">
+                <property name="label" translatable="yes">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">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">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="button5">
+                <property name="label" translatable="yes">gtk-open</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">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>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">button4</action-widget>
+      <action-widget response="-5">button5</action-widget>
+    </action-widgets>
+  </object>
   <object class="GtkSizeGroup" id="general-labels-sizegroup">
     <property name="mode">both</property>
   </object>
diff --git a/src/ui/rygel-folder-pref-section.vala b/src/ui/rygel-folder-pref-section.vala
index b4ad858..344f212 100644
--- a/src/ui/rygel-folder-pref-section.vala
+++ b/src/ui/rygel-folder-pref-section.vala
@@ -28,9 +28,11 @@ public class Rygel.FolderPrefSection : Rygel.PluginPrefSection {
     const string FOLDERS_KEY = "folders";
     const string FOLDERS_TEXTVIEW = FOLDERS_KEY + "-treeview";
     const string FOLDERS_LISTSTORE = FOLDERS_KEY + "-liststore";
+    const string FOLDERS_DIALOG = FOLDERS_KEY + "-dialog";
 
     private TreeView treeview;
     private ListStore liststore;
+    private FileChooserDialog dialog;
 
     public FolderPrefSection (Builder       builder,
                               Configuration config) {
@@ -40,6 +42,8 @@ public class Rygel.FolderPrefSection : Rygel.PluginPrefSection {
         assert (this.treeview != null);
         this.liststore = (ListStore) builder.get_object (FOLDERS_LISTSTORE);
         assert (this.liststore != null);
+        this.dialog = (FileChooserDialog) builder.get_object (FOLDERS_DIALOG);
+        assert (this.dialog != null);
 
         treeview.insert_column_with_attributes (-1,
                                                 "paths",
@@ -86,6 +90,18 @@ public class Rygel.FolderPrefSection : Rygel.PluginPrefSection {
 
     [CCode (instance_pos = -1)]
     public void on_add_button_clicked (Button button) {
+        if (this.dialog.run () == ResponseType.OK) {
+            TreeIter iter;
+
+            var uris = this.dialog.get_uris ();
+
+            foreach (var uri in uris) {
+                this.liststore.append (out iter);
+                this.liststore.set (iter, 0, uri, -1);
+            }
+        }
+
+        this.dialog.hide ();
     }
 
     [CCode (instance_pos = -1)]



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]