/* Licensed to Stichting The Commons Conservancy (TCC) under one or more * contributor license agreements. See the AUTHORS file distributed with * this work for additional information regarding copyright ownership. * TCC licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include #include "signtext.h" #include "crypto.h" #include "message.h" /* * The activate signal is fired at the end of the command line handler. At this * point we set ourselves up with our windows, and we trigger the first task to * read a single message from stdin. */ static void activate (GtkApplication *app, gpointer user_data) { SignTextData *signtext = user_data; #if 0 g_printerr ("activate\n"); #endif signtext->cancellable = g_cancellable_new(); signtext->stack = GTK_STACK(gtk_stack_new ()); gtk_widget_show (GTK_WIDGET(signtext->stack)); signtext->switcher = GTK_STACK_SWITCHER(gtk_stack_switcher_new ()); gtk_stack_switcher_set_stack (signtext->switcher, signtext->stack); gtk_widget_show (GTK_WIDGET(signtext->switcher)); signtext->box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 6)); #ifdef HAVE_GTK_BOX_APPEND gtk_box_append (signtext->box, GTK_WIDGET(signtext->switcher)); gtk_box_append (signtext->box, GTK_WIDGET(signtext->stack)); #else gtk_box_pack_start (signtext->box, GTK_WIDGET(signtext->switcher), FALSE, FALSE, 0); gtk_box_pack_start (signtext->box, GTK_WIDGET(signtext->stack), TRUE, TRUE, 0); #endif gtk_widget_show (GTK_WIDGET(signtext->box)); signtext->window = gtk_application_window_new (app); gtk_window_set_title (GTK_WINDOW (signtext->window), "Redwax SignText"); gtk_window_set_default_size (GTK_WINDOW (signtext->window), -1, -1); #ifdef HAVE_GTK_WINDOW_SET_CHILD gtk_window_set_child (GTK_WINDOW(signtext->window), GTK_WIDGET(signtext->box)); #else gtk_container_add(GTK_CONTAINER(signtext->window), GTK_WIDGET(signtext->box)); #endif // gtk_widget_show (GTK_WIDGET(signtext->window)); // gtk_widget_show_all(GTK_WIDGET(signtext->window)); /* go fetch our smartcards */ crypto_start(signtext); /* go fetch our first instruction from stdin */ message_receive(signtext); } /* * The command line signal is fired first, and we process the command line options * ourselves because we're not a typical app that opens files. */ static gint command_line ( GApplication *app, GApplicationCommandLine* cmdline, gpointer user_data ) { gchar **argv; gint argc; #if 0 gint i; #endif #if 0 g_printerr ("command_line\n"); #endif // g_application_hold(app); argv = g_application_command_line_get_arguments (cmdline, &argc); #if 0 for (i = 0; i < argc; i++) { g_printerr ("argument %d: %s\n", i, argv[i]); } #endif g_strfreev (argv); // g_application_command_line_set_exit_status (cmdline, 0); /* fire off the activation */ g_application_activate(app); return 0; } int main (int argc, char **argv) { GtkApplication *app; int status; SignTextData *signtext = signtext_data_new(); app = gtk_application_new("eu.redwax.signtext", G_APPLICATION_NON_UNIQUE | G_APPLICATION_HANDLES_COMMAND_LINE); g_signal_connect(app, "activate", G_CALLBACK (activate), signtext); g_signal_connect(app, "command-line", G_CALLBACK (command_line), signtext); status = g_application_run(G_APPLICATION (app), argc, argv); g_object_unref(app); signtext_data_free(signtext); return status; }