static void screenshot_show_interactive_dialog (ScreenshotApplication *self) { GtkWidget *dialog; dialog = screenshot_interactive_dialog_new (); g_signal_connect (dialog, "response", G_CALLBACK (interactive_dialog_response_cb), self); }
/* main */ int main (int argc, char *argv[]) { GOptionContext *context; gboolean clipboard_arg = FALSE; gboolean window_arg = FALSE; gboolean area_arg = FALSE; gboolean include_border_arg = FALSE; gboolean disable_border_arg = FALSE; gboolean interactive_arg = FALSE; gchar *border_effect_arg = NULL; guint delay_arg = 0; GError *error = NULL; gboolean res; const GOptionEntry entries[] = { { "clipboard", 'c', 0, G_OPTION_ARG_NONE, &clipboard_arg, N_("Send the grab directly to the clipboard"), NULL }, { "window", 'w', 0, G_OPTION_ARG_NONE, &window_arg, N_("Grab a window instead of the entire screen"), NULL }, { "area", 'a', 0, G_OPTION_ARG_NONE, &area_arg, N_("Grab an area of the screen instead of the entire screen"), NULL }, { "include-border", 'b', 0, G_OPTION_ARG_NONE, &include_border_arg, N_("Include the window border with the screenshot"), NULL }, { "remove-border", 'B', 0, G_OPTION_ARG_NONE, &disable_border_arg, N_("Remove the window border from the screenshot"), NULL }, { "delay", 'd', 0, G_OPTION_ARG_INT, &delay_arg, N_("Take screenshot after specified delay [in seconds]"), N_("seconds") }, { "border-effect", 'e', 0, G_OPTION_ARG_STRING, &border_effect_arg, N_("Effect to add to the border (shadow, border or none)"), N_("effect") }, { "interactive", 'i', 0, G_OPTION_ARG_NONE, &interactive_arg, N_("Interactively set options"), NULL }, { NULL }, }; setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); g_thread_init (NULL); context = g_option_context_new (_("Take a picture of the screen")); g_option_context_set_ignore_unknown_options (context, FALSE); g_option_context_set_help_enabled (context, TRUE); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_parse (context, &argc, &argv, &error); if (error) { g_critical ("Unable to parse arguments: %s", error->message); g_error_free (error); g_option_context_free (context); exit (1); } g_option_context_free (context); res = screenshot_load_config (clipboard_arg, window_arg, area_arg, include_border_arg, disable_border_arg, border_effect_arg, delay_arg, interactive_arg); if (!res || !screenshot_app_init ()) exit (1); /* interactive mode: trigger the dialog and wait for the response */ if (interactive_arg) { GtkWidget *dialog; dialog = screenshot_interactive_dialog_new (); gtk_widget_show (dialog); g_signal_connect (dialog, "response", G_CALLBACK (interactive_dialog_response_cb), NULL); } else { screenshot_start (); } gtk_main (); g_clear_object (&connection); return EXIT_SUCCESS; }