2015-04-19 01:03:52 +00:00
|
|
|
/* Copyright 2015 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* GTK+ is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GLib 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with GTK+; see the file COPYING. If not,
|
|
|
|
* see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Author: Matthias Clasen
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2016-11-13 03:29:02 +00:00
|
|
|
#include <errno.h>
|
2015-04-27 22:39:22 +00:00
|
|
|
|
|
|
|
#include <glib/gi18n.h>
|
2016-04-15 17:37:49 +00:00
|
|
|
#include <glib/gprintf.h>
|
2016-11-13 03:29:02 +00:00
|
|
|
#include <glib/gstdio.h>
|
2015-04-19 01:03:52 +00:00
|
|
|
#include <gtk/gtk.h>
|
2015-04-30 05:18:48 +00:00
|
|
|
#include "gtkbuilderprivate.h"
|
2015-04-19 01:03:52 +00:00
|
|
|
|
2019-02-07 09:12:09 +00:00
|
|
|
extern void do_simplify (int *argc, const char ***argv);
|
|
|
|
extern void do_validate (int *argc, const char ***argv);
|
|
|
|
extern void do_enumerate (int *argc, const char ***argv);
|
|
|
|
extern void do_preview (int *argc, const char ***argv);
|
2016-01-31 17:57:50 +00:00
|
|
|
|
2015-04-27 22:25:09 +00:00
|
|
|
static void
|
|
|
|
usage (void)
|
|
|
|
{
|
2015-04-28 03:31:03 +00:00
|
|
|
g_print (_("Usage:\n"
|
|
|
|
" gtk-builder-tool [COMMAND] FILE\n"
|
|
|
|
"\n"
|
|
|
|
"Commands:\n"
|
2016-01-31 17:57:50 +00:00
|
|
|
" validate Validate the file\n"
|
2016-11-13 03:29:02 +00:00
|
|
|
" simplify [OPTIONS] Simplify the file\n"
|
2016-01-31 17:57:50 +00:00
|
|
|
" enumerate List all named objects\n"
|
|
|
|
" preview [OPTIONS] Preview the file\n"
|
|
|
|
"\n"
|
2016-11-13 03:29:02 +00:00
|
|
|
"Simplify Options:\n"
|
|
|
|
" --replace Replace the file\n"
|
2019-02-07 12:12:15 +00:00
|
|
|
" --3to4 Convert from a GTK3 to GTK4\n"
|
2016-11-13 03:29:02 +00:00
|
|
|
"\n"
|
2016-01-31 17:57:50 +00:00
|
|
|
"Preview Options:\n"
|
|
|
|
" --id=ID Preview only the named object\n"
|
|
|
|
" --css=FILE Use style from CSS file\n"
|
2015-04-28 03:31:03 +00:00
|
|
|
"\n"
|
2015-04-30 11:11:49 +00:00
|
|
|
"Perform various tasks on GtkBuilder .ui files.\n"));
|
2015-04-27 22:25:09 +00:00
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2016-01-31 17:57:50 +00:00
|
|
|
main (int argc, const char *argv[])
|
2015-04-27 22:25:09 +00:00
|
|
|
{
|
2015-04-27 22:39:22 +00:00
|
|
|
g_set_prgname ("gtk-builder-tool");
|
|
|
|
|
2016-12-28 13:53:22 +00:00
|
|
|
gtk_init ();
|
2015-04-27 22:25:09 +00:00
|
|
|
|
|
|
|
gtk_test_register_all_types ();
|
|
|
|
|
2015-04-28 03:31:03 +00:00
|
|
|
if (argc < 3)
|
2015-04-27 22:25:09 +00:00
|
|
|
usage ();
|
|
|
|
|
2016-01-31 16:01:46 +00:00
|
|
|
if (strcmp (argv[2], "--help") == 0)
|
|
|
|
usage ();
|
|
|
|
|
2016-01-31 17:57:50 +00:00
|
|
|
argv++;
|
|
|
|
argc--;
|
|
|
|
|
|
|
|
if (strcmp (argv[0], "validate") == 0)
|
2019-02-07 09:12:09 +00:00
|
|
|
do_validate (&argc, &argv);
|
2016-01-31 17:57:50 +00:00
|
|
|
else if (strcmp (argv[0], "simplify") == 0)
|
2016-11-13 03:29:02 +00:00
|
|
|
do_simplify (&argc, &argv);
|
2016-01-31 17:57:50 +00:00
|
|
|
else if (strcmp (argv[0], "enumerate") == 0)
|
2019-02-07 09:12:09 +00:00
|
|
|
do_enumerate (&argc, &argv);
|
2016-01-31 17:57:50 +00:00
|
|
|
else if (strcmp (argv[0], "preview") == 0)
|
|
|
|
do_preview (&argc, &argv);
|
2015-04-28 03:31:03 +00:00
|
|
|
else
|
|
|
|
usage ();
|
2015-04-27 22:25:09 +00:00
|
|
|
|
2015-04-19 01:03:52 +00:00
|
|
|
return 0;
|
|
|
|
}
|