Ardour  9.0-pre0-822-g12e3bc5c20
library_download_dialog.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 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 #ifndef __gtk2_ardour_library_download_dialog_h__
20 #define __gtk2_ardour_library_download_dialog_h__
21 
22 #include <string>
23 
24 #include <ytkmm/cellrendererprogress.h>
25 #include <ytkmm/cellrenderertext.h>
26 #include <ytkmm/entry.h>
27 #include <ytkmm/liststore.h>
28 #include <ytkmm/scrolledwindow.h>
29 #include <ytkmm/treeview.h>
30 #include <ytkmm/textview.h>
31 
32 #include "ardour_dialog.h"
33 
34 namespace PBD {
35  class Inflater;
36  class Downloader;
37 }
38 
39 namespace ARDOUR {
40  class LibraryDescription;
41  class LibraryFetcher;
42 }
43 
45 {
46  public:
49 
51  void on_show ();
52 
53  private:
54  class LibraryColumns : public Gtk::TreeModelColumnRecord {
55  public:
57  add (name);
58  add (author);
59  add (license);
60  add (size);
61  add (installed);
62  add (description);
63  add (url);
64  add (toplevel);
65  add (install);
66  add (progress);
67  add (downloader);
68  }
69 
70  Gtk::TreeModelColumn<std::string> name;
71  Gtk::TreeModelColumn<std::string> author;
72  Gtk::TreeModelColumn<std::string> license;
73  Gtk::TreeModelColumn<std::string> size;
74  Gtk::TreeModelColumn<std::string> install;
75  Gtk::TreeModelColumn<bool> installed;
76  /* these are not displayed */
77  Gtk::TreeModelColumn<std::string> url;
78  Gtk::TreeModelColumn<std::string> toplevel;
79  Gtk::TreeModelColumn<PBD::Downloader*> downloader;
80  Gtk::TreeModelColumn<int> progress;
81  /* used as tooltip */
82  Gtk::TreeModelColumn<std::string> description;
83  };
84 
85  Gtk::TreeView _display;
86  Gtk::ScrolledWindow scroller;
87  Glib::RefPtr<Gtk::ListStore> _model;
89 
90  template <class T>
91  Gtk::TreeViewColumn* append_col (Gtk::TreeModelColumn<T> const& col, int width = 0)
92  {
93  Gtk::TreeViewColumn* c = manage (new Gtk::TreeViewColumn ("", col));
94  if (width) {
95  c->set_fixed_width (width);
96  c->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
97  }
98  _display.append_column (*c);
99  return c;
100  }
101 
102  Gtk::CellRendererProgress* progress_renderer;
103  Gtk::CellRendererText* install_renderer;
104 
107 
108  void download (Gtk::TreePath const &);
109 
110  bool dl_timer_callback (PBD::Downloader*, Gtk::TreePath);
111  bool display_button_press (GdkEventButton* ev);
112 
114  void install (std::string const & path, Gtk::TreePath const & treepath);
115  void install_progress (float, std::string, Gtk::TreePath);
116  void install_finished (Gtk::TreeModel::iterator row, std::string path, int status);
118 
119  Gtk::TextView description_view;
121  void refill ();
122 };
123 
124 
125 
126 #endif /* __gtk2_ardour_library_download_dialog_h__ */
Gtk::TreeModelColumn< std::string > install
Gtk::TreeModelColumn< std::string > author
Gtk::TreeModelColumn< std::string > size
Gtk::TreeModelColumn< std::string > toplevel
Gtk::TreeModelColumn< PBD::Downloader * > downloader
Gtk::TreeModelColumn< std::string > description
Gtk::TreeModelColumn< std::string > license
Gtk::TreeModelColumn< std::string > name
Gtk::TreeModelColumn< std::string > url
Gtk::CellRendererProgress * progress_renderer
PBD::ScopedConnection install_connection
Gtk::CellRendererText * install_renderer
void install(std::string const &path, Gtk::TreePath const &treepath)
void install_progress(float, std::string, Gtk::TreePath)
Gtk::TreeViewColumn * append_col(Gtk::TreeModelColumn< T > const &col, int width=0)
bool dl_timer_callback(PBD::Downloader *, Gtk::TreePath)
void add_library(ARDOUR::LibraryDescription const &)
void download(Gtk::TreePath const &)
bool display_button_press(GdkEventButton *ev)
Glib::RefPtr< Gtk::ListStore > _model
void install_finished(Gtk::TreeModel::iterator row, std::string path, int status)
Gtk::ScrolledWindow scroller
Definition: axis_view.h:42