[gnome-applets/wip/segeiger/in-process] stickynotes: migrate to GResource
- From: Sebastian Geiger <segeiger src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets/wip/segeiger/in-process] stickynotes: migrate to GResource
- Date: Sun, 21 Aug 2016 14:28:39 +0000 (UTC)
commit e70800e7026db2f5bcf58414b4d6c4eb878894fb
Author: Sebastian Geiger <sbastig gmx net>
Date: Sun Aug 21 16:09:13 2016 +0200
stickynotes: migrate to GResource
po/POTFILES.in | 14 +++++-----
stickynotes/Makefile.am | 25 --------------------
stickynotes/src/Makefile.am | 18 ++++++++++++++
.../sticky-notes-applet-menu.xml} | 0
.../sticky-notes-delete-all.ui} | 0
.../sticky-notes-delete.ui} | 0
.../sticky-notes-note-menu.xml} | 0
.../sticky-notes-note.ui} | 0
.../sticky-notes-preferences.ui} | 0
.../sticky-notes-properties.ui} | 0
.../src/sticky-notes-resources.gresource.xml | 12 +++++++++
stickynotes/src/stickynotes.c | 16 ++++++++----
stickynotes/src/stickynotes_applet.c | 17 +++++++++----
stickynotes/src/stickynotes_applet_callbacks.c | 6 ++++-
14 files changed, 64 insertions(+), 44 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 5fab8ad..3c3db17 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -97,17 +97,17 @@ netspeed/src/netspeed.c
netspeed/src/preferences.c
[type: gettext/ini]stickynotes/data/org.gnome.applets.StickyNotesApplet.panel-applet.in.in
stickynotes/src/org.gnome.gnome-applets.stickynotes.gschema.xml.in.in
-[type: gettext/glade]stickynotes/stickynotes-applet-menu.xml
stickynotes/src/stickynotes.c
stickynotes/src/stickynotes_applet.c
stickynotes/src/stickynotes_applet_callbacks.c
stickynotes/src/stickynotes_callbacks.c
-[type: gettext/glade]stickynotes/stickynotes-delete-all.ui
-[type: gettext/glade]stickynotes/stickynotes-delete.ui
-[type: gettext/glade]stickynotes/stickynotes-note-menu.xml
-[type: gettext/glade]stickynotes/stickynotes-note.ui
-[type: gettext/glade]stickynotes/stickynotes-preferences.ui
-[type: gettext/glade]stickynotes/stickynotes-properties.ui
+[type: gettext/glade]stickynotes/src/sticky-notes-applet-menu.xml
+[type: gettext/glade]stickynotes/src/sticky-notes-delete-all.ui
+[type: gettext/glade]stickynotes/src/sticky-notes-delete.ui
+[type: gettext/glade]stickynotes/src/sticky-notes-note-menu.xml
+[type: gettext/glade]stickynotes/src/sticky-notes-note.ui
+[type: gettext/glade]stickynotes/src/sticky-notes-preferences.ui
+[type: gettext/glade]stickynotes/src/sticky-notes-properties.ui
[type: gettext/ini]timer/data/org.gnome.applets.TimerApplet.panel-applet.in.in
timer/src/org.gnome.gnome-applets.timer.gschema.xml.in.in
timer/src/timerapplet.c
diff --git a/stickynotes/Makefile.am b/stickynotes/Makefile.am
index 401c760..f3eea96 100644
--- a/stickynotes/Makefile.am
+++ b/stickynotes/Makefile.am
@@ -1,28 +1,3 @@
-NULL =
-
SUBDIRS = data help pixmaps src
-ui_files = stickynotes-applet-menu.xml \
- stickynotes-note-menu.xml
-builder_files = stickynotes-note.ui \
- stickynotes-delete.ui \
- stickynotes-delete-all.ui \
- stickynotes-preferences.ui \
- stickynotes-properties.ui
-
-if BUILD_STICKYNOTES_APPLET
-
-builderdir = $(pkgdatadir)/builder
-builder_DATA = $(builder_files)
-
-uidir = $(pkgdatadir)/ui
-ui_DATA = $(ui_files)
-
-endif
-
-EXTRA_DIST = \
- $(builder_files) \
- $(ui_files) \
- $(NULL)
-
-include $(top_srcdir)/git.mk
diff --git a/stickynotes/src/Makefile.am b/stickynotes/src/Makefile.am
index dd18a6f..69f32f7 100644
--- a/stickynotes/src/Makefile.am
+++ b/stickynotes/src/Makefile.am
@@ -32,6 +32,8 @@ libsticky_notes_applet_la_SOURCES = \
stickynotes_applet_callbacks.h \
stickynotes_callbacks.c \
stickynotes_callbacks.h \
+ sticky-notes-resources.c \
+ sticky-notes-resources.h \
util.c \
util.h \
$(NULL)
@@ -62,15 +64,31 @@ gsettings_SCHEMAS = $(gsettings_schemas_in:.xml.in=.xml)
@GSETTINGS_RULES@
+sticky-notes-resources.c: sticky-notes-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES)
--sourcedir=$(srcdir) --generate-dependencies $(srcdir)/sticky-notes-resources.gresource.xml)
+ $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name
sticky_notes $<
+
+sticky-notes-resources.h: sticky-notes-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES)
--sourcedir=$(srcdir) --generate-dependencies $(srcdir)/sticky-notes-resources.gresource.xml)
+ $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name
sticky_notes $<
+
CLEANFILES = \
$(gsettings_SCHEMAS) \
*.gschema.valid \
+ sticky-notes-resources.c \
+ sticky-notes-resources.h \
$(NULL)
endif
EXTRA_DIST = \
$(gsettings_schemas_in_in) \
+ sticky-notes-applet-menu.xml \
+ sticky-notes-delete.ui \
+ sticky-notes-delete-all.ui \
+ sticky-notes-note.ui \
+ sticky-notes-note-menu.xml \
+ sticky-notes-preferences.ui \
+ sticky-notes-properties.ui
+ sticky-notes-resources.gresource.xml \
$(NULL)
-include $(top_srcdir)/git.mk
diff --git a/stickynotes/stickynotes-applet-menu.xml b/stickynotes/src/sticky-notes-applet-menu.xml
similarity index 100%
rename from stickynotes/stickynotes-applet-menu.xml
rename to stickynotes/src/sticky-notes-applet-menu.xml
diff --git a/stickynotes/stickynotes-delete-all.ui b/stickynotes/src/sticky-notes-delete-all.ui
similarity index 100%
rename from stickynotes/stickynotes-delete-all.ui
rename to stickynotes/src/sticky-notes-delete-all.ui
diff --git a/stickynotes/stickynotes-delete.ui b/stickynotes/src/sticky-notes-delete.ui
similarity index 100%
rename from stickynotes/stickynotes-delete.ui
rename to stickynotes/src/sticky-notes-delete.ui
diff --git a/stickynotes/stickynotes-note-menu.xml b/stickynotes/src/sticky-notes-note-menu.xml
similarity index 100%
rename from stickynotes/stickynotes-note-menu.xml
rename to stickynotes/src/sticky-notes-note-menu.xml
diff --git a/stickynotes/stickynotes-note.ui b/stickynotes/src/sticky-notes-note.ui
similarity index 100%
rename from stickynotes/stickynotes-note.ui
rename to stickynotes/src/sticky-notes-note.ui
diff --git a/stickynotes/stickynotes-preferences.ui b/stickynotes/src/sticky-notes-preferences.ui
similarity index 100%
rename from stickynotes/stickynotes-preferences.ui
rename to stickynotes/src/sticky-notes-preferences.ui
diff --git a/stickynotes/stickynotes-properties.ui b/stickynotes/src/sticky-notes-properties.ui
similarity index 100%
rename from stickynotes/stickynotes-properties.ui
rename to stickynotes/src/sticky-notes-properties.ui
diff --git a/stickynotes/src/sticky-notes-resources.gresource.xml
b/stickynotes/src/sticky-notes-resources.gresource.xml
new file mode 100644
index 0000000..328b7e3
--- /dev/null
+++ b/stickynotes/src/sticky-notes-resources.gresource.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/gnome-applets/sticky-notes">
+ <file compressed="true">sticky-notes-applet-menu.xml</file>
+ <file compressed="true">sticky-notes-delete.ui</file>
+ <file compressed="true">sticky-notes-delete-all.ui</file>
+ <file compressed="true">sticky-notes-note.ui</file>
+ <file compressed="true">sticky-notes-note-menu.xml</file>
+ <file compressed="true">sticky-notes-preferences.ui</file>
+ <file compressed="true">sticky-notes-properties.ui</file>
+ </gresource>
+</gresources>
diff --git a/stickynotes/src/stickynotes.c b/stickynotes/src/stickynotes.c
index 5ff4294..b33026c 100644
--- a/stickynotes/src/stickynotes.c
+++ b/stickynotes/src/stickynotes.c
@@ -29,6 +29,7 @@
#include "stickynotes_applet.h"
#include "gsettings.h"
+#define GRESOURCE "/org/gnome/gnome-applets/sticky-notes/"
/* Stop gcc complaining about xmlChar's signedness */
#define XML_CHAR(str) ((xmlChar *) (str))
#define XML_PATH "/.config/gnome-applets/stickynotes"
@@ -53,6 +54,7 @@ setup_note_menu (StickyNote *note)
gchar *ui_file;
GtkBuilder *builder;
GMenu *gmenu;
+ const gchar *resource_name;
action_group = g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (action_group),
@@ -60,9 +62,8 @@ setup_note_menu (StickyNote *note)
G_N_ELEMENTS (stickynotes_note_menu_actions),
note);
- ui_file = g_build_filename (STICKYNOTES_MENU_UI_DIR, "stickynotes-note-menu.xml", NULL);
- builder = gtk_builder_new_from_file (ui_file);
- g_free (ui_file);
+ resource_name = GRESOURCE "sticky-notes-note-menu.xml";
+ builder = gtk_builder_new_from_resource (resource_name);
gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
@@ -140,8 +141,10 @@ stickynote_new_aux (GdkScreen *screen, gint x, gint y, gint w, gint h)
note = g_new (StickyNote, 1);
builder = gtk_builder_new ();
- gtk_builder_add_from_file (builder, GTK_BUILDERDIR "/stickynotes-note.ui", NULL);
- gtk_builder_add_from_file (builder, GTK_BUILDERDIR "/stickynotes-properties.ui", NULL);
+ gtk_builder_add_from_resource (builder,
+ GRESOURCE "sticky-notes-note.ui", NULL);
+ gtk_builder_add_from_resource (builder,
+ GRESOURCE "sticky-notes-properties.ui", NULL);
note->w_window = GTK_WIDGET (gtk_builder_get_object (builder, "stickynote_window"));
gtk_window_set_screen(GTK_WINDOW(note->w_window),screen);
@@ -671,7 +674,8 @@ void stickynotes_remove(StickyNote *note)
GtkWidget *dialog;
builder = gtk_builder_new ();
- gtk_builder_add_from_file (builder, GTK_BUILDERDIR "/stickynotes-delete.ui", NULL);
+ gtk_builder_add_from_resource (builder,
+ GRESOURCE "/sticky-notes-delete.ui", NULL);
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "delete_dialog"));
diff --git a/stickynotes/src/stickynotes_applet.c b/stickynotes/src/stickynotes_applet.c
index 7872e81..a930504 100644
--- a/stickynotes/src/stickynotes_applet.c
+++ b/stickynotes/src/stickynotes_applet.c
@@ -24,6 +24,8 @@
#include <gtk/gtk.h>
+#define GRESOURCE "/org/gnome/gnome-applets/sticky-notes/"
+
StickyNotes *stickynotes = NULL;
/* Popup menu on the applet */
@@ -185,7 +187,9 @@ void stickynotes_applet_init_prefs(void)
stickynotes->builder = gtk_builder_new ();
- gtk_builder_add_from_file (stickynotes->builder, GTK_BUILDERDIR "/stickynotes-preferences.ui", NULL);
+ gtk_builder_add_from_resource (stickynotes->builder,
+ GRESOURCE "sticky-notes-preferences.ui",
+ NULL);
stickynotes->w_prefs = GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,
"preferences_dialog"));
@@ -315,7 +319,7 @@ StickyNotesApplet *
stickynotes_applet_new (PanelApplet *panel_applet)
{
AtkObject *atk_obj;
- gchar *ui_path;
+ const gchar *resource_name;
GAction *action;
/* Create Sticky Notes Applet */
@@ -344,9 +348,12 @@ stickynotes_applet_new (PanelApplet *panel_applet)
stickynotes_applet_menu_actions,
G_N_ELEMENTS (stickynotes_applet_menu_actions),
applet);
- ui_path = g_build_filename (STICKYNOTES_MENU_UI_DIR, "stickynotes-applet-menu.xml", NULL);
- panel_applet_setup_menu_from_file(panel_applet, ui_path, applet->action_group, GETTEXT_PACKAGE);
- g_free (ui_path);
+
+ resource_name = GRESOURCE "sticky-notes-applet-menu.xml";
+ panel_applet_setup_menu_from_resource (panel_applet,
+ resource_name,
+ applet->action_group,
+ GETTEXT_PACKAGE);
gtk_widget_insert_action_group (GTK_WIDGET (panel_applet), "stickynotes",
G_ACTION_GROUP (applet->action_group));
diff --git a/stickynotes/src/stickynotes_applet_callbacks.c b/stickynotes/src/stickynotes_applet_callbacks.c
index 10a6484..9bccf35 100644
--- a/stickynotes/src/stickynotes_applet_callbacks.c
+++ b/stickynotes/src/stickynotes_applet_callbacks.c
@@ -24,6 +24,8 @@
#include <X11/Xatom.h>
#include <gdk/gdkx.h>
+#define GRESOURCE "/org/gnome/gnome-applets/sticky-notes/"
+
static gboolean get_desktop_window (Window *window)
{
Window *desktop_window;
@@ -295,7 +297,9 @@ void menu_destroy_all_cb(GSimpleAction *action, GVariant *parameter, gpointer us
GtkBuilder *builder;
builder = gtk_builder_new ();
- gtk_builder_add_from_file (builder, GTK_BUILDERDIR "/stickynotes-delete-all.ui", NULL);
+ gtk_builder_add_from_resource (builder,
+ GRESOURCE "/sticky-notes-delete-all.ui",
+ NULL);
if (applet->destroy_all_dialog != NULL) {
gtk_window_set_screen (GTK_WINDOW (applet->destroy_all_dialog),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]