Use gresources for about_DATA, uimanager_DATA & builder_DATA

rbuj 2019-02-22 12:02:30 +01:00 committed by ZenWalker
parent 773ef17921
commit 449753407d
12 changed files with 92 additions and 66 deletions

View File

@ -72,6 +72,24 @@ AC_SUBST([GLIB_GENMARSHAL])
GLIB_MKENUMS="$($PKG_CONFIG --variable=glib_mkenums glib-2.0)"
AC_SUBST([GLIB_MKENUMS])
# **********************
# GLIB_COMPILE_RESOURCES
# **********************
AC_ARG_VAR([GLIB_COMPILE_RESOURCES],[glib-compile-resources bin])
AC_PATH_PROG([GLIB_COMPILE_RESOURCES],[glib-compile-resources],[])
if test -z "$GLIB_COMPILE_RESOURCES"; then
AC_MSG_ERROR([glib-compile-resources not found])
fi
# *******
# XMLLINT
# *******
AC_ARG_VAR([XMLLINT],[xmllint bin])
AC_PATH_PROG([XMLLINT],[xmllint],[])
if test -z "$XMLLINT"; then
AC_MSG_ERROR([xmllint not found])
fi
# *****
# S/Key
# *****

View File

@ -9,6 +9,8 @@ bin_PROGRAMS = mate-terminal
BUILT_SOURCES = \
terminal-marshal.c \
terminal-marshal.h \
terminal-resources.c \
terminal-resources.h \
terminal-type-builtins.c \
terminal-type-builtins.h \
$(NULL)
@ -64,6 +66,7 @@ nodist_mate_terminal_SOURCES= $(BUILT_SOURCES)
mate_terminal_CPPFLAGS = \
-DTERMINAL_COMPILATION \
-DTERMINAL_RESOURCES_PATH_PREFIX="\"/org/mate/terminal\"" \
-DTERM_DATADIR="\"$(datadir)\"" \
-DTERM_LOCALEDIR="\"$(datadir)/locale\"" \
-DTERM_PKGDATADIR="\"$(pkgdatadir)\"" \
@ -136,32 +139,14 @@ terminal-marshal.c: $(srcdir)/terminal-marshal.list
&& mv terminal-marshal.c.tmp terminal-marshal.c ) \
|| ( rm -f terminal-marshal.c.tmp && exit 1 )
terminal-resources.h terminal-resources.c: terminal.gresource.xml Makefile $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir $(srcdir) $(srcdir)/terminal.gresource.xml)
$(AM_V_GEN) XMLLINT=$(XMLLINT) $(GLIB_COMPILE_RESOURCES) --target $@ --sourcedir $(srcdir) --generate --c-name terminal $<
gsettingsschema_in_files = org.mate.terminal.gschema.xml.in
gsettings_SCHEMAS = $(gsettingsschema_in_files:.xml.in=.xml)
.PRECIOUS: $(gsettings_SCHEMAS)
@INTLTOOL_XML_NOMERGE_RULE@
aboutdir = $(pkgdatadir)
about_DATA = \
terminal.about \
$(NULL)
uimanagerdir = $(pkgdatadir)
uimanager_DATA = \
terminal.xml \
$(NULL)
builderdir = $(pkgdatadir)
builder_DATA = \
encodings-dialog.ui \
find-dialog.ui \
keybinding-editor.ui \
profile-manager.ui \
profile-new-dialog.ui \
profile-preferences.ui \
skey-challenge.ui \
$(NULL)
CLEANFILES = \
stamp-terminal-type-builtins.h \
mate-terminal.schemas \
@ -170,6 +155,16 @@ CLEANFILES = \
$(BUILT_SOURCES)
EXTRA_DIST = \
encodings-dialog.ui \
find-dialog.ui \
keybinding-editor.ui \
profile-manager.ui \
profile-new-dialog.ui \
profile-preferences.ui \
skey-challenge.ui \
terminal.about \
terminal.xml \
terminal.gresource.xml \
terminal-marshal.list \
terminal-type-builtins.c.template \
terminal-type-builtins.h.template \

View File

@ -660,7 +660,6 @@ terminal_profile_edit (TerminalProfile *profile,
GtkWindow *transient_parent,
const char *widget_name)
{
char *path;
GtkBuilder *builder;
GError *error = NULL;
GtkWidget *editor, *w;
@ -677,17 +676,9 @@ terminal_profile_edit (TerminalProfile *profile,
return;
}
path = g_build_filename (TERM_PKGDATADIR, "profile-preferences.ui", NULL);
builder = gtk_builder_new ();
if (!gtk_builder_add_from_file (builder, path, &error))
{
g_warning ("Failed to load %s: %s\n", path, error->message);
g_error_free (error);
g_free (path);
g_object_unref (builder);
return;
}
g_free (path);
gtk_builder_add_from_resource (builder, TERMINAL_RESOURCES_PATH_PREFIX G_DIR_SEPARATOR_S "ui/profile-preferences.ui", &error);
g_assert_no_error (error);
editor = (GtkWidget *) gtk_builder_get_object (builder, "profile-editor-dialog");
g_object_set_data_full (G_OBJECT (editor), "builder",

View File

@ -180,7 +180,7 @@ terminal_skey_do_popup (GtkWindow *window,
}
}
if (!terminal_util_load_builder_file ("skey-challenge.ui",
if (!terminal_util_load_builder_resource (TERMINAL_RESOURCES_PATH_PREFIX G_DIR_SEPARATOR_S "ui/skey-challenge.ui",
"skey-dialog", &dialog,
"skey-entry", &entry,
"text-label", &label,

View File

@ -992,7 +992,7 @@ terminal_edit_keys_dialog_show (GtkWindow *transient_parent)
if (edit_keys_dialog != NULL)
goto done;
if (!terminal_util_load_builder_file ("keybinding-editor.ui",
if (!terminal_util_load_builder_resource (TERMINAL_RESOURCES_PATH_PREFIX G_DIR_SEPARATOR_S "ui/keybinding-editor.ui",
"keybindings-dialog", &dialog,
"disable-mnemonics-checkbutton", &disable_mnemonics_button,
"disable-menu-accel-checkbutton", &disable_menu_accel_button,

View File

@ -1229,7 +1229,7 @@ terminal_app_new_profile (TerminalApp *app,
{
GtkWidget *create_button, *grid, *name_label, *name_entry, *base_label, *combo;
if (!terminal_util_load_builder_file ("profile-new-dialog.ui",
if (!terminal_util_load_builder_resource (TERMINAL_RESOURCES_PATH_PREFIX G_DIR_SEPARATOR_S "ui/profile-new-dialog.ui",
"new-profile-dialog", &app->new_profile_dialog,
"new-profile-create-button", &create_button,
"new-profile-grid", &grid,
@ -1332,7 +1332,7 @@ terminal_app_manage_profiles (TerminalApp *app,
return;
}
if (!terminal_util_load_builder_file ("profile-manager.ui",
if (!terminal_util_load_builder_resource (TERMINAL_RESOURCES_PATH_PREFIX G_DIR_SEPARATOR_S "ui/profile-manager.ui",
"profile-manager", &dialog,
"profiles-treeview-container", &tree_view_container,
"new-profile-button", &new_button,

View File

@ -474,7 +474,7 @@ terminal_encoding_dialog_show (GtkWindow *transient_parent)
data = g_new (EncodingDialogData, 1);
if (!terminal_util_load_builder_file ("encodings-dialog.ui",
if (!terminal_util_load_builder_resource (TERMINAL_RESOURCES_PATH_PREFIX G_DIR_SEPARATOR_S "ui/encodings-dialog.ui",
"encodings-dialog", &data->dialog,
"add-button", &data->add_button,
"remove-button", &data->remove_button,

View File

@ -83,7 +83,7 @@ terminal_search_dialog_new (GtkWindow *parent)
priv = g_new0 (TerminalSearchDialogPrivate, 1);
if (!terminal_util_load_builder_file ("find-dialog.ui",
if (!terminal_util_load_builder_resource (TERMINAL_RESOURCES_PATH_PREFIX G_DIR_SEPARATOR_S "ui/find-dialog.ui",
"find-dialog", &dialog,
"search-label", &priv->search_label,
"search-entry", &priv->search_entry,

View File

@ -339,26 +339,17 @@ terminal_util_get_licence_text (void)
}
gboolean
terminal_util_load_builder_file (const char *filename,
terminal_util_load_builder_resource (const char *path,
const char *object_name,
...)
{
char *path;
GtkBuilder *builder;
GError *error = NULL;
va_list args;
path = g_build_filename (TERM_PKGDATADIR, filename, NULL);
builder = gtk_builder_new ();
if (!gtk_builder_add_from_file (builder, path, &error))
{
g_warning ("Failed to load %s: %s\n", filename, error->message);
g_error_free (error);
g_free (path);
g_object_unref (builder);
return FALSE;
}
g_free (path);
gtk_builder_add_from_resource (builder, path, &error);
g_assert_no_error (error);
va_start (args, object_name);

View File

@ -63,7 +63,7 @@ char *terminal_util_concat_uris (char **uris,
char *terminal_util_get_licence_text (void);
gboolean terminal_util_load_builder_file (const char *filename,
gboolean terminal_util_load_builder_resource (const char *path,
const char *object_name,
...);

View File

@ -2237,14 +2237,10 @@ terminal_window_init (TerminalWindow *window)
/* Load the UI */
error = NULL;
priv->ui_id = gtk_ui_manager_add_ui_from_file (manager,
TERM_PKGDATADIR G_DIR_SEPARATOR_S "terminal.xml",
priv->ui_id = gtk_ui_manager_add_ui_from_resource (manager,
TERMINAL_RESOURCES_PATH_PREFIX G_DIR_SEPARATOR_S "ui/terminal.xml",
&error);
if (error)
{
g_printerr ("Failed to load UI: %s\n", error->message);
g_error_free (error);
}
g_assert_no_error (error);
priv->menubar = gtk_ui_manager_get_widget (manager, "/menubar");
gtk_box_pack_start (GTK_BOX (priv->main_vbox),
@ -4337,26 +4333,31 @@ help_about_callback (GtkAction *action,
"Copyright © 2011 Perberos\n"
"Copyright © 2012-2018 MATE developers";
char *licence_text;
GBytes *bytes;
const guint8 *data;
GKeyFile *key_file;
GError *error = NULL;
char **authors, **contributors, **artists, **documenters, **array_strv;
gsize n_authors = 0, n_contributors = 0, n_artists = 0, n_documenters = 0 , i;
gsize data_len, n_authors = 0, n_contributors = 0, n_artists = 0, n_documenters = 0 , i;
GPtrArray *array;
bytes = g_resources_lookup_data (TERMINAL_RESOURCES_PATH_PREFIX G_DIR_SEPARATOR_S "ui/terminal.about",
G_RESOURCE_LOOKUP_FLAGS_NONE,
&error);
g_assert_no_error (error);
data = g_bytes_get_data (bytes, &data_len);
key_file = g_key_file_new ();
if (!g_key_file_load_from_file (key_file, TERM_PKGDATADIR G_DIR_SEPARATOR_S "terminal.about", 0, &error))
{
g_warning ("Couldn't load about data: %s\n", error->message);
g_error_free (error);
g_key_file_free (key_file);
return;
}
g_key_file_load_from_data (key_file, (const char *) data, data_len, 0, &error);
g_assert_no_error (error);
authors = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Authors", &n_authors, NULL);
contributors = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Contributors", &n_contributors, NULL);
artists = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Artists", &n_artists, NULL);
documenters = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Documenters", &n_documenters, NULL);
g_key_file_free (key_file);
g_bytes_unref (bytes);
array = g_ptr_array_new ();

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is part of MATE Terminal.
MATE Terminal is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
MATE Terminal 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with MATE Terminal. If not, see <http://www.gnu.org/licenses/>.
-->
<gresources>
<gresource prefix="/org/mate/terminal/ui">
<file compressed="true" preprocess="xml-stripblanks">encodings-dialog.ui</file>
<file compressed="true" preprocess="xml-stripblanks">find-dialog.ui</file>
<file compressed="true" preprocess="xml-stripblanks">keybinding-editor.ui</file>
<file compressed="true" preprocess="xml-stripblanks">profile-manager.ui</file>
<file compressed="true" preprocess="xml-stripblanks">profile-new-dialog.ui</file>
<file compressed="true" preprocess="xml-stripblanks">profile-preferences.ui</file>
<file compressed="true" preprocess="xml-stripblanks">skey-challenge.ui</file>
<file compressed="true" preprocess="xml-stripblanks">terminal.xml</file>
<file compressed="true">terminal.about</file>
</gresource>
</gresources>