From b0b271274c98274d4c53608c856194270ae12d0f Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Fri, 4 Sep 2020 08:26:04 +0100 Subject: [PATCH] Make GTK UI resources more consistent The GTK UI resources have to be different resources between major versions. When kept in one directory with slightly different filenames they were difficult to distinguish and resource definition was difficult to update. The resources for both gtk versions were stored in both builds resulting in unneccessary increased binary size. The new stratagy lists the UI files once in a single gresources file and only includes what is required. If a UI file is added it must be provided in both gtk2 and 3 or a build failure will occour rather than a runtime error. --- frontends/gtk/Makefile | 10 ++++++- .../res/{cookies.gtk2.ui => gtk2/cookies.ui} | 0 .../{downloads.gtk2.ui => gtk2/downloads.ui} | 0 .../globalhistory.ui} | 0 .../res/{hotlist.gtk2.ui => gtk2/hotlist.ui} | 0 .../localhistory.ui} | 0 .../res/{netsurf.gtk2.ui => gtk2/netsurf.ui} | 0 .../res/{options.gtk2.ui => gtk2/options.ui} | 0 .../{pageinfo.gtk2.ui => gtk2/pageinfo.ui} | 0 .../{password.gtk2.ui => gtk2/password.ui} | 0 .../tabcontents.ui} | 0 .../res/{toolbar.gtk2.ui => gtk2/toolbar.ui} | 0 .../{viewdata.gtk2.ui => gtk2/viewdata.ui} | 0 .../res/{warning.gtk2.ui => gtk2/warning.ui} | 0 .../res/{cookies.gtk3.ui => gtk3/cookies.ui} | 0 .../{downloads.gtk3.ui => gtk3/downloads.ui} | 0 .../globalhistory.ui} | 0 .../res/{hotlist.gtk3.ui => gtk3/hotlist.ui} | 0 .../localhistory.ui} | 0 .../res/{netsurf.gtk3.ui => gtk3/netsurf.ui} | 0 .../res/{options.gtk3.ui => gtk3/options.ui} | 0 .../{pageinfo.gtk3.ui => gtk3/pageinfo.ui} | 0 .../{password.gtk3.ui => gtk3/password.ui} | 0 .../tabcontents.ui} | 0 .../res/{toolbar.gtk3.ui => gtk3/toolbar.ui} | 0 .../{viewdata.gtk3.ui => gtk3/viewdata.ui} | 0 .../res/{warning.gtk3.ui => gtk3/warning.ui} | 0 frontends/gtk/res/netsurf.gresource.xml | 26 ------------------- frontends/gtk/res/ui.gresource.xml | 18 +++++++++++++ frontends/gtk/resources.c | 7 +---- 30 files changed, 28 insertions(+), 33 deletions(-) rename frontends/gtk/res/{cookies.gtk2.ui => gtk2/cookies.ui} (100%) rename frontends/gtk/res/{downloads.gtk2.ui => gtk2/downloads.ui} (100%) rename frontends/gtk/res/{globalhistory.gtk2.ui => gtk2/globalhistory.ui} (100%) rename frontends/gtk/res/{hotlist.gtk2.ui => gtk2/hotlist.ui} (100%) rename frontends/gtk/res/{localhistory.gtk2.ui => gtk2/localhistory.ui} (100%) rename frontends/gtk/res/{netsurf.gtk2.ui => gtk2/netsurf.ui} (100%) rename frontends/gtk/res/{options.gtk2.ui => gtk2/options.ui} (100%) rename frontends/gtk/res/{pageinfo.gtk2.ui => gtk2/pageinfo.ui} (100%) rename frontends/gtk/res/{password.gtk2.ui => gtk2/password.ui} (100%) rename frontends/gtk/res/{tabcontents.gtk2.ui => gtk2/tabcontents.ui} (100%) rename frontends/gtk/res/{toolbar.gtk2.ui => gtk2/toolbar.ui} (100%) rename frontends/gtk/res/{viewdata.gtk2.ui => gtk2/viewdata.ui} (100%) rename frontends/gtk/res/{warning.gtk2.ui => gtk2/warning.ui} (100%) rename frontends/gtk/res/{cookies.gtk3.ui => gtk3/cookies.ui} (100%) rename frontends/gtk/res/{downloads.gtk3.ui => gtk3/downloads.ui} (100%) rename frontends/gtk/res/{globalhistory.gtk3.ui => gtk3/globalhistory.ui} (100%) rename frontends/gtk/res/{hotlist.gtk3.ui => gtk3/hotlist.ui} (100%) rename frontends/gtk/res/{localhistory.gtk3.ui => gtk3/localhistory.ui} (100%) rename frontends/gtk/res/{netsurf.gtk3.ui => gtk3/netsurf.ui} (100%) rename frontends/gtk/res/{options.gtk3.ui => gtk3/options.ui} (100%) rename frontends/gtk/res/{pageinfo.gtk3.ui => gtk3/pageinfo.ui} (100%) rename frontends/gtk/res/{password.gtk3.ui => gtk3/password.ui} (100%) rename frontends/gtk/res/{tabcontents.gtk3.ui => gtk3/tabcontents.ui} (100%) rename frontends/gtk/res/{toolbar.gtk3.ui => gtk3/toolbar.ui} (100%) rename frontends/gtk/res/{viewdata.gtk3.ui => gtk3/viewdata.ui} (100%) rename frontends/gtk/res/{warning.gtk3.ui => gtk3/warning.ui} (100%) create mode 100644 frontends/gtk/res/ui.gresource.xml diff --git a/frontends/gtk/Makefile b/frontends/gtk/Makefile index e4929e416..3bf3ea063 100644 --- a/frontends/gtk/Makefile +++ b/frontends/gtk/Makefile @@ -103,6 +103,7 @@ GLIB_COMPILE_RESOURCES := glib-compile-resources CFLAGS += -DWITH_GRESOURCE NETSURF_GRESOURCE_XML := $(NSGTK_RESOURCES_DIR)/netsurf.gresource.xml +UI_GRESOURCE_XML := $(NSGTK_RESOURCES_DIR)/ui.gresource.xml MESSAGES_GRESOURCE_XML := $(NSGTK_RESOURCES_DIR)/messages.gresource.xml # generate the netsurf gresource source files @@ -112,6 +113,13 @@ $(OBJROOT)/netsurf_gresource.c: $(NETSURF_GRESOURCE_XML) $(shell $(GLIB_COMPILE_ S_RESOURCE += $(OBJROOT)/netsurf_gresource.c +# generate the ui gresource source files +$(OBJROOT)/ui_gresource.c: $(UI_GRESOURCE_XML) $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir $(NSGTK_RESOURCES_DIR)/gtk$(NETSURF_GTK_MAJOR) --generate-dependencies $(UI_GRESOURCE_XML)) + $(VQ)echo "GRESORCE: $<" + $(Q)$(GLIB_COMPILE_RESOURCES) --generate-source --sourcedir $(NSGTK_RESOURCES_DIR)/gtk$(NETSURF_GTK_MAJOR) --target=$@ $< + +S_RESOURCE += $(OBJROOT)/ui_gresource.c + # generate the messages gresource source file $(OBJROOT)/messages_gresource.c: $(MESSAGES_GRESOURCE_XML) $(addsuffix /Messages,$(addprefix $(MESSAGES_TARGET)/,$(MESSAGES_LANGUAGES))) $(VQ)echo "GRESORCE: $<" @@ -182,7 +190,7 @@ GTK_RESOURCES_LIST := \ GTK_RESOURCES_LIST := \ $(addprefix $(NSGTK_RESOURCES_DIR)/, $(GTK_RESOURCES_LIST)) \ - $(wildcard $(NSGTK_RESOURCES_DIR)/*.gtk$(NETSURF_GTK_MAJOR).ui) + $(wildcard $(NSGTK_RESOURCES_DIR)/gtk$(NETSURF_GTK_MAJOR)/*.ui) # translations with more than just Messages files GTK_TRANSLATIONS_HTML := de en fr it ja nl zh_CN diff --git a/frontends/gtk/res/cookies.gtk2.ui b/frontends/gtk/res/gtk2/cookies.ui similarity index 100% rename from frontends/gtk/res/cookies.gtk2.ui rename to frontends/gtk/res/gtk2/cookies.ui diff --git a/frontends/gtk/res/downloads.gtk2.ui b/frontends/gtk/res/gtk2/downloads.ui similarity index 100% rename from frontends/gtk/res/downloads.gtk2.ui rename to frontends/gtk/res/gtk2/downloads.ui diff --git a/frontends/gtk/res/globalhistory.gtk2.ui b/frontends/gtk/res/gtk2/globalhistory.ui similarity index 100% rename from frontends/gtk/res/globalhistory.gtk2.ui rename to frontends/gtk/res/gtk2/globalhistory.ui diff --git a/frontends/gtk/res/hotlist.gtk2.ui b/frontends/gtk/res/gtk2/hotlist.ui similarity index 100% rename from frontends/gtk/res/hotlist.gtk2.ui rename to frontends/gtk/res/gtk2/hotlist.ui diff --git a/frontends/gtk/res/localhistory.gtk2.ui b/frontends/gtk/res/gtk2/localhistory.ui similarity index 100% rename from frontends/gtk/res/localhistory.gtk2.ui rename to frontends/gtk/res/gtk2/localhistory.ui diff --git a/frontends/gtk/res/netsurf.gtk2.ui b/frontends/gtk/res/gtk2/netsurf.ui similarity index 100% rename from frontends/gtk/res/netsurf.gtk2.ui rename to frontends/gtk/res/gtk2/netsurf.ui diff --git a/frontends/gtk/res/options.gtk2.ui b/frontends/gtk/res/gtk2/options.ui similarity index 100% rename from frontends/gtk/res/options.gtk2.ui rename to frontends/gtk/res/gtk2/options.ui diff --git a/frontends/gtk/res/pageinfo.gtk2.ui b/frontends/gtk/res/gtk2/pageinfo.ui similarity index 100% rename from frontends/gtk/res/pageinfo.gtk2.ui rename to frontends/gtk/res/gtk2/pageinfo.ui diff --git a/frontends/gtk/res/password.gtk2.ui b/frontends/gtk/res/gtk2/password.ui similarity index 100% rename from frontends/gtk/res/password.gtk2.ui rename to frontends/gtk/res/gtk2/password.ui diff --git a/frontends/gtk/res/tabcontents.gtk2.ui b/frontends/gtk/res/gtk2/tabcontents.ui similarity index 100% rename from frontends/gtk/res/tabcontents.gtk2.ui rename to frontends/gtk/res/gtk2/tabcontents.ui diff --git a/frontends/gtk/res/toolbar.gtk2.ui b/frontends/gtk/res/gtk2/toolbar.ui similarity index 100% rename from frontends/gtk/res/toolbar.gtk2.ui rename to frontends/gtk/res/gtk2/toolbar.ui diff --git a/frontends/gtk/res/viewdata.gtk2.ui b/frontends/gtk/res/gtk2/viewdata.ui similarity index 100% rename from frontends/gtk/res/viewdata.gtk2.ui rename to frontends/gtk/res/gtk2/viewdata.ui diff --git a/frontends/gtk/res/warning.gtk2.ui b/frontends/gtk/res/gtk2/warning.ui similarity index 100% rename from frontends/gtk/res/warning.gtk2.ui rename to frontends/gtk/res/gtk2/warning.ui diff --git a/frontends/gtk/res/cookies.gtk3.ui b/frontends/gtk/res/gtk3/cookies.ui similarity index 100% rename from frontends/gtk/res/cookies.gtk3.ui rename to frontends/gtk/res/gtk3/cookies.ui diff --git a/frontends/gtk/res/downloads.gtk3.ui b/frontends/gtk/res/gtk3/downloads.ui similarity index 100% rename from frontends/gtk/res/downloads.gtk3.ui rename to frontends/gtk/res/gtk3/downloads.ui diff --git a/frontends/gtk/res/globalhistory.gtk3.ui b/frontends/gtk/res/gtk3/globalhistory.ui similarity index 100% rename from frontends/gtk/res/globalhistory.gtk3.ui rename to frontends/gtk/res/gtk3/globalhistory.ui diff --git a/frontends/gtk/res/hotlist.gtk3.ui b/frontends/gtk/res/gtk3/hotlist.ui similarity index 100% rename from frontends/gtk/res/hotlist.gtk3.ui rename to frontends/gtk/res/gtk3/hotlist.ui diff --git a/frontends/gtk/res/localhistory.gtk3.ui b/frontends/gtk/res/gtk3/localhistory.ui similarity index 100% rename from frontends/gtk/res/localhistory.gtk3.ui rename to frontends/gtk/res/gtk3/localhistory.ui diff --git a/frontends/gtk/res/netsurf.gtk3.ui b/frontends/gtk/res/gtk3/netsurf.ui similarity index 100% rename from frontends/gtk/res/netsurf.gtk3.ui rename to frontends/gtk/res/gtk3/netsurf.ui diff --git a/frontends/gtk/res/options.gtk3.ui b/frontends/gtk/res/gtk3/options.ui similarity index 100% rename from frontends/gtk/res/options.gtk3.ui rename to frontends/gtk/res/gtk3/options.ui diff --git a/frontends/gtk/res/pageinfo.gtk3.ui b/frontends/gtk/res/gtk3/pageinfo.ui similarity index 100% rename from frontends/gtk/res/pageinfo.gtk3.ui rename to frontends/gtk/res/gtk3/pageinfo.ui diff --git a/frontends/gtk/res/password.gtk3.ui b/frontends/gtk/res/gtk3/password.ui similarity index 100% rename from frontends/gtk/res/password.gtk3.ui rename to frontends/gtk/res/gtk3/password.ui diff --git a/frontends/gtk/res/tabcontents.gtk3.ui b/frontends/gtk/res/gtk3/tabcontents.ui similarity index 100% rename from frontends/gtk/res/tabcontents.gtk3.ui rename to frontends/gtk/res/gtk3/tabcontents.ui diff --git a/frontends/gtk/res/toolbar.gtk3.ui b/frontends/gtk/res/gtk3/toolbar.ui similarity index 100% rename from frontends/gtk/res/toolbar.gtk3.ui rename to frontends/gtk/res/gtk3/toolbar.ui diff --git a/frontends/gtk/res/viewdata.gtk3.ui b/frontends/gtk/res/gtk3/viewdata.ui similarity index 100% rename from frontends/gtk/res/viewdata.gtk3.ui rename to frontends/gtk/res/gtk3/viewdata.ui diff --git a/frontends/gtk/res/warning.gtk3.ui b/frontends/gtk/res/gtk3/warning.ui similarity index 100% rename from frontends/gtk/res/warning.gtk3.ui rename to frontends/gtk/res/gtk3/warning.ui diff --git a/frontends/gtk/res/netsurf.gresource.xml b/frontends/gtk/res/netsurf.gresource.xml index 272c1ade2..ada2d59fc 100644 --- a/frontends/gtk/res/netsurf.gresource.xml +++ b/frontends/gtk/res/netsurf.gresource.xml @@ -1,32 +1,6 @@ - cookies.gtk2.ui - cookies.gtk3.ui - downloads.gtk2.ui - downloads.gtk3.ui - globalhistory.gtk2.ui - globalhistory.gtk3.ui - hotlist.gtk2.ui - hotlist.gtk3.ui - localhistory.gtk2.ui - localhistory.gtk3.ui - netsurf.gtk2.ui - netsurf.gtk3.ui - options.gtk2.ui - options.gtk3.ui - pageinfo.gtk2.ui - pageinfo.gtk3.ui - password.gtk2.ui - password.gtk3.ui - tabcontents.gtk2.ui - tabcontents.gtk3.ui - toolbar.gtk2.ui - toolbar.gtk3.ui - viewdata.gtk2.ui - viewdata.gtk3.ui - warning.gtk3.ui - warning.gtk2.ui favicon.png netsurf.xpm menu_cursor.png diff --git a/frontends/gtk/res/ui.gresource.xml b/frontends/gtk/res/ui.gresource.xml new file mode 100644 index 000000000..dd43ddf59 --- /dev/null +++ b/frontends/gtk/res/ui.gresource.xml @@ -0,0 +1,18 @@ + + + + cookies.ui + downloads.ui + globalhistory.ui + hotlist.ui + localhistory.ui + netsurf.ui + options.ui + pageinfo.ui + password.ui + tabcontents.ui + toolbar.ui + viewdata.ui + warning.ui + + diff --git a/frontends/gtk/resources.c b/frontends/gtk/resources.c index 432ddb8b5..fc17f7418 100644 --- a/frontends/gtk/resources.c +++ b/frontends/gtk/resources.c @@ -345,11 +345,6 @@ init_pixbuf_resource(char **respath, struct nsgtk_resource_s *resource) */ static nserror init_ui_resource(char **respath, struct nsgtk_resource_s *ui_res) { -#if GTK_CHECK_VERSION(3,0,0) - int gtkv = 3; -#else - int gtkv = 2; -#endif int resnamelen; char *resname; struct nsgtk_resource_s resource; @@ -361,7 +356,7 @@ static nserror init_ui_resource(char **respath, struct nsgtk_resource_s *ui_res) if (resname == NULL) { return NSERROR_NOMEM; } - snprintf(resname, resnamelen, "%s.gtk%d.ui", ui_res->name, gtkv); + snprintf(resname, resnamelen, "%s.ui", ui_res->name); resource.name = resname; resource.len = ui_res->len; resource.path = NULL;