1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
/*
* Copyright (C) 2013-2025 Graeme Gott <graeme@gottcode.org>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WHISKERMENU_WINDOW_H
#define WHISKERMENU_WINDOW_H
#include <vector>
#include <gtk/gtk.h>
namespace WhiskerMenu
{
class ApplicationsPage;
class CategoryButton;
class FavoritesPage;
class Page;
class Plugin;
class Profile;
class Resizer;
class RecentPage;
class SearchPage;
class Window
{
public:
explicit Window(Plugin* plugin);
~Window();
Window(const Window&) = delete;
Window(Window&&) = delete;
Window& operator=(const Window&) = delete;
Window& operator=(Window&&) = delete;
enum Position
{
PositionAtButton,
PositionAtCursor,
PositionAtCenter
};
GtkWidget* get_widget() const
{
return GTK_WIDGET(m_window);
}
GtkEntry* get_search_entry() const
{
return m_search_entry;
}
ApplicationsPage* get_applications() const
{
return m_applications;
}
FavoritesPage* get_favorites() const
{
return m_favorites;
}
RecentPage* get_recent() const
{
return m_recent;
}
Page* get_active_page();
void hide(bool lost_focus = false);
void show(const Position position);
void resize(int delta_x, int delta_y, int delta_width, int delta_height);
void resize_start();
void resize_end();
void set_child_has_focus();
void set_categories(const std::vector<CategoryButton*>& categories);
void set_items();
void set_loaded();
void unset_items();
private:
GtkWidget* get_active_category_button();
gboolean on_key_press_event(GtkWidget* widget, GdkEventKey* key_event);
gboolean on_key_press_event_after(GtkWidget* widget, GdkEventKey* key_event);
gboolean on_map_event();
void on_state_flags_changed(GtkWidget* widget);
void on_screen_changed(GtkWidget* widget);
gboolean on_draw_event(GtkWidget* widget, cairo_t* cr);
void check_scrollbar_needed();
void favorites_toggled();
void recent_toggled();
void category_toggled();
void center_window();
void move_window();
bool set_size(int width, int height);
void reset_default_button();
void show_favorites();
void show_default_page();
void search();
void update_layout();
private:
Plugin* m_plugin;
GtkWindow* m_window;
GtkStack* m_window_stack;
GtkSpinner* m_window_load_spinner;
GtkBox* m_vbox;
GtkBox* m_title_box;
GtkBox* m_commands_box;
GtkBox* m_search_box;
GtkStack* m_contents_stack;
GtkGrid* m_contents_box;
GtkBox* m_categories_box;
GtkStack* m_panels_stack;
Resizer* m_resize[8];
Position m_position;
GdkRectangle m_monitor;
Profile* m_profile;
GtkWidget* m_commands_spacer;
GtkWidget* m_commands_button[9];
gulong m_command_slots[9];
GtkEntry* m_search_entry;
SearchPage* m_search_results;
FavoritesPage* m_favorites;
RecentPage* m_recent;
ApplicationsPage* m_applications;
GtkScrolledWindow* m_sidebar;
GtkBox* m_category_buttons;
CategoryButton* m_default_button;
GtkSizeGroup* m_sidebar_size_group;
GdkRectangle m_geometry;
bool m_layout_ltr;
bool m_layout_categories_horizontal;
bool m_layout_categories_alternate;
bool m_layout_search_alternate;
bool m_layout_commands_alternate;
bool m_layout_profile_alternate;
int m_profile_shape;
bool m_supports_alpha;
bool m_child_has_focus;
bool m_resizing;
};
}
#endif // WHISKERMENU_WINDOW_H
|