int main(int argc, char** argv) { int status = 0; mate_gettext(GETTEXT_PACKAGE, LOCALE_DIR, "UTF-8"); /* http://www.gtk.org/api/2.6/glib/glib-Commandline-option-parser.html */ GOptionContext* context = g_option_context_new(NULL); g_option_context_add_main_entries(context, command_entries, GETTEXT_PACKAGE); g_option_context_add_group(context, gtk_get_option_group(TRUE)); g_option_context_parse(context, &argc, &argv, NULL); /* Not necesary at all, program just run and die. * But it free a little memory. */ g_option_context_free(context); if (mate_about_nogui == TRUE) { printf("%s %s\n", gettext(program_name), version); } else { gtk_init(&argc, &argv); #if GTK_CHECK_VERSION(3, 0, 0) mate_about_application = gtk_application_new("org.mate.about", 0); g_signal_connect(mate_about_application, "activate", G_CALLBACK(mate_about_on_activate), NULL); status = g_application_run(G_APPLICATION(mate_about_application), argc, argv); g_object_unref(mate_about_application); #else mate_about_application = g_application_new("org.mate.about", G_APPLICATION_FLAGS_NONE); g_signal_connect(mate_about_application, "activate", G_CALLBACK(mate_about_on_activate), NULL); status = g_application_run(G_APPLICATION(mate_about_application), argc, argv); g_object_unref(mate_about_application); #endif } return status; }
int main(int argc, char** argv) { int status = 0; mate_gettext(GETTEXT_PACKAGE, LOCALE_DIR, "UTF-8"); #if !GLIB_CHECK_VERSION (2, 36, 0) g_type_init(); #endif /* http://www.gtk.org/api/2.6/glib/glib-Commandline-option-parser.html */ GOptionContext* context = g_option_context_new(NULL); g_option_context_add_main_entries(context, command_entries, GETTEXT_PACKAGE); g_option_context_add_group(context, gtk_get_option_group(TRUE)); g_option_context_parse(context, &argc, &argv, NULL); /* Not necesary at all, program just run and die. * But it free a little memory. */ g_option_context_free(context); if (mate_about_nogui == TRUE) { printf("%s %s\n", gettext(program_name), version); } else { gtk_init(&argc, &argv); /** * Examples taken from: * http://developer.gnome.org/gtk3/3.0/gtk-migrating-GtkApplication.html */ #ifdef USE_UNIQUE mate_about_application = unique_app_new("org.mate.about", NULL); if (unique_app_is_running(mate_about_application)) { UniqueResponse response = unique_app_send_message(mate_about_application, UNIQUE_ACTIVATE, NULL); if (response != UNIQUE_RESPONSE_OK) { status = 1; } } else { mate_about_run(); } #elif GTK_CHECK_VERSION(3, 0, 0) && !defined(USE_UNIQUE) mate_about_application = gtk_application_new("org.mate.about", 0); g_signal_connect(mate_about_application, "activate", G_CALLBACK(mate_about_on_activate), NULL); status = g_application_run(G_APPLICATION(mate_about_application), argc, argv); g_object_unref(mate_about_application); #elif GLIB_CHECK_VERSION(2, 26, 0) && !defined(USE_UNIQUE) mate_about_application = g_application_new("org.mate.about", G_APPLICATION_FLAGS_NONE); g_signal_connect(mate_about_application, "activate", G_CALLBACK(mate_about_on_activate), NULL); status = g_application_run(G_APPLICATION(mate_about_application), argc, argv); g_object_unref(mate_about_application); #else mate_about_run(); #endif } return status; }