1 #ifndef LAUNCHERS_HPP 2 #define LAUNCHERS_HPP 3 4 #include "../widget.hpp" 5 #include <vector> 6 #include <giomm/desktopappinfo.h> 7 #include <gdkmm/pixbuf.h> 8 #include <gtkmm/image.h> 9 #include <gtkmm/hvbox.h> 10 #include <gtkmm/eventbox.h> 11 #include <wayfire/util/duration.hpp> 12 13 #define LAUNCHERS_ICON_SCALE 1.42 14 15 struct LauncherInfo 16 { 17 virtual Glib::RefPtr<Gdk::Pixbuf> get_pixbuf(int32_t size) = 0; 18 virtual std::string get_text() = 0; 19 virtual void execute() = 0; ~LauncherInfoLauncherInfo20 virtual ~LauncherInfo() {} 21 }; 22 23 class LauncherAnimation : 24 public wf::animation::duration_t, 25 public wf::animation::timed_transition_t 26 { 27 public: LauncherAnimation(wf::option_sptr_t<int> length,int start,int end)28 LauncherAnimation(wf::option_sptr_t<int> length, int start, int end) : 29 duration_t(length, wf::animation::smoothing::linear), 30 timed_transition_t((duration_t&)*this) 31 { 32 this->set(start, end); 33 this->duration_t::start(); 34 } 35 }; 36 37 struct WfLauncherButton 38 { 39 std::string launcher_name; 40 int32_t base_size; 41 42 Gtk::Image image; 43 Gtk::EventBox evbox; 44 LauncherInfo *info = NULL; 45 LauncherAnimation current_size{wf::create_option(1000), 0, 0}; 46 47 WfLauncherButton(); 48 WfLauncherButton(const WfLauncherButton& other) = delete; 49 WfLauncherButton& operator = (const WfLauncherButton&) = delete; 50 ~WfLauncherButton(); 51 52 bool initialize(std::string name, std::string icon = "none", std::string label = ""); 53 54 bool on_click(GdkEventButton *ev); 55 bool on_enter(GdkEventCrossing *ev); 56 bool on_leave(GdkEventCrossing *ev); 57 bool on_draw(const Cairo::RefPtr<Cairo::Context>& ctx); 58 void on_scale_update(); 59 60 void set_size(int size); 61 }; 62 63 using launcher_container = std::vector<std::unique_ptr<WfLauncherButton>>; 64 class WayfireLaunchers : public WayfireWidget 65 { 66 Gtk::HBox box; 67 launcher_container launchers; 68 launcher_container get_launchers_from_config(); 69 70 public: 71 virtual void init(Gtk::HBox *container); 72 virtual void handle_config_reload(); ~WayfireLaunchers()73 virtual ~WayfireLaunchers() {}; 74 }; 75 76 77 #endif /* end of include guard: LAUNCHERS_HPP */ 78