int main (int argc, char **argv) { ByzanzSession *rec; GOptionContext* context; GError *error = NULL; GFile *file; g_set_prgname (argv[0]); #ifdef GETTEXT_PACKAGE bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif context = g_option_context_new (_("record your current desktop session")); #ifdef GETTEXT_PACKAGE g_option_context_set_translation_domain(context, GETTEXT_PACKAGE); #endif g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_print (_("Wrong option: %s\n"), error->message); usage (); return 1; } if (argc != 2) { usage (); return 0; } if (!clamp_to_window (&area, gdk_get_default_root_window (), &area)) { g_print (_("Given area is not inside desktop.\n")); return 1; } file = g_file_new_for_commandline_arg (argv[1]); rec = byzanz_session_new (file, byzanz_encoder_get_type_from_file (file), gdk_get_default_root_window (), &area, cursor, audio); g_object_unref (file); g_signal_connect (rec, "notify", G_CALLBACK (session_notify_cb), NULL); delay = MAX (delay, 1); delay = (delay - 1) * 1000; duration = MAX (duration, 0); duration *= 1000; g_timeout_add (delay, start_recording, rec); gtk_main (); g_object_unref (rec); return 0; }
int main (int argc, char **argv) { GOptionContext* context; GError *error = NULL; GFile *infile; GFile *outfile; GInputStream *instream; GOutputStream *outstream; GMainLoop *loop; ByzanzEncoder *encoder; g_set_prgname (argv[0]); #ifdef GETTEXT_PACKAGE bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif context = g_option_context_new (_("process a Byzanz debug recording")); #ifdef GETTEXT_PACKAGE g_option_context_set_translation_domain(context, GETTEXT_PACKAGE); #endif g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_print (_("Wrong option: %s\n"), error->message); usage (); g_error_free (error); return 1; } if (argc != 3) { usage (); return 0; } infile = g_file_new_for_commandline_arg (argv[1]); outfile = g_file_new_for_commandline_arg (argv[2]); loop = g_main_loop_new (NULL, FALSE); instream = G_INPUT_STREAM (g_file_read (infile, NULL, &error)); if (instream == NULL) { g_print ("%s\n", error->message); g_error_free (error); return 1; } outstream = G_OUTPUT_STREAM (g_file_replace (outfile, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, NULL, &error)); if (outstream == NULL) { g_print ("%s\n", error->message); g_error_free (error); return 1; } encoder = byzanz_encoder_new (byzanz_encoder_get_type_from_file (outfile), instream, outstream, FALSE, NULL); g_signal_connect (encoder, "notify", G_CALLBACK (encoder_notify), loop); g_main_loop_run (loop); g_main_loop_unref (loop); g_object_unref (encoder); g_object_unref (instream); g_object_unref (outstream); g_object_unref (infile); g_object_unref (outfile); return 0; }