Gtk3 by Hombre, issue 2807
This commit is contained in:
109
rtgui/main.cc
109
rtgui/main.cc
@@ -64,7 +64,10 @@ Glib::ustring creditsPath;
|
||||
Glib::ustring licensePath;
|
||||
Glib::ustring argv1;
|
||||
bool simpleEditor;
|
||||
Glib::Thread* mainThread;
|
||||
Glib::RefPtr<Gtk::CssProvider> css;
|
||||
Glib::RefPtr<Gtk::CssProvider> cssSlim;
|
||||
Glib::RefPtr<Gtk::CssProvider> cssForced;
|
||||
//Glib::Threads::Thread* mainThread;
|
||||
|
||||
|
||||
// This recursive mutex will be used by gdk_threads_enter/leave instead of a simple mutex
|
||||
@@ -100,18 +103,24 @@ static void myGdkLockLeave()
|
||||
* -3 if at least one required procparam file was not found */
|
||||
int processLineParams( int argc, char **argv );
|
||||
|
||||
/*
|
||||
*
|
||||
* M A I N
|
||||
*
|
||||
*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
setlocale(LC_ALL, "");
|
||||
setlocale(LC_NUMERIC, "C"); // to set decimal point to "."
|
||||
// Uncomment the following line if you want to use the "--g-fatal-warnings" command line flag
|
||||
//gtk_init (&argc, &argv);
|
||||
gtk_init (&argc, &argv); // use the "--g-fatal-warnings" command line flag to make warnings fatal
|
||||
|
||||
Glib::thread_init();
|
||||
Glib::init(); // called by Gtk::Main, but this may be important for thread handling, so we call it ourselves now
|
||||
gdk_threads_set_lock_functions(G_CALLBACK(myGdkLockEnter), (G_CALLBACK(myGdkLockLeave)));
|
||||
gdk_threads_init();
|
||||
Gio::init ();
|
||||
|
||||
//mainThread = Glib::Threads::Thread::self();
|
||||
|
||||
#ifdef BUILD_BUNDLE
|
||||
char exname[512] = {0};
|
||||
Glib::ustring exePath;
|
||||
@@ -154,8 +163,6 @@ int main(int argc, char **argv)
|
||||
licensePath = LICENCE_SEARCH_PATH;
|
||||
#endif
|
||||
|
||||
mainThread = Glib::Thread::self();
|
||||
|
||||
if (!Options::load ()) {
|
||||
Gtk::Main m(&argc, &argv);
|
||||
Gtk::MessageDialog msgd ("Fatal error!\nThe RT_SETTINGS and/or RT_PATH environment variables are set, but use a relative path. The path must be absolute!", true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
|
||||
@@ -276,20 +283,6 @@ int main(int argc, char **argv)
|
||||
simpleEditor = true;
|
||||
}
|
||||
|
||||
if (!options.useSystemTheme) {
|
||||
std::vector<Glib::ustring> rcfiles;
|
||||
rcfiles.push_back (argv0 + "/themes/" + options.theme + ".gtkrc");
|
||||
|
||||
if (options.slimUI) {
|
||||
rcfiles.push_back (argv0 + "/themes/slim");
|
||||
}
|
||||
|
||||
// Set the font face and size
|
||||
Gtk::RC::parse_string (Glib::ustring::compose(
|
||||
"style \"clearlooks-default\" { font_name = \"%1\" }", options.font));
|
||||
Gtk::RC::set_default_files (rcfiles);
|
||||
}
|
||||
|
||||
Gtk::Main m(&argc, &argv);
|
||||
|
||||
Glib::ustring icon_path = Glib::build_filename(argv0, "images");
|
||||
@@ -299,19 +292,78 @@ int main(int argc, char **argv)
|
||||
RTImage::setPaths(options);
|
||||
MyExpander::init(); // has to stay AFTER RTImage::setPaths
|
||||
|
||||
#ifndef WIN32
|
||||
// For an unknown reason, gtkmm 2.22 don't know the gtk-button-images property, while it exists in the documentation...
|
||||
// Anyway, the problem was Linux only
|
||||
static Glib::RefPtr<Gtk::Settings> settings = Gtk::Settings::get_default();
|
||||
// ------- loading theme files
|
||||
|
||||
if (settings) {
|
||||
settings->property_gtk_button_images().set_value(true);
|
||||
} else {
|
||||
printf("Error: no default settings to update!\n");
|
||||
Glib::RefPtr<Gtk::CssProvider> cssDefault;
|
||||
Glib::RefPtr<Gdk::Screen> screen = Gdk::Screen::get_default();
|
||||
|
||||
cssDefault = Gtk::CssProvider::get_default();
|
||||
Gtk::StyleContext::add_provider_for_screen(screen, cssDefault, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
Gtk::Settings::get_for_screen(screen)->set_property("gtk-application-prefer-dark-theme", true);
|
||||
|
||||
if (!options.useSystemTheme && screen) {
|
||||
|
||||
|
||||
css = Gtk::CssProvider::create();
|
||||
|
||||
//Glib::ustring filename(argv0+"/themes/"+options.theme+".css");
|
||||
// Forcing the default dark theme
|
||||
Glib::ustring filename(argv0 + "/themes/rtcommon.css");
|
||||
|
||||
try {
|
||||
css->load_from_path (filename);
|
||||
Gtk::StyleContext::add_provider_for_screen(screen, css, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
} catch (Glib::Error &err) {
|
||||
printf("Error: Can't load css file \"%s\"\nMessage: %s\n", filename.c_str(), err.what().c_str());
|
||||
} catch (...) {
|
||||
printf("Error: Can't load css file \"%s\"\n", filename.c_str());
|
||||
}
|
||||
|
||||
if (options.slimUI) {
|
||||
filename = argv0 + "/themes/slim.css";
|
||||
cssSlim = Gtk::CssProvider::create();
|
||||
|
||||
try {
|
||||
cssSlim->load_from_path (filename);
|
||||
Gtk::StyleContext::add_provider_for_screen(screen, cssSlim, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
} catch (Glib::Error &err) {
|
||||
printf("Error: Can't load css file \"%s\"\nMessage: %s\n", filename.c_str(), err.what().c_str());
|
||||
} catch (...) {
|
||||
printf("Error: Can't load css file \"%s\"\n", filename.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// Set the font face and size
|
||||
if (options.font != "default") {
|
||||
try {
|
||||
cssForced = Gtk::CssProvider::create();
|
||||
Glib::ustring font(options.font);
|
||||
size_t pos = font.find(',');
|
||||
|
||||
if (pos != Glib::ustring::npos) {
|
||||
font = font.replace(pos, 1, " ");
|
||||
}
|
||||
|
||||
cssForced->load_from_data (Glib::ustring::compose("* { font: %1; }", font));
|
||||
Gtk::StyleContext::add_provider_for_screen(screen, cssForced, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
} catch (Glib::Error &err) {
|
||||
printf("Error: \"%s\"\n", err.what().c_str());
|
||||
} catch (...) {
|
||||
printf("Error: Can't find the font named \"%s\"\n", options.font.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
else if (!screen) {
|
||||
printf("ERROR: Can't get default screen!\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ------- end loading theme files
|
||||
|
||||
gdk_threads_enter ();
|
||||
RTWindow *rtWindow = new class RTWindow();
|
||||
|
||||
@@ -810,4 +862,3 @@ int processLineParams( int argc, char **argv )
|
||||
|
||||
return errors > 0 ? -2 : 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user