13
0

rearrange and redesign UIConfiguration/ARDOUR_UI APIs to allow correct initialization.

We need to be able to set an environment variable *before* gtk_init() is called, but also to
load the color theme right after gtk_init() and before the rest of the GUI is created.
This commit is contained in:
Paul Davis 2015-05-28 12:46:31 -04:00
parent 34d19ce879
commit 173b007779
5 changed files with 41 additions and 10 deletions

View File

@ -181,10 +181,10 @@ ask_about_configuration_copy (string const & old_dir, string const & new_dir, in
return (msg.run() == Gtk::RESPONSE_YES);
}
ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir, UIConfiguration* uic)
: Gtkmm2ext::UI (PROGRAM_NAME, argcp, argvp)
, ui_config (new UIConfiguration)
, ui_config (uic->post_gui_init ())
, session_loaded (false)
, gui_object_state (new GUIObjectState)
, primary_clock (new MainClock (X_("primary"), X_("transport"), true ))

View File

@ -140,7 +140,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
UIConfiguration* ui_config;
public:
ARDOUR_UI (int *argcp, char **argvp[], const char* localedir);
ARDOUR_UI (int *argcp, char **argvp[], const char* localedir, UIConfiguration*);
~ARDOUR_UI();
bool run_startup (bool should_be_new, std::string load_template);

View File

@ -345,8 +345,15 @@ int main (int argc, char *argv[])
}
#endif
UIConfiguration* ui_config = new UIConfiguration;
if (ui_config->pre_gui_init ()) {
error << _("Could not complete pre-GUI initialization") << endmsg;
exit (1);
}
try {
ui = new ARDOUR_UI (&argc, &argv, localedir.c_str());
ui = new ARDOUR_UI (&argc, &argv, localedir.c_str(), ui_config);
} catch (failed_constructor& err) {
error << string_compose (_("could not create %1 GUI"), PROGRAM_NAME) << endmsg;
exit (1);

View File

@ -78,10 +78,6 @@ UIConfiguration::UIConfiguration ()
ARDOUR_UI_UTILS::ColorsChanged.connect (boost::bind (&UIConfiguration::colors_changed, this));
ParameterChanged.connect (sigc::mem_fun (*this, &UIConfiguration::parameter_changed));
/* force GTK theme setting, so that loading an RC file will work */
load_color_theme ();
}
UIConfiguration::~UIConfiguration ()
@ -151,6 +147,23 @@ UIConfiguration::map_parameters (boost::function<void (std::string)>& functor)
#undef UI_CONFIG_VARIABLE
}
int
UIConfiguration::pre_gui_init ()
{
if (get_buggy_gradients()) {
g_setenv ("FORCE_BUGGY_GRADIENTS", "1", 1);
}
return 0;
}
UIConfiguration*
UIConfiguration::post_gui_init ()
{
load_color_theme ();
return this;
}
int
UIConfiguration::load_defaults ()
{
@ -177,13 +190,14 @@ UIConfiguration::load_defaults ()
warning << string_compose (_("Could not find default UI configuration file %1"), default_ui_config_file_name) << endmsg;
}
if (ret == 0) {
/* reload color theme */
load_color_theme (false);
ARDOUR_UI_UTILS::ColorsChanged (); /* EMIT SIGNAL */
}
return 0;
return ret;
}
int

View File

@ -48,6 +48,7 @@ class UIConfiguration : public PBD::Stateful
int load_state ();
int save_state ();
int load_defaults ();
int load_color_theme (bool allow_own=true);
int set_state (const XMLNode&, int version);
XMLNode& get_state (void);
@ -79,6 +80,16 @@ class UIConfiguration : public PBD::Stateful
void map_parameters (boost::function<void (std::string)>&);
void parameter_changed (std::string);
/** called before initializing any part of the GUI. Sets up
* any runtime environment required to make the GUI work
* in specific ways.
*/
int pre_gui_init ();
/** called after the GUI toolkit has been initialized.
*/
UIConfiguration* post_gui_init ();
#undef UI_CONFIG_VARIABLE
#define UI_CONFIG_VARIABLE(Type,var,name,value) \
@ -118,7 +129,6 @@ class UIConfiguration : public PBD::Stateful
void load_modifiers (XMLNode const &);
void reset_gtk_theme ();
void colors_changed ();
int load_color_theme (bool allow_own=true);
uint32_t block_save;
};