1 /* 2 * Copyright 2008-2021 Fabrice Colin 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 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 */ 18 19 #ifndef _PREFSWINDOW_HH 20 #define _PREFSWINDOW_HH 21 22 #include <string> 23 #include <map> 24 #include <set> 25 #include <vector> 26 #include <glibmm/refptr.h> 27 #include <glibmm/ustring.h> 28 #include <gtkmm/builder.h> 29 #include <gtkmm/checkbutton.h> 30 #include <gtkmm/colorbutton.h> 31 #include <gtkmm/comboboxtext.h> 32 #include <gtkmm/liststore.h> 33 #include <gtkmm/notebook.h> 34 #include <gtkmm/radiobutton.h> 35 #include <gtkmm/spinbutton.h> 36 #include <gtkmm/table.h> 37 #include <gtkmm/window.h> 38 39 #include "PinotSettings.h" 40 #include "ModelColumns.h" 41 #include "UIThreads.h" 42 43 class PrefsWindow : public Gtk::Window 44 { 45 public: 46 PrefsWindow(_GtkWindow *&pParent, Glib::RefPtr<Gtk::Builder>& refBuilder); 47 virtual ~PrefsWindow(); 48 49 protected: 50 Gtk::Button *prefsCancelbutton; 51 Gtk::Button *prefsOkbutton; 52 Gtk::TreeView *directoriesTreeview; 53 Gtk::Button *addDirectoryButton; 54 Gtk::Button *removeDirectoryButton; 55 Gtk::TreeView *patternsTreeview; 56 Gtk::ComboBoxText *patternsCombobox; 57 Gtk::Button *addPatternButton; 58 Gtk::Button *removePatternButton; 59 Gtk::Button *resetPatternsButton; 60 Gtk::TreeView *labelsTreeview; 61 Gtk::Button *addLabelButton; 62 Gtk::Button *removeLabelButton; 63 Gtk::RadioButton *directConnectionRadiobutton; 64 Gtk::RadioButton *proxyRadiobutton; 65 Gtk::Entry *proxyAddressEntry; 66 Gtk::SpinButton *proxyPortSpinbutton; 67 Gtk::ComboBoxText *proxyTypeCombobox; 68 Gtk::Label *apiKeyLabel; 69 Gtk::Entry *apiKeyEntry; 70 Gtk::CheckButton *enableCompletionCheckbutton; 71 Gtk::ColorButton *newResultsColorbutton; 72 Gtk::CheckButton *ignoreRobotsCheckbutton; 73 Gtk::Label *robotsLabels; 74 Gtk::Table *generalTable; 75 Gtk::Notebook *prefsNotebook; 76 77 PinotSettings &m_settings; 78 Glib::RefPtr<Gtk::ListStore> m_refViewTree; 79 LabelModelColumns m_labelsColumns; 80 Glib::RefPtr<Gtk::ListStore> m_refLabelsTree; 81 IndexableModelColumns m_directoriesColumns; 82 Glib::RefPtr<Gtk::ListStore> m_refDirectoriesTree; 83 TimestampedModelColumns m_mailColumns; 84 TimestampedModelColumns m_patternsColumns; 85 Glib::RefPtr<Gtk::ListStore> m_refPatternsTree; 86 std::vector<Gtk::Entry *> m_editableValueEntries; 87 std::set<std::string> m_addedLabels; 88 std::set<std::string> m_deletedLabels; 89 std::set<std::string> m_deletedDirectories; 90 std::string m_directoriesHash; 91 std::string m_patternsHash; 92 class InternalState : public QueueManager 93 { 94 public: 95 InternalState(PrefsWindow *pWindow); 96 ~InternalState(); 97 98 bool m_savedPrefs; 99 100 } m_state; 101 102 // Handlers defined in the XML file 103 virtual void on_prefsCancelbutton_clicked(); 104 virtual void on_prefsOkbutton_clicked(); 105 virtual void on_addDirectoryButton_clicked(); 106 virtual void on_removeDirectoryButton_clicked(); 107 virtual void on_patternsCombobox_changed(); 108 virtual void on_addPatternButton_clicked(); 109 virtual void on_removePatternButton_clicked(); 110 virtual void on_resetPatternsButton_clicked(); 111 virtual void on_addLabelButton_clicked(); 112 virtual void on_removeLabelButton_clicked(); 113 virtual void on_directConnectionRadiobutton_toggled(); 114 virtual bool on_prefsWindow_delete_event(GdkEventAny *ev); 115 116 // Handlers 117 void on_thread_end(WorkerThread *pThread); 118 void updateLabelRow(const Glib::ustring &path_string, const Glib::ustring &text); 119 void renderLabelNameColumn(Gtk::CellRenderer *pRenderer, const Gtk::TreeModel::iterator &iter); 120 void attach_value_widgets(const std::string &name, const std::string &value, guint rowNumber); 121 void populate_proxyTypeCombobox(); 122 void populate_labelsTreeview(); 123 void save_labelsTreeview(); 124 void populate_directoriesTreeview(); 125 bool save_directoriesTreeview(); 126 void populate_patternsCombobox(); 127 void populate_patternsTreeview(const std::set<Glib::ustring> &patternsList, bool isBlackList); 128 bool save_patternsTreeview(); 129 130 }; 131 132 #endif 133