Mercurial > hg > octave-nkf
changeset 18653:ca1648b2e673 gui-release
set default toolkit when registering toolkits (bug #41665).
* graphics.in.h, graphics.cc (gtk_manager::gtk_manager):
Don't set default toolkit.
(gtk_manager::do_register_toolkit): Set default toolkit here.
(gtk_manager::do_unregister_toolkit): If removing default toolkit,
reset it using same rules as in do_register_toolkit.
author | Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 10 Mar 2014 10:46:37 -0500 |
parents | 4daf647c86c3 |
children | 26d15a57f45b |
files | libinterp/corefcn/graphics.cc libinterp/corefcn/graphics.in.h |
diffstat | 2 files changed, 43 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.cc +++ b/libinterp/corefcn/graphics.cc @@ -9584,18 +9584,6 @@ gtk_manager *gtk_manager::instance = 0; -gtk_manager::gtk_manager (void) - : dtk (), available_toolkits (), loaded_toolkits () -{ -#if defined (HAVE_QT) - dtk = display_info::display_available () ? "qt" : "gnuplot"; -#elif defined (HAVE_FLTK) - dtk = display_info::display_available () ? "fltk" : "gnuplot"; -#else - dtk = "gnuplot"; -#endif -} - void gtk_manager::create_instance (void) { @@ -9640,6 +9628,45 @@ return retval; } +void +gtk_manager::do_register_toolkit (const std::string& name) +{ + if (dtk.empty () || name == "qt" + || (name == "fltk" + && available_toolkits.find ("qt") == available_toolkits.end ())) + dtk = name; + + available_toolkits.insert (name); +} + +void +gtk_manager::do_unregister_toolkit (const std::string& name) +{ + available_toolkits.erase (name); + + if (dtk == name) + { + if (available_toolkits.empty ()) + dtk.clear (); + else + { + const_available_toolkits_iterator pa = available_toolkits.begin (); + + dtk = *pa++; + + while (pa != available_toolkits.end ()) + { + std::string name = *pa++; + + if (name == "qt" + || (name == "fltk" + && available_toolkits.find ("qt") == available_toolkits.end ())) + dtk = name; + } + } + } +} + DEFUN (available_graphics_toolkits, , , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} available_graphics_toolkits ()\n\
--- a/libinterp/corefcn/graphics.in.h +++ b/libinterp/corefcn/graphics.in.h @@ -2273,7 +2273,7 @@ private: - gtk_manager (void); + gtk_manager (void) { } ~gtk_manager (void) { } @@ -2322,15 +2322,9 @@ graphics_toolkit do_get_toolkit (void) const; - void do_register_toolkit (const std::string& name) - { - available_toolkits.insert (name); - } - - void do_unregister_toolkit (const std::string& name) - { - available_toolkits.erase (name); - } + void do_register_toolkit (const std::string& name); + + void do_unregister_toolkit (const std::string& name); void do_load_toolkit (const graphics_toolkit& tk) {