1 /*
2  * gnote
3  *
4  * Copyright (C) 2013,2015-2017,2019,2021 Aurimas Cernius
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 
21 #ifndef _MAINWINDOWEMBEDS_HPP_
22 #define _MAINWINDOWEMBEDS_HPP_
23 
24 
25 #include <gtkmm/widget.h>
26 
27 #include "mainwindowaction.hpp"
28 #include "popoverwidgets.hpp"
29 
30 
31 namespace gnote {
32 
33 class EmbeddableWidget;
34 class EmbeddableWidgetHost
35 {
36 public:
~EmbeddableWidgetHost()37   virtual ~EmbeddableWidgetHost() {}
38   virtual void embed_widget(EmbeddableWidget &) = 0;
39   virtual void unembed_widget(EmbeddableWidget &) = 0;
40   virtual void foreground_embedded(EmbeddableWidget &) = 0;
41   virtual void background_embedded(EmbeddableWidget &) = 0;
42   virtual bool running() = 0;
43   virtual bool contains(EmbeddableWidget &) = 0;
44   virtual bool is_foreground(EmbeddableWidget &) = 0;
45   virtual MainWindowAction::Ptr find_action(const Glib::ustring & name) = 0;
46   virtual void enabled(bool is_enabled) = 0;
47 };
48 
49 class EmbeddableWidget
50 {
51 public:
EmbeddableWidget()52   EmbeddableWidget() : m_host(NULL) {}
~EmbeddableWidget()53   virtual ~EmbeddableWidget() {}
54   virtual Glib::ustring get_name() const = 0;
55   virtual void embed(EmbeddableWidgetHost *h);
56   virtual void unembed();
57   virtual void foreground();
58   virtual void background();
59   virtual void hint_position(int & x, int & y);
60   virtual void hint_size(int & width, int & height);
61   virtual void size_internals();
set_initial_focus()62   virtual void set_initial_focus() {}
host() const63   EmbeddableWidgetHost *host() const
64     {
65       return m_host;
66     }
67 
68   sigc::signal<void, const Glib::ustring &> signal_name_changed;
69   sigc::signal<void> signal_embedded;
70   sigc::signal<void> signal_unembedded;
71   sigc::signal<void> signal_foregrounded;
72   sigc::signal<void> signal_backgrounded;
73 private:
74   EmbeddableWidgetHost *m_host;
75 };
76 
77 
78 class SearchableItem
79 {
80 public:
~SearchableItem()81   virtual ~SearchableItem() {}
82   virtual void perform_search(const Glib::ustring & search_text) = 0;
83   virtual bool supports_goto_result();
84   virtual bool goto_next_result();
85   virtual bool goto_previous_result();
86 };
87 
88 
89 class HasEmbeddableToolbar
90 {
91 public:
~HasEmbeddableToolbar()92   virtual ~HasEmbeddableToolbar() {}
93   virtual Gtk::Widget *embeddable_toolbar() = 0;
94 };
95 
96 
97 class HasActions
98 {
99 public:
~HasActions()100   virtual ~HasActions() {}
101   virtual std::vector<PopoverWidget> get_popover_widgets() = 0;
102 
103   sigc::signal<void> signal_popover_widgets_changed;
104 };
105 
106 }
107 
108 
109 #endif
110 
111