[tracker] tracker-needle: use gsettings
- From: Kunal Jain <kunaljain src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] tracker-needle: use gsettings
- Date: Wed, 1 Apr 2015 10:54:01 +0000 (UTC)
commit 6d9e9d01c71501c0a5aa86dc353cddc1a91e4be0
Author: Kunaal <kunaalus gmail com>
Date: Wed Apr 1 14:03:17 2015 +0530
tracker-needle: use gsettings
Added gsettings for tracker-needle.
Store the last view selected by user in tracker-needle before closing.
https://bugzilla.gnome.org/show_bug.cgi?id=740302
src/tracker-needle/Makefile.am | 26 ++++++++++--
.../org.freedesktop.Tracker.Needle.gschema.xml.in | 19 +++++++++
src/tracker-needle/tracker-needle.vala | 40 +++++++++++++++++++-
3 files changed, 78 insertions(+), 7 deletions(-)
---
diff --git a/src/tracker-needle/Makefile.am b/src/tracker-needle/Makefile.am
index d2dcecd..14d65cd 100644
--- a/src/tracker-needle/Makefile.am
+++ b/src/tracker-needle/Makefile.am
@@ -49,16 +49,32 @@ appdata_DATA = tracker-needle.appdata.xml
BUILT_SOURCES = \
tracker_needle_vala.stamp
+#Desktop files
+%.desktop.in: %.desktop.in.in
+ @sed -e "s|@VERSION[ ]|${VERSION}|" $< > $@
+
+#GSettings
+gsettings_ENUM_NAMESPACE = org.freedesktop.Tracker
+gsettings_ENUM_FILES = $(top_srcdir)/src/libtracker-common/tracker-enums.h
+
+gsettings_SCHEMAS = $(schemalist)
+
+schemalist = org.freedesktop.Tracker.Needle.gschema.xml
+
+ INTLTOOL_XML_NOMERGE_RULE@
+
+ GSETTINGS_RULES@
+
+# Dist / Clean rules for all data
CLEANFILES = \
$(desktop_DATA:.desktop=.desktop.in) \
- $(desktop_DATA)
+ $(desktop_DATA) \
+ $(gsettings_SCHEMAS)
EXTRA_DIST = \
$(desktop_DATA:.desktop=.desktop.in.in) \
$(ui_DATA) \
$(desktop_DATA) \
$(appdata_DATA) \
- config.vapi
-
-%.desktop.in: %.desktop.in.in
- @sed -e "s|@VERSION[ ]|${VERSION}|" $< > $@
+ config.vapi \
+ $(gsettings_SCHEMAS:.xml=.xml.in)
diff --git a/src/tracker-needle/org.freedesktop.Tracker.Needle.gschema.xml.in
b/src/tracker-needle/org.freedesktop.Tracker.Needle.gschema.xml.in
new file mode 100644
index 0000000..9a8df48
--- /dev/null
+++ b/src/tracker-needle/org.freedesktop.Tracker.Needle.gschema.xml.in
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Author: Kunaal Jain <kunaalus gmail com>
+-->
+
+<schemalist>
+ <schema id="org.freedesktop.Tracker.Needle" path="/org/freedesktop/tracker/needle/"
gettext-domain="tracker">
+ <key name="default-view" type="i">
+ <range min="0" max="2"/>
+ <default> 1 </default>
+ <_summary> Default View </_summary>
+ <_description>
+ When 0, Default view of tracker-needle will be Icons view
+ When 1, Default view of tracker-needle will be Categories view
+ When 2, Default view of tracker-needle will be Files view
+ </_description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/src/tracker-needle/tracker-needle.vala b/src/tracker-needle/tracker-needle.vala
index 231a9e4..4abf8d2 100644
--- a/src/tracker-needle/tracker-needle.vala
+++ b/src/tracker-needle/tracker-needle.vala
@@ -27,6 +27,7 @@ extern static const string UIDIR;
extern static const string SRCDIR;
public class Tracker.Needle {
+ private GLib.Settings settings_needle = null;
private const string UI_FILE = "tracker-needle.ui";
private History history;
private Gtk.Window window;
@@ -58,6 +59,7 @@ public class Tracker.Needle {
private int size_medium = 0;
private int size_big = 0;
private uint limit = 500;
+ private int default_view = 1;
static bool current_find_in_filelist = true;
static bool current_find_in_icons = true;
private Widget current_view;
@@ -218,6 +220,13 @@ public class Tracker.Needle {
public Needle () {
create_models ();
history = new Tracker.History ();
+
+ // Load Gsettings
+ settings_needle = new GLib.Settings ("org.freedesktop.Tracker.Needle");
+
+ settings_needle.changed.connect ((key) => {
+ debug ("tracker-needle: Key %s changed\n", key);
+ });
}
public void show () {
@@ -285,7 +294,7 @@ public class Tracker.Needle {
Gtk.icon_size_lookup (Gtk.IconSize.DIALOG, out size_big, null);
window = builder.get_object ("window_needle") as Gtk.Window;
- window.destroy.connect (Gtk.main_quit);
+ window.destroy.connect (window_closed);
window.key_press_event.connect (window_key_press_event);
toolbar = builder.get_object ("toolbar_main") as Toolbar;
@@ -397,7 +406,21 @@ public class Tracker.Needle {
tags_view.hide_label ();
paned.pack2 (tags_view, false, false);
- view_categories.set_active (true);
+ //Set up the default view
+ view_categories.active = false;
+ view_icons.active = false;
+ view_filelist.active = false;
+
+ //By default we assume Categories view
+ default_view = settings_needle.get_int ("default-view");
+
+ if (default_view == 0) {
+ view_icons.active = true;
+ } else if (default_view == 2) {
+ view_filelist.active = true;
+ } else {
+ view_categories.active = true;
+ }
}
private bool window_key_press_event (Gtk.Widget widget, Gdk.EventKey event) {
@@ -571,6 +594,19 @@ public class Tracker.Needle {
return false;
}
+ private void window_closed() {
+ // Before exiting save the current view
+ // By default, we assume categories view
+ if (view_icons.active) {
+ settings_needle.set_int ("default-view", 0);
+ } else if (view_filelist.active) {
+ settings_needle.set_int ("default-view", 2);
+ } else {
+ settings_needle.set_int ("default-view", 1);
+ }
+ Gtk.main_quit();
+ }
+
private void view_toggled () {
if (!view_icons.active &&
!view_filelist.active &&
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]