[tracker/tracker-preferences-xdg-dirs] tracker-preferences: Use one list for locations and add XDG toggle buttons
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/tracker-preferences-xdg-dirs] tracker-preferences: Use one list for locations and add XDG toggle buttons
- Date: Fri, 16 Sep 2011 22:54:12 +0000 (UTC)
commit f9e86a2ec8067e9bcace3e06ef281521e8c96191
Author: Martyn Russell <martyn lanedo com>
Date: Wed Sep 14 19:31:23 2011 +0100
tracker-preferences: Use one list for locations and add XDG toggle buttons
src/tracker-preferences/tracker-preferences.ui | 506 ++++++++++++----------
src/tracker-preferences/tracker-preferences.vala | 451 +++++++++++++++-----
2 files changed, 627 insertions(+), 330 deletions(-)
---
diff --git a/src/tracker-preferences/tracker-preferences.ui b/src/tracker-preferences/tracker-preferences.ui
index aac6b98..36ab666 100644
--- a/src/tracker-preferences/tracker-preferences.ui
+++ b/src/tracker-preferences/tracker-preferences.ui
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.16"/>
+ <!-- interface-naming-policy toplevel-contextual -->
<object class="GtkAdjustment" id="adjustment_delay">
<property name="upper">1000</property>
<property name="value">10</property>
@@ -24,18 +25,13 @@
<property name="step_increment">1</property>
<property name="page_increment">2</property>
</object>
- <object class="GtkImage" id="image1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-missing-image</property>
- </object>
- <object class="GtkListStore" id="liststore_gnored_directories_with_content">
+ <object class="GtkListStore" id="liststore_ignored_directories">
<columns>
<!-- column-name Directory -->
<column type="gchararray"/>
</columns>
</object>
- <object class="GtkListStore" id="liststore_ignored_directories">
+ <object class="GtkListStore" id="liststore_ignored_directories_with_content">
<columns>
<!-- column-name Directory -->
<column type="gchararray"/>
@@ -47,16 +43,12 @@
<column type="gchararray"/>
</columns>
</object>
- <object class="GtkListStore" id="liststore_index_recursively">
- <columns>
- <!-- column-name Directory -->
- <column type="gchararray"/>
- </columns>
- </object>
- <object class="GtkListStore" id="liststore_index_single">
+ <object class="GtkListStore" id="liststore_index">
<columns>
<!-- column-name Directory -->
<column type="gchararray"/>
+ <!-- column-name Recurse -->
+ <column type="gboolean"/>
</columns>
</object>
<object class="GtkDialog" id="tracker-preferences">
@@ -70,13 +62,12 @@
<signal name="delete-event" handler="gtk_main_quit" swapped="no"/>
<signal name="response" handler="tracker_preferences_response_cb" swapped="no"/>
<child internal-child="vbox">
- <object class="GtkBox" id="dialog-vbox1">
+ <object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
- <object class="GtkButtonBox" id="dialog-action_area1">
+ <object class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
@@ -111,6 +102,12 @@
</packing>
</child>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
</child>
<child>
<object class="GtkNotebook" id="notebook">
@@ -167,6 +164,10 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">â</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
<property name="adjustment">adjustment_delay</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
@@ -373,7 +374,7 @@
</child>
</object>
<packing>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
@@ -409,14 +410,15 @@
<object class="GtkAlignment" id="alignment7">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="top_padding">2</property>
+ <property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
- <object class="GtkVBox" id="vbox_general1">
+ <object class="GtkVBox" id="vbox11">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="spacing">18</property>
<child>
- <object class="GtkVBox" id="vbox11">
+ <object class="GtkVBox" id="vbox13">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
@@ -428,7 +430,6 @@
<property name="ypad">4</property>
<property name="label" translatable="yes">Stop indexing when _disk space is below:</property>
<property name="use_underline">True</property>
- <property name="mnemonic_widget">hscale_disk_space_limit</property>
</object>
<packing>
<property name="expand">False</property>
@@ -441,15 +442,27 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment_disk_space_limit</property>
+ <property name="round_digits">0</property>
<property name="digits">0</property>
<signal name="format-value" handler="tracker_preferences_hscale_disk_space_limit_format_value_cb" swapped="no"/>
</object>
<packing>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox12">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label_throttle">
<property name="visible">True</property>
@@ -464,7 +477,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">2</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
@@ -516,15 +529,27 @@
</object>
<packing>
<property name="right_attach">2</property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
</object>
<packing>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">3</property>
+ <property name="position">1</property>
</packing>
</child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox9">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label_device_drop_threshold1">
<property name="visible">True</property>
@@ -533,60 +558,36 @@
<property name="yalign">0</property>
<property name="xpad">3</property>
<property name="ypad">4</property>
- <property name="label" translatable="yes">Drop removable device from database after:</property>
+ <property name="label" translatable="yes">Days before deleting removable devices / files since last mounted:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">hscale_drop_device_threshold</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">4</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox7">
+ <object class="GtkHScale" id="hscale_drop_device_threshold">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkHScale" id="hscale_drop_device_threshold">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="adjustment">adjustment_drop_device_threshold</property>
- <property name="digits">0</property>
- <signal name="format-value" handler="tracker_preferences_hscale_drop_device_threshold_format_value_cb" swapped="no"/>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label_days1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">Day(s)</property>
- <property name="justify">right</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="can_focus">True</property>
+ <property name="adjustment">adjustment_drop_device_threshold</property>
+ <property name="round_digits">0</property>
+ <property name="digits">0</property>
+ <signal name="format-value" handler="tracker_preferences_hscale_drop_device_threshold_format_value_cb" swapped="no"/>
</object>
<packing>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">5</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
<packing>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">0</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
@@ -610,6 +611,9 @@
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <placeholder/>
+ </child>
</object>
<packing>
<property name="position">1</property>
@@ -633,83 +637,69 @@
<property name="border_width">12</property>
<property name="spacing">18</property>
<child>
- <object class="GtkFrame" id="frame_index_recursive_directories">
+ <object class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
- <object class="GtkAlignment" id="alignment5">
+ <object class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
- <object class="GtkVBox" id="vbox7">
+ <object class="GtkVBox" id="vbox14">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="label_index_recursively">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Directories:</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
+ <property name="spacing">18</property>
<child>
- <object class="GtkHBox" id="hbox1">
+ <object class="GtkVBox" id="vbox5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <object class="GtkLabel" id="label8">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkTreeView" id="treeview_index_recursively">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="model">liststore_index_recursively</property>
- <property name="headers_visible">False</property>
- <property name="headers_clickable">False</property>
- <property name="rules_hint">True</property>
- <property name="search_column">0</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="treeview-selection1"/>
- </child>
- </object>
- </child>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Special locations such as your <b>Home</b>, <b>Desktop</b> or <b>Documents</b> directory, can be easily toggled below. This will add or remove their real paths from the list underneath.
+
+You can decide if you want to index the content recursively or not using the checkbuttons in the list next to each entry.
+
+If some special directories are not available, it may be because they're not defined or duplicate another special directory.</property>
+ <property name="use_markup">True</property>
+ <property name="justify">fill</property>
+ <property name="wrap">True</property>
</object>
<packing>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkVBox" id="vbox23">
+ <object class="GtkHBox" id="hbox7">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
- <object class="GtkButton" id="button_index_recursively_add">
+ <object class="GtkToggleButton" id="togglebutton_home">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="tooltip_markup">Index Home Directory</property>
<property name="use_action_appearance">False</property>
- <signal name="clicked" handler="tracker_preferences_button_index_recursively_add_clicked_cb" swapped="no"/>
+ <property name="relief">none</property>
+ <signal name="toggled" handler="tracker_preferences_togglebutton_home_toggled_cb" swapped="no"/>
<child>
- <object class="GtkImage" id="image3">
+ <object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="stock">gtk-add</property>
+ <property name="xpad">1</property>
+ <property name="ypad">1</property>
+ <property name="pixel_size">24</property>
+ <property name="icon_name">folder-home</property>
</object>
</child>
</object>
@@ -720,17 +710,22 @@
</packing>
</child>
<child>
- <object class="GtkButton" id="button_index_recursively_remove">
+ <object class="GtkToggleButton" id="togglebutton_desktop">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="tooltip_markup">Index Desktop Directory</property>
<property name="use_action_appearance">False</property>
- <signal name="clicked" handler="tracker_preferences_button_index_recursively_remove_clicked_cb" swapped="no"/>
+ <property name="relief">none</property>
+ <signal name="toggled" handler="tracker_preferences_togglebutton_desktop_toggled_cb" swapped="no"/>
<child>
- <object class="GtkImage" id="image4">
+ <object class="GtkImage" id="image">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="stock">gtk-remove</property>
+ <property name="xpad">1</property>
+ <property name="ypad">1</property>
+ <property name="pixel_size">24</property>
+ <property name="icon_name">user-desktop</property>
</object>
</child>
</object>
@@ -741,19 +736,21 @@
</packing>
</child>
<child>
- <object class="GtkToggleButton" id="togglebutton_home">
+ <object class="GtkToggleButton" id="togglebutton_documents">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">When toggled, this makes sure your home directory is included in the list.</property>
+ <property name="tooltip_markup">Index Documents Directory</property>
<property name="use_action_appearance">False</property>
- <property name="active">True</property>
- <signal name="toggled" handler="tracker_preferences_togglebutton_home_toggled_cb" swapped="no"/>
+ <property name="relief">none</property>
+ <signal name="toggled" handler="tracker_preferences_togglebutton_documents_toggled_cb" swapped="no"/>
<child>
<object class="GtkImage" id="image11">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="stock">gtk-home</property>
+ <property name="xpad">1</property>
+ <property name="pixel_size">24</property>
+ <property name="icon_name">folder-documents</property>
</object>
</child>
</object>
@@ -763,6 +760,106 @@
<property name="position">2</property>
</packing>
</child>
+ <child>
+ <object class="GtkToggleButton" id="togglebutton_music">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_markup">Index Music Directory</property>
+ <property name="use_action_appearance">False</property>
+ <property name="relief">none</property>
+ <signal name="toggled" handler="tracker_preferences_togglebutton_music_toggled_cb" swapped="no"/>
+ <child>
+ <object class="GtkImage" id="image14">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xpad">1</property>
+ <property name="pixel_size">24</property>
+ <property name="icon_name">folder-music</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="togglebutton_pictures">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_markup">Index Pictures Directory</property>
+ <property name="use_action_appearance">False</property>
+ <property name="relief">none</property>
+ <signal name="toggled" handler="tracker_preferences_togglebutton_pictures_toggled_cb" swapped="no"/>
+ <child>
+ <object class="GtkImage" id="image15">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xpad">1</property>
+ <property name="pixel_size">24</property>
+ <property name="icon_name">folder-pictures</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="togglebutton_videos">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_markup">Index Videos Directory</property>
+ <property name="use_action_appearance">False</property>
+ <property name="relief">none</property>
+ <signal name="toggled" handler="tracker_preferences_togglebutton_videos_toggled_cb" swapped="no"/>
+ <child>
+ <object class="GtkImage" id="image16">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xpad">1</property>
+ <property name="pixel_size">24</property>
+ <property name="icon_name">folder-videos</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="togglebutton_download">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_markup">Index Download Directory</property>
+ <property name="use_action_appearance">False</property>
+ <property name="relief">none</property>
+ <signal name="toggled" handler="tracker_preferences_togglebutton_download_toggled_cb" swapped="no"/>
+ <child>
+ <object class="GtkImage" id="image17">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xpad">1</property>
+ <property name="pixel_size">24</property>
+ <property name="icon_name">folder-downloads</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">6</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -772,148 +869,104 @@
</child>
</object>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Recursively Indexed</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkFrame" id="frame_index_single_directories">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkAlignment" id="alignment6">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="top_padding">6</property>
- <property name="left_padding">12</property>
- <child>
- <object class="GtkVBox" id="vbox3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="label_index_single">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Directories (no sub-directories are indexed):</property>
- </object>
- <packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox4">
+ <object class="GtkVBox" id="vbox3">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">6</property>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow4">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkTreeView" id="treeview_index_single">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="model">liststore_index_single</property>
- <property name="headers_visible">False</property>
- <property name="headers_clickable">False</property>
- <property name="rules_hint">True</property>
- <property name="search_column">0</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="treeview-selection2"/>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="vbox5">
+ <object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
- <object class="GtkButton" id="button_index_single_add">
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
- <signal name="clicked" handler="tracker_preferences_button_index_single_add_clicked_cb" swapped="no"/>
+ <property name="shadow_type">in</property>
<child>
- <object class="GtkImage" id="image5">
+ <object class="GtkTreeView" id="treeview_index">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-add</property>
+ <property name="can_focus">True</property>
+ <property name="model">liststore_index</property>
+ <property name="headers_clickable">False</property>
+ <property name="rules_hint">True</property>
+ <property name="search_column">0</property>
</object>
</child>
</object>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkButton" id="button_index_single_remove">
+ <object class="GtkVBox" id="vbox23">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
- <signal name="clicked" handler="tracker_preferences_button_index_single_remove_clicked_cb" swapped="no"/>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
<child>
- <object class="GtkImage" id="image10">
+ <object class="GtkButton" id="button_index_add">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-remove</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <signal name="clicked" handler="tracker_preferences_button_index_add_clicked_cb" swapped="no"/>
+ <child>
+ <object class="GtkImage" id="image3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-add</property>
+ </object>
+ </child>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_index_remove">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <signal name="clicked" handler="tracker_preferences_button_index_remove_clicked_cb" swapped="no"/>
+ <child>
+ <object class="GtkImage" id="image4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-remove</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
- <property name="fill">True</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
- <child>
- <placeholder/>
- </child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
</packing>
</child>
</object>
@@ -928,20 +981,18 @@
</object>
</child>
<child type="label">
- <object class="GtkLabel" id="label7">
+ <object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">Non-Recursively Indexed</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
+ <property name="label" translatable="yes"><b>Where is your content?</b></property>
+ <property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
</object>
@@ -1020,9 +1071,6 @@
<property name="headers_visible">False</property>
<property name="rules_hint">True</property>
<property name="search_column">0</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="treeview-selection3"/>
- </child>
</object>
</child>
</object>
@@ -1155,13 +1203,10 @@
<object class="GtkTreeView" id="treeview_ignored_directories_with_content">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="model">liststore_gnored_directories_with_content</property>
+ <property name="model">liststore_ignored_directories_with_content</property>
<property name="headers_visible">False</property>
<property name="rules_hint">True</property>
<property name="search_column">0</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="treeview-selection4"/>
- </child>
</object>
</child>
</object>
@@ -1314,9 +1359,6 @@ Most commonly this is used to ignore directories like *~, *.o, *.la, etc</proper
<property name="headers_clickable">False</property>
<property name="rules_hint">True</property>
<property name="search_column">0</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="treeview-selection5"/>
- </child>
</object>
</child>
</object>
@@ -1429,7 +1471,7 @@ Most commonly this is used to ignore directories like *~, *.o, *.la, etc</proper
</child>
</object>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
diff --git a/src/tracker-preferences/tracker-preferences.vala b/src/tracker-preferences/tracker-preferences.vala
index f4b6007..06bc6f7 100644
--- a/src/tracker-preferences/tracker-preferences.vala
+++ b/src/tracker-preferences/tracker-preferences.vala
@@ -33,6 +33,7 @@ public class Tracker.Preferences {
private const string UI_FILE = "tracker-preferences.ui";
private const string HOME_STRING = "$HOME";
+ private string HOME_STRING_EVALUATED;
private Window window;
private CheckButton checkbutton_enable_index_on_battery_first_time;
@@ -44,22 +45,30 @@ public class Tracker.Preferences {
private Scale hscale_disk_space_limit;
private Scale hscale_throttle;
private Scale hscale_drop_device_threshold;
- private ListStore liststore_index_recursively;
- private ListStore liststore_index_single;
+ private ListStore liststore_index;
private ListStore liststore_ignored_directories;
private ListStore liststore_ignored_files;
- private ListStore liststore_gnored_directories_with_content;
- private TreeView treeview_index_recursively;
- private TreeView treeview_index_single;
+ private ListStore liststore_ignored_directories_with_content;
+ private TreeView treeview_index;
private TreeView treeview_ignored_directories;
private TreeView treeview_ignored_directories_with_content;
private TreeView treeview_ignored_files;
+ private TreeViewColumn treeviewcolumn_index1;
+ private TreeViewColumn treeviewcolumn_index2;
private ToggleButton togglebutton_home;
+ private ToggleButton togglebutton_desktop;
+ private ToggleButton togglebutton_documents;
+ private ToggleButton togglebutton_music;
+ private ToggleButton togglebutton_pictures;
+ private ToggleButton togglebutton_videos;
+ private ToggleButton togglebutton_download;
private Notebook notebook;
public Preferences () {
debug ("Getting current settings");
+ HOME_STRING_EVALUATED = dir_from_config (HOME_STRING);
+
//config = new Config ();
settings = new GLib.Settings ("org.freedesktop.Tracker.Miner.Files");
@@ -107,24 +116,30 @@ public class Tracker.Preferences {
hscale_throttle = builder.get_object ("hscale_throttle") as Scale;
hscale_drop_device_threshold = builder.get_object ("hscale_drop_device_threshold") as Scale;
togglebutton_home = builder.get_object ("togglebutton_home") as ToggleButton;
-
- treeview_index_recursively = builder.get_object ("treeview_index_recursively") as TreeView;
- treeview_index_single = builder.get_object ("treeview_index_single") as TreeView;
+ togglebutton_desktop = builder.get_object ("togglebutton_desktop") as ToggleButton;
+ togglebutton_documents = builder.get_object ("togglebutton_documents") as ToggleButton;
+ togglebutton_music = builder.get_object ("togglebutton_music") as ToggleButton;
+ togglebutton_pictures = builder.get_object ("togglebutton_pictures") as ToggleButton;
+ togglebutton_videos = builder.get_object ("togglebutton_videos") as ToggleButton;
+ togglebutton_download = builder.get_object ("togglebutton_download") as ToggleButton;
+
+ treeview_index = builder.get_object ("treeview_index") as TreeView;
+ treeviewcolumn_index1 = builder.get_object ("treeviewcolumn_index1") as TreeViewColumn;
+ treeviewcolumn_index2 = builder.get_object ("treeviewcolumn_index1") as TreeViewColumn;
treeview_ignored_directories = builder.get_object ("treeview_ignored_directories") as TreeView;
treeview_ignored_directories_with_content = builder.get_object ("treeview_ignored_directories_with_content") as TreeView;
treeview_ignored_files = builder.get_object ("treeview_ignored_files") as TreeView;
- setup_standard_treeview (treeview_index_recursively, _("Directory"));
- setup_standard_treeview (treeview_index_single, _("Directory"));
- setup_standard_treeview (treeview_ignored_directories, _("Directory"));
- setup_standard_treeview (treeview_ignored_directories_with_content, _("Directory"));
- setup_standard_treeview (treeview_ignored_files, _("File"));
+ treeview_setup (treeview_index, _("Directory"), true);
+ treeview_setup (treeview_ignored_directories, _("Directory"), false);
+ treeview_setup (treeview_ignored_directories_with_content, _("Directory"), false);
+ treeview_setup (treeview_ignored_files, _("File"), false);
- liststore_index_recursively = builder.get_object ("liststore_index_recursively") as ListStore;
- liststore_index_single = builder.get_object ("liststore_index_single") as ListStore;
+ liststore_index = builder.get_object ("liststore_index") as ListStore;
+ liststore_index.set_sort_column_id (0, Gtk.SortType.ASCENDING);
liststore_ignored_directories = builder.get_object ("liststore_ignored_directories") as ListStore;
liststore_ignored_files = builder.get_object ("liststore_ignored_files") as ListStore;
- liststore_gnored_directories_with_content = builder.get_object ("liststore_gnored_directories_with_content") as ListStore;
+ liststore_ignored_directories_with_content = builder.get_object ("liststore_ignored_directories_with_content") as ListStore;
// Set initial values
checkbutton_enable_index_on_battery.active = settings.get_boolean ("index-on-battery");
@@ -139,14 +154,19 @@ public class Tracker.Preferences {
hscale_throttle.set_value ((double) settings.get_int ("throttle"));
hscale_drop_device_threshold.set_value ((double) settings.get_int ("removable-days-threshold"));
- // FIXME: Work out how to do this
- fill_in_model (liststore_index_recursively, settings.get_strv ("index-recursive-directories"));
- fill_in_model (liststore_index_single, settings.get_strv ("index-single-directories"));
- fill_in_model (liststore_ignored_directories, settings.get_strv ("ignored-directories"));
- fill_in_model (liststore_ignored_files, settings.get_strv ("ignored-files"));
- fill_in_model (liststore_gnored_directories_with_content, settings.get_strv ("ignored-directories-with-content"));
+ model_populate (liststore_index, settings.get_strv ("index-recursive-directories"), true, true);
+ model_populate (liststore_index, settings.get_strv ("index-single-directories"), true, false);
+ model_populate (liststore_ignored_directories, settings.get_strv ("ignored-directories"), false, false);
+ model_populate (liststore_ignored_files, settings.get_strv ("ignored-files"), false, false);
+ model_populate (liststore_ignored_directories_with_content, settings.get_strv ("ignored-directories-with-content"), false, false);
- togglebutton_home.active = model_contains (liststore_index_recursively, HOME_STRING);
+ togglebutton_home.active = model_contains (liststore_index, HOME_STRING_EVALUATED);
+ togglebutton_desktop.active = model_contains (liststore_index, "&DESKTOP");
+ togglebutton_documents.active = model_contains (liststore_index, "&DOCUMENTS");
+ togglebutton_music.active = model_contains (liststore_index, "&MUSIC");
+ togglebutton_pictures.active = model_contains (liststore_index, "&PICTURES");
+ togglebutton_videos.active = model_contains (liststore_index, "&VIDEOS");
+ togglebutton_download.active = model_contains (liststore_index, "&DOWNLOAD");
// We hide this page because it contains the start up
// delay which is not necessary to display for most people.
@@ -163,7 +183,6 @@ public class Tracker.Preferences {
window.show ();
}
-
// This function is used to fix up the parameter ordering for callbacks
// from the .ui file which has the callback names.
[CCode (instance_pos = -1)]
@@ -189,12 +208,11 @@ public class Tracker.Preferences {
case ResponseType.APPLY:
debug ("Converting directories for storage");
- // FIXME: Work out how to do this.
- settings.set_strv ("index-single-directories", model_to_strv (liststore_index_single));
- settings.set_strv ("index-recursive-directories", model_to_strv (liststore_index_recursively));
- settings.set_strv ("ignored-directories", model_to_strv (liststore_ignored_directories));
- settings.set_strv ("ignored-files", model_to_strv (liststore_ignored_files));
- settings.set_strv ("ignored-directories-with-content", model_to_strv (liststore_gnored_directories_with_content));
+ settings.set_strv ("index-single-directories", model_to_strv (liststore_index, true, false));
+ settings.set_strv ("index-recursive-directories", model_to_strv (liststore_index, true, true));
+ settings.set_strv ("ignored-directories", model_to_strv (liststore_ignored_directories, false, false));
+ settings.set_strv ("ignored-files", model_to_strv (liststore_ignored_files, false, false));
+ settings.set_strv ("ignored-directories-with-content", model_to_strv (liststore_ignored_directories_with_content, false, false));
settings.set_int ("low-disk-space-limit", (int) hscale_disk_space_limit.get_value ());
settings.set_int ("throttle", (int) hscale_throttle.get_value ());
@@ -270,89 +288,142 @@ public class Tracker.Preferences {
}
[CCode (instance_pos = -1)]
- public void button_index_recursively_add_clicked_cb (Button source) {
- add_dir (liststore_index_recursively);
+ public void button_index_add_clicked_cb (Button source) {
+ store_add_dir (liststore_index);
}
[CCode (instance_pos = -1)]
- public void button_index_recursively_remove_clicked_cb (Button source) {
- del_dir (treeview_index_recursively);
- }
-
- [CCode (instance_pos = -1)]
- public void button_index_single_remove_clicked_cb (Button source) {
- del_dir (treeview_index_single);
- }
-
- [CCode (instance_pos = -1)]
- public void button_index_single_add_clicked_cb (Button source) {
- add_dir (liststore_index_single);
+ public void button_index_remove_clicked_cb (Button source) {
+ store_del_dir (treeview_index);
}
[CCode (instance_pos = -1)]
public void button_ignored_directories_globs_add_clicked_cb (Button source) {
- add_freevalue (liststore_ignored_directories);
+ store_add_value_dialog (liststore_ignored_directories);
}
[CCode (instance_pos = -1)]
public void button_ignored_directories_add_clicked_cb (Button source) {
- add_dir (liststore_ignored_directories);
+ store_add_dir (liststore_ignored_directories);
}
[CCode (instance_pos = -1)]
public void button_ignored_directories_remove_clicked_cb (Button source) {
- del_dir (treeview_ignored_directories);
+ store_del_dir (treeview_ignored_directories);
}
[CCode (instance_pos = -1)]
public void button_ignored_directories_with_content_add_clicked_cb (Button source) {
- add_freevalue (liststore_gnored_directories_with_content);
+ store_add_value_dialog (liststore_ignored_directories_with_content);
}
[CCode (instance_pos = -1)]
public void button_ignored_directories_with_content_remove_clicked_cb (Button source) {
- del_dir (treeview_ignored_directories_with_content);
+ store_del_dir (treeview_ignored_directories_with_content);
}
[CCode (instance_pos = -1)]
public void button_ignored_files_add_clicked_cb (Button source) {
- add_freevalue (liststore_ignored_files);
+ store_add_value_dialog (liststore_ignored_files);
}
[CCode (instance_pos = -1)]
public void button_ignored_files_remove_clicked_cb (Button source) {
- del_dir (treeview_ignored_files);
+ store_del_dir (treeview_ignored_files);
}
- [CCode (instance_pos = -1)]
- public void togglebutton_home_toggled_cb (ToggleButton source) {
- if (source.active && !model_contains (liststore_index_recursively, HOME_STRING)) {
+ private void togglebutton_directory_update_model (ToggleButton source, ListStore store, string to_check) {
+ if (source.active && !model_contains (store, to_check)) {
TreeIter iter;
- liststore_index_recursively.append (out iter);
+ liststore_index.append (out iter);
var v = Value (typeof (string));
- v.set_string (HOME_STRING);
- liststore_index_recursively.set_value (iter, 0, v);
+ v.set_string (to_check);
+
+ bool recurse = to_check != HOME_STRING_EVALUATED;
+ liststore_index.set_value (iter, 0, v);
+ liststore_index.set_value (iter, 1, recurse);
}
- if (!source.active && model_contains (liststore_index_recursively, HOME_STRING)) {
+ if (!source.active && model_contains (store, to_check)) {
bool valid;
TreeIter iter;
- valid = liststore_index_recursively.get_iter_first (out iter);
+ valid = store.get_iter_first (out iter);
while (valid) {
Value value;
- liststore_index_recursively.get_value (iter, 0, out value);
- if (value.get_string () == HOME_STRING) {
- liststore_index_recursively.remove (iter);
- valid = liststore_index_recursively.get_iter_first (out iter);
+ store.get_value (iter, 0, out value);
+ if (value.get_string () == to_check) {
+ store.remove (iter);
+ valid = store.get_iter_first (out iter);
} else {
- valid = liststore_index_recursively.iter_next (ref iter);
+ valid = store.iter_next (ref iter);
}
}
}
}
- private void add_freevalue (ListStore model) {
+ [CCode (instance_pos = -1)]
+ public void togglebutton_home_toggled_cb (ToggleButton source) {
+ togglebutton_directory_update_model (source, liststore_index, HOME_STRING_EVALUATED);
+ }
+
+ [CCode (instance_pos = -1)]
+ public void togglebutton_desktop_toggled_cb (ToggleButton source) {
+ togglebutton_directory_update_model (source, liststore_index, Environment.get_user_special_dir (UserDirectory.DESKTOP));
+ }
+
+ [CCode (instance_pos = -1)]
+ public void togglebutton_documents_toggled_cb (ToggleButton source) {
+ togglebutton_directory_update_model (source, liststore_index, Environment.get_user_special_dir (UserDirectory.DOCUMENTS));
+ }
+
+ [CCode (instance_pos = -1)]
+ public void togglebutton_music_toggled_cb (ToggleButton source) {
+ togglebutton_directory_update_model (source, liststore_index, Environment.get_user_special_dir (UserDirectory.MUSIC));
+ }
+
+ [CCode (instance_pos = -1)]
+ public void togglebutton_pictures_toggled_cb (ToggleButton source) {
+ togglebutton_directory_update_model (source, liststore_index, Environment.get_user_special_dir (UserDirectory.PICTURES));
+ }
+
+ [CCode (instance_pos = -1)]
+ public void togglebutton_videos_toggled_cb (ToggleButton source) {
+ togglebutton_directory_update_model (source, liststore_index, Environment.get_user_special_dir (UserDirectory.VIDEOS));
+ }
+
+ [CCode (instance_pos = -1)]
+ public void togglebutton_download_toggled_cb (ToggleButton source) {
+ togglebutton_directory_update_model (source, liststore_index, Environment.get_user_special_dir (UserDirectory.DOWNLOAD));
+ }
+
+ private void toggles_update (UserDirectory[] matches, bool active) {
+ // Check if we need to untoggle a button
+ foreach (UserDirectory ud in matches) {
+ switch (ud) {
+ case UserDirectory.DESKTOP:
+ togglebutton_desktop.active = active;
+ break;
+ case UserDirectory.DOCUMENTS:
+ togglebutton_documents.active = active;
+ break;
+ case UserDirectory.DOWNLOAD:
+ togglebutton_download.active = active;
+ break;
+ case UserDirectory.MUSIC:
+ togglebutton_music.active = active;
+ break;
+ case UserDirectory.PICTURES:
+ togglebutton_pictures.active = active;
+ break;
+ case UserDirectory.VIDEOS:
+ togglebutton_videos.active = active;
+ break;
+ }
+ }
+ }
+
+ private void store_add_value_dialog (ListStore store) {
Dialog dialog;
Entry entry;
Container content_area;
@@ -375,56 +446,177 @@ public class Tracker.Preferences {
if (text != null && text != "") {
TreeIter iter;
- model.append (out iter);
+ store.append (out iter);
var v = Value (typeof (string));
v.set_string (text);
- model.set_value (iter, 0, v);
+ store.set_value (iter, 0, v);
}
}
dialog.destroy ();
}
- private void add_dir (ListStore model) {
- FileChooserDialog dialog = new FileChooserDialog (_("Select directory"), window,
+ private void store_add_dir (ListStore store) {
+ FileChooserDialog dialog = new FileChooserDialog (_("Select directory"),
+ window,
FileChooserAction.SELECT_FOLDER,
- Stock.CANCEL, ResponseType.CANCEL,
- Stock.OK, ResponseType.ACCEPT);
+ Stock.CANCEL,
+ ResponseType.CANCEL,
+ Stock.OK,
+ ResponseType.ACCEPT);
- if (dialog.run () == ResponseType.ACCEPT) {
- TreeIter iter;
- File dir;
+ while (true) {
+ if (dialog.run () == ResponseType.ACCEPT) {
+ TreeIter iter;
+ File f;
+
+ f = dialog.get_file ();
+ string path = f.get_path ();
+
+ if (model_contains (store, path)) {
+ MessageDialog md = new MessageDialog (dialog,
+ DialogFlags.DESTROY_WITH_PARENT,
+ MessageType.ERROR,
+ ButtonsType.CLOSE,
+ _("That directory is already selected as a location to index"),
+ null);
+ md.run ();
+ md.destroy ();
+ continue;
+ }
- dir = dialog.get_file ();
+ string dir = f.get_path ();
- model.append (out iter);
- var v = Value (typeof (string));
- v.set_string (dir.get_path());
- model.set_value (iter, 0, v);
+ // Check which UserDirectorys we match with str
+ UserDirectory[] matches = dir_match_user_directories (dir);
+
+ // Add to store
+ store.append (out iter);
+ var v = Value (typeof (string));
+ v.set_string (dir);
+ store.set_value (iter, 0, v);
+
+ toggles_update (matches, true);
+
+ if (dir == HOME_STRING_EVALUATED)
+ togglebutton_home.active = true;
+
+ }
+
+ break;
}
dialog.destroy ();
}
- private void del_dir (TreeView view) {
+ private void store_del_dir (TreeView view) {
List<TreePath> list;
ListStore store;
TreeModel model;
TreeSelection selection = view.get_selection ();
- list= selection.get_selected_rows (out model);
+ list = selection.get_selected_rows (out model);
store = (ListStore) model;
foreach (TreePath path in list) {
TreeIter iter;
- if (model.get_iter (out iter, path)) {
- store.remove (iter);
+
+ if (!model.get_iter (out iter, path)) {
+ continue;
+ }
+
+ Value value;
+
+ model.get_value (iter, 0, out value);
+ string dir = value.get_string ();
+
+ // Check which UserDirectorys we match with str
+ UserDirectory[] matches = dir_match_user_directories (dir);
+
+ store.remove (iter);
+
+ // Check if we need to untoggle a button
+ toggles_update (matches, false);
+
+ if (dir == HOME_STRING_EVALUATED)
+ togglebutton_home.active = false;
+ }
+ }
+
+ private UserDirectory[] dir_match_user_directories (string input) {
+ UserDirectory[] matches = {};
+ int i;
+
+ for (i = 0; i < UserDirectory.N_DIRECTORIES; i++) {
+ UserDirectory ud = (UserDirectory) i;
+ unowned string dir = null;
+
+ dir = Environment.get_user_special_dir (ud);
+ if (input == dir) {
+ matches += ud;
+ }
+ }
+
+ return matches;
+ }
+
+ private string dir_to_config (string input) {
+ string output = input;
+
+ if (HOME_STRING_EVALUATED != null && HOME_STRING_EVALUATED == input) {
+ return HOME_STRING;
+ }
+
+ for (int i = 0; i < UserDirectory.N_DIRECTORIES; i++) {
+ UserDirectory ud = (UserDirectory) i;
+ unowned string dir = null;
+
+ dir = Environment.get_user_special_dir (ud);
+ if (input == dir) {
+ // Convert 'G_USER_DIRECTORY_FOO' to '&FOO'
+ string ud_string = ud.to_string ();
+ output = "&%s".printf (ud_string.substring (ud_string.last_index_of_char ('_') + 1, -1));
+ }
+ }
+
+ return output;
+ }
+
+ private string dir_from_config (string input) {
+ string output = input;
+
+ if (input.has_prefix ("&")) {
+ unowned string dir = null;
+
+ // Convert '&FOO' to 'G_USER_DIRECTORY_FOO'
+ string ud_input = "G_USER_DIRECTORY_%s".printf (input.next_char ());
+
+ for (int i = 0; i < UserDirectory.N_DIRECTORIES && dir == null; i++) {
+ UserDirectory ud = (UserDirectory) i;
+
+ if (ud_input == ud.to_string ()) {
+ dir = Environment.get_user_special_dir (ud);
+ }
}
+
+ // debug ("Found dir '%s' evaluates to '%s'", input, dir);
+
+ if (dir != null)
+ output = dir;
+ } else if (input.has_prefix ("$")) {
+ unowned string env = Environment.get_variable (input.substring (1, -1));
+
+ // debug ("Found env '%s' (%s) evaluates to '%s'", input, input.substring (1, -1), env);
+
+ if (env != null)
+ output = env;
}
+
+ return output;
}
- private string[] model_to_strv (ListStore model) {
+ private string[] model_to_strv (ListStore model, bool recurse_required, bool recurse_value) {
string[] list = {};
TreeIter iter;
bool valid;
@@ -435,7 +627,20 @@ public class Tracker.Preferences {
Value value;
model.get_value (iter, 0, out value);
- list += value.get_string ();
+
+ if (recurse_required) {
+ Value recurse;
+
+ model.get_value (iter, 1, out recurse);
+
+ if (recurse_value != recurse.get_boolean ())
+ continue;
+ }
+
+ // Convert from real value to config values,
+ // e.g. '$HOME/Desktop' to '&DESKTOP'
+ string dir = dir_to_config (value.get_string ());
+ list += dir;
}
return list;
@@ -443,8 +648,11 @@ public class Tracker.Preferences {
public bool model_contains (TreeModel model, string needle) {
TreeIter iter;
+ string needle_evaluated;
bool valid;
+ needle_evaluated = dir_from_config (needle);
+
for (valid = model.get_iter_first (out iter);
valid;
valid = model.iter_next (ref iter)) {
@@ -452,7 +660,7 @@ public class Tracker.Preferences {
model.get_value (iter, 0, out value);
- if (value.get_string () == needle) {
+ if (value.get_string () == needle_evaluated) {
return true;
}
}
@@ -460,29 +668,76 @@ public class Tracker.Preferences {
return false;
}
- private void fill_in_model (ListStore model, string[] list) {
+ private void model_populate (ListStore model, string[] list, bool have_recurse, bool recurse) {
int position = 0;
foreach (string str in list) {
+ // Convert any dirs from config to real values
+ str = dir_from_config (str);
+
try {
- model.insert_with_values (null,
- position++,
- 0,
- Filename.to_utf8 (str,
- -1,
- null,
- null));
+ if (have_recurse)
+ model.insert_with_values (null,
+ position++,
+ 0,
+ Filename.to_utf8 (str,
+ -1,
+ null,
+ null),
+ 1,
+ recurse,
+ -1);
+ else
+ model.insert_with_values (null,
+ position++,
+ 0,
+ Filename.to_utf8 (str,
+ -1,
+ null,
+ null),
+ -1);
} catch (GLib.ConvertError e) {
print ("Could not convert filename to UTF8: %s", e.message);
}
}
}
- private void setup_standard_treeview (TreeView view, string title) {
- TreeViewColumn column = new TreeViewColumn.with_attributes (title,
- new CellRendererText (),
- "text", 0);
+ private void treeview_setup (TreeView view, string title, bool show_recurse_column) {
+ TreeViewColumn column;
+ GLib.List<weak TreeViewColumn> columns = view.get_columns ();
+
+ // Needed to fix glade mess
+ foreach (TreeViewColumn c in columns) {
+ view.remove_column (c);
+ }
+
+ column = new TreeViewColumn.with_attributes (title,
+ new CellRendererText (),
+ "text", 0,
+ null);
+ column.set_expand (true);
view.append_column (column);
+
+ if (show_recurse_column) {
+ ListStore store = view.get_model () as ListStore;
+ CellRendererToggle cell = new CellRendererToggle ();
+
+ column = new TreeViewColumn.with_attributes ("Recurse",
+ cell,
+ "active", 1,
+ null);
+ column.set_expand (false);
+ column.set_fixed_width (50);
+ view.append_column (column);
+
+ cell.toggled.connect ((toggle, path) => {
+ var tree_path = new TreePath.from_string (path);
+ TreeIter iter;
+
+ store.get_iter (out iter, tree_path);
+ store.set (iter, 1, !toggle.active);
+ });
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]