[gnome-mud] Use GResources for UI files instead of installing them on filesystem
- From: Mart Raudsepp <mraudsepp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-mud] Use GResources for UI files instead of installing them on filesystem
- Date: Thu, 3 Jan 2019 12:32:27 +0000 (UTC)
commit ffaf9f1bbe18cb28a723a5011b8e9d2b1f65207b
Author: Mart Raudsepp <leio gentoo org>
Date: Thu Jan 3 14:27:20 2019 +0200
Use GResources for UI files instead of installing them on filesystem
The code is a bit awkward due to no gtk3 yet, but a step forward until gtk3.
Makefile.am | 2 +-
configure.ac | 4 ++-
data/Makefile.am | 9 ++++++
{ui => data}/main.ui | 0
{ui => data}/muds.ui | 0
data/org.gnome.MUD.gresource.xml | 8 ++++++
{ui => data}/prefs.ui | 0
po/POTFILES.in | 8 +++---
src/Makefile.am | 22 +++++++++------
src/debug-logger.c | 25 ++++++++++++----
src/mud-connections.c | 61 ++++++++++++++++++++++++++++++++--------
src/mud-log.c | 25 ++++++++++++----
src/mud-subwindow.c | 13 +++++++--
src/mud-window-prefs.c | 13 +++++++--
src/mud-window-profile.c | 25 ++++++++++++----
src/mud-window.c | 25 ++++++++++++----
ui/Makefile.am | 11 --------
17 files changed, 184 insertions(+), 67 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 95ec2be..d3066a9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = data doc po src ui
+SUBDIRS = data doc po src
@INTLTOOL_SCHEMAS_RULE@
@INTLTOOL_DESKTOP_RULE@
diff --git a/configure.ac b/configure.ac
index 41bdca5..00de11f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -129,6 +129,9 @@ if test "x$enable_debug_logger" != "xno"; then
fi
AM_CONDITIONAL(USE_DEBUG_LOGGER, test "x$enable_debug_logger" = xyes)
+GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable glib_compile_resources gio-2.0`
+AC_SUBST(GLIB_COMPILE_RESOURCES)
+
AC_CONFIG_FILES([
Makefile
gnome-mud.spec
@@ -139,7 +142,6 @@ AC_CONFIG_FILES([
src/handlers/Makefile
src/zmp/Makefile
po/Makefile.in
- ui/Makefile
])
AC_OUTPUT
diff --git a/data/Makefile.am b/data/Makefile.am
index 8fc2f87..50cc1a1 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -6,4 +6,13 @@ gsettings_SCHEMAS = \
@GSETTINGS_RULES@
+EXTRA_DIST = \
+ org.gnome.MUD.gresource.xml \
+ main.ui \
+ muds.ui \
+ prefs.ui \
+ $(NULL)
+
+CLEANFILES = $(BUILT_SOURCES)
+
-include $(top_srcdir)/git.mk
diff --git a/ui/main.ui b/data/main.ui
similarity index 100%
rename from ui/main.ui
rename to data/main.ui
diff --git a/ui/muds.ui b/data/muds.ui
similarity index 100%
rename from ui/muds.ui
rename to data/muds.ui
diff --git a/data/org.gnome.MUD.gresource.xml b/data/org.gnome.MUD.gresource.xml
new file mode 100644
index 0000000..eaca15d
--- /dev/null
+++ b/data/org.gnome.MUD.gresource.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/MUD">
+ <file preprocess="xml-stripblanks">main.ui</file>
+ <file preprocess="xml-stripblanks">muds.ui</file>
+ <file preprocess="xml-stripblanks">prefs.ui</file>
+ </gresource>
+</gresources>
diff --git a/ui/prefs.ui b/data/prefs.ui
similarity index 100%
rename from ui/prefs.ui
rename to data/prefs.ui
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 9e8c567..880d880 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,7 +2,6 @@
# List of source files containing translatable strings.
# Please keep this file sorted alphabetically.
gnome-mud.desktop.in
-[type: gettext/gsettings]data/org.gnome.MUD.gschema.xml
src/debug-logger.c
src/mud-connections.c
src/mud-connection-view.c
@@ -13,6 +12,7 @@ src/mud-trigger.c
src/mud-window.c
src/mud-window-prefs.c
src/handlers/mud-telnet-mccp.c
-[type: gettext/glade]ui/main.ui
-[type: gettext/glade]ui/muds.ui
-[type: gettext/glade]ui/prefs.ui
+[type: gettext/glade]data/main.ui
+[type: gettext/glade]data/muds.ui
+[type: gettext/glade]data/prefs.ui
+[type: gettext/gsettings]data/org.gnome.MUD.gschema.xml
diff --git a/src/Makefile.am b/src/Makefile.am
index 2a8a60c..23c84db 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,6 +4,18 @@ bin_PROGRAMS = gnome-mud
localedir = $(datadir)/locale
+resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(top_srcdir)/data --generate-dependencies
$(top_srcdir)/data/org.gnome.MUD.gresource.xml)
+resources.c: $(top_srcdir)/data/org.gnome.MUD.gresource.xml $(resource_files)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(top_srcdir)/data --generate-source
--c-name gnome_mud $<
+resources.h: $(top_srcdir)/data/org.gnome.MUD.gresource.xml $(resource_files)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(top_srcdir)/data --generate-header
--c-name gnome_mud $<
+
+BUILT_SOURCES = \
+ gnome-mud-builtins.c \
+ gnome-mud-builtins.h \
+ resources.c \
+ resources.h
+
gnome_mud_CPPFLAGS = \
-DLOCALEDIR=\"$(localedir)\" \
-DPIXMAPSDIR=\""$(datadir)/pixmaps"\" \
@@ -12,7 +24,6 @@ gnome_mud_CPPFLAGS = \
-DSYSCONFDIR=\""$(sysconfdir)"\" \
-DDATADIR=\""$(datadir)"\" \
-DLIBDIR=\""$(libdir)"\" \
- -DUIDIR=\""$(pkgdatadir)"\" \
-DPKGDATADIR=\""$(pkgdatadir)"\"
gnome_mud_CFLAGS = \
@@ -33,8 +44,6 @@ gnome_mud_SOURCES = \
ecma48.h \
gnome-mud.c \
gnome-mud.h \
- gnome-mud-builtins.c \
- gnome-mud-builtins.h \
gnome-mud-icons.h \
mud-character.c \
mud-character.h \
@@ -77,11 +86,8 @@ gnome_mud_SOURCES = \
mud-window-profile.c \
mud-window-profile.h \
utils.c \
- utils.h
-
-BUILT_SOURCES = \
- gnome-mud-builtins.c \
- gnome-mud-builtins.h
+ utils.h \
+ $(BUILT_SOURCES)
enumheaders = \
mud-trigger.h
diff --git a/src/debug-logger.c b/src/debug-logger.c
index 2b2e4cf..f1752e7 100644
--- a/src/debug-logger.c
+++ b/src/debug-logger.c
@@ -30,6 +30,7 @@
#include <glib/gprintf.h>
#include "debug-logger.h"
+#include "resources.h"
struct _DebugLoggerPrivate
{
@@ -600,6 +601,9 @@ static void
debug_logger_save_clicked(GtkWidget *widget, DebugLogger *logger)
{
GtkBuilder *builder;
+ GBytes *res_bytes;
+ gconstpointer res_data;
+ gsize res_size;
GError *error = NULL;
GtkWidget *dialog;
gint result;
@@ -615,9 +619,12 @@ debug_logger_save_clicked(GtkWidget *widget, DebugLogger *logger)
if (gtk_notebook_get_n_pages(logger->priv->notebook) == 0)
return;
- builder = gtk_builder_new();
- if(gtk_builder_add_from_file(builder, UIDIR "/main.ui", &error) == 0)
- g_error("Failed to load: %s", error->message);
+ builder = gtk_builder_new ();
+ res_bytes = g_resource_lookup_data (gnome_mud_get_resource (), "/org/gnome/MUD/main.ui", 0, NULL);
+ res_data = g_bytes_get_data (res_bytes, &res_size);
+ if (gtk_builder_add_from_string (builder, res_data, res_size, &error) == 0)
+ g_error ("Failed to load resources: %s", error->message);
+ g_bytes_unref (res_bytes);
dialog = GTK_WIDGET(gtk_builder_get_object(builder, "save_dialog"));
@@ -1038,6 +1045,9 @@ void
debug_logger_create_window(DebugLogger *self)
{
GtkBuilder *builder;
+ GBytes *res_bytes;
+ gconstpointer res_data;
+ gsize res_size;
GError *error = NULL;
GSList *entry;
@@ -1048,9 +1058,12 @@ debug_logger_create_window(DebugLogger *self)
self->ui_enabled = TRUE;
- builder = gtk_builder_new();
- if(gtk_builder_add_from_file(builder, UIDIR "/main.ui", &error) == 0)
- g_error("Failed to load: %s", error->message);
+ builder = gtk_builder_new ();
+ res_bytes = g_resource_lookup_data (gnome_mud_get_resource (), "/org/gnome/MUD/main.ui", 0, NULL);
+ res_data = g_bytes_get_data (res_bytes, &res_size);
+ if (gtk_builder_add_from_string (builder, res_data, res_size, &error) == 0)
+ g_error ("Failed to load resources: %s", error->message);
+ g_bytes_unref (res_bytes);
self->priv->window = GTK_WINDOW(gtk_builder_get_object(builder, "log_window"));
self->priv->vbox = GTK_VBOX(gtk_builder_get_object(builder, "vbox"));
diff --git a/src/mud-connections.c b/src/mud-connections.c
index 2f50a59..04c42c0 100644
--- a/src/mud-connections.c
+++ b/src/mud-connections.c
@@ -32,6 +32,7 @@
#include "gnome-mud.h"
#include "mud-connections.h"
+#include "resources.h"
#include "mud-mud.h"
#include "mud-character.h"
#include "mud-window.h"
@@ -494,6 +495,9 @@ mud_connections_popup (MudConnections *self,
GdkEventButton *event)
{
GtkBuilder *builder;
+ GBytes *res_bytes;
+ gconstpointer res_data;
+ gsize res_size;
GError *error = NULL;
GtkWidget *popup;
GList *selected = gtk_icon_view_get_selected_items (GTK_ICON_VIEW (self->iconview));
@@ -502,8 +506,11 @@ mud_connections_popup (MudConnections *self,
return;
builder = gtk_builder_new ();
- if (gtk_builder_add_from_file (builder, UIDIR "/muds.ui", &error) == 0)
- g_error ("Failed to load: %s", error->message);
+ res_bytes = g_resource_lookup_data (gnome_mud_get_resource (), "/org/gnome/MUD/muds.ui", 0, NULL);
+ res_data = g_bytes_get_data (res_bytes, &res_size);
+ if (gtk_builder_add_from_string (builder, res_data, res_size, &error) == 0)
+ g_error ("Failed to load resources: %s", error->message);
+ g_bytes_unref (res_bytes);
popup = GTK_WIDGET (gtk_builder_get_object (builder, "popupmenu"));
@@ -536,6 +543,9 @@ static gboolean
mud_connections_delete_confirm (gchar *name)
{
GtkBuilder *builder;
+ GBytes *res_bytes;
+ gconstpointer res_data;
+ gsize res_size;
GError *error = NULL;
GtkWidget *dialog;
GtkWidget *label;
@@ -544,8 +554,11 @@ mud_connections_delete_confirm (gchar *name)
gchar *title;
builder = gtk_builder_new ();
- if(gtk_builder_add_from_file (builder, UIDIR "/muds.ui", &error) == 0)
- g_error ("Failed to load: %s", error->message);
+ res_bytes = g_resource_lookup_data (gnome_mud_get_resource (), "/org/gnome/MUD/muds.ui", 0, NULL);
+ res_data = g_bytes_get_data (res_bytes, &res_size);
+ if (gtk_builder_add_from_string (builder, res_data, res_size, &error) == 0)
+ g_error ("Failed to load resources: %s", error->message);
+ g_bytes_unref (res_bytes);
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "mudviewdelconfirm"));
label = GTK_WIDGET (gtk_builder_get_object (builder, "message"));
@@ -571,14 +584,20 @@ mud_connections_show_properties (MudConnections *self,
MudCharacter *character)
{
GtkBuilder *builder;
+ GBytes *res_bytes;
+ gconstpointer res_data;
+ gsize res_size;
GError *error = NULL;
GtkTextBuffer *buffer;
MudMud *mud;
const gchar *icon_name, *connect_string;
builder = gtk_builder_new ();
- if (gtk_builder_add_from_file (builder, UIDIR "/muds.ui", &error) == 0)
- g_error ("Failed to load: %s", error->message);
+ res_bytes = g_resource_lookup_data (gnome_mud_get_resource (), "/org/gnome/MUD/muds.ui", 0, NULL);
+ res_data = g_bytes_get_data (res_bytes, &res_size);
+ if (gtk_builder_add_from_string (builder, res_data, res_size, &error) == 0)
+ g_error ("Failed to load resources: %s", error->message);
+ g_bytes_unref (res_bytes);
self->properties_window = GTK_WIDGET (gtk_builder_get_object (builder, "mudviewproperties"));
self->name_entry = GTK_WIDGET (gtk_builder_get_object (builder, "name_entry"));
@@ -755,13 +774,19 @@ static gint
mud_connections_property_confirm (void)
{
GtkBuilder *builder;
+ GBytes *res_bytes;
+ gconstpointer res_data;
+ gsize res_size;
GError *error = NULL;
GtkWidget *dialog;
gint result;
builder = gtk_builder_new ();
- if (gtk_builder_add_from_file (builder, UIDIR "/muds.ui", &error) == 0)
- g_error ("Failed to load: %s", error->message);
+ res_bytes = g_resource_lookup_data (gnome_mud_get_resource (), "/org/gnome/MUD/muds.ui", 0, NULL);
+ res_data = g_bytes_get_data (res_bytes, &res_size);
+ if (gtk_builder_add_from_string (builder, res_data, res_size, &error) == 0)
+ g_error ("Failed to load resources: %s", error->message);
+ g_bytes_unref (res_bytes);
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "mudviewconfirm"));
g_object_unref (builder);
@@ -903,12 +928,18 @@ static void
mud_connections_show_icon_dialog (MudConnections *self)
{
GtkBuilder *builder;
+ GBytes *res_bytes;
+ gconstpointer res_data;
+ gsize res_size;
GError *error = NULL;
gint result;
builder = gtk_builder_new ();
- if (gtk_builder_add_from_file (builder, UIDIR "/muds.ui", &error) == 0)
- g_error ("Failed to load: %s", error->message);
+ res_bytes = g_resource_lookup_data (gnome_mud_get_resource (), "/org/gnome/MUD/muds.ui", 0, NULL);
+ res_data = g_bytes_get_data (res_bytes, &res_size);
+ if (gtk_builder_add_from_string (builder, res_data, res_size, &error) == 0)
+ g_error ("Failed to load resources: %s", error->message);
+ g_bytes_unref (res_bytes);
self->icon_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "iconselect"));
self->icon_dialog_view = GTK_WIDGET (gtk_builder_get_object (builder, "view"));
@@ -1041,6 +1072,9 @@ mud_connections_constructed (GObject *object)
MudConnections *self = (MudConnections *)object;
GtkBuilder *builder;
+ GBytes *res_bytes;
+ gconstpointer res_data;
+ gsize res_size;
GError *error = NULL;
GtkWidget *main_window;
@@ -1052,8 +1086,11 @@ mud_connections_constructed (GObject *object)
NULL);
builder = gtk_builder_new ();
- if (gtk_builder_add_from_file (builder, UIDIR "/muds.ui", &error) == 0)
- g_error ("Failed to load: %s", error->message);
+ res_bytes = g_resource_lookup_data (gnome_mud_get_resource (), "/org/gnome/MUD/muds.ui", 0, NULL);
+ res_data = g_bytes_get_data (res_bytes, &res_size);
+ if (gtk_builder_add_from_string (builder, res_data, res_size, &error) == 0)
+ g_error ("Failed to load resources: %s", error->message);
+ g_bytes_unref (res_bytes);
self->window = GTK_WIDGET (gtk_builder_get_object (builder, "mudviewwindow"));
self->iconview = GTK_WIDGET (gtk_builder_get_object (builder, "iconview"));
diff --git a/src/mud-log.c b/src/mud-log.c
index d1d2bc9..e81b57f 100644
--- a/src/mud-log.c
+++ b/src/mud-log.c
@@ -33,6 +33,7 @@
#include "gnome-mud.h"
#include "mud-log.h"
+#include "resources.h"
#include "mud-window.h"
#include "mud-connection-view.h"
#include "mud-line-buffer.h"
@@ -383,13 +384,19 @@ mud_log_select_clicked_cb(GtkWidget *widget,
MudLog *self)
{
GtkBuilder *builder;
+ GBytes *res_bytes;
+ gconstpointer res_data;
+ gsize res_size;
GError *error = NULL;
GtkWidget *dialog;
gint result;
- builder = gtk_builder_new();
- if(gtk_builder_add_from_file(builder, UIDIR "/main.ui", &error) == 0)
- g_error("Failed to load: %s", error->message);
+ builder = gtk_builder_new ();
+ res_bytes = g_resource_lookup_data (gnome_mud_get_resource (), "/org/gnome/MUD/main.ui", 0, NULL);
+ res_data = g_bytes_get_data (res_bytes, &res_size);
+ if (gtk_builder_add_from_string (builder, res_data, res_size, &error) == 0)
+ g_error ("Failed to load resources: %s", error->message);
+ g_bytes_unref (res_bytes);
dialog = GTK_WIDGET(gtk_builder_get_object(builder, "save_dialog"));
g_object_unref(builder);
@@ -613,6 +620,9 @@ void
mud_log_open(MudLog *self)
{
GtkBuilder *builder;
+ GBytes *res_bytes;
+ gconstpointer res_data;
+ gsize res_size;
GError *error = NULL;
GtkWidget *main_window;
gchar buf[1024];
@@ -621,9 +631,12 @@ mud_log_open(MudLog *self)
g_return_if_fail(MUD_IS_LOG(self));
- builder = gtk_builder_new();
- if(gtk_builder_add_from_file(builder, UIDIR "/main.ui", &error) == 0)
- g_error("Failed to load: %s", error->message);
+ builder = gtk_builder_new ();
+ res_bytes = g_resource_lookup_data (gnome_mud_get_resource (), "/org/gnome/MUD/main.ui", 0, NULL);
+ res_data = g_bytes_get_data (res_bytes, &res_size);
+ if (gtk_builder_add_from_string (builder, res_data, res_size, &error) == 0)
+ g_error ("Failed to load resources: %s", error->message);
+ g_bytes_unref (res_bytes);
self->priv->window = GTK_WIDGET(gtk_builder_get_object(builder, "log_config_window"));
self->priv->check_log_next = GTK_WIDGET(gtk_builder_get_object(builder, "inc_next_check_btn"));
diff --git a/src/mud-subwindow.c b/src/mud-subwindow.c
index 405f7fc..2315570 100644
--- a/src/mud-subwindow.c
+++ b/src/mud-subwindow.c
@@ -31,6 +31,7 @@
#include "mud-connection-view.h"
#include "mud-window.h"
#include "mud-subwindow.h"
+#include "resources.h"
struct _MudSubwindowPrivate
{
@@ -346,6 +347,9 @@ mud_subwindow_constructor (GType gtype,
MudSubwindowClass *klass;
GObjectClass *parent_class;
GtkBuilder *builder;
+ GBytes *res_bytes;
+ gconstpointer res_data;
+ gsize res_size;
GError *error = NULL;
/* Chain up to parent constructor */
@@ -385,9 +389,12 @@ mud_subwindow_constructor (GType gtype,
self->priv->initial_height = self->priv->height;
/* start glading */
- builder = gtk_builder_new();
- if(gtk_builder_add_from_file(builder, UIDIR "/main.ui", &error) == 0)
- g_error("Failed to load: %s", error->message);
+ builder = gtk_builder_new ();
+ res_bytes = g_resource_lookup_data (gnome_mud_get_resource (), "/org/gnome/MUD/main.ui", 0, NULL);
+ res_data = g_bytes_get_data (res_bytes, &res_size);
+ if (gtk_builder_add_from_string (builder, res_data, res_size, &error) == 0)
+ g_error ("Failed to load resources: %s", error->message);
+ g_bytes_unref (res_bytes);
self->priv->window = GTK_WIDGET(gtk_builder_get_object(builder, "subwindow"));
diff --git a/src/mud-window-prefs.c b/src/mud-window-prefs.c
index 11f07ca..e2468a9 100644
--- a/src/mud-window-prefs.c
+++ b/src/mud-window-prefs.c
@@ -31,6 +31,7 @@
#include "mud-profile-manager.h"
#include "mud-window.h"
#include "mud-window-prefs.h"
+#include "resources.h"
struct _MudWindowPrefsPrivate
{
@@ -385,13 +386,19 @@ static void
mud_window_prefs_construct_window(MudWindowPrefs *self)
{
GtkBuilder *builder;
+ GBytes *res_bytes;
+ gconstpointer res_data;
+ gsize res_size;
GError *error = NULL;
GtkWidget *main_window;
gint i;
- builder = gtk_builder_new();
- if(gtk_builder_add_from_file(builder, UIDIR "/prefs.ui", &error) == 0)
- g_error("Failed to load: %s", error->message);
+ builder = gtk_builder_new ();
+ res_bytes = g_resource_lookup_data (gnome_mud_get_resource (), "/org/gnome/MUD/prefs.ui", 0, NULL);
+ res_data = g_bytes_get_data (res_bytes, &res_size);
+ if (gtk_builder_add_from_string (builder, res_data, res_size, &error) == 0)
+ g_error ("Failed to load resources: %s", error->message);
+ g_bytes_unref (res_bytes);
self->priv->window = GTK_WIDGET(gtk_builder_get_object(builder, "preferences_window"));
diff --git a/src/mud-window-profile.c b/src/mud-window-profile.c
index c74b09e..e0aed98 100644
--- a/src/mud-window-profile.c
+++ b/src/mud-window-profile.c
@@ -30,6 +30,7 @@
#include "mud-connection-view.h"
#include "mud-window.h"
#include "mud-window-profile.h"
+#include "resources.h"
#include "utils.h"
#include "mud-profile-manager.h"
#include "mud-window-prefs.h"
@@ -147,6 +148,9 @@ mud_profile_window_constructor (GType gtype,
GObjectClass *parent_class;
GtkBuilder *builder;
+ GBytes *res_bytes;
+ gconstpointer res_data;
+ gsize res_size;
GError *error = NULL;
GtkWindow *main_window;
GtkCellRenderer *renderer;
@@ -164,9 +168,12 @@ mud_profile_window_constructor (GType gtype,
g_error("Tried to instantiate MudProfileWindow without passing parent GtkWindow\n");
}
- builder = gtk_builder_new();
- if(gtk_builder_add_from_file(builder, UIDIR "/prefs.ui", &error) == 0)
- g_error("Failed to load: %s", error->message);
+ builder = gtk_builder_new ();
+ res_bytes = g_resource_lookup_data (gnome_mud_get_resource (), "/org/gnome/MUD/prefs.ui", 0, NULL);
+ res_data = g_bytes_get_data (res_bytes, &res_size);
+ if (gtk_builder_add_from_string (builder, res_data, res_size, &error) == 0)
+ g_error ("Failed to load resources: %s", error->message);
+ g_bytes_unref (res_bytes);
profwin->priv->window = GTK_WIDGET(gtk_builder_get_object(builder, "profiles_window"));
@@ -290,6 +297,9 @@ static void
mud_profile_window_add_cb(GtkWidget *widget, MudProfileWindow *profwin)
{
GtkBuilder *builder;
+ GBytes *res_bytes;
+ gconstpointer res_data;
+ gsize res_size;
GError *error = NULL;
GtkWidget *window;
GtkWidget *entry_profile;
@@ -297,9 +307,12 @@ mud_profile_window_add_cb(GtkWidget *widget, MudProfileWindow *profwin)
gint result;
MudProfile *prof;
- builder = gtk_builder_new();
- if(gtk_builder_add_from_file(builder, UIDIR "/prefs.ui", &error) == 0)
- g_error("Failed to load: %s", error->message);
+ builder = gtk_builder_new ();
+ res_bytes = g_resource_lookup_data (gnome_mud_get_resource (), "/org/gnome/MUD/prefs.ui", 0, NULL);
+ res_data = g_bytes_get_data (res_bytes, &res_size);
+ if (gtk_builder_add_from_string (builder, res_data, res_size, &error) == 0)
+ g_error ("Failed to load resources: %s", error->message);
+ g_bytes_unref (res_bytes);
window = GTK_WIDGET(gtk_builder_get_object(builder, "newprofile_dialog"));
diff --git a/src/mud-window.c b/src/mud-window.c
index 8a81a00..ec46323 100644
--- a/src/mud-window.c
+++ b/src/mud-window.c
@@ -33,6 +33,7 @@
#include <stdlib.h>
#include <glib/gprintf.h>
+#include "resources.h"
#include "gnome-mud.h"
#include "gnome-mud-icons.h"
#include "mud-connection-view.h"
@@ -228,6 +229,9 @@ static void
mud_window_init (MudWindow *self)
{
GtkBuilder *builder;
+ GBytes *res_bytes;
+ gconstpointer res_data;
+ gsize res_size;
GError *error = NULL;
GtkTextIter iter;
gint y;
@@ -236,9 +240,12 @@ mud_window_init (MudWindow *self)
self->priv = MUD_WINDOW_GET_PRIVATE(self);
/* start glading */
- builder = gtk_builder_new();
- if(gtk_builder_add_from_file(builder, UIDIR "/main.ui", &error) == 0)
- g_error("Failed to load: %s", error->message);
+ builder = gtk_builder_new ();
+ res_bytes = g_resource_lookup_data (gnome_mud_get_resource (), "/org/gnome/MUD/main.ui", 0, NULL);
+ res_data = g_bytes_get_data (res_bytes, &res_size);
+ if (gtk_builder_add_from_string (builder, res_data, res_size, &error) == 0)
+ g_error ("Failed to load resources: %s", error->message);
+ g_bytes_unref (res_bytes);
/* set public properties */
self->window = GTK_WINDOW(gtk_builder_get_object(builder, "main_window"));
@@ -890,13 +897,19 @@ static void
mud_window_buffer_cb(GtkWidget *widget, MudWindow *self)
{
GtkBuilder *builder;
+ GBytes *res_bytes;
+ gconstpointer res_data;
+ gsize res_size;
GError *error = NULL;
GtkWidget *dialog;
gint result;
- builder = gtk_builder_new();
- if(gtk_builder_add_from_file(builder, UIDIR "/main.ui", &error) == 0)
- g_error("Failed to load: %s", error->message);
+ builder = gtk_builder_new ();
+ res_bytes = g_resource_lookup_data (gnome_mud_get_resource (), "/org/gnome/MUD/main.ui", 0, NULL);
+ res_data = g_bytes_get_data (res_bytes, &res_size);
+ if (gtk_builder_add_from_string (builder, res_data, res_size, &error) == 0)
+ g_error ("Failed to load resources: %s", error->message);
+ g_bytes_unref (res_bytes);
dialog = GTK_WIDGET(gtk_builder_get_object(builder, "save_dialog"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]