Ardour  9.0-pre0-1324-g9d17303199
string_completion.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2025 Paul Davis <paul@linuxaudiosystems.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #pragma once
20 
21 #include <vector>
22 #include <ytkmm/entry.h>
23 #include <ytkmm/liststore.h>
24 #include "gtkmm2ext/visibility.h"
25 
26 namespace Gtkmm2ext {
27 
29 {
30  public:
32  StringCompletion (std::vector<Glib::ustring> strVector, bool norepeat = true);
33 
34  virtual ~StringCompletion();
35 
36  void add_string (Glib::ustring str, bool norepeat=true);
37  void clear_strings();
38  void delete_string (Glib::ustring str);
39  void insert_vector (std::vector<Glib::ustring> strVector, bool norepeat = true);
40 
42  void set_case_fold (bool);
43 
44  static Glib::RefPtr<StringCompletion> create();
45  static Glib::RefPtr<StringCompletion> create (std::vector<Glib::ustring> strVector, bool norepeat = true);
46 
47  protected:
48  Glib::RefPtr<Gtk::ListStore> m_refCompletionModel;
49  bool case_fold;
50 
52  {
53  public:
55  {
56  add(col_text);
57  }
59  };
60 
62  bool _delete_string (const Gtk::TreeModel::iterator &iter, const Glib::ustring &str);
63  bool _string_exists (const Glib::ustring &str);
64  bool match_anywhere (Glib::ustring const & str, Gtk::TreeModel::const_iterator const & iter);
65 
66  void init();
67 };
68 
69 } /* namespace */
Gtk::TreeModelColumn< Glib::ustring > col_text
void insert_vector(std::vector< Glib::ustring > strVector, bool norepeat=true)
bool match_anywhere(Glib::ustring const &str, Gtk::TreeModel::const_iterator const &iter)
static Glib::RefPtr< StringCompletion > create(std::vector< Glib::ustring > strVector, bool norepeat=true)
void add_string(Glib::ustring str, bool norepeat=true)
bool _string_exists(const Glib::ustring &str)
CompletionRecord m_completionRecord
Glib::RefPtr< Gtk::ListStore > m_refCompletionModel
static Glib::RefPtr< StringCompletion > create()
bool _delete_string(const Gtk::TreeModel::iterator &iter, const Glib::ustring &str)
void delete_string(Glib::ustring str)
StringCompletion(std::vector< Glib::ustring > strVector, bool norepeat=true)
#define LIBGTKMM2EXT_API
void add(const Gtk::StockItem &item)