Merge lp:~tintou/slingshot/consistent-searchbar into lp:~elementary-pantheon/slingshot/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
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 :

* 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.

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
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2014-10-05 03:06:34 +0000
+++ CMakeLists.txt 2014-10-14 20:19:51 +0000
@@ -78,7 +78,6 @@
78 src/Backend/SynapseSearch.vala78 src/Backend/SynapseSearch.vala
79 src/Widgets/AppEntry.vala79 src/Widgets/AppEntry.vala
80 src/Widgets/Grid.vala80 src/Widgets/Grid.vala
81 src/Widgets/LargeSearchEntry.vala
82 src/Widgets/Switcher.vala81 src/Widgets/Switcher.vala
83 src/Widgets/SearchView.vala82 src/Widgets/SearchView.vala
84 src/Widgets/SearchItem.vala83 src/Widgets/SearchItem.vala
@@ -93,6 +92,7 @@
93 vapi/config.vapi92 vapi/config.vapi
94OPTIONS93OPTIONS
95 --thread94 --thread
95 --target-glib=2.32
96 --vapidir=${CMAKE_BINARY_DIR}/lib/synapse-core96 --vapidir=${CMAKE_BINARY_DIR}/lib/synapse-core
97 --vapidir=${CMAKE_BINARY_DIR}/lib/synapse-plugins97 --vapidir=${CMAKE_BINARY_DIR}/lib/synapse-plugins
98 -g98 -g
@@ -127,4 +127,4 @@
127add_schema ("org.pantheon.desktop.slingshot.gschema.xml")127add_schema ("org.pantheon.desktop.slingshot.gschema.xml")
128128
129# Translations129# Translations
130add_subdirectory (po)130add_subdirectory (po)
131\ No newline at end of file131\ No newline at end of file
132132
=== modified file 'src/SlingshotView.vala'
--- src/SlingshotView.vala 2014-10-14 01:30:37 +0000
+++ src/SlingshotView.vala 2014-10-14 20:19:51 +0000
@@ -27,10 +27,10 @@
27 public class SlingshotView : Granite.Widgets.PopOver {27 public class SlingshotView : Granite.Widgets.PopOver {
2828
29 // Widgets29 // Widgets
30 public Gtk.SearchEntry dummy_search_entry;30 public Gtk.SearchEntry search_entry;
31 public Widgets.LargeSearchEntry real_search_entry;
32 public Gtk.Stack stack;31 public Gtk.Stack stack;
33 public Granite.Widgets.ModeButton view_selector;32 public Granite.Widgets.ModeButton view_selector;
33 private Gtk.Revealer view_selector_revealer;
3434
35 // Views35 // Views
36 private Widgets.Grid grid_view;36 private Widgets.Grid grid_view;
@@ -38,7 +38,6 @@
38 private Widgets.CategoryView category_view;38 private Widgets.CategoryView category_view;
3939
40 public Gtk.Grid top;40 public Gtk.Grid top;
41 public Gtk.Grid center;
42 public Gtk.Grid container;41 public Gtk.Grid container;
43 public Gtk.Stack main_stack;42 public Gtk.Stack main_stack;
44 public Gtk.Box content_area;43 public Gtk.Box content_area;
@@ -109,7 +108,7 @@
109 }108 }
110109
111 public int calculate_grid_width () {110 public int calculate_grid_width () {
112 return (int) default_columns * Pixels.ITEM_SIZE;111 return (int) default_columns * Pixels.ITEM_SIZE + 24;
113 }112 }
114113
115 private void setup_size () {114 private void setup_size () {
@@ -139,18 +138,19 @@
139138
140 // Create the base container139 // Create the base container
141 container = new Gtk.Grid ();140 container = new Gtk.Grid ();
142141 container.row_spacing = 12;
143 main_stack = new Gtk.Stack ();
144
145 main_stack.add_named (container, "apps");
146142
147 // Add top bar143 // Add top bar
148 top = new Gtk.Grid ();144 top = new Gtk.Grid ();
149145 top.orientation = Gtk.Orientation.HORIZONTAL;
150 var top_separator = new Gtk.Label (""); // A fake label146 top.margin_left = 12;
151 top_separator.set_hexpand(true);147 top.margin_right = 12;
152148
153 view_selector = new Granite.Widgets.ModeButton ();149 view_selector = new Granite.Widgets.ModeButton ();
150 view_selector.margin_right = 12;
151 view_selector_revealer = new Gtk.Revealer ();
152 view_selector_revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_RIGHT;
153 view_selector_revealer.add (view_selector);
154154
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);
156 image.tooltip_text = _("View as Grid");156 image.tooltip_text = _("View as Grid");
@@ -165,61 +165,45 @@
165 else165 else
166 view_selector.selected = 0;166 view_selector.selected = 0;
167167
168 dummy_search_entry = new Gtk.SearchEntry ();168 search_entry = new Gtk.SearchEntry ();
169 dummy_search_entry.placeholder_text = _("Search Apps");169 search_entry.placeholder_text = _("Search Apps");
170 dummy_search_entry.width_request = 250;170 search_entry.hexpand = true;
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;});
172172
173 if (Slingshot.settings.show_category_filter) {173 if (Slingshot.settings.show_category_filter) {
174 top.attach (view_selector, 0, 0, 1, 1);174 top.add (view_selector_revealer);
175 }175 }
176 top.attach (top_separator, 1, 0, 1, 1);176 top.add (search_entry);
177 top.attach (dummy_search_entry, 2, 0, 1, 1);
178
179 center = new Gtk.Grid ();
180177
181 stack = new Gtk.Stack ();178 stack = new Gtk.Stack ();
182 stack.set_size_request (calculate_grid_width (), calculate_grid_height ());179 stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT;
183
184 center.attach (stack, 0, 0, 1, 1);
185180
186 // Create the "NORMAL_VIEW"181 // Create the "NORMAL_VIEW"
187 var scrolled_normal = new Gtk.ScrolledWindow (null, null);182 var scrolled_normal = new Gtk.ScrolledWindow (null, null);
183 scrolled_normal.set_size_request (calculate_grid_width (), calculate_grid_height ());
188 grid_view = new Widgets.Grid (default_rows, default_columns);184 grid_view = new Widgets.Grid (default_rows, default_columns);
189 scrolled_normal.add_with_viewport (grid_view);185 scrolled_normal.add_with_viewport (grid_view);
190
191 stack.add_named (scrolled_normal, "normal");186 stack.add_named (scrolled_normal, "normal");
192187
188 // Create the "CATEGORY_VIEW"
189 category_view = new Widgets.CategoryView (this);
190 category_view.set_size_request (calculate_grid_width (), calculate_grid_height ());
191 stack.add_named (category_view, "category");
192
193 // Create the "SEARCH_VIEW"193 // Create the "SEARCH_VIEW"
194 var search_view_container = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
195
196 real_search_entry = new Widgets.LargeSearchEntry ();
197 real_search_entry.margin_left = Pixels.PADDING;
198 real_search_entry.margin_right = Pixels.PADDING;
199
200 search_view = new Widgets.SearchView (this);194 search_view = new Widgets.SearchView (this);
195 search_view.set_size_request (calculate_grid_width (), calculate_grid_height ());
201 search_view.start_search.connect ((match, target) => {196 search_view.start_search.connect ((match, target) => {
202 search.begin (real_search_entry.text, match, target);197 search.begin (search_entry.text, match, target);
203 });198 });
204199
205 search_view_container.pack_start (real_search_entry, false);200 stack.add_named (search_view, "search");
206 search_view_container.pack_start (new Gtk.Separator (Gtk.Orientation.HORIZONTAL), false);201
207 search_view_container.pack_start (search_view);
208
209 main_stack.add_named (search_view_container, "search");
210
211 // Create the "CATEGORY_VIEW"
212 category_view = new Widgets.CategoryView (this);
213 stack.add_named (category_view, "category");
214
215 Utils.set_padding (top, 12, Pixels.PADDING, 12, Pixels.PADDING);
216 Utils.set_padding (center, 0, Pixels.PADDING, 12, Pixels.PADDING);
217
218 container.attach (top, 0, 0, 1, 1);202 container.attach (top, 0, 0, 1, 1);
219 container.attach (center, 0, 1, 1, 1);203 container.attach (stack, 0, 1, 1, 1);
220204
221 event_box = new Gtk.EventBox ();205 event_box = new Gtk.EventBox ();
222 event_box.add (main_stack);206 event_box.add (container);
223 // Add the container to the dialog's content area207 // Add the container to the dialog's content area
224 content_area = get_content_area () as Gtk.Box;208 content_area = get_content_area () as Gtk.Box;
225 content_area.pack_start (event_box);209 content_area.pack_start (event_box);
@@ -227,7 +211,7 @@
227 content_area.set_margin_right (SHADOW_SIZE-1);211 content_area.set_margin_right (SHADOW_SIZE-1);
228 content_area.set_margin_top (SHADOW_SIZE-1);212 content_area.set_margin_top (SHADOW_SIZE-1);
229 content_area.set_margin_bottom (SHADOW_SIZE-1);213 content_area.set_margin_bottom (SHADOW_SIZE-1);
230 214
231 if (Slingshot.settings.use_category)215 if (Slingshot.settings.use_category)
232 set_modality (Modality.CATEGORY_VIEW);216 set_modality (Modality.CATEGORY_VIEW);
233 else217 else
@@ -298,38 +282,20 @@
298 private void connect_signals () {282 private void connect_signals () {
299283
300 this.focus_in_event.connect (() => {284 this.focus_in_event.connect (() => {
301 get_current_search_entry ().grab_focus ();285 search_entry.grab_focus ();
302 return false;286 return false;
303 });287 });
304288
305 event_box.key_press_event.connect (on_key_press);289 event_box.key_press_event.connect (on_key_press);
306 dummy_search_entry.key_press_event.connect (search_entry_key_press);290 search_entry.key_press_event.connect (search_entry_key_press);
307 real_search_entry.widget.key_press_event.connect (search_entry_key_press);
308291
309 real_search_entry.search_changed.connect (() => {292 search_entry.search_changed.connect (() => {
310 search.begin (real_search_entry.text);
311 });
312 dummy_search_entry.search_changed.connect (() => {
313 if (modality != Modality.SEARCH_VIEW)293 if (modality != Modality.SEARCH_VIEW)
314 set_modality (Modality.SEARCH_VIEW);294 set_modality (Modality.SEARCH_VIEW);
315 });295 search.begin (search_entry.text);
316 dummy_search_entry.grab_focus ();296 });
317297 search_entry.grab_focus ();
318 dummy_search_entry.activate.connect (search_entry_activated);298 search_entry.activate.connect (search_entry_activated);
319 real_search_entry.widget.activate.connect (search_entry_activated);
320
321 // the focus-out event is fired as soon as the stack transition is ended
322 // at which point we're able to focus the real_search_entry
323 dummy_search_entry.focus_out_event.connect (() => {
324 real_search_entry.text = dummy_search_entry.text;
325 real_search_entry.widget.grab_focus ();
326 var cursor_pos = real_search_entry.text.length;
327 real_search_entry.widget.select_region (cursor_pos, cursor_pos);
328
329 dummy_search_entry.text = "";
330
331 return false;
332 });
333299
334 search_view.app_launched.connect (() => hide ());300 search_view.app_launched.connect (() => hide ());
335301
@@ -433,11 +399,6 @@
433 }399 }
434 }400 }
435401
436 public Gtk.Entry get_current_search_entry ()
437 {
438 return modality == Modality.SEARCH_VIEW ? real_search_entry.widget : dummy_search_entry;
439 }
440
441 /*402 /*
442 Overriding the default handler results in infinite loop of error messages403 Overriding the default handler results in infinite loop of error messages
443 when an input method is in use (Gtk3 bug?). Key press events are404 when an input method is in use (Gtk3 bug?). Key press events are
@@ -459,8 +420,6 @@
459 return true;420 return true;
460 }421 }
461422
462 var search_entry = get_current_search_entry ();
463
464 switch (key) {423 switch (key) {
465 case "F4":424 case "F4":
466 if ((event.state & Gdk.ModifierType.MOD1_MASK) != 0) {425 if ((event.state & Gdk.ModifierType.MOD1_MASK) != 0) {
@@ -678,6 +637,7 @@
678 if (!search_entry.has_focus) {637 if (!search_entry.has_focus) {
679 search_entry.grab_focus ();638 search_entry.grab_focus ();
680 search_entry.move_cursor (Gtk.MovementStep.BUFFER_ENDS, 0, false);639 search_entry.move_cursor (Gtk.MovementStep.BUFFER_ENDS, 0, false);
640 search_entry.key_press_event (event);
681 }641 }
682 return false;642 return false;
683643
@@ -713,16 +673,20 @@
713673
714 public void show_slingshot () {674 public void show_slingshot () {
715675
716 dummy_search_entry.text = "";676 search_entry.text = "";
717 real_search_entry.text = "";
718677
719 reposition ();678 reposition ();
720 show_all ();679 show_all ();
721 present ();680 present ();
722681
723 set_focus(null);682 set_focus (null);
724 get_current_search_entry ().grab_focus ();683 search_entry.grab_focus ();
684 //This is needed in order to not animate if the previous view was the search view.
685 view_selector_revealer.transition_type = Gtk.RevealerTransitionType.NONE;
686 stack.transition_type = Gtk.StackTransitionType.NONE;
725 set_modality ((Modality) view_selector.selected);687 set_modality ((Modality) view_selector.selected);
688 view_selector_revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_RIGHT;
689 stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT;
726 }690 }
727691
728 private void set_modality (Modality new_modality) {692 private void set_modality (Modality new_modality) {
@@ -733,35 +697,25 @@
733697
734 if (Slingshot.settings.use_category)698 if (Slingshot.settings.use_category)
735 Slingshot.settings.use_category = false;699 Slingshot.settings.use_category = false;
736 view_selector.show_all ();700 view_selector_revealer.set_reveal_child (true);
737 main_stack.set_visible_child_name ("apps");
738 stack.set_visible_child_name ("normal");701 stack.set_visible_child_name ("normal");
739702
740 // change the paddings/margins back to normal703 search_entry.grab_focus ();
741 center.set_margin_left (Pixels.PADDING);
742 stack.set_size_request (calculate_grid_width (), calculate_grid_height ());
743
744 dummy_search_entry.grab_focus ();
745 break;704 break;
746705
747 case Modality.CATEGORY_VIEW:706 case Modality.CATEGORY_VIEW:
748707
749 if (!Slingshot.settings.use_category)708 if (!Slingshot.settings.use_category)
750 Slingshot.settings.use_category = true;709 Slingshot.settings.use_category = true;
751 view_selector.show_all ();710 view_selector_revealer.set_reveal_child (true);
752 main_stack.set_visible_child_name ("apps");
753 stack.set_visible_child_name ("category");711 stack.set_visible_child_name ("category");
754712
755 // remove the padding/margin on the left713 search_entry.grab_focus ();
756 center.set_margin_left (0);
757 stack.set_size_request (calculate_grid_width () + Pixels.PADDING, calculate_grid_height ());
758
759 dummy_search_entry.grab_focus ();
760 break;714 break;
761715
762 case Modality.SEARCH_VIEW:716 case Modality.SEARCH_VIEW:
763 view_selector.hide ();717 view_selector_revealer.set_reveal_child (false);
764 main_stack.set_visible_child_name ("search");718 stack.set_visible_child_name ("search");
765 break;719 break;
766720
767 }721 }
@@ -780,7 +734,7 @@
780 // picked up. If we add an idle and recheck that the entry is indeed still734 // picked up. If we add an idle and recheck that the entry is indeed still
781 // empty before switching, this problem is gone.735 // empty before switching, this problem is gone.
782 Idle.add (() => {736 Idle.add (() => {
783 if (real_search_entry.text.strip () == "")737 if (search_entry.text.strip () == "")
784 set_modality ((Modality) view_selector.selected);738 set_modality ((Modality) view_selector.selected);
785 return false;739 return false;
786 });740 });
@@ -799,10 +753,10 @@
799 matches = yield synapse.search (text);753 matches = yield synapse.search (text);
800 }754 }
801755
802 search_view.clear ();756 Idle.add (() => {
803 search_view.set_results (matches, text);757 search_view.set_results (matches, text);
804758 return false;
805 search_view.selected = 0;759 });
806760
807 }761 }
808762
@@ -900,7 +854,7 @@
900 return;854 return;
901 }855 }
902 else if (category_column_focus == 0 && delta_column < 0) {856 else if (category_column_focus == 0 && delta_column < 0) {
903 get_current_search_entry ().grab_focus ();857 search_entry.grab_focus ();
904 category_column_focus = 0;858 category_column_focus = 0;
905 category_row_focus = 0;859 category_row_focus = 0;
906 return;860 return;
907861
=== modified file 'src/Widgets/AppEntry.vala'
--- src/Widgets/AppEntry.vala 2014-10-05 03:06:34 +0000
+++ src/Widgets/AppEntry.vala 2014-10-14 20:19:51 +0000
@@ -36,7 +36,6 @@
36 private Backend.App application;36 private Backend.App application;
3737
38 public AppEntry (Backend.App app) {38 public AppEntry (Backend.App app) {
39 this.relief = Gtk.ReliefStyle.NONE;
40 Gtk.TargetEntry dnd = {"text/uri-list", 0, 0};39 Gtk.TargetEntry dnd = {"text/uri-list", 0, 0};
41 Gtk.drag_source_set (this, Gdk.ModifierType.BUTTON1_MASK, {dnd},40 Gtk.drag_source_set (this, Gdk.ModifierType.BUTTON1_MASK, {dnd},
42 Gdk.DragAction.COPY);41 Gdk.DragAction.COPY);
@@ -112,4 +111,4 @@
112 application.launch ();111 application.launch ();
113 app_launched ();112 app_launched ();
114 }113 }
115}114}
116\ No newline at end of file115\ No newline at end of file
117116
=== modified file 'src/Widgets/CategoryView.vala'
--- src/Widgets/CategoryView.vala 2014-08-14 20:44:46 +0000
+++ src/Widgets/CategoryView.vala 2014-10-14 20:19:51 +0000
@@ -124,7 +124,7 @@
124 else124 else
125 page_switcher.hide ();125 page_switcher.hide ();
126126
127 view.get_current_search_entry ().grab_focus ();127 view.search_entry.grab_focus ();
128128
129 }129 }
130130
131131
=== modified file 'src/Widgets/Grid.vala'
--- src/Widgets/Grid.vala 2014-08-14 20:09:40 +0000
+++ src/Widgets/Grid.vala 2014-10-14 20:19:51 +0000
@@ -37,6 +37,8 @@
37 private Page page;37 private Page page;
3838
39 public Grid (int rows, int columns) {39 public Grid (int rows, int columns) {
40 margin_left = 12;
41 margin_right = 12;
40 page.rows = rows;42 page.rows = rows;
41 page.columns = columns;43 page.columns = columns;
42 page.number = 1;44 page.number = 1;
4345
=== removed file 'src/Widgets/LargeSearchEntry.vala'
--- src/Widgets/LargeSearchEntry.vala 2014-06-10 10:30:05 +0000
+++ src/Widgets/LargeSearchEntry.vala 1970-01-01 00:00:00 +0000
@@ -1,73 +0,0 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2//
3// Copyright (C) 2014 Tom Beckmann <tomjonabc@gmail.com>
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <http://www.gnu.org/licenses/>.
17//
18
19namespace Slingshot.Widgets
20{
21 public class LargeSearchEntry : Gtk.Box {
22 const int ICON_SIZE = 24;
23
24 public signal void search_changed ();
25
26 public string text {
27 get {
28 return widget.text;
29 }
30 set {
31 widget.text = value;
32 }
33 }
34
35 public Gtk.Entry widget { get; private set; }
36
37 public LargeSearchEntry ()
38 {
39 Object (orientation: Gtk.Orientation.HORIZONTAL, spacing: 4);
40
41 var find_pixbuf = get_icon ("edit-find-symbolic");
42 var clear_pixbuf = get_icon ("edit-clear-symbolic");
43
44 var clear_box = new Gtk.Button ();
45 clear_box.add (new Gtk.Image.from_pixbuf (clear_pixbuf));
46 clear_box.relief = Gtk.ReliefStyle.NONE;
47 clear_box.clicked.connect (() => text = "" );
48
49 widget = new Gtk.Entry ();
50 widget.get_style_context ().add_class ("search-entry-large");
51
52 pack_start (new Gtk.Image.from_pixbuf (find_pixbuf), false);
53 pack_start (widget);
54 pack_start (clear_box, false);
55
56 widget.changed.connect (() => search_changed ());
57 }
58
59 Gdk.Pixbuf? get_icon (string name)
60 {
61 Gdk.Pixbuf? pixbuf = null;
62 var info = Gtk.IconTheme.get_default ().lookup_icon (name, ICON_SIZE, 0);
63 try {
64 if (info != null)
65 pixbuf = info.load_symbolic ({ 0.5, 0.5, 0.5, 1 });
66 } catch (Error e) {}
67
68 return pixbuf;
69 }
70
71 }
72}
73
740
=== modified file 'src/Widgets/SearchItem.vala'
--- src/Widgets/SearchItem.vala 2014-06-12 09:14:57 +0000
+++ src/Widgets/SearchItem.vala 2014-10-14 20:19:51 +0000
@@ -35,7 +35,6 @@
35 Object (app: app);35 Object (app: app);
3636
37 get_style_context ().add_class ("app");37 get_style_context ().add_class ("app");
38 get_style_context ().add_class ("search-item");
3938
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);
4140
@@ -79,4 +78,4 @@
79 }78 }
80 }79 }
8180
82}81}
83\ No newline at end of file82\ No newline at end of file
8483
=== modified file 'src/Widgets/SearchView.vala'
--- src/Widgets/SearchView.vala 2014-06-12 09:14:57 +0000
+++ src/Widgets/SearchView.vala 2014-10-14 20:19:51 +0000
@@ -21,6 +21,7 @@
21 public class SearchView : Gtk.ScrolledWindow {21 public class SearchView : Gtk.ScrolledWindow {
22 const int CONTEXT_WIDTH = 200;22 const int CONTEXT_WIDTH = 200;
23 const int CONTEXT_ARROW_SIZE = 12;23 const int CONTEXT_ARROW_SIZE = 12;
24 const int MAX_RESULTS = 20;
24 const int MAX_RESULTS_BEFORE_LIMIT = 10;25 const int MAX_RESULTS_BEFORE_LIMIT = 10;
2526
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);
@@ -90,9 +91,10 @@
90 items = new Gee.HashMap<Backend.App, SearchItem> ();91 items = new Gee.HashMap<Backend.App, SearchItem> ();
9192
92 main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);93 main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
94 main_box.margin_left = 12;
95 main_box.margin_right = 12;
9396
94 context_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);97 context_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
95 context_box.width_request = CONTEXT_WIDTH;
96 context_fixed = new Gtk.Fixed ();98 context_fixed = new Gtk.Fixed ();
97 context_fixed.margin_left = CONTEXT_ARROW_SIZE;99 context_fixed.margin_left = CONTEXT_ARROW_SIZE;
98 context_fixed.put (context_box, 0, 0);100 context_fixed.put (context_box, 0, 0);
@@ -103,7 +105,6 @@
103 revealer = new Gtk.Revealer ();105 revealer = new Gtk.Revealer ();
104 revealer.transition_duration = 400;106 revealer.transition_duration = 400;
105 revealer.transition_type = Gtk.RevealerTransitionType.CROSSFADE;107 revealer.transition_type = Gtk.RevealerTransitionType.CROSSFADE;
106 revealer.width_request = CONTEXT_WIDTH + CONTEXT_ARROW_SIZE;
107 revealer.no_show_all = true;108 revealer.no_show_all = true;
108 revealer.add (context);109 revealer.add (context);
109110
@@ -149,7 +150,7 @@
149 // if we're showing more than about 10 results and we have more than150 // if we're showing more than about 10 results and we have more than
150 // categories, we limit the results per category to the most relevant151 // categories, we limit the results per category to the most relevant
151 // ones.152 // ones.
152 var limit = int.MAX;153 var limit = MAX_RESULTS;
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)
154 limit = 5;155 limit = 5;
155156
@@ -185,14 +186,16 @@
185186
186 var header = new Gtk.Label (label);187 var header = new Gtk.Label (label);
187 header.xalign = 0;188 header.xalign = 0;
188 header.margin_left = header.margin_top = 8;189 header.margin_left = 8;
189 header.margin_bottom = 4;190 header.margin_bottom = 4;
190 header.use_markup = true;191 header.use_markup = true;
192 header.get_style_context ().add_class ("category-label");
191 header.show ();193 header.show ();
192 header.get_style_context ().add_class ("search-category-header");
193 main_box.pack_start (header, false);194 main_box.pack_start (header, false);
194195
195 var list = categories.get (type);196 var list = categories.get (type);
197 var old_selected = selected;
198 clear ();
196 for (var i = 0; i < limit && i < list.size; i++) {199 for (var i = 0; i < limit && i < list.size; i++) {
197 var match = list.get (i);200 var match = list.get (i);
198201
@@ -208,6 +211,7 @@
208 n_results++;211 n_results++;
209 }212 }
210 }213 }
214 selected = old_selected;
211 }215 }
212 }216 }
213217
@@ -352,4 +356,4 @@
352356
353 }357 }
354358
355}359}
356\ No newline at end of file360\ No newline at end of file

Subscribers

People subscribed via source and target branches