Compare commits
2 Commits
css-variab
...
builder-pr
Author | SHA1 | Date | |
---|---|---|---|
|
1cc3c019e6 | ||
|
319aa558a5 |
@@ -16,6 +16,7 @@ SYNOPSIS
|
||||
| **gtk4-builder-tool** enumerate <FILE>
|
||||
| **gtk4-builder-tool** simplify [OPTIONS...] <FILE>
|
||||
| **gtk4-builder-tool** preview [OPTIONS...] <FILE>
|
||||
| **gtk4-builder-tool** precompile [OPTIONS...] <FILE>
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
@@ -83,3 +84,10 @@ to do manual fixups after the initial conversion.
|
||||
``--3to4``
|
||||
|
||||
Transform a GTK 3 UI definition file to the equivalent GTK 4 definitions.
|
||||
|
||||
Precompilation
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
The ``precompile`` command creates a more compact, and faster to load compiled
|
||||
form of the ui file that is understood by GtkBuilder. The output is written
|
||||
to a file with the extension ``.precompiled``.
|
||||
|
@@ -66,7 +66,7 @@ for f in get_files('theme/Default/assets-hc', '.svg'):
|
||||
xml += ' <file preprocess=\'xml-stripblanks\'>theme/Default/assets-hc/{0}</file>\n'.format(f)
|
||||
|
||||
for f in get_files('ui', '.ui'):
|
||||
xml += ' <file>ui/{0}</file>\n'.format(f)
|
||||
xml += ' <file alias="ui/{0}">ui/{0}.precompiled</file>\n'.format(f)
|
||||
|
||||
xml += '\n'
|
||||
|
||||
|
BIN
gtk/ui/gtkaboutdialog.ui.precompiled
Normal file
BIN
gtk/ui/gtkaboutdialog.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkappchooserdialog.ui.precompiled
Normal file
BIN
gtk/ui/gtkappchooserdialog.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkappchooserwidget.ui.precompiled
Normal file
BIN
gtk/ui/gtkappchooserwidget.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkapplication-quartz.ui.precompiled
Normal file
BIN
gtk/ui/gtkapplication-quartz.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkassistant.ui.precompiled
Normal file
BIN
gtk/ui/gtkassistant.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkcolorchooserdialog.ui.precompiled
Normal file
BIN
gtk/ui/gtkcolorchooserdialog.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkcoloreditor.ui.precompiled
Normal file
BIN
gtk/ui/gtkcoloreditor.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkcombobox.ui.precompiled
Normal file
BIN
gtk/ui/gtkcombobox.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkdialog.ui.precompiled
Normal file
BIN
gtk/ui/gtkdialog.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkdropdown.ui.precompiled
Normal file
BIN
gtk/ui/gtkdropdown.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkemojichooser.ui.precompiled
Normal file
BIN
gtk/ui/gtkemojichooser.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkemojicompletion.ui.precompiled
Normal file
BIN
gtk/ui/gtkemojicompletion.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkfilechooserdialog.ui.precompiled
Normal file
BIN
gtk/ui/gtkfilechooserdialog.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkfilechooserwidget.ui.precompiled
Normal file
BIN
gtk/ui/gtkfilechooserwidget.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkfontchooserdialog.ui.precompiled
Normal file
BIN
gtk/ui/gtkfontchooserdialog.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkfontchooserwidget.ui.precompiled
Normal file
BIN
gtk/ui/gtkfontchooserwidget.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtklockbutton.ui.precompiled
Normal file
BIN
gtk/ui/gtklockbutton.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkmediacontrols.ui.precompiled
Normal file
BIN
gtk/ui/gtkmediacontrols.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkmessagedialog.ui.precompiled
Normal file
BIN
gtk/ui/gtkmessagedialog.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkpagesetupunixdialog.ui.precompiled
Normal file
BIN
gtk/ui/gtkpagesetupunixdialog.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkplacesview.ui.precompiled
Normal file
BIN
gtk/ui/gtkplacesview.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkplacesviewrow.ui.precompiled
Normal file
BIN
gtk/ui/gtkplacesviewrow.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkprintunixdialog.ui.precompiled
Normal file
BIN
gtk/ui/gtkprintunixdialog.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkscalebutton.ui.precompiled
Normal file
BIN
gtk/ui/gtkscalebutton.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtksidebarrow.ui.precompiled
Normal file
BIN
gtk/ui/gtksidebarrow.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkstatusbar.ui.precompiled
Normal file
BIN
gtk/ui/gtkstatusbar.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtktooltipwindow.ui.precompiled
Normal file
BIN
gtk/ui/gtktooltipwindow.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkvideo.ui.precompiled
Normal file
BIN
gtk/ui/gtkvideo.ui.precompiled
Normal file
Binary file not shown.
BIN
gtk/ui/gtkvolumebutton.ui.precompiled
Normal file
BIN
gtk/ui/gtkvolumebutton.ui.precompiled
Normal file
Binary file not shown.
106
tools/gtk-builder-tool-precompile.c
Normal file
106
tools/gtk-builder-tool-precompile.c
Normal file
@@ -0,0 +1,106 @@
|
||||
/* Copyright 2020 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
|
||||
*/
|
||||
|
||||
#define GTK_COMPILATION
|
||||
#include "../gtk/gtkbuilderprecompile.c"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <glib/gprintf.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gtk-builder-tool.h"
|
||||
|
||||
static void
|
||||
precompile_file (const char *filename)
|
||||
{
|
||||
char *data;
|
||||
gsize len;
|
||||
GError *error = NULL;
|
||||
char *outfile;
|
||||
GBytes *bytes;
|
||||
|
||||
if (!g_file_get_contents (filename, &data, &len, &error))
|
||||
{
|
||||
g_warning ("Failed to load '%s': %s", filename, error->message);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
bytes = _gtk_buildable_parser_precompile (data, len, &error);
|
||||
if (bytes == NULL)
|
||||
{
|
||||
g_warning ("Failed to precompile '%s': %s", filename, error->message);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
outfile = g_strconcat (filename, ".precompiled", NULL);
|
||||
if (!g_file_set_contents (outfile, g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes), &error))
|
||||
if (bytes == NULL)
|
||||
{
|
||||
g_warning ("Failed to write precompiled data to '%s': %s", outfile, error->message);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
g_print ("Wrote %ld bytes to %s.\n", g_bytes_get_size (bytes), outfile);
|
||||
|
||||
g_free (outfile);
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
|
||||
void
|
||||
do_precompile (int *argc,
|
||||
const char ***argv)
|
||||
{
|
||||
GOptionContext *context;
|
||||
char **filenames = NULL;
|
||||
const GOptionEntry entries[] = {
|
||||
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL, NULL },
|
||||
{ NULL, }
|
||||
};
|
||||
GError *error = NULL;
|
||||
int i;
|
||||
|
||||
context = g_option_context_new (NULL);
|
||||
g_option_context_set_help_enabled (context, FALSE);
|
||||
g_option_context_add_main_entries (context, entries, NULL);
|
||||
|
||||
if (!g_option_context_parse (context, argc, (char ***)argv, &error))
|
||||
{
|
||||
g_printerr ("%s\n", error->message);
|
||||
g_error_free (error);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
g_option_context_free (context);
|
||||
|
||||
if (filenames == NULL)
|
||||
{
|
||||
g_printerr ("No .ui file specified\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
for (i = 0; filenames[i]; i++)
|
||||
precompile_file (filenames[i]);
|
||||
|
||||
g_strfreev (filenames);
|
||||
}
|
@@ -134,6 +134,8 @@ main (int argc, const char *argv[])
|
||||
do_enumerate (&argc, &argv);
|
||||
else if (strcmp (argv[0], "preview") == 0)
|
||||
do_preview (&argc, &argv);
|
||||
else if (strcmp (argv[0], "precompile") == 0)
|
||||
do_precompile (&argc, &argv);
|
||||
else
|
||||
usage ();
|
||||
|
||||
|
@@ -2,9 +2,10 @@
|
||||
#ifndef __GTK_BUILDER_TOOL_H__
|
||||
#define __GTK_BUILDER_TOOL_H__
|
||||
|
||||
void do_simplify (int *argc, const char ***argv);
|
||||
void do_validate (int *argc, const char ***argv);
|
||||
void do_enumerate (int *argc, const char ***argv);
|
||||
void do_preview (int *argc, const char ***argv);
|
||||
void do_simplify (int *argc, const char ***argv);
|
||||
void do_validate (int *argc, const char ***argv);
|
||||
void do_enumerate (int *argc, const char ***argv);
|
||||
void do_preview (int *argc, const char ***argv);
|
||||
void do_precompile (int *argc, const char ***argv);
|
||||
|
||||
#endif
|
||||
|
@@ -28,7 +28,8 @@ gtk_tools = [
|
||||
'gtk-builder-tool-simplify.c',
|
||||
'gtk-builder-tool-validate.c',
|
||||
'gtk-builder-tool-enumerate.c',
|
||||
'gtk-builder-tool-preview.c'], [libgtk_dep] ],
|
||||
'gtk-builder-tool-preview.c',
|
||||
'gtk-builder-tool-precompile.c'], [libgtk_dep] ],
|
||||
['gtk4-update-icon-cache', ['updateiconcache.c'] + extra_update_icon_cache_objs, [ libgtk_static_dep ] ],
|
||||
['gtk4-encode-symbolic-svg', ['encodesymbolic.c'], [ libgtk_static_dep ] ],
|
||||
]
|
||||
|
Reference in New Issue
Block a user