[tracker/needle: 36/53] tracker-needle: Added tracker-view.vala to handle different result set views
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/needle: 36/53] tracker-needle: Added tracker-view.vala to handle different result set views
- Date: Fri, 12 Nov 2010 23:48:52 +0000 (UTC)
commit 47738ed8b4a3a1fa80037e39357cca03d5ec55fd
Author: Martyn Russell <martyn lanedo com>
Date: Thu Sep 9 23:33:53 2010 +0100
tracker-needle: Added tracker-view.vala to handle different result set views
src/tracker-needle/Makefile.am | 3 +-
src/tracker-needle/tracker-needle.ui | 35 +--------------
src/tracker-needle/tracker-needle.vala | 61 +++++++++++++++++++++-----
src/tracker-needle/tracker-view.vala | 76 ++++++++++++++++++++++++++++++++
4 files changed, 129 insertions(+), 46 deletions(-)
---
diff --git a/src/tracker-needle/Makefile.am b/src/tracker-needle/Makefile.am
index 2fbb8a8..bcd03ac 100644
--- a/src/tracker-needle/Makefile.am
+++ b/src/tracker-needle/Makefile.am
@@ -7,7 +7,8 @@ tracker_needle_VALASOURCES = \
tracker-needle.vala \
tracker-query.vala \
tracker-stats.vala \
- tracker-utils.vala
+ tracker-utils.vala \
+ tracker-view.vala
tracker_needle_SOURCES = \
$(tracker_needle_VALASOURCES:.vala=.c)
diff --git a/src/tracker-needle/tracker-needle.ui b/src/tracker-needle/tracker-needle.ui
index e5f3fd2..afce65b 100644
--- a/src/tracker-needle/tracker-needle.ui
+++ b/src/tracker-needle/tracker-needle.ui
@@ -172,40 +172,7 @@
<object class="GtkHBox" id="hbox_view">
<property name="visible">True</property>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow_treeview">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">never</property>
- <property name="vscrollbar_policy">automatic</property>
- <child>
- <object class="GtkTreeView" id="treeview_results">
- <property name="can_focus">True</property>
- <property name="model">liststore_results</property>
- <property name="enable_search">False</property>
- <property name="tooltip_column">2</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow_iconview">
- <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="GtkIconView" id="iconview_results">
- <property name="can_focus">True</property>
- <property name="model">liststore_results</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
+ <placeholder/>
</child>
</object>
<packing>
diff --git a/src/tracker-needle/tracker-needle.vala b/src/tracker-needle/tracker-needle.vala
index ea6107b..2795714 100644
--- a/src/tracker-needle/tracker-needle.vala
+++ b/src/tracker-needle/tracker-needle.vala
@@ -19,6 +19,7 @@
using Gtk;
using Tracker.Sparql;
+using Tracker.View;
[CCode (cname = "TRACKER_UI_DIR")]
extern static const string UIDIR;
@@ -37,9 +38,11 @@ public class TrackerNeedle {
private ToggleToolButton find_in_titles;
private Entry search;
private ToolButton show_stats;
- private ScrolledWindow sw_treeview;
+ private HBox view;
+ private Tracker.View sw_noresults;
+ private Tracker.View sw_treeview;
private TreeView treeview;
- private ScrolledWindow sw_iconview;
+ private Tracker.View sw_iconview;
private IconView iconview;
private uint last_search_id = 0;
private ListStore store;
@@ -107,10 +110,23 @@ public class TrackerNeedle {
show_stats = builder.get_object ("toolbutton_show_stats") as ToolButton;
show_stats.clicked.connect (show_stats_clicked);
- sw_treeview = builder.get_object ("scrolledwindow_treeview") as ScrolledWindow;
- treeview = builder.get_object ("treeview_results") as TreeView;
- sw_iconview = builder.get_object ("scrolledwindow_iconview") as ScrolledWindow;
- iconview = builder.get_object ("iconview_results") as IconView;
+ view = builder.get_object ("hbox_view") as HBox;
+
+ sw_noresults = new Tracker.View (Tracker.View.Display.NO_RESULTS);
+ view.pack_start (sw_noresults, true, true, 0);
+
+ sw_treeview = new Tracker.View (Tracker.View.Display.CATEGORIES);
+ treeview = (TreeView) sw_treeview.get_child ();
+ view.pack_start (sw_treeview, true, true, 0);
+ //sw_treeview = builder.get_object ("scrolledwindow_treeview") as ScrolledWindow;
+ //treeview = builder.get_object ("treeview_results") as TreeView;
+
+ sw_iconview = new Tracker.View (Tracker.View.Display.FILE_ICONS);
+ iconview = (IconView) sw_iconview.get_child ();
+ view.pack_start (sw_iconview, true, true, 0);
+ //sw_iconview = builder.get_object ("scrolledwindow_iconview") as ScrolledWindow;
+ //iconview = builder.get_object ("iconview_results") as IconView;
+
setup_ui_results (treeview, iconview);
view_details.set_active (true);
@@ -432,9 +448,27 @@ public class TrackerNeedle {
last_search_id = 0;
if (search.get_text ().length < 1) {
+ // Show no results window
+ sw_noresults.show ();
+ sw_iconview.hide ();
+ sw_treeview.hide ();
+
return false;
}
+ // Show correct window
+ bool rows = view_list.active || view_details.active;
+
+ if (rows) {
+ sw_noresults.hide ();
+ sw_iconview.hide ();
+ sw_treeview.show ();
+ } else {
+ sw_noresults.hide ();
+ sw_iconview.show ();
+ sw_treeview.hide ();
+ }
+
if (view_details.active) {
search_detailed ();
} else {
@@ -449,15 +483,16 @@ public class TrackerNeedle {
bool show_find_in;
rows = view_list.active || view_details.active;
-
+
if (current_view == rows) {
return;
}
if (rows) {
// FIXME: if list/details changes, re-run query
- sw_iconview.hide ();
- sw_treeview.show_all ();
+
+ // Was: sw_treeview.show_all ();
+
debug ("View toggled to 'list' or 'details'");
if (view_details.active) {
@@ -472,12 +507,16 @@ public class TrackerNeedle {
show_find_in = true;
}
} else {
- sw_iconview.show_all ();
- sw_treeview.hide ();
+ // Was: sw_iconview.show_all ();
show_find_in = true;
debug ("View toggled to 'icons'");
}
+ // Show no results Window when switching
+ sw_noresults.show ();
+ sw_iconview.hide ();
+ sw_treeview.hide ();
+
// Show/Hide secondary widgets
separator_secondary.visible = show_find_in;
find_in_contents.visible = show_find_in;
diff --git a/src/tracker-needle/tracker-view.vala b/src/tracker-needle/tracker-view.vala
new file mode 100644
index 0000000..30f3e3c
--- /dev/null
+++ b/src/tracker-needle/tracker-view.vala
@@ -0,0 +1,76 @@
+//
+// Copyright 2010, Martyn Russell <martyn lanedo com>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
+//
+
+using Gtk;
+
+public class Tracker.View : ScrolledWindow {
+ public enum Display {
+ NO_RESULTS,
+ CATEGORIES,
+ FILE_LIST,
+ FILE_ICONS
+ }
+
+ public Display display {
+ get;
+ private set;
+ }
+
+ public View (Display? _display = Display.NO_RESULTS) {
+ Widget results = null;
+
+ set_policy (PolicyType.NEVER, PolicyType.AUTOMATIC);
+
+ display = _display;
+
+ switch (display) {
+ case Display.NO_RESULTS:
+ Label l;
+
+ l = new Label ("");
+
+ string message = _("No Search Results");
+ string markup = @"<big>$message</big>";
+
+ l.set_use_markup (true);
+ l.set_markup (markup);
+
+ results = l;
+ break;
+
+ case Display.CATEGORIES:
+ case Display.FILE_LIST:
+ results = new TreeView ();
+ break;
+
+ case Display.FILE_ICONS:
+ results = new IconView ();
+ break;
+ }
+
+ if (display == Display.NO_RESULTS) {
+ add_with_viewport (results);
+ } else {
+ add (results);
+ }
+
+ base.show_all ();
+ }
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]