Commit a29dabb5 authored by Grumbel's avatar Grumbel

Fixed "This application can not open files." error

Fixes #22
parent d2078b9d
......@@ -35,10 +35,10 @@
Main* Main::current_ = 0;
Main::Main(const std::string& datadir_)
: Gtk::Application("com.gmail.grumbel.jstest-gtk"),
datadir(datadir_),
m_simple_ui(false)
Main::Main(const std::string& datadir_) :
Gtk::Application("com.gmail.grumbel.jstest-gtk", Gio::APPLICATION_HANDLES_OPEN),
datadir(datadir_),
m_simple_ui(false)
{
current_ = this;
}
......@@ -47,21 +47,22 @@ Main::~Main()
{
}
void
JoystickTestWidget*
Main::show_device_property_dialog(const std::string& filename, Gtk::Window* parent)
{
Joystick* joystick = new Joystick(filename);
JoystickTestWidget* dialog = new JoystickTestWidget(*joystick, m_simple_ui);
if (parent) {
dialog->set_transient_for(*parent);
} else {
dialog->unset_transient_for();
}
dialog->signal_hide().connect(sigc::bind(sigc::mem_fun(this, &Main::on_dialog_hide), dialog));
dialog->show_all();
joysticks.push_back(joystick);
dialogs.push_back(dialog);
return dialog;
}
void
......@@ -144,12 +145,12 @@ Main::run(int argc, char** argv)
{
JoystickListWidget list_dialog;
list_dialog.show_all();
return Gtk::Application::run(list_dialog, argc, argv);
return Gtk::Application::run(list_dialog);
}
else
{
show_device_property_dialog(*device_files.begin());
return Gtk::Application::run(argc, argv);
auto dialog = show_device_property_dialog(*device_files.begin());
return Gtk::Application::run(*dialog);
}
}
catch(std::exception& err)
......
......@@ -24,7 +24,8 @@
class Joystick;
class JoystickListWidget;
class JoystickTestWidget;
class Main : public Gtk::Application
{
private:
......@@ -45,7 +46,7 @@ public:
Main(const std::string& datadir);
~Main();
void show_device_property_dialog(const std::string& filename, Gtk::Window* parent = nullptr);
JoystickTestWidget* show_device_property_dialog(const std::string& filename, Gtk::Window* parent = nullptr);
void show_calibration_dialog(Joystick& joystick);
void show_mapping_dialog(Joystick& joystick);
......@@ -55,7 +56,7 @@ public:
std::string get_data_directory() const { return datadir; }
};
#endif
/* EOF */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment