summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>2009-06-02 17:32:02 +0300
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>2009-06-03 01:05:24 +0300
commit1a59a45a5808a2928234868f305c182b429a7908 (patch)
treefd3287f699b6856aceea074c4025d98ec8309c7a
parentb2d72bc74839d911edfb5194e4abb04c6f1fed79 (diff)
downloadrygel-1a59a45a5808a2928234868f305c182b429a7908.tar.gz
ui: Treeview to handle 'folders' option
Instead of providing a text area to put the paths, provide a treeview and buttons to interact with it. For now only clear button works.
-rw-r--r--data/rygel-preferences.ui73
-rw-r--r--src/ui/rygel-folder-pref-section.vala66
2 files changed, 108 insertions, 31 deletions
diff --git a/data/rygel-preferences.ui b/data/rygel-preferences.ui
index f5c94101..a4c70b3f 100644
--- a/data/rygel-preferences.ui
+++ b/data/rygel-preferences.ui
@@ -2,10 +2,15 @@
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
+ <object class="GtkListStore" id="folders-liststore">
+ <columns>
+ <!-- column-name path -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkDialog" id="preferences-dialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">Rygel Preferences</property>
- <property name="resizable">False</property>
<property name="default_height">400</property>
<property name="type_hint">normal</property>
<property name="has_separator">False</property>
@@ -377,17 +382,70 @@
</packing>
</child>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow2">
+ <object class="GtkHBox" id="hbox2">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">automatic</property>
- <property name="vscrollbar_policy">automatic</property>
<child>
- <object class="GtkTextView" id="folders-textview">
+ <object class="GtkTreeView" id="folders-treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="buffer">folders-textbuffer</property>
+ <property name="model">folders-liststore</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
+ <property name="fixed_height_mode">True</property>
</object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox4">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkButton" id="add-button">
+ <property name="label" translatable="yes">gtk-add</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="rygel_folder_pref_section_on_add_button_clicked"/>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="remove-button">
+ <property name="label" translatable="yes">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>
+ <signal name="clicked" handler="rygel_folder_pref_section_on_remove_button_clicked"/>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="clear-button">
+ <property name="label" translatable="yes">gtk-clear</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="rygel_folder_pref_section_on_clear_button_clicked"/>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
<packing>
@@ -501,5 +559,4 @@
<property name="mode">both</property>
</object>
<object class="GtkSizeGroup" id="plugin-labels-sizegroup"/>
- <object class="GtkTextBuffer" id="folders-textbuffer"/>
</interface>
diff --git a/src/ui/rygel-folder-pref-section.vala b/src/ui/rygel-folder-pref-section.vala
index 2948380a..4e1d811a 100644
--- a/src/ui/rygel-folder-pref-section.vala
+++ b/src/ui/rygel-folder-pref-section.vala
@@ -26,43 +26,50 @@ using Gee;
public class Rygel.FolderPrefSection : Rygel.PluginPrefSection {
const string NAME = "Folder";
const string FOLDERS_KEY = "folders";
- const string FOLDERS_TEXTVIEW = FOLDERS_KEY + "-textview";
- const string FOLDERS_TEXTBUFFER = FOLDERS_KEY + "-textbuffer";
+ const string FOLDERS_TEXTVIEW = FOLDERS_KEY + "-treeview";
+ const string FOLDERS_LISTSTORE = FOLDERS_KEY + "-liststore";
- private TextView text_view;
- private TextBuffer text_buffer;
+ private TreeView treeview;
+ private ListStore liststore;
public FolderPrefSection (Builder builder,
Configuration config) {
base (builder, config, NAME);
- this.text_view = (TextView) builder.get_object (FOLDERS_TEXTVIEW);
- assert (this.text_view != null);
- this.text_buffer = (TextBuffer) builder.get_object (FOLDERS_TEXTBUFFER);
- assert (this.text_buffer != null);
+ this.treeview = (TreeView) builder.get_object (FOLDERS_TEXTVIEW);
+ assert (this.treeview != null);
+ this.liststore = (ListStore) builder.get_object (FOLDERS_LISTSTORE);
+ assert (this.liststore != null);
+
+ treeview.insert_column_with_attributes (-1,
+ "paths",
+ new CellRendererText (),
+ "text",
+ 0,
+ null);
var folders = config.get_string_list (this.name, FOLDERS_KEY);
- string text = "";
foreach (var folder in folders) {
- text += folder + "\n";
+ TreeIter iter;
+
+ this.liststore.append (out iter);
+ this.liststore.set (iter, 0, folder, -1);
}
- this.text_buffer.set_text (text, -1);
+
+ builder.connect_signals (this);
}
public override void save () {
- TextIter start;
- TextIter end;
-
- this.text_buffer.get_start_iter (out start);
- this.text_buffer.get_end_iter (out end);
-
- var text = this.text_buffer.get_text (start, end, false);
-
- var folders = text.split ("\n", -1);
+ TreeIter iter;
var folder_list = new ArrayList<string> ();
- foreach (var folder in folders) {
- folder_list.add (folder);
+ if (this.liststore.get_iter_first (out iter)) {
+ do {
+ string folder;
+
+ this.liststore.get (iter, 0, out folder, -1);
+ folder_list.add (folder);
+ } while (this.liststore.iter_next (ref iter));
}
this.config.set_string_list (this.name, FOLDERS_KEY, folder_list);
@@ -72,6 +79,19 @@ public class Rygel.FolderPrefSection : Rygel.PluginPrefSection {
CheckButton enabled_check) {
base.on_enabled_check_toggled (enabled_check);
- this.text_view.sensitive = enabled_check.active;
+ this.treeview.sensitive = enabled_check.active;
+ }
+
+ [CCode (instance_pos = -1)]
+ public void on_add_button_clicked (Button button) {
+ }
+
+ [CCode (instance_pos = -1)]
+ public void on_remove_button_clicked (Button button) {
+ }
+
+ [CCode (instance_pos = -1)]
+ public void on_clear_button_clicked (Button button) {
+ this.liststore.clear ();
}
}