37
public class SlingshotView : PopOver {
27
public class SlingshotView : Granite.Widgets.PopOver {
40
30
public Granite.Widgets.SearchBar searchbar;
41
public Layout view_manager;
42
public Switcher page_switcher;
43
public ModeButton view_selector;
31
public Gtk.Layout view_manager;
32
public Widgets.Switcher page_switcher;
33
public Granite.Widgets.ModeButton view_selector;
46
36
private Widgets.Grid grid_view;
47
private SearchView search_view;
48
private CategoryView category_view;
37
private Widgets.SearchView search_view;
38
private Widgets.CategoryView category_view;
50
40
public Gtk.Grid top;
51
41
public Gtk.Grid center;
54
44
public Gtk.Box content_area;
55
45
private Gtk.EventBox event_box;
57
public AppSystem app_system;
58
private ArrayList<TreeDirectory> categories;
59
public HashMap<string, ArrayList<App>> apps;
47
public Backend.AppSystem app_system;
48
private Gee.ArrayList<GMenu.TreeDirectory> categories;
49
public Gee.HashMap<string, Gee.ArrayList<Backend.App>> apps;
61
51
private int current_position = 0;
62
52
private int search_view_position = 0;
100
90
// Have the window in the right place
101
91
read_settings (true);
103
Slingshot.icon_theme = IconTheme.get_default ();
93
Slingshot.icon_theme = Gtk.IconTheme.get_default ();
105
app_system = new AppSystem ();
95
app_system = new Backend.AppSystem ();
107
97
categories = app_system.get_categories ();
108
98
apps = app_system.get_apps ();
149
139
top = new Gtk.Grid ();
151
var top_separator = new Label (""); // A fake label
141
var top_separator = new Gtk.Label (""); // A fake label
152
142
top_separator.set_hexpand(true);
154
view_selector = new ModeButton ();
144
view_selector = new Granite.Widgets.ModeButton ();
156
var image = new Image.from_icon_name ("view-grid-symbolic", IconSize.MENU);
146
var image = new Gtk.Image.from_icon_name ("view-grid-symbolic", Gtk.IconSize.MENU);
157
147
image.tooltip_text = _("View as Grid");
158
148
view_selector.append (image);
160
image = new Image.from_icon_name ("view-filter-symbolic", IconSize.MENU);
150
image = new Gtk.Image.from_icon_name ("view-filter-symbolic", Gtk.IconSize.MENU);
161
151
image.tooltip_text = _("View by Category");
162
152
view_selector.append (image);
180
170
center = new Gtk.Grid ();
181
171
// Create the layout which works like view_manager
182
view_manager = new Layout (null, null);
172
view_manager = new Gtk.Layout (null, null);
183
173
view_manager.set_size_request (default_columns * 130, default_rows * 145);
184
174
center.attach (view_manager, 0, 0, 1, 1);
188
178
view_manager.put (grid_view, 0, 0);
190
180
// Create the "SEARCH_VIEW"
191
search_view = new SearchView (this);
192
foreach (ArrayList<App> app_list in apps.values) {
181
search_view = new Widgets.SearchView (this);
182
foreach (Gee.ArrayList<Backend.App> app_list in apps.values) {
193
183
search_view.add_apps (app_list);
195
185
view_manager.put (search_view, -columns * 130, 0);
197
187
// Create the "CATEGORY_VIEW"
198
category_view = new CategoryView (this);
188
category_view = new Widgets.CategoryView (this);
199
189
view_manager.put (category_view, -columns * 130, 0);
201
191
// Create the page switcher
202
page_switcher = new Switcher ();
192
page_switcher = new Widgets.Switcher ();
204
194
// A bottom widget to keep the page switcher center
205
195
bottom = new Gtk.Grid ();
208
var bottom_separator1 = new Label (""); // A fake label
198
var bottom_separator1 = new Gtk.Label (""); // A fake label
209
199
bottom_separator1.set_hexpand (true);
210
var bottom_separator2 = new Label (""); // A fake label
200
var bottom_separator2 = new Gtk.Label (""); // A fake label
211
201
bottom_separator2.set_hexpand (true);
212
202
bottom.attach (bottom_separator1, 0, 0, 1, 1); // A fake label
213
203
bottom.attach (page_switcher, 1, 0, 1, 1);
220
210
event_box = new Gtk.EventBox ();
221
211
event_box.add (container);
222
212
// Add the container to the dialog's content area
223
content_area = get_content_area () as Box;
213
content_area = get_content_area () as Gtk.Box;
224
214
content_area.pack_start (event_box);
226
216
if (Slingshot.settings.use_category)
294
284
//view_manager.draw.connect (this.draw_background);
296
286
event_box.key_press_event.connect (on_key_press);
297
searchbar.text_changed_pause.connect ((text) => this.search (text));
287
searchbar.text_changed_pause.connect ((text) => this.search.begin (text));
298
288
searchbar.grab_focus ();
300
290
searchbar.activate.connect (() => {
302
292
search_view.launch_selected ();
305
if (get_focus () as AppEntry != null) // checking the selected widget is an AppEntry
306
((AppEntry) get_focus ()).launch_app ();
295
if (get_focus () as Widgets.AppEntry != null) // checking the selected widget is an AppEntry
296
((Widgets.AppEntry) get_focus ()).launch_app ();
433
423
search_view.launch_selected ();
436
if (get_focus () as AppEntry != null) // checking the selected widget is an AppEntry
437
((AppEntry)get_focus ()).launch_app ();
426
if (get_focus () as Widgets.AppEntry != null) // checking the selected widget is an AppEntry
427
((Widgets.AppEntry)get_focus ()).launch_app ();
836
826
page_switcher.append ("1");
837
827
page_switcher.set_active (0);
839
foreach (App app in app_system.get_apps_by_name ()) {
829
foreach (Backend.App app in app_system.get_apps_by_name ()) {
841
var app_entry = new AppEntry (app);
831
var app_entry = new Widgets.AppEntry (app);
842
832
app_entry.app_launched.connect (() => hide ());
843
833
grid_view.append (app_entry);
844
834
app_entry.show_all ();
880
870
private void normal_move_focus (int delta_column, int delta_row) {
881
if (get_focus () as AppEntry != null) { // we check if any AppEntry has focus. If it does, we move
871
if (get_focus () as Widgets.AppEntry != null) { // we check if any AppEntry has focus. If it does, we move
882
872
var new_focus = grid_view.get_child_at (column_focus + delta_column, row_focus + delta_row); // we check if the new widget exists
883
873
if (new_focus == null) {
884
874
if (delta_column <= 0)