GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
gtk-manager.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2007-2018 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if defined (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #include "error.h"
28 #include "graphics-toolkit.h"
29 #include "gtk-manager.h"
30 #include "ovl.h"
31 #include "parse.h"
32 
33 namespace octave
34 {
37  {
39 
40  if (dtk.empty ())
41  error ("no graphics toolkits are available!");
42 
44 
45  if (pl == loaded_toolkits.end ())
46  {
48 
49  if (pa == available_toolkits.end ())
50  error ("default graphics toolkit '%s' is not available!",
51  dtk.c_str ());
52 
53  octave_value_list args;
54  args(0) = dtk;
55  octave::feval ("graphics_toolkit", args);
56 
57  pl = loaded_toolkits.find (dtk);
58 
59  if (pl == loaded_toolkits.end ())
60  error ("failed to load %s graphics toolkit", dtk.c_str ());
61 
62  retval = pl->second;
63  }
64  else
65  retval = pl->second;
66 
67  return retval;
68  }
69 
70  void
72  {
73  if (dtk.empty () || name == "qt"
74  || (name == "fltk"
75  && available_toolkits.find ("qt") == available_toolkits.end ()))
76  dtk = name;
77 
78  available_toolkits.insert (name);
79  }
80 
81  void
83  {
84  available_toolkits.erase (name);
85 
86  if (dtk == name)
87  {
88  if (available_toolkits.empty ())
89  dtk.clear ();
90  else
91  {
93 
94  dtk = *pa++;
95 
96  while (pa != available_toolkits.end ())
97  {
98  std::string tk_name = *pa++;
99 
100  if (tk_name == "qt"
101  || (tk_name == "fltk"
102  && (available_toolkits.find ("qt")
103  == available_toolkits.end ())))
104  dtk = tk_name;
105  }
106  }
107  }
108  }
109 }
OCTINTERP_API octave_value_list feval(const std::string &name, const octave_value_list &args=octave_value_list(), int nargout=0)
std::set< std::string > available_toolkits
Definition: gtk-manager.h:120
void unregister_toolkit(const std::string &name)
Definition: gtk-manager.cc:82
void error(const char *fmt,...)
Definition: error.cc:578
std::map< std::string, graphics_toolkit >::const_iterator const_loaded_toolkits_iterator
Definition: gtk-manager.h:134
nd deftypefn *std::string name
Definition: sysdep.cc:647
std::set< std::string >::const_iterator const_available_toolkits_iterator
Definition: gtk-manager.h:128
octave_value retval
Definition: data.cc:6246
void register_toolkit(const std::string &name)
Definition: gtk-manager.cc:71
std::map< std::string, graphics_toolkit > loaded_toolkits
Definition: gtk-manager.h:123
graphics_toolkit get_toolkit(void) const
Definition: gtk-manager.cc:36
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888