Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle command line arguments in a gtk application?

Tags:

rust

gtk

gtk3

How do I handle command line arguments like --config <file> in a rust based gtk application?

like image 478
ferd tomale Avatar asked Oct 27 '25 08:10

ferd tomale


1 Answers

Add a call to gtk::Application::add_main_option as shown in the GTK Documentation. First:

gtk_app.add_main_option(
  "config",
  glib::Char::new("c"),
  glib::OptionFlags::IN_MAIN,
  glib::OptionArg::Filename,
  "some description",
  Some("some other description")
);

then add a call to:

gtk_app.connect_handle_local_options( ... );
like image 195
ferd tomale Avatar answered Oct 30 '25 08:10

ferd tomale



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!