1 /*
2  * Copyright (C) 2013-2021 Graeme Gott <graeme@gottcode.org>
3  *
4  * This library is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef WHISKERMENU_PAGE_H
19 #define WHISKERMENU_PAGE_H
20 
21 #include <gtk/gtk.h>
22 
23 namespace WhiskerMenu
24 {
25 
26 class CategoryButton;
27 class DesktopAction;
28 class Launcher;
29 class LauncherView;
30 class Window;
31 
32 class Page
33 {
34 public:
35 	explicit Page(Window* window, const gchar* icon = nullptr, const gchar* text = nullptr);
36 	virtual ~Page();
37 
38 	Page(const Page&) = delete;
39 	Page(Page&&) = delete;
40 	Page& operator=(const Page&) = delete;
41 	Page& operator=(Page&&) = delete;
42 
get_widget()43 	GtkWidget* get_widget() const
44 	{
45 		return m_widget;
46 	}
47 
get_button()48 	CategoryButton* get_button() const
49 	{
50 		return m_button;
51 	}
52 
get_view()53 	LauncherView* get_view() const
54 	{
55 		return m_view;
56 	}
57 
58 	void reset_selection();
59 	void select_first();
60 	void update_view();
61 
62 protected:
get_window()63 	Window* get_window() const
64 	{
65 		return m_window;
66 	}
67 
view_created()68 	virtual void view_created()
69 	{
70 	}
71 
72 	void set_reorderable(bool reorderable);
73 
74 private:
75 	void create_view();
76 	virtual bool remember_launcher(Launcher* launcher);
77 	void launcher_activated(GtkTreePath* path);
78 	void launcher_action_activated(GtkMenuItem* menuitem, DesktopAction* action);
79 	gboolean view_button_press_event(GdkEvent* event);
80 	gboolean view_button_release_event(GdkEvent* event);
81 	void view_drag_data_get(GtkSelectionData* data, guint info);
82 	void view_drag_end();
83 	gboolean view_popup_menu_event();
84 	void add_selected_to_desktop();
85 	void add_selected_to_panel();
86 	void edit_selected();
87 	void create_context_menu(GtkTreePath* path, GdkEvent* event);
88 	virtual void extend_context_menu(GtkWidget* menu);
89 
90 private:
91 	Window* m_window;
92 	CategoryButton* m_button;
93 	GtkWidget* m_widget;
94 	LauncherView* m_view;
95 	Launcher* m_selected_launcher;
96 	bool m_drag_enabled;
97 	bool m_launcher_dragged;
98 	bool m_reorderable;
99 };
100 
101 }
102 
103 #endif // WHISKERMENU_PAGE_H
104