#46: Add open callback to GApplication

This commit is contained in:
Mario Hüttel 2023-01-24 18:46:53 +01:00
parent 504dc476b1
commit bc2fe92e07
1 changed files with 14 additions and 2 deletions

16
main.c
View File

@ -171,6 +171,16 @@ static void gapp_activate(GApplication *app, gpointer user_data)
gtk_widget_show(GTK_WIDGET(main_window));
}
/**
* @brief Activation of GUI when opening a file from commandline
* @param app he GApplication reference
* @param user_data Used to store the individual GUI instances.
*/
static void gapp_activate_open(GApplication *app, gpointer user_data)
{
gapp_activate(app, user_data);
}
/**
* @brief Start the graphical interface.
*
@ -201,10 +211,11 @@ static int start_gui(int argc, char **argv)
application_domain = g_string_new(NULL);
g_string_printf(application_domain, "de.shimatta.gds_render_%s", _app_git_commit);
gapp = gtk_application_new(application_domain->str, G_APPLICATION_FLAGS_NONE);
gapp = gtk_application_new(application_domain->str, G_APPLICATION_HANDLES_OPEN);
g_string_free(application_domain, TRUE);
g_application_register(G_APPLICATION(gapp), NULL, NULL);
g_signal_connect(gapp, "open", G_CALLBACK(gapp_activate_open), &appdata);
g_signal_connect(gapp, "activate", G_CALLBACK(gapp_activate), &appdata);
if (g_application_get_is_remote(G_APPLICATION(gapp)) == TRUE) {
@ -311,7 +322,8 @@ int main(int argc, char **argv)
goto ret_status;
}
if (argc >= 2) {
/* A minimum of a file name and a cell or analyze command are needed to use CLI */
if (argc >= 2 && (analyze || cellname || output_paths)) {
if (scale < 1) {
printf(_("Scale < 1 not allowed. Setting to 1\n"));
scale = 1;