1 /* 2 * gnote 3 * 4 * Copyright (C) 2010-2017,2019-2021 Aurimas Cernius 5 * Copyright (C) 2010 Debarshi Ray 6 * Copyright (C) 2009 Hubert Figuiere 7 * 8 * This program is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 23 24 #ifndef __NOTE_RECENT_CHANGES_HPP_ 25 #define __NOTE_RECENT_CHANGES_HPP_ 26 27 #include <gtkmm/applicationwindow.h> 28 #include <gtkmm/grid.h> 29 #include <gtkmm/popovermenu.h> 30 31 #include "mainwindowaction.hpp" 32 #include "note.hpp" 33 #include "searchnoteswidget.hpp" 34 #include "utils.hpp" 35 36 namespace gnote { 37 class IGnote; 38 class NoteManagerBase; 39 40 class NoteRecentChanges 41 : public MainWindow 42 { 43 public: 44 NoteRecentChanges(IGnote & g, NoteManagerBase & m); 45 virtual ~NoteRecentChanges(); 46 virtual void show_search_bar(bool grab_focus = true) override; 47 virtual void set_search_text(const Glib::ustring & value) override; 48 virtual void new_note() override; 49 virtual void present_search() override; 50 virtual void close_window() override; 51 virtual bool is_search() override; keybinder()52 virtual utils::GlobalKeybinder & keybinder() override 53 { 54 return m_keybinder; 55 } 56 57 virtual void embed_widget(EmbeddableWidget &) override; 58 virtual void unembed_widget(EmbeddableWidget &) override; 59 virtual void foreground_embedded(EmbeddableWidget &) override; 60 virtual void background_embedded(EmbeddableWidget &) override; running()61 virtual bool running() 62 { 63 return m_mapped; 64 } 65 virtual bool contains(EmbeddableWidget &) override; 66 virtual bool is_foreground(EmbeddableWidget &) override; 67 virtual MainWindowAction::Ptr find_action(const Glib::ustring & name) override; 68 virtual void enabled(bool is_enabled) override; 69 protected: 70 virtual void present_note(const Note::Ptr & note) override; 71 virtual void on_show() override; 72 virtual bool on_map_event(GdkEventAny *evt) override; 73 private: 74 void on_open_note(const Note::Ptr &); 75 void on_open_note_new_window(const Note::Ptr &); 76 void on_delete_note(); 77 bool on_delete(GdkEventAny *); 78 bool on_key_pressed(GdkEventKey *); 79 EmbeddableWidget *currently_foreground(); 80 void make_header_bar(); 81 void make_search_box(); 82 void make_find_next_prev(); 83 bool on_entry_key_pressed(GdkEventKey *); 84 void on_entry_changed(); 85 void on_entry_activated(); 86 void entry_changed_timeout(); 87 Glib::ustring get_search_text(); 88 void update_toolbar(EmbeddableWidget & widget); 89 void update_search_bar(EmbeddableWidget & widget, bool perform_search); 90 void on_all_notes_button_clicked(); 91 void on_show_window_menu(); 92 void on_search_button_toggled(); 93 void on_find_next_button_clicked(); 94 void on_find_prev_button_clicked(); 95 Gtk::PopoverMenu *make_window_menu(Gtk::Button *button, std::vector<PopoverWidget> && items); 96 void on_embedded_name_changed(const Glib::ustring & name); 97 bool on_notes_widget_key_press(GdkEventKey*); 98 void on_close_window(const Glib::VariantBase&); 99 void add_action(const MainWindowAction::Ptr & action); 100 void on_popover_widgets_changed(); 101 102 IGnote &m_gnote; 103 NoteManagerBase &m_note_manager; 104 Preferences &m_preferences; 105 Gtk::Widget *m_header_bar; 106 SearchNotesWidget *m_search_notes_widget; 107 Gtk::Grid *m_search_box; 108 Gtk::Grid *m_find_next_prev_box; 109 union 110 { 111 Gtk::SearchEntry *m_search_entry; 112 Glib::ustring *m_search_text; 113 }; 114 Gtk::ToggleButton m_search_button; 115 Gtk::Grid m_embedded_toolbar; 116 Gtk::Grid m_embed_box; 117 Gtk::Button *m_all_notes_button; 118 Gtk::Button *m_new_note_button; 119 Gtk::Button *m_window_actions_button; 120 EmbeddableWidget* m_embedded_widget; 121 bool m_mapped; 122 sigc::connection m_current_embedded_name_slot; 123 sigc::connection m_signal_popover_widgets_changed_cid; 124 utils::InterruptableTimeout *m_entry_changed_timeout; 125 Gtk::PopoverMenu *m_window_menu_embedded; 126 Gtk::PopoverMenu *m_window_menu_default; 127 Glib::RefPtr<Gtk::AccelGroup> m_accel_group; 128 utils::GlobalKeybinder m_keybinder; 129 std::map<Glib::ustring, MainWindowAction::Ptr> m_actions; 130 }; 131 132 133 } 134 135 #endif 136