summaryrefslogtreecommitdiffstats
path: root/src/ui/widget/completion-popup.h
blob: b7b77a11729f23f465af7a2f6a59caef6a9960a1 (plain)
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
// SPDX-License-Identifier: GPL-2.0-or-later


#ifndef INKSCAPE_UI_WIDGET_COMPLETION_POPUP_H
#define INKSCAPE_UI_WIDGET_COMPLETION_POPUP_H

#include <glibmm/refptr.h>
#include <glibmm/ustring.h>
#include <gtkmm/builder.h>
#include <gtkmm/entrycompletion.h>
#include <gtkmm/liststore.h>
#include <gtkmm/menu.h>
#include <gtkmm/menubutton.h>
#include <gtkmm/searchentry.h>
#include <sigc++/connection.h>
#include "labelled.h"

namespace Inkscape {
namespace UI {
namespace Widget {

class CompletionPopup : public Gtk::Box {
public:
    CompletionPopup();

    Gtk::Menu& get_menu();
    Gtk::SearchEntry& get_entry();
    Glib::RefPtr<Gtk::ListStore> get_list();

    void clear_completion_list();
    void add_to_completion_list(int id, Glib::ustring name, Glib::ustring icon_name, Glib::ustring search_text = Glib::ustring());

    sigc::signal<void (int)>& on_match_selected();
    sigc::signal<void ()>& on_button_press();
    sigc::signal<bool ()>& on_focus();

private:
    Glib::RefPtr<Gtk::Builder> _builder;
    Glib::RefPtr<Gtk::ListStore> _list;
    Gtk::SearchEntry& _search;
    Gtk::MenuButton& _button;
    Gtk::Menu& _popup;
    Glib::RefPtr<Gtk::EntryCompletion> _completion;
    sigc::signal<void (int)> _match_selected;
    sigc::signal<void ()> _button_press;
    sigc::signal<bool ()> _on_focus;
};

}}} // namespaces

#endif // INKSCAPE_UI_WIDGET_COMPLETION_POPUP_H