Merge lp:~mefrio-g/light-software-center/fix-search into lp:light-software-center

Proposed by Mario Guerriero
Status: Merged
Merged at revision: 43
Proposed branch: lp:~mefrio-g/light-software-center/fix-search
Merge into: lp:light-software-center
Diff against target: 144 lines (+55/-5)
4 files modified
src/Backend/AppsManager.vala (+38/-4)
src/Backend/Backend.vala (+2/-1)
src/Frontend.vala (+3/-0)
src/Widgets/Pages/AppsView.vala (+12/-0)
To merge this branch: bzr merge lp:~mefrio-g/light-software-center/fix-search
Reviewer Review Type Date Requested Status
Lubuntu Software Center Team Pending
Review via email: mp+114592@code.launchpad.net

Description of the change

* Implemented a search function (not yet tested but it should work)
* Made some function private
* Used stderr to print some error messages but we need to decide if we want to use sdtout/sdterr way or the GLib.erro/warning one

To post a comment you must log in.
Revision history for this message
Stephen Smally (stephen-smally) wrote :

Wouldn't be better to implement the search via sqlite?

Revision history for this message
Michael Rawson (michael.rawson) wrote :

> Wouldn't be better to implement the search via sqlite?

You mean sqlheavy?

Revision history for this message
Stephen Smally (stephen-smally) wrote :

Just the same, SQLHeavy is a wrapper for Sqlite3

Revision history for this message
Mario Guerriero (mefrio-g) wrote :

Yes I'll implement it using database, it's better

Revision history for this message
Stephen Smally (stephen-smally) wrote :

Thanks, or we will end having ghost applications.

43. By Mario Guerriero

fixed searching using sqlheavy

Revision history for this message
Mario Guerriero (mefrio-g) wrote :

I implemented the searching using SQLheavy in rev 43

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Backend/AppsManager.vala'
2--- src/Backend/AppsManager.vala 2012-07-11 18:59:07 +0000
3+++ src/Backend/AppsManager.vala 2012-07-12 15:01:18 +0000
4@@ -78,14 +78,16 @@
5 result.fetch_string (1),
6 result.fetch_string (2),
7 result.fetch_string (3)));
8- }
9+ //if ("x" in result.fetch_string (0))
10+ //stdout.printf ("\n%s", result.fetch_string (0));
11+ }
12 } catch (GLib.Error e) {
13 GLib.error ("Error retrieving packages: %s\n", e.message);
14 }
15
16 }
17
18- public void get_details_2 (LscApp pkg, Package p) {
19+ private void get_details_2 (LscApp pkg, Package p) {
20 client.get_details_async({p.get_id(), null},
21 null,
22 () => {
23@@ -98,7 +100,7 @@
24 Results res = client.generic_finish (resu);
25 details_received (pkg, p, res.get_details_array()[0]);
26 } catch (GLib.Error e) {
27- stdout.printf ("ERROR! %s\n", e.message);
28+ stderr.printf ("ERROR! %s\n", e.message);
29 }
30 loading_finished (LoadingType.DETAILS);
31 }
32@@ -125,7 +127,7 @@
33 });
34 }
35
36- public int count_category (string category) {
37+ private int count_category (string category) {
38 try {
39 Query q = database.prepare ("SELECT COUNT (*) FROM '%s';".printf (category));
40 QueryResult r = q.execute();
41@@ -156,6 +158,38 @@
42 loading_finished(LoadingType.CATEGORIES);
43 }
44
45+ public void search_for_apps (string search_string) {
46+
47+ // Categories
48+ try {
49+ Query get_query = database.prepare ("SELECT * FROM 'DIRECTORIES';");
50+ QueryResult result = get_query.execute ();
51+
52+ // Foreach category
53+ for (int record = 1; ! result.finished; record++, result.next ()) {
54+ // Check for a package
55+ stdout.printf ("\n%s", result.fetch_string (0));
56+ try {
57+ get_query = database.prepare ("SELECT * FROM '%s';".printf (result.fetch_string (0)));
58+ result = get_query.execute ();
59+
60+ for (record = 1; ! result.finished; record++, result.next ()) {
61+ if (search_string in result.fetch_string (0)) // If something is found let's send the application
62+ app_added (new LscApp (
63+ result.fetch_string (0),
64+ result.fetch_string (1),
65+ result.fetch_string (2),
66+ result.fetch_string (3)));
67+ }
68+ } catch (GLib.Error e) {
69+ GLib.error ("Error retrieving packages: %s\n", e.message);
70+ }
71+ }
72+ } catch (GLib.Error e) {
73+ GLib.error ("Error retrieving packages: %s\n", e.message);
74+ }
75+ }
76+
77 public AppsManager () {
78 client = new Client();
79 control = new Control();
80
81=== modified file 'src/Backend/Backend.vala'
82--- src/Backend/Backend.vala 2012-07-10 09:44:20 +0000
83+++ src/Backend/Backend.vala 2012-07-12 15:01:18 +0000
84@@ -5,7 +5,8 @@
85 CATEGORIES, // Loaded categories
86 DETAILS, // Loading details
87 INSTALL,
88- REMOVE; // Installed or so
89+ REMOVE, // Installed or so
90+ SEARCH; // When it is searching apps
91 }
92
93 public enum ActionType {
94
95=== modified file 'src/Frontend.vala'
96--- src/Frontend.vala 2012-07-10 09:44:20 +0000
97+++ src/Frontend.vala 2012-07-12 15:01:18 +0000
98@@ -198,6 +198,9 @@
99 info_message.update (a);
100 info_box.set_visible (true);
101 });
102+ pages_view.apps_view.apps_tree.activated_row.connect((a) => {
103+ info_message.choosed (0, a);
104+ });
105 // When the page is switched
106 pages_view.switch_page.connect(update_back_button);
107 pages_view.switch_page.connect(toolbar.update_label);
108
109=== modified file 'src/Widgets/Pages/AppsView.vala'
110--- src/Widgets/Pages/AppsView.vala 2012-07-10 16:27:53 +0000
111+++ src/Widgets/Pages/AppsView.vala 2012-07-12 15:01:18 +0000
112@@ -23,6 +23,7 @@
113 public class AppsTree : TreeView {
114 // Signals
115 public signal void selected_row (LscApp app);
116+ public signal void activated_row (LscApp app);
117
118 // Vars
119 private IconTheme theme;
120@@ -50,6 +51,16 @@
121 }
122 }
123
124+ public void on_row_activated (TreePath path, TreeViewColumn column) {
125+ get_cursor(out this.path, null);
126+ if (path != null) {
127+ LscApp val;
128+ model.get_iter(out iter, this.path);
129+ model.get(iter, 2, out val);
130+ activated_row(val);
131+ }
132+ }
133+
134 public AppsTree () {
135 theme = IconTheme.get_default ();
136 theme.append_search_path ("/usr/share/app-install/icons");
137@@ -82,6 +93,7 @@
138 rules_hint = true;
139
140 cursor_changed.connect(on_cursor_changed);
141+ row_activated.connect(on_row_activated);
142
143 headers_visible = false;
144 }

Subscribers

People subscribed via source and target branches