Merge lp:~tintou/slingshot/consistent-searchbar into lp:~elementary-pantheon/slingshot/trunk
- consistent-searchbar
- Merge into trunk
Proposed by
Corentin Noël
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Danielle Foré | ||||||||
Approved revision: | 466 | ||||||||
Merged at revision: | 461 | ||||||||
Proposed branch: | lp:~tintou/slingshot/consistent-searchbar | ||||||||
Merge into: | lp:~elementary-pantheon/slingshot/trunk | ||||||||
Diff against target: |
569 lines (+76/-191) 8 files modified
CMakeLists.txt (+2/-2) src/SlingshotView.vala (+59/-105) src/Widgets/AppEntry.vala (+1/-2) src/Widgets/CategoryView.vala (+1/-1) src/Widgets/Grid.vala (+2/-0) src/Widgets/LargeSearchEntry.vala (+0/-73) src/Widgets/SearchItem.vala (+1/-2) src/Widgets/SearchView.vala (+10/-6) |
||||||||
To merge this branch: | bzr merge lp:~tintou/slingshot/consistent-searchbar | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tom Beckmann (community) | Approve | ||
Danielle Foré | ux | Approve | |
Review via email: mp+238334@code.launchpad.net |
Commit message
* Get a consistent search entry.
* Do search asynchronously.
* Animate the view change with recent Gtk technology.
* Simplify the code regarding the addition of margins.
Description of the change
* Get a consistent search entry.
* Do search asynchronously.
* Anymate the view change with recent Gtk technology.
* Simplify the code regarding the addition of margins.
To post a comment you must log in.
Revision history for this message
Danielle Foré (danrabbit) wrote : | # |
- 464. By Corentin Noël
-
Some fixes.
Revision history for this message
Danielle Foré (danrabbit) wrote : | # |
UX approve. Fantastic :)
review:
Approve
(ux)
- 465. By Corentin Noël
-
Restrict results to 20.
- 466. By Corentin Noël
-
Refinements.
Revision history for this message
Tom Beckmann (tombeckmann) wrote : | # |
Great changes!
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2014-10-05 03:06:34 +0000 | |||
3 | +++ CMakeLists.txt 2014-10-14 20:19:51 +0000 | |||
4 | @@ -78,7 +78,6 @@ | |||
5 | 78 | src/Backend/SynapseSearch.vala | 78 | src/Backend/SynapseSearch.vala |
6 | 79 | src/Widgets/AppEntry.vala | 79 | src/Widgets/AppEntry.vala |
7 | 80 | src/Widgets/Grid.vala | 80 | src/Widgets/Grid.vala |
8 | 81 | src/Widgets/LargeSearchEntry.vala | ||
9 | 82 | src/Widgets/Switcher.vala | 81 | src/Widgets/Switcher.vala |
10 | 83 | src/Widgets/SearchView.vala | 82 | src/Widgets/SearchView.vala |
11 | 84 | src/Widgets/SearchItem.vala | 83 | src/Widgets/SearchItem.vala |
12 | @@ -93,6 +92,7 @@ | |||
13 | 93 | vapi/config.vapi | 92 | vapi/config.vapi |
14 | 94 | OPTIONS | 93 | OPTIONS |
15 | 95 | --thread | 94 | --thread |
16 | 95 | --target-glib=2.32 | ||
17 | 96 | --vapidir=${CMAKE_BINARY_DIR}/lib/synapse-core | 96 | --vapidir=${CMAKE_BINARY_DIR}/lib/synapse-core |
18 | 97 | --vapidir=${CMAKE_BINARY_DIR}/lib/synapse-plugins | 97 | --vapidir=${CMAKE_BINARY_DIR}/lib/synapse-plugins |
19 | 98 | -g | 98 | -g |
20 | @@ -127,4 +127,4 @@ | |||
21 | 127 | add_schema ("org.pantheon.desktop.slingshot.gschema.xml") | 127 | add_schema ("org.pantheon.desktop.slingshot.gschema.xml") |
22 | 128 | 128 | ||
23 | 129 | # Translations | 129 | # Translations |
25 | 130 | add_subdirectory (po) | 130 | add_subdirectory (po) |
26 | 131 | \ No newline at end of file | 131 | \ No newline at end of file |
27 | 132 | 132 | ||
28 | === modified file 'src/SlingshotView.vala' | |||
29 | --- src/SlingshotView.vala 2014-10-14 01:30:37 +0000 | |||
30 | +++ src/SlingshotView.vala 2014-10-14 20:19:51 +0000 | |||
31 | @@ -27,10 +27,10 @@ | |||
32 | 27 | public class SlingshotView : Granite.Widgets.PopOver { | 27 | public class SlingshotView : Granite.Widgets.PopOver { |
33 | 28 | 28 | ||
34 | 29 | // Widgets | 29 | // Widgets |
37 | 30 | public Gtk.SearchEntry dummy_search_entry; | 30 | public Gtk.SearchEntry search_entry; |
36 | 31 | public Widgets.LargeSearchEntry real_search_entry; | ||
38 | 32 | public Gtk.Stack stack; | 31 | public Gtk.Stack stack; |
39 | 33 | public Granite.Widgets.ModeButton view_selector; | 32 | public Granite.Widgets.ModeButton view_selector; |
40 | 33 | private Gtk.Revealer view_selector_revealer; | ||
41 | 34 | 34 | ||
42 | 35 | // Views | 35 | // Views |
43 | 36 | private Widgets.Grid grid_view; | 36 | private Widgets.Grid grid_view; |
44 | @@ -38,7 +38,6 @@ | |||
45 | 38 | private Widgets.CategoryView category_view; | 38 | private Widgets.CategoryView category_view; |
46 | 39 | 39 | ||
47 | 40 | public Gtk.Grid top; | 40 | public Gtk.Grid top; |
48 | 41 | public Gtk.Grid center; | ||
49 | 42 | public Gtk.Grid container; | 41 | public Gtk.Grid container; |
50 | 43 | public Gtk.Stack main_stack; | 42 | public Gtk.Stack main_stack; |
51 | 44 | public Gtk.Box content_area; | 43 | public Gtk.Box content_area; |
52 | @@ -109,7 +108,7 @@ | |||
53 | 109 | } | 108 | } |
54 | 110 | 109 | ||
55 | 111 | public int calculate_grid_width () { | 110 | public int calculate_grid_width () { |
57 | 112 | return (int) default_columns * Pixels.ITEM_SIZE; | 111 | return (int) default_columns * Pixels.ITEM_SIZE + 24; |
58 | 113 | } | 112 | } |
59 | 114 | 113 | ||
60 | 115 | private void setup_size () { | 114 | private void setup_size () { |
61 | @@ -139,18 +138,19 @@ | |||
62 | 139 | 138 | ||
63 | 140 | // Create the base container | 139 | // Create the base container |
64 | 141 | container = new Gtk.Grid (); | 140 | container = new Gtk.Grid (); |
69 | 142 | 141 | container.row_spacing = 12; | |
66 | 143 | main_stack = new Gtk.Stack (); | ||
67 | 144 | |||
68 | 145 | main_stack.add_named (container, "apps"); | ||
70 | 146 | 142 | ||
71 | 147 | // Add top bar | 143 | // Add top bar |
72 | 148 | top = new Gtk.Grid (); | 144 | top = new Gtk.Grid (); |
76 | 149 | 145 | top.orientation = Gtk.Orientation.HORIZONTAL; | |
77 | 150 | var top_separator = new Gtk.Label (""); // A fake label | 146 | top.margin_left = 12; |
78 | 151 | top_separator.set_hexpand(true); | 147 | top.margin_right = 12; |
79 | 152 | 148 | ||
80 | 153 | view_selector = new Granite.Widgets.ModeButton (); | 149 | view_selector = new Granite.Widgets.ModeButton (); |
81 | 150 | view_selector.margin_right = 12; | ||
82 | 151 | view_selector_revealer = new Gtk.Revealer (); | ||
83 | 152 | view_selector_revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_RIGHT; | ||
84 | 153 | view_selector_revealer.add (view_selector); | ||
85 | 154 | 154 | ||
86 | 155 | var image = new Gtk.Image.from_icon_name ("view-grid-symbolic", Gtk.IconSize.MENU); | 155 | var image = new Gtk.Image.from_icon_name ("view-grid-symbolic", Gtk.IconSize.MENU); |
87 | 156 | image.tooltip_text = _("View as Grid"); | 156 | image.tooltip_text = _("View as Grid"); |
88 | @@ -165,61 +165,45 @@ | |||
89 | 165 | else | 165 | else |
90 | 166 | view_selector.selected = 0; | 166 | view_selector.selected = 0; |
91 | 167 | 167 | ||
96 | 168 | dummy_search_entry = new Gtk.SearchEntry (); | 168 | search_entry = new Gtk.SearchEntry (); |
97 | 169 | dummy_search_entry.placeholder_text = _("Search Apps"); | 169 | search_entry.placeholder_text = _("Search Apps"); |
98 | 170 | dummy_search_entry.width_request = 250; | 170 | search_entry.hexpand = true; |
99 | 171 | dummy_search_entry.button_press_event.connect ((e) => {return e.button == 3;}); | 171 | search_entry.button_press_event.connect ((e) => {return e.button == 3;}); |
100 | 172 | 172 | ||
101 | 173 | if (Slingshot.settings.show_category_filter) { | 173 | if (Slingshot.settings.show_category_filter) { |
103 | 174 | top.attach (view_selector, 0, 0, 1, 1); | 174 | top.add (view_selector_revealer); |
104 | 175 | } | 175 | } |
109 | 176 | top.attach (top_separator, 1, 0, 1, 1); | 176 | top.add (search_entry); |
106 | 177 | top.attach (dummy_search_entry, 2, 0, 1, 1); | ||
107 | 178 | |||
108 | 179 | center = new Gtk.Grid (); | ||
110 | 180 | 177 | ||
111 | 181 | stack = new Gtk.Stack (); | 178 | stack = new Gtk.Stack (); |
115 | 182 | stack.set_size_request (calculate_grid_width (), calculate_grid_height ()); | 179 | stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT; |
113 | 183 | |||
114 | 184 | center.attach (stack, 0, 0, 1, 1); | ||
116 | 185 | 180 | ||
117 | 186 | // Create the "NORMAL_VIEW" | 181 | // Create the "NORMAL_VIEW" |
118 | 187 | var scrolled_normal = new Gtk.ScrolledWindow (null, null); | 182 | var scrolled_normal = new Gtk.ScrolledWindow (null, null); |
119 | 183 | scrolled_normal.set_size_request (calculate_grid_width (), calculate_grid_height ()); | ||
120 | 188 | grid_view = new Widgets.Grid (default_rows, default_columns); | 184 | grid_view = new Widgets.Grid (default_rows, default_columns); |
121 | 189 | scrolled_normal.add_with_viewport (grid_view); | 185 | scrolled_normal.add_with_viewport (grid_view); |
122 | 190 | |||
123 | 191 | stack.add_named (scrolled_normal, "normal"); | 186 | stack.add_named (scrolled_normal, "normal"); |
124 | 192 | 187 | ||
125 | 188 | // Create the "CATEGORY_VIEW" | ||
126 | 189 | category_view = new Widgets.CategoryView (this); | ||
127 | 190 | category_view.set_size_request (calculate_grid_width (), calculate_grid_height ()); | ||
128 | 191 | stack.add_named (category_view, "category"); | ||
129 | 192 | |||
130 | 193 | // Create the "SEARCH_VIEW" | 193 | // Create the "SEARCH_VIEW" |
131 | 194 | var search_view_container = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); | ||
132 | 195 | |||
133 | 196 | real_search_entry = new Widgets.LargeSearchEntry (); | ||
134 | 197 | real_search_entry.margin_left = Pixels.PADDING; | ||
135 | 198 | real_search_entry.margin_right = Pixels.PADDING; | ||
136 | 199 | |||
137 | 200 | search_view = new Widgets.SearchView (this); | 194 | search_view = new Widgets.SearchView (this); |
138 | 195 | search_view.set_size_request (calculate_grid_width (), calculate_grid_height ()); | ||
139 | 201 | search_view.start_search.connect ((match, target) => { | 196 | search_view.start_search.connect ((match, target) => { |
141 | 202 | search.begin (real_search_entry.text, match, target); | 197 | search.begin (search_entry.text, match, target); |
142 | 203 | }); | 198 | }); |
143 | 204 | 199 | ||
157 | 205 | search_view_container.pack_start (real_search_entry, false); | 200 | stack.add_named (search_view, "search"); |
158 | 206 | search_view_container.pack_start (new Gtk.Separator (Gtk.Orientation.HORIZONTAL), false); | 201 | |
146 | 207 | search_view_container.pack_start (search_view); | ||
147 | 208 | |||
148 | 209 | main_stack.add_named (search_view_container, "search"); | ||
149 | 210 | |||
150 | 211 | // Create the "CATEGORY_VIEW" | ||
151 | 212 | category_view = new Widgets.CategoryView (this); | ||
152 | 213 | stack.add_named (category_view, "category"); | ||
153 | 214 | |||
154 | 215 | Utils.set_padding (top, 12, Pixels.PADDING, 12, Pixels.PADDING); | ||
155 | 216 | Utils.set_padding (center, 0, Pixels.PADDING, 12, Pixels.PADDING); | ||
156 | 217 | |||
159 | 218 | container.attach (top, 0, 0, 1, 1); | 202 | container.attach (top, 0, 0, 1, 1); |
161 | 219 | container.attach (center, 0, 1, 1, 1); | 203 | container.attach (stack, 0, 1, 1, 1); |
162 | 220 | 204 | ||
163 | 221 | event_box = new Gtk.EventBox (); | 205 | event_box = new Gtk.EventBox (); |
165 | 222 | event_box.add (main_stack); | 206 | event_box.add (container); |
166 | 223 | // Add the container to the dialog's content area | 207 | // Add the container to the dialog's content area |
167 | 224 | content_area = get_content_area () as Gtk.Box; | 208 | content_area = get_content_area () as Gtk.Box; |
168 | 225 | content_area.pack_start (event_box); | 209 | content_area.pack_start (event_box); |
169 | @@ -227,7 +211,7 @@ | |||
170 | 227 | content_area.set_margin_right (SHADOW_SIZE-1); | 211 | content_area.set_margin_right (SHADOW_SIZE-1); |
171 | 228 | content_area.set_margin_top (SHADOW_SIZE-1); | 212 | content_area.set_margin_top (SHADOW_SIZE-1); |
172 | 229 | content_area.set_margin_bottom (SHADOW_SIZE-1); | 213 | content_area.set_margin_bottom (SHADOW_SIZE-1); |
174 | 230 | 214 | ||
175 | 231 | if (Slingshot.settings.use_category) | 215 | if (Slingshot.settings.use_category) |
176 | 232 | set_modality (Modality.CATEGORY_VIEW); | 216 | set_modality (Modality.CATEGORY_VIEW); |
177 | 233 | else | 217 | else |
178 | @@ -298,38 +282,20 @@ | |||
179 | 298 | private void connect_signals () { | 282 | private void connect_signals () { |
180 | 299 | 283 | ||
181 | 300 | this.focus_in_event.connect (() => { | 284 | this.focus_in_event.connect (() => { |
183 | 301 | get_current_search_entry ().grab_focus (); | 285 | search_entry.grab_focus (); |
184 | 302 | return false; | 286 | return false; |
185 | 303 | }); | 287 | }); |
186 | 304 | 288 | ||
187 | 305 | event_box.key_press_event.connect (on_key_press); | 289 | event_box.key_press_event.connect (on_key_press); |
190 | 306 | dummy_search_entry.key_press_event.connect (search_entry_key_press); | 290 | search_entry.key_press_event.connect (search_entry_key_press); |
189 | 307 | real_search_entry.widget.key_press_event.connect (search_entry_key_press); | ||
191 | 308 | 291 | ||
196 | 309 | real_search_entry.search_changed.connect (() => { | 292 | search_entry.search_changed.connect (() => { |
193 | 310 | search.begin (real_search_entry.text); | ||
194 | 311 | }); | ||
195 | 312 | dummy_search_entry.search_changed.connect (() => { | ||
197 | 313 | if (modality != Modality.SEARCH_VIEW) | 293 | if (modality != Modality.SEARCH_VIEW) |
198 | 314 | set_modality (Modality.SEARCH_VIEW); | 294 | set_modality (Modality.SEARCH_VIEW); |
217 | 315 | }); | 295 | search.begin (search_entry.text); |
218 | 316 | dummy_search_entry.grab_focus (); | 296 | }); |
219 | 317 | 297 | search_entry.grab_focus (); | |
220 | 318 | dummy_search_entry.activate.connect (search_entry_activated); | 298 | search_entry.activate.connect (search_entry_activated); |
203 | 319 | real_search_entry.widget.activate.connect (search_entry_activated); | ||
204 | 320 | |||
205 | 321 | // the focus-out event is fired as soon as the stack transition is ended | ||
206 | 322 | // at which point we're able to focus the real_search_entry | ||
207 | 323 | dummy_search_entry.focus_out_event.connect (() => { | ||
208 | 324 | real_search_entry.text = dummy_search_entry.text; | ||
209 | 325 | real_search_entry.widget.grab_focus (); | ||
210 | 326 | var cursor_pos = real_search_entry.text.length; | ||
211 | 327 | real_search_entry.widget.select_region (cursor_pos, cursor_pos); | ||
212 | 328 | |||
213 | 329 | dummy_search_entry.text = ""; | ||
214 | 330 | |||
215 | 331 | return false; | ||
216 | 332 | }); | ||
221 | 333 | 299 | ||
222 | 334 | search_view.app_launched.connect (() => hide ()); | 300 | search_view.app_launched.connect (() => hide ()); |
223 | 335 | 301 | ||
224 | @@ -433,11 +399,6 @@ | |||
225 | 433 | } | 399 | } |
226 | 434 | } | 400 | } |
227 | 435 | 401 | ||
228 | 436 | public Gtk.Entry get_current_search_entry () | ||
229 | 437 | { | ||
230 | 438 | return modality == Modality.SEARCH_VIEW ? real_search_entry.widget : dummy_search_entry; | ||
231 | 439 | } | ||
232 | 440 | |||
233 | 441 | /* | 402 | /* |
234 | 442 | Overriding the default handler results in infinite loop of error messages | 403 | Overriding the default handler results in infinite loop of error messages |
235 | 443 | when an input method is in use (Gtk3 bug?). Key press events are | 404 | when an input method is in use (Gtk3 bug?). Key press events are |
236 | @@ -459,8 +420,6 @@ | |||
237 | 459 | return true; | 420 | return true; |
238 | 460 | } | 421 | } |
239 | 461 | 422 | ||
240 | 462 | var search_entry = get_current_search_entry (); | ||
241 | 463 | |||
242 | 464 | switch (key) { | 423 | switch (key) { |
243 | 465 | case "F4": | 424 | case "F4": |
244 | 466 | if ((event.state & Gdk.ModifierType.MOD1_MASK) != 0) { | 425 | if ((event.state & Gdk.ModifierType.MOD1_MASK) != 0) { |
245 | @@ -678,6 +637,7 @@ | |||
246 | 678 | if (!search_entry.has_focus) { | 637 | if (!search_entry.has_focus) { |
247 | 679 | search_entry.grab_focus (); | 638 | search_entry.grab_focus (); |
248 | 680 | search_entry.move_cursor (Gtk.MovementStep.BUFFER_ENDS, 0, false); | 639 | search_entry.move_cursor (Gtk.MovementStep.BUFFER_ENDS, 0, false); |
249 | 640 | search_entry.key_press_event (event); | ||
250 | 681 | } | 641 | } |
251 | 682 | return false; | 642 | return false; |
252 | 683 | 643 | ||
253 | @@ -713,16 +673,20 @@ | |||
254 | 713 | 673 | ||
255 | 714 | public void show_slingshot () { | 674 | public void show_slingshot () { |
256 | 715 | 675 | ||
259 | 716 | dummy_search_entry.text = ""; | 676 | search_entry.text = ""; |
258 | 717 | real_search_entry.text = ""; | ||
260 | 718 | 677 | ||
261 | 719 | reposition (); | 678 | reposition (); |
262 | 720 | show_all (); | 679 | show_all (); |
263 | 721 | present (); | 680 | present (); |
264 | 722 | 681 | ||
267 | 723 | set_focus(null); | 682 | set_focus (null); |
268 | 724 | get_current_search_entry ().grab_focus (); | 683 | search_entry.grab_focus (); |
269 | 684 | //This is needed in order to not animate if the previous view was the search view. | ||
270 | 685 | view_selector_revealer.transition_type = Gtk.RevealerTransitionType.NONE; | ||
271 | 686 | stack.transition_type = Gtk.StackTransitionType.NONE; | ||
272 | 725 | set_modality ((Modality) view_selector.selected); | 687 | set_modality ((Modality) view_selector.selected); |
273 | 688 | view_selector_revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_RIGHT; | ||
274 | 689 | stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT; | ||
275 | 726 | } | 690 | } |
276 | 727 | 691 | ||
277 | 728 | private void set_modality (Modality new_modality) { | 692 | private void set_modality (Modality new_modality) { |
278 | @@ -733,35 +697,25 @@ | |||
279 | 733 | 697 | ||
280 | 734 | if (Slingshot.settings.use_category) | 698 | if (Slingshot.settings.use_category) |
281 | 735 | Slingshot.settings.use_category = false; | 699 | Slingshot.settings.use_category = false; |
284 | 736 | view_selector.show_all (); | 700 | view_selector_revealer.set_reveal_child (true); |
283 | 737 | main_stack.set_visible_child_name ("apps"); | ||
285 | 738 | stack.set_visible_child_name ("normal"); | 701 | stack.set_visible_child_name ("normal"); |
286 | 739 | 702 | ||
292 | 740 | // change the paddings/margins back to normal | 703 | search_entry.grab_focus (); |
288 | 741 | center.set_margin_left (Pixels.PADDING); | ||
289 | 742 | stack.set_size_request (calculate_grid_width (), calculate_grid_height ()); | ||
290 | 743 | |||
291 | 744 | dummy_search_entry.grab_focus (); | ||
293 | 745 | break; | 704 | break; |
294 | 746 | 705 | ||
295 | 747 | case Modality.CATEGORY_VIEW: | 706 | case Modality.CATEGORY_VIEW: |
296 | 748 | 707 | ||
297 | 749 | if (!Slingshot.settings.use_category) | 708 | if (!Slingshot.settings.use_category) |
298 | 750 | Slingshot.settings.use_category = true; | 709 | Slingshot.settings.use_category = true; |
301 | 751 | view_selector.show_all (); | 710 | view_selector_revealer.set_reveal_child (true); |
300 | 752 | main_stack.set_visible_child_name ("apps"); | ||
302 | 753 | stack.set_visible_child_name ("category"); | 711 | stack.set_visible_child_name ("category"); |
303 | 754 | 712 | ||
309 | 755 | // remove the padding/margin on the left | 713 | search_entry.grab_focus (); |
305 | 756 | center.set_margin_left (0); | ||
306 | 757 | stack.set_size_request (calculate_grid_width () + Pixels.PADDING, calculate_grid_height ()); | ||
307 | 758 | |||
308 | 759 | dummy_search_entry.grab_focus (); | ||
310 | 760 | break; | 714 | break; |
311 | 761 | 715 | ||
312 | 762 | case Modality.SEARCH_VIEW: | 716 | case Modality.SEARCH_VIEW: |
315 | 763 | view_selector.hide (); | 717 | view_selector_revealer.set_reveal_child (false); |
316 | 764 | main_stack.set_visible_child_name ("search"); | 718 | stack.set_visible_child_name ("search"); |
317 | 765 | break; | 719 | break; |
318 | 766 | 720 | ||
319 | 767 | } | 721 | } |
320 | @@ -780,7 +734,7 @@ | |||
321 | 780 | // picked up. If we add an idle and recheck that the entry is indeed still | 734 | // picked up. If we add an idle and recheck that the entry is indeed still |
322 | 781 | // empty before switching, this problem is gone. | 735 | // empty before switching, this problem is gone. |
323 | 782 | Idle.add (() => { | 736 | Idle.add (() => { |
325 | 783 | if (real_search_entry.text.strip () == "") | 737 | if (search_entry.text.strip () == "") |
326 | 784 | set_modality ((Modality) view_selector.selected); | 738 | set_modality ((Modality) view_selector.selected); |
327 | 785 | return false; | 739 | return false; |
328 | 786 | }); | 740 | }); |
329 | @@ -799,10 +753,10 @@ | |||
330 | 799 | matches = yield synapse.search (text); | 753 | matches = yield synapse.search (text); |
331 | 800 | } | 754 | } |
332 | 801 | 755 | ||
337 | 802 | search_view.clear (); | 756 | Idle.add (() => { |
338 | 803 | search_view.set_results (matches, text); | 757 | search_view.set_results (matches, text); |
339 | 804 | 758 | return false; | |
340 | 805 | search_view.selected = 0; | 759 | }); |
341 | 806 | 760 | ||
342 | 807 | } | 761 | } |
343 | 808 | 762 | ||
344 | @@ -900,7 +854,7 @@ | |||
345 | 900 | return; | 854 | return; |
346 | 901 | } | 855 | } |
347 | 902 | else if (category_column_focus == 0 && delta_column < 0) { | 856 | else if (category_column_focus == 0 && delta_column < 0) { |
349 | 903 | get_current_search_entry ().grab_focus (); | 857 | search_entry.grab_focus (); |
350 | 904 | category_column_focus = 0; | 858 | category_column_focus = 0; |
351 | 905 | category_row_focus = 0; | 859 | category_row_focus = 0; |
352 | 906 | return; | 860 | return; |
353 | 907 | 861 | ||
354 | === modified file 'src/Widgets/AppEntry.vala' | |||
355 | --- src/Widgets/AppEntry.vala 2014-10-05 03:06:34 +0000 | |||
356 | +++ src/Widgets/AppEntry.vala 2014-10-14 20:19:51 +0000 | |||
357 | @@ -36,7 +36,6 @@ | |||
358 | 36 | private Backend.App application; | 36 | private Backend.App application; |
359 | 37 | 37 | ||
360 | 38 | public AppEntry (Backend.App app) { | 38 | public AppEntry (Backend.App app) { |
361 | 39 | this.relief = Gtk.ReliefStyle.NONE; | ||
362 | 40 | Gtk.TargetEntry dnd = {"text/uri-list", 0, 0}; | 39 | Gtk.TargetEntry dnd = {"text/uri-list", 0, 0}; |
363 | 41 | Gtk.drag_source_set (this, Gdk.ModifierType.BUTTON1_MASK, {dnd}, | 40 | Gtk.drag_source_set (this, Gdk.ModifierType.BUTTON1_MASK, {dnd}, |
364 | 42 | Gdk.DragAction.COPY); | 41 | Gdk.DragAction.COPY); |
365 | @@ -112,4 +111,4 @@ | |||
366 | 112 | application.launch (); | 111 | application.launch (); |
367 | 113 | app_launched (); | 112 | app_launched (); |
368 | 114 | } | 113 | } |
370 | 115 | } | 114 | } |
371 | 116 | \ No newline at end of file | 115 | \ No newline at end of file |
372 | 117 | 116 | ||
373 | === modified file 'src/Widgets/CategoryView.vala' | |||
374 | --- src/Widgets/CategoryView.vala 2014-08-14 20:44:46 +0000 | |||
375 | +++ src/Widgets/CategoryView.vala 2014-10-14 20:19:51 +0000 | |||
376 | @@ -124,7 +124,7 @@ | |||
377 | 124 | else | 124 | else |
378 | 125 | page_switcher.hide (); | 125 | page_switcher.hide (); |
379 | 126 | 126 | ||
381 | 127 | view.get_current_search_entry ().grab_focus (); | 127 | view.search_entry.grab_focus (); |
382 | 128 | 128 | ||
383 | 129 | } | 129 | } |
384 | 130 | 130 | ||
385 | 131 | 131 | ||
386 | === modified file 'src/Widgets/Grid.vala' | |||
387 | --- src/Widgets/Grid.vala 2014-08-14 20:09:40 +0000 | |||
388 | +++ src/Widgets/Grid.vala 2014-10-14 20:19:51 +0000 | |||
389 | @@ -37,6 +37,8 @@ | |||
390 | 37 | private Page page; | 37 | private Page page; |
391 | 38 | 38 | ||
392 | 39 | public Grid (int rows, int columns) { | 39 | public Grid (int rows, int columns) { |
393 | 40 | margin_left = 12; | ||
394 | 41 | margin_right = 12; | ||
395 | 40 | page.rows = rows; | 42 | page.rows = rows; |
396 | 41 | page.columns = columns; | 43 | page.columns = columns; |
397 | 42 | page.number = 1; | 44 | page.number = 1; |
398 | 43 | 45 | ||
399 | === removed file 'src/Widgets/LargeSearchEntry.vala' | |||
400 | --- src/Widgets/LargeSearchEntry.vala 2014-06-10 10:30:05 +0000 | |||
401 | +++ src/Widgets/LargeSearchEntry.vala 1970-01-01 00:00:00 +0000 | |||
402 | @@ -1,73 +0,0 @@ | |||
403 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | ||
404 | 2 | // | ||
405 | 3 | // Copyright (C) 2014 Tom Beckmann <tomjonabc@gmail.com> | ||
406 | 4 | // | ||
407 | 5 | // This program is free software: you can redistribute it and/or modify | ||
408 | 6 | // it under the terms of the GNU General Public License as published by | ||
409 | 7 | // the Free Software Foundation, either version 3 of the License, or | ||
410 | 8 | // (at your option) any later version. | ||
411 | 9 | // | ||
412 | 10 | // This program is distributed in the hope that it will be useful, | ||
413 | 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
414 | 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
415 | 13 | // GNU General Public License for more details. | ||
416 | 14 | // | ||
417 | 15 | // You should have received a copy of the GNU General Public License | ||
418 | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
419 | 17 | // | ||
420 | 18 | |||
421 | 19 | namespace Slingshot.Widgets | ||
422 | 20 | { | ||
423 | 21 | public class LargeSearchEntry : Gtk.Box { | ||
424 | 22 | const int ICON_SIZE = 24; | ||
425 | 23 | |||
426 | 24 | public signal void search_changed (); | ||
427 | 25 | |||
428 | 26 | public string text { | ||
429 | 27 | get { | ||
430 | 28 | return widget.text; | ||
431 | 29 | } | ||
432 | 30 | set { | ||
433 | 31 | widget.text = value; | ||
434 | 32 | } | ||
435 | 33 | } | ||
436 | 34 | |||
437 | 35 | public Gtk.Entry widget { get; private set; } | ||
438 | 36 | |||
439 | 37 | public LargeSearchEntry () | ||
440 | 38 | { | ||
441 | 39 | Object (orientation: Gtk.Orientation.HORIZONTAL, spacing: 4); | ||
442 | 40 | |||
443 | 41 | var find_pixbuf = get_icon ("edit-find-symbolic"); | ||
444 | 42 | var clear_pixbuf = get_icon ("edit-clear-symbolic"); | ||
445 | 43 | |||
446 | 44 | var clear_box = new Gtk.Button (); | ||
447 | 45 | clear_box.add (new Gtk.Image.from_pixbuf (clear_pixbuf)); | ||
448 | 46 | clear_box.relief = Gtk.ReliefStyle.NONE; | ||
449 | 47 | clear_box.clicked.connect (() => text = "" ); | ||
450 | 48 | |||
451 | 49 | widget = new Gtk.Entry (); | ||
452 | 50 | widget.get_style_context ().add_class ("search-entry-large"); | ||
453 | 51 | |||
454 | 52 | pack_start (new Gtk.Image.from_pixbuf (find_pixbuf), false); | ||
455 | 53 | pack_start (widget); | ||
456 | 54 | pack_start (clear_box, false); | ||
457 | 55 | |||
458 | 56 | widget.changed.connect (() => search_changed ()); | ||
459 | 57 | } | ||
460 | 58 | |||
461 | 59 | Gdk.Pixbuf? get_icon (string name) | ||
462 | 60 | { | ||
463 | 61 | Gdk.Pixbuf? pixbuf = null; | ||
464 | 62 | var info = Gtk.IconTheme.get_default ().lookup_icon (name, ICON_SIZE, 0); | ||
465 | 63 | try { | ||
466 | 64 | if (info != null) | ||
467 | 65 | pixbuf = info.load_symbolic ({ 0.5, 0.5, 0.5, 1 }); | ||
468 | 66 | } catch (Error e) {} | ||
469 | 67 | |||
470 | 68 | return pixbuf; | ||
471 | 69 | } | ||
472 | 70 | |||
473 | 71 | } | ||
474 | 72 | } | ||
475 | 73 | |||
476 | 74 | 0 | ||
477 | === modified file 'src/Widgets/SearchItem.vala' | |||
478 | --- src/Widgets/SearchItem.vala 2014-06-12 09:14:57 +0000 | |||
479 | +++ src/Widgets/SearchItem.vala 2014-10-14 20:19:51 +0000 | |||
480 | @@ -35,7 +35,6 @@ | |||
481 | 35 | Object (app: app); | 35 | Object (app: app); |
482 | 36 | 36 | ||
483 | 37 | get_style_context ().add_class ("app"); | 37 | get_style_context ().add_class ("app"); |
484 | 38 | get_style_context ().add_class ("search-item"); | ||
485 | 39 | 38 | ||
486 | 40 | var markup = Backend.SynapseSearch.markup_string_with_search (app.name, search_term); | 39 | var markup = Backend.SynapseSearch.markup_string_with_search (app.name, search_term); |
487 | 41 | 40 | ||
488 | @@ -79,4 +78,4 @@ | |||
489 | 79 | } | 78 | } |
490 | 80 | } | 79 | } |
491 | 81 | 80 | ||
493 | 82 | } | 81 | } |
494 | 83 | \ No newline at end of file | 82 | \ No newline at end of file |
495 | 84 | 83 | ||
496 | === modified file 'src/Widgets/SearchView.vala' | |||
497 | --- src/Widgets/SearchView.vala 2014-06-12 09:14:57 +0000 | |||
498 | +++ src/Widgets/SearchView.vala 2014-10-14 20:19:51 +0000 | |||
499 | @@ -21,6 +21,7 @@ | |||
500 | 21 | public class SearchView : Gtk.ScrolledWindow { | 21 | public class SearchView : Gtk.ScrolledWindow { |
501 | 22 | const int CONTEXT_WIDTH = 200; | 22 | const int CONTEXT_WIDTH = 200; |
502 | 23 | const int CONTEXT_ARROW_SIZE = 12; | 23 | const int CONTEXT_ARROW_SIZE = 12; |
503 | 24 | const int MAX_RESULTS = 20; | ||
504 | 24 | const int MAX_RESULTS_BEFORE_LIMIT = 10; | 25 | const int MAX_RESULTS_BEFORE_LIMIT = 10; |
505 | 25 | 26 | ||
506 | 26 | public signal void start_search (Synapse.SearchMatch search_match, Synapse.Match? target); | 27 | public signal void start_search (Synapse.SearchMatch search_match, Synapse.Match? target); |
507 | @@ -90,9 +91,10 @@ | |||
508 | 90 | items = new Gee.HashMap<Backend.App, SearchItem> (); | 91 | items = new Gee.HashMap<Backend.App, SearchItem> (); |
509 | 91 | 92 | ||
510 | 92 | main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); | 93 | main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); |
511 | 94 | main_box.margin_left = 12; | ||
512 | 95 | main_box.margin_right = 12; | ||
513 | 93 | 96 | ||
514 | 94 | context_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); | 97 | context_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); |
515 | 95 | context_box.width_request = CONTEXT_WIDTH; | ||
516 | 96 | context_fixed = new Gtk.Fixed (); | 98 | context_fixed = new Gtk.Fixed (); |
517 | 97 | context_fixed.margin_left = CONTEXT_ARROW_SIZE; | 99 | context_fixed.margin_left = CONTEXT_ARROW_SIZE; |
518 | 98 | context_fixed.put (context_box, 0, 0); | 100 | context_fixed.put (context_box, 0, 0); |
519 | @@ -103,7 +105,6 @@ | |||
520 | 103 | revealer = new Gtk.Revealer (); | 105 | revealer = new Gtk.Revealer (); |
521 | 104 | revealer.transition_duration = 400; | 106 | revealer.transition_duration = 400; |
522 | 105 | revealer.transition_type = Gtk.RevealerTransitionType.CROSSFADE; | 107 | revealer.transition_type = Gtk.RevealerTransitionType.CROSSFADE; |
523 | 106 | revealer.width_request = CONTEXT_WIDTH + CONTEXT_ARROW_SIZE; | ||
524 | 107 | revealer.no_show_all = true; | 108 | revealer.no_show_all = true; |
525 | 108 | revealer.add (context); | 109 | revealer.add (context); |
526 | 109 | 110 | ||
527 | @@ -149,7 +150,7 @@ | |||
528 | 149 | // if we're showing more than about 10 results and we have more than | 150 | // if we're showing more than about 10 results and we have more than |
529 | 150 | // categories, we limit the results per category to the most relevant | 151 | // categories, we limit the results per category to the most relevant |
530 | 151 | // ones. | 152 | // ones. |
532 | 152 | var limit = int.MAX; | 153 | var limit = MAX_RESULTS; |
533 | 153 | if (matches.size + 3 > MAX_RESULTS_BEFORE_LIMIT && categories_order.size > 2) | 154 | if (matches.size + 3 > MAX_RESULTS_BEFORE_LIMIT && categories_order.size > 2) |
534 | 154 | limit = 5; | 155 | limit = 5; |
535 | 155 | 156 | ||
536 | @@ -185,14 +186,16 @@ | |||
537 | 185 | 186 | ||
538 | 186 | var header = new Gtk.Label (label); | 187 | var header = new Gtk.Label (label); |
539 | 187 | header.xalign = 0; | 188 | header.xalign = 0; |
541 | 188 | header.margin_left = header.margin_top = 8; | 189 | header.margin_left = 8; |
542 | 189 | header.margin_bottom = 4; | 190 | header.margin_bottom = 4; |
543 | 190 | header.use_markup = true; | 191 | header.use_markup = true; |
544 | 192 | header.get_style_context ().add_class ("category-label"); | ||
545 | 191 | header.show (); | 193 | header.show (); |
546 | 192 | header.get_style_context ().add_class ("search-category-header"); | ||
547 | 193 | main_box.pack_start (header, false); | 194 | main_box.pack_start (header, false); |
548 | 194 | 195 | ||
549 | 195 | var list = categories.get (type); | 196 | var list = categories.get (type); |
550 | 197 | var old_selected = selected; | ||
551 | 198 | clear (); | ||
552 | 196 | for (var i = 0; i < limit && i < list.size; i++) { | 199 | for (var i = 0; i < limit && i < list.size; i++) { |
553 | 197 | var match = list.get (i); | 200 | var match = list.get (i); |
554 | 198 | 201 | ||
555 | @@ -208,6 +211,7 @@ | |||
556 | 208 | n_results++; | 211 | n_results++; |
557 | 209 | } | 212 | } |
558 | 210 | } | 213 | } |
559 | 214 | selected = old_selected; | ||
560 | 211 | } | 215 | } |
561 | 212 | } | 216 | } |
562 | 213 | 217 | ||
563 | @@ -352,4 +356,4 @@ | |||
564 | 352 | 356 | ||
565 | 353 | } | 357 | } |
566 | 354 | 358 | ||
568 | 355 | } | 359 | } |
569 | 356 | \ No newline at end of file | 360 | \ No newline at end of file |
* If I don't have the search entry focused and start typing, focus will switch the entry, but the first character will be missing. If we can fix this, I think we also shouldn't focus the search entry by default so that the hint text will be shown.
* We seem to have lost the color distinction between :focus and :hover. Is that a theme issue?
* I love the animations and the margins look much better. This is amazing. The transition between the views is very smooth.