Merge lp:~voluntatefaber/scratch/smart_search into lp:~elementary-apps/scratch/scratch

Proposed by Mario Guerriero
Status: Merged
Approved by: Mario Guerriero
Approved revision: 601
Merged at revision: 603
Proposed branch: lp:~voluntatefaber/scratch/smart_search
Merge into: lp:~elementary-apps/scratch/scratch
Diff against target: 154 lines (+8/-73)
3 files modified
scratchcore/SearchManager.vala (+2/-64)
scratchcore/core-tests/main.vala (+6/-8)
src/MainWindow.vala (+0/-1)
To merge this branch: bzr merge lp:~voluntatefaber/scratch/smart_search
Reviewer Review Type Date Requested Status
Mario Guerriero (community) Approve
Review via email: mp+97242@code.launchpad.net

Commit message

To post a comment you must log in.
Revision history for this message
Mario Guerriero (mefrio-g) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scratchcore/SearchManager.vala'
2--- scratchcore/SearchManager.vala 2012-02-18 15:51:56 +0000
3+++ scratchcore/SearchManager.vala 2012-03-13 15:27:19 +0000
4@@ -27,7 +27,6 @@
5 Gtk.ToolItem tool_arrow_up;
6 Gtk.ToolItem tool_arrow_down;
7 Gtk.ToolButton tool_close_button;
8- Granite.Widgets.ToolArrow search_arrow;
9
10 Granite.Widgets.SearchBar search_entry;
11 Granite.Widgets.SearchBar replace_entry;
12@@ -48,11 +47,6 @@
13 * of the search entry.
14 **/
15 public bool cycle_search {get; set; default = false; }
16-
17- /**
18- * Wether the search is or isn't case sensitive.
19- **/
20- public bool case_sensitive {get; set; default = false; }
21
22 public signal void need_hide ();
23
24@@ -123,20 +117,12 @@
25 settings.show_go_to_line = false;
26
27 Scratch.settings.changed.connect (restore_settings);
28-
29-
30- search_arrow = new Granite.Widgets.ToolArrow ();
31- search_arrow.clicked.connect(on_show_popover);
32 }
33
34 public Gtk.ToolItem get_search_entry () {
35 return tool_search_entry;
36 }
37
38- public Gtk.ToolItem get_search_arrow () {
39- return search_arrow;
40- }
41-
42 public Gtk.ToolItem get_close_button () {
43 return tool_close_button;
44 }
45@@ -252,56 +238,6 @@
46 search_entry.select_region(0, -1);
47 return false;
48 }
49-
50-
51- void on_show_popover() {
52- search_arrow.set_state (true);
53- var search_popover = new Granite.Widgets.PopOver ();
54- search_popover.move_to_widget (search_arrow);
55- var box = search_popover.get_content_area() as Gtk.Box;
56-
57- var grid = new Gtk.Grid ();
58- grid.row_spacing = 5;
59- grid.column_spacing = 5;
60- grid.margin_left = 12;
61- grid.margin_right = 12;
62- grid.margin_top = 12;
63- grid.margin_bottom = 12;
64-
65- int row = 0;
66-
67- var label = new Gtk.Label (_("Search options:"));
68- add_section (grid, label, ref row);
69- var case_sensitive = new Gtk.Switch ();
70- Scratch.settings.schema.bind("search-sensitive", case_sensitive, "active", SettingsBindFlags.DEFAULT);
71- label = new Gtk.Label (_("Case sensitive search:"));
72- add_option (grid, label, case_sensitive, ref row);
73- /*
74- label = new Gtk.Label (_("Entries:"));
75- add_section (grid, label, ref row);
76- unowned SList<Gtk.RadioButton> group = null;
77- var search = new Gtk.RadioButton (group);
78- Scratch.settings.schema.bind("show-search", search, "active", SettingsBindFlags.DEFAULT);
79- label = new Gtk.Label (_("Search:"));
80- add_option (grid, label, search, ref row);
81- var replace = new Gtk.RadioButton (search.get_group ());
82- Scratch.settings.schema.bind("show-replace", replace, "active", SettingsBindFlags.DEFAULT);
83- label = new Gtk.Label (_("Replace:"));
84- add_option (grid, label, replace, ref row);
85- var go_to_line = new Gtk.RadioButton (search.get_group ());
86- Scratch.settings.schema.bind("show-go-to-line", go_to_line, "active", SettingsBindFlags.DEFAULT);
87- label = new Gtk.Label (_("Go to line:"));
88- add_option (grid, label, go_to_line, ref row);
89- */
90- box.pack_start (grid);
91-
92- search_popover.show_all();
93- search_popover.present();
94- search_popover.run();
95- search_popover.destroy();
96- search_arrow.set_state(false);
97- }
98-
99
100 void add_section (Gtk.Grid grid, Gtk.Label name, ref int row) {
101 name.use_markup = true;
102@@ -372,6 +308,7 @@
103
104 bool search_for_iter (Gtk.TextIter? start_iter, out Gtk.TextIter? end_iter, string search_string) {
105 end_iter = start_iter;
106+ bool case_sensitive = !((search_string.up () == search_string) || (search_string.down () == search_string));
107 bool found = start_iter.forward_search (search_string,
108 case_sensitive ? 0 : Gtk.TextSearchFlags.CASE_INSENSITIVE,
109 out start_iter, out end_iter, null);
110@@ -387,6 +324,7 @@
111
112 bool search_for_iter_backward (Gtk.TextIter? start_iter, out Gtk.TextIter? end_iter, string search_string) {
113 end_iter = start_iter;
114+ bool case_sensitive = !((search_string.up () == search_string) || (search_string.down () == search_string));
115 bool found = start_iter.backward_search (search_string,
116 case_sensitive ? 0 : Gtk.TextSearchFlags.CASE_INSENSITIVE,
117 out start_iter, out end_iter, null);
118
119=== modified file 'scratchcore/core-tests/main.vala'
120--- scratchcore/core-tests/main.vala 2012-02-18 14:07:59 +0000
121+++ scratchcore/core-tests/main.vala 2012-03-13 15:27:19 +0000
122@@ -37,14 +37,12 @@
123 assert(sourceview.buffer.cursor_position == "elementary ".length);
124
125 /* Case sensitive */
126- assert(search.case_sensitive == false);
127- search.set_search_string ("E");
128- search.search ();
129- assert(sourceview.buffer.cursor_position == "elementary scratch t".length);
130- search.case_sensitive = true;
131- search.set_search_string ("E");
132- search.search ();
133- assert(sourceview.buffer.cursor_position == "elementary scratch test ".length);
134+ search.set_search_string ("EST");
135+ search.search ();
136+ assert(sourceview.buffer.cursor_position == "elementary scratch test".length);
137+ search.set_search_string ("Eu");
138+ search.search ();
139+ assert(sourceview.buffer.cursor_position == "elementary scratch test E".length);
140 });
141
142 Test.add_func("/scratch/core/source_view", () => {
143
144=== modified file 'src/MainWindow.vala'
145--- src/MainWindow.vala 2012-03-12 15:37:30 +0000
146+++ src/MainWindow.vala 2012-03-13 15:27:19 +0000
147@@ -314,7 +314,6 @@
148 search_manager.get_search_entry ().set_margin_right (5);
149 search_bar.add (search_manager.get_replace_entry ());
150 search_bar.add (search_manager.get_go_to_entry ());
151- search_bar.add (search_manager.get_search_arrow ());
152 var spacer = new Gtk.ToolItem ();
153 spacer.set_expand (true);
154 search_bar.add (spacer);

Subscribers

People subscribed via source and target branches