Horizon
pnp_export_window.hpp
1 #pragma once
2 #include <array>
3 #include <gtkmm.h>
4 #include <set>
5 #include "util/window_state_store.hpp"
6 #include "util/changeable.hpp"
7 #include "util/export_file_chooser.hpp"
8 #include "board/pnp.hpp"
9 #include "widgets/column_chooser.hpp"
10 
11 namespace horizon {
12 
13 class PnPExportWindow : public Gtk::Window, public Changeable {
14 
15 public:
16  PnPExportWindow(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &x, const class Board &brd,
17  class PnPExportSettings &settings, const std::string &project_dir);
18  static PnPExportWindow *create(Gtk::Window *p, const class Board &brd, class PnPExportSettings &settings,
19  const std::string &project_dir);
20 
21  void set_can_export(bool v);
22  void generate();
23  void update_preview();
24  void update();
25 
26 private:
27  const class Board &board;
28  class PnPExportSettings &settings;
29 
30  ExportFileChooser export_filechooser;
31 
32  Gtk::Button *export_button = nullptr;
33  Gtk::Label *done_label = nullptr;
34  Gtk::Revealer *done_revealer = nullptr;
35  Gtk::Entry *directory_entry = nullptr;
36  Gtk::Button *directory_button = nullptr;
37 
38  Gtk::ComboBoxText *mode_combo = nullptr;
39  Gtk::CheckButton *nopopulate_check = nullptr;
40  Gtk::Label *filename_merged_label = nullptr;
41  Gtk::Label *filename_top_label = nullptr;
42  Gtk::Label *filename_bottom_label = nullptr;
43  Gtk::Entry *filename_merged_entry = nullptr;
44  Gtk::Entry *filename_top_entry = nullptr;
45  Gtk::Entry *filename_bottom_entry = nullptr;
46  bool can_export = true;
47  void update_export_button();
48 
49  void update_filename_visibility();
50 
51  Gtk::TreeView *preview_tv = nullptr;
52 
53  WindowStateStore state_store;
54 
55  ColumnChooser *column_chooser = nullptr;
56 
57  class MyAdapter : public ColumnChooser::Adapter<PnPColumn> {
58  public:
60  std::string get_column_name(int col) const override;
61  std::map<int, std::string> get_column_names() const override;
62  };
63 
64  MyAdapter adapter;
65 
66  void flash(const std::string &s);
67  sigc::connection flash_connection;
68 
69  class ListColumnsPreview : public Gtk::TreeModelColumnRecord {
70  public:
71  ListColumnsPreview()
72  {
73  Gtk::TreeModelColumnRecord::add(row);
74  }
75  Gtk::TreeModelColumn<PnPRow> row;
76  };
77  ListColumnsPreview list_columns_preview;
78 
79  Glib::RefPtr<Gtk::ListStore> store;
80 };
81 } // namespace horizon
horizon::ExportFileChooser
Definition: export_file_chooser.hpp:7
horizon::WindowStateStore
Definition: window_state_store.hpp:20
horizon::Changeable
Definition: changeable.hpp:5
horizon::Board
Definition: board.hpp:42
horizon::PnPExportWindow
Definition: pnp_export_window.hpp:13
horizon::PnPExportSettings
Definition: pnp_export_settings.hpp:11
horizon::ColumnChooser
Definition: column_chooser.hpp:6
horizon::ColumnChooser::Adapter
Definition: column_chooser.hpp:23