* Copyright (C) 2021 Elliott Sales de Andrade <quantum.analyst@gmail.com> * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. #include "gplugin-gtk-viewer-window.h" /****************************************************************************** *****************************************************************************/ static gboolean show_internal = FALSE; /****************************************************************************** *****************************************************************************/ G_GNUC_UNUSED GApplication *app, G_GNUC_UNUSED gpointer data) if(g_variant_dict_lookup(options, "version", "b", &option, NULL)) { /* Handle --version and exit with success. */ printf("gplugin-gtk-viewer %s\n", GPLUGIN_VERSION); startup_cb(G_GNUC_UNUSED GApplication *app, G_GNUC_UNUSED gpointer data) GPluginManager *manager = NULL; gplugin_init(GPLUGIN_CORE_FLAGS_NONE); manager = gplugin_manager_get_default(); gplugin_manager_prepend_paths_from_environment( gplugin_manager_refresh(manager); shutdown_cb(G_GNUC_UNUSED GApplication *app, G_GNUC_UNUSED gpointer data) activate_cb(GApplication *app) GtkWindow *window = NULL; g_return_if_fail(GTK_IS_APPLICATION(app)); window = gtk_application_get_active_window(GTK_APPLICATION(app)); GPluginGtkView *view = NULL; GPLUGIN_GTK_VIEWER_TYPE_WINDOW, view = gplugin_gtk_viewer_window_get_view( GPLUGIN_GTK_VIEWER_WINDOW(window)); gplugin_gtk_view_set_manager(view, gplugin_manager_get_default()); gplugin_gtk_view_set_show_internal(view, show_internal); gtk_window_present(window); /****************************************************************************** *****************************************************************************/ static GOptionEntry entries[] = { "internal", 'i', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &show_internal, "Show internal plugins", NULL, "version", 'V', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL, "Display the version and exit", NULL, NULL, 0, 0, 0, NULL, NULL, NULL, main(gint argc, gchar **argv) GtkApplication *app = NULL; /* Set up gettext translations. */ bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); /* Prepare application and options. */ app = gtk_application_new(NULL, G_APPLICATION_FLAGS_NONE); g_application_add_main_option_entries(G_APPLICATION(app), entries); g_application_add_option_group( gplugin_get_option_group()); g_signal_connect(app, "activate", G_CALLBACK(activate_cb), NULL); G_CALLBACK(handle_local_options_cb), g_signal_connect(app, "startup", G_CALLBACK(startup_cb), NULL); g_signal_connect(app, "shutdown", G_CALLBACK(shutdown_cb), NULL); /* Run and get exit code. */ ret = g_application_run(G_APPLICATION(app), argc, argv);