~nonamenoname/slingshot/fix-1084101

« back to all changes in this revision

Viewing changes to src/Widgets/SearchView.vala

  • Committer: RabbitBot
  • Author(s): Corentin Noël
  • Date: 2014-03-13 20:30:47 UTC
  • mfrom: (407.1.3 gtk+-3.10)
  • Revision ID: rabbitbot-20140313203047-r7xz011rs52s1lok
Port forward to Gtk 3.10 for improved page switching and other benefits

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
    }
29
29
 
30
 
    public class SearchView : Gtk.Box {
 
30
    public class SearchView : Gtk.ScrolledWindow {
31
31
 
32
32
        private Gee.HashMap<Backend.App, SearchItem> items;
33
33
        private SeparatorItem separator;
34
34
        private SearchItem selected_app = null;
 
35
        private Gtk.Box main_box;
35
36
 
36
37
        private int _selected = 0;
37
38
        public int selected {
63
64
        private SlingshotView view;
64
65
 
65
66
        public SearchView (SlingshotView parent) {
66
 
            orientation = Gtk.Orientation.VERTICAL;
67
 
 
68
 
            can_focus = true;
69
 
            homogeneous = false;
 
67
            main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
 
68
            main_box.can_focus = true;
 
69
            main_box.homogeneous = false;
70
70
 
71
71
            this.view = parent;
72
 
            width_request = view.columns * 130;
 
72
            main_box. width_request = view.columns * 130;
73
73
 
74
74
            items = new Gee.HashMap<Backend.App, SearchItem> ();
75
75
            separator = new SeparatorItem ();
76
76
 
 
77
            var expand_grid = new Gtk.Grid ();
 
78
            expand_grid.expand = true;
 
79
            var search_grid = new Gtk.Grid ();
 
80
            search_grid.orientation = Gtk.Orientation.VERTICAL;
 
81
            search_grid.add (main_box);
 
82
            search_grid.add (expand_grid);
 
83
            add_with_viewport (search_grid);
77
84
        }
78
85
 
79
86
        public void add_apps (Gee.ArrayList<Backend.App> apps) {
111
118
            }
112
119
 
113
120
            if (!(items[app].in_box)) {
114
 
                pack_start (items[app], true, true, 0);
 
121
                main_box.pack_start (items[app], true, true, 0);
115
122
                items[app].in_box = true;
116
123
                items[app].icon_size = 48;
117
124
                items[app].queue_draw ();
143
150
            foreach (SearchItem app in items.values) {
144
151
                app.hide ();
145
152
                if (app.in_box) {
146
 
                    remove (app);
 
153
                    main_box.remove (app);
147
154
                    app.in_box = false;
148
155
                }
149
156
            }
 
157
 
 
158
            vadjustment.value = vadjustment.lower;
150
159
            apps_showed = 0;
151
160
        }
152
161
 
163
172
        private void show_separator () {
164
173
 
165
174
            if (!(separator.in_box)) {
166
 
                pack_start (separator, true, true, 3);
 
175
                main_box.pack_start (separator, true, true, 3);
167
176
                separator.in_box = true;
168
177
            }
169
178
            separator.show_all ();
174
183
 
175
184
            separator.hide ();
176
185
            if (separator.in_box) {
177
 
                remove (separator);
 
186
                main_box.remove (separator);
178
187
                separator.in_box = false;
179
188
            }
180
189
 
185
194
            if (selected_app != null)
186
195
                selected_app.unset_state_flags (Gtk.StateFlags.PRELIGHT);
187
196
 
188
 
            selected_app = (SearchItem) get_children ().nth_data (index);
 
197
            selected_app = (SearchItem) main_box.get_children ().nth_data (index);
189
198
            selected_app.set_state_flags (Gtk.StateFlags.PRELIGHT, false);
190
199
 
191
200
        }