[ghex] meson/config.h: Don't hardcode the app-id
- From: Logan Rathbone <larathbone src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ghex] meson/config.h: Don't hardcode the app-id
- Date: Wed, 8 Dec 2021 03:54:16 +0000 (UTC)
commit 11351c6ca813edab048f9544eadd56f9a15021bc
Author: Logan Rathbone <poprocks gmail com>
Date: Tue Dec 7 22:51:49 2021 -0500
meson/config.h: Don't hardcode the app-id
Among other things, this should resolve the issue of the keyboard
shortcut menu not being accessible in development builds.
data/meson.build | 7 ++++--
data/org.gnome.GHex.gschema.xml.in | 12 +++++------
meson.build | 3 +++
src/configuration.c | 2 +-
src/ghex-application-window.c | 4 +++-
...ion-window.ui => ghex-application-window.ui.in} | 2 +-
src/{ghex.gresource.xml => ghex.gresource.xml.in} | 4 ++--
src/gtkhex.c | 2 +-
src/meson.build | 25 ++++++++++++++++++----
src/paste-special.c | 4 +++-
src/preferences.c | 4 ++--
11 files changed, 48 insertions(+), 21 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index c5f76ed..5835a14 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -7,6 +7,7 @@ endif
desktop_file_in_config = configuration_data()
desktop_file_in_config.set('app_id', app_id)
desktop_file_in_config.set('app_name', app_name)
+
desktop_file_in = configure_file(
input: 'org.gnome.GHex.desktop.in.in',
output: '@0 desktop in'.format(app_id),
@@ -53,11 +54,13 @@ configure_file(
)
schema_conf = configuration_data()
-schema_conf.set_quoted('XML_SHADED_BOX_MAX', shaded_box_max.to_string())
+schema_conf.set('shaded_box_max', shaded_box_max)
+schema_conf.set('app_id', app_id)
+schema_conf.set('resource_base_path', resource_base_path)
configure_file(
input: 'org.gnome.GHex.gschema.xml.in',
- output: 'org.gnome.GHex.gschema.xml',
+ output: '@0 gschema xml'.format(app_id),
configuration: schema_conf,
install_dir: ghex_schemasdir,
install: true
diff --git a/data/org.gnome.GHex.gschema.xml.in b/data/org.gnome.GHex.gschema.xml.in
index 32c02e2..fc2d2dc 100644
--- a/data/org.gnome.GHex.gschema.xml.in
+++ b/data/org.gnome.GHex.gschema.xml.in
@@ -5,22 +5,22 @@
<!-- it does not appear possible to automate this (enums) with meson presently.
See: https://github.com/mesonbuild/meson/issues/1687
-->
- <enum id="org.gnome.GHex.GroupType">
+ <enum id="@app_id@.GroupType">
<value nick="bytes" value="1"/>
<value nick="words" value="2"/>
<value nick="longwords" value="4"/>
</enum>
- <enum id="org.gnome.GHex.DarkMode">
+ <enum id="@app_id@.DarkMode">
<value nick="off" value="0"/>
<value nick="on" value="1"/>
<value nick="system" value="2"/>
</enum>
- <schema id="org.gnome.GHex" path="/org/gnome/ghex/">
+ <schema id="@app_id@" path="@resource_base_path@/">
<key name="font" type="s">
<default>'Monospace 12'</default>
</key>
- <key name="group-data-by" enum="org.gnome.GHex.GroupType">
+ <key name="group-data-by" enum="@app_id@.GroupType">
<default>'bytes'</default>
</key>
<key name="print-font-data" type="s">
@@ -30,13 +30,13 @@
<default>'Sans 12'</default>
</key>
<key name="print-shaded-rows" type="u">
- <range min="0" max=@XML_SHADED_BOX_MAX@/>
+ <range min="0" max="@shaded_box_max@"/>
<default>0</default>
</key>
<key name="show-offsets" type="b">
<default>true</default>
</key>
- <key name="dark-mode" enum="org.gnome.GHex.DarkMode">
+ <key name="dark-mode" enum="@app_id@.DarkMode">
<default>'system'</default>
</key>
</schema>
diff --git a/meson.build b/meson.build
index e16796b..2c857fa 100644
--- a/meson.build
+++ b/meson.build
@@ -7,8 +7,10 @@ project(
if get_option('development')
app_id = 'org.gnome.GHex.Devel'
+ resource_base_path = '/org/gnome/GHex/Devel'
else
app_id = 'org.gnome.GHex'
+ resource_base_path = '/org/gnome/GHex'
endif
version_arr = meson.project_version().split('.')
@@ -49,6 +51,7 @@ shaded_box_max = 1000
config_h = configuration_data()
config_h.set_quoted('APP_ID', app_id)
+config_h.set_quoted('RESOURCE_BASE_PATH', resource_base_path)
config_h.set_quoted('PACKAGE_NAME', meson.project_name())
config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
config_h.set_quoted('PACKAGE_STRING', '@0@ @1@'.format(meson.project_name(), meson.project_version()))
diff --git a/src/configuration.c b/src/configuration.c
index 3b225ef..9fea4d2 100644
--- a/src/configuration.c
+++ b/src/configuration.c
@@ -133,7 +133,7 @@ void ghex_init_configuration ()
{
/* GSettings */
- settings = g_settings_new ("org.gnome.GHex");
+ settings = g_settings_new (APP_ID);
g_return_if_fail (settings);
g_signal_connect (settings, "changed::" GHEX_PREF_OFFSETS_COLUMN,
diff --git a/src/ghex-application-window.c b/src/ghex-application-window.c
index 0424deb..7ea9e25 100644
--- a/src/ghex-application-window.c
+++ b/src/ghex-application-window.c
@@ -28,6 +28,8 @@
* other, so keep this header here in the source file to avoid issues. */
#include "paste-special.h"
+#include <config.h>
+
/* DEFINES */
#define offset_fmt "0x%X"
@@ -1837,7 +1839,7 @@ ghex_application_window_class_init(GHexApplicationWindowClass *klass)
/* WIDGET TEMPLATE .UI */
gtk_widget_class_set_template_from_resource (widget_class,
- "/org/gnome/GHex/ghex-application-window.ui");
+ RESOURCE_BASE_PATH "/ghex-application-window.ui");
gtk_widget_class_bind_template_child (widget_class, GHexApplicationWindow,
no_doc_label);
diff --git a/src/ghex-application-window.ui b/src/ghex-application-window.ui.in
similarity index 99%
rename from src/ghex-application-window.ui
rename to src/ghex-application-window.ui.in
index ab4f2d8..7cac445 100644
--- a/src/ghex-application-window.ui
+++ b/src/ghex-application-window.ui.in
@@ -139,7 +139,7 @@
<property name="title" translatable="yes">GHex</property>
<property name="default-width">800</property>
<property name="default-height">600</property>
- <property name="icon-name">org.gnome.GHex</property>
+ <property name="icon-name">@app_id@</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="headerbar">
diff --git a/src/ghex.gresource.xml b/src/ghex.gresource.xml.in
similarity index 93%
rename from src/ghex.gresource.xml
rename to src/ghex.gresource.xml.in
index 11c6a52..8153bbb 100644
--- a/src/ghex.gresource.xml
+++ b/src/ghex.gresource.xml.in
@@ -24,13 +24,13 @@
-->
<gresources>
- <gresource prefix="/org/gnome/GHex">
+ <gresource prefix="@resource_base_path@">
<file preprocess="xml-stripblanks" compressed="true">ghex-application-window.ui</file>
<file preprocess="xml-stripblanks" compressed="true">context-menu.ui</file>
<file preprocess="xml-stripblanks" compressed="true">preferences.ui</file>
<file preprocess="xml-stripblanks" compressed="true">paste-special.ui</file>
</gresource>
- <gresource prefix="/org/gnome/GHex/gtk">
+ <gresource prefix="@resource_base_path@/gtk">
<file preprocess="xml-stripblanks">help-overlay.ui</file>
</gresource>
</gresources>
diff --git a/src/gtkhex.c b/src/gtkhex.c
index 119bdcb..8b481d2 100644
--- a/src/gtkhex.c
+++ b/src/gtkhex.c
@@ -2486,7 +2486,7 @@ gtk_hex_init (GtkHex *gh)
/* Context Menu */
- builder = gtk_builder_new_from_resource ("/org/gnome/GHex/context-menu.ui");
+ builder = gtk_builder_new_from_resource (RESOURCE_BASE_PATH "/context-menu.ui");
menu = G_MENU_MODEL(gtk_builder_get_object (builder, "context-menu"));
gh->context_menu = gtk_popover_menu_new_from_model (menu);
diff --git a/src/meson.build b/src/meson.build
index 56dfee3..690ac43 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -81,10 +81,27 @@ ghex_deps = [
gtk_dep
]
-ghex_res = gnome.compile_resources(
+src_conf = configuration_data()
+src_conf.set('app_id', app_id)
+src_conf.set('resource_base_path', resource_base_path)
+
+app_ui = configure_file(
+ input: 'ghex-application-window.ui.in',
+ output: 'ghex-application-window.ui',
+ configuration: src_conf
+)
+
+res_in = configure_file(
+ input: 'ghex.gresource.xml.in',
+ output: 'ghex.gresource.xml',
+ configuration: src_conf
+)
+
+res = gnome.compile_resources(
'ghex-resources',
- 'ghex.gresource.xml',
- c_name: 'ghex'
+ res_in,
+ c_name: 'ghex',
+ dependencies: app_ui
)
ghex_c_args = [
@@ -93,7 +110,7 @@ ghex_c_args = [
ghex = executable(
meson.project_name(),
- ghex_sources + ghex_res,
+ ghex_sources + res,
include_directories: ghex_root_dir,
dependencies: ghex_deps + [libghex_dep, ],
c_args: ghex_c_args,
diff --git a/src/paste-special.c b/src/paste-special.c
index b0e0c79..020003a 100644
--- a/src/paste-special.c
+++ b/src/paste-special.c
@@ -25,9 +25,11 @@
#include "paste-special.h"
+#include <config.h>
+
/* DEFINES */
-#define PASTE_SPECIAL_RESOURCE "/org/gnome/GHex/paste-special.ui"
+#define PASTE_SPECIAL_RESOURCE RESOURCE_BASE_PATH "/paste-special.ui"
/* MACROS */
diff --git a/src/preferences.c b/src/preferences.c
index e4f1755..7e400b7 100644
--- a/src/preferences.c
+++ b/src/preferences.c
@@ -36,8 +36,8 @@
/* CONSTANTS */
-#define SHADED_BOX_MAX CONFIG_H_SHADED_BOX_MAX
-#define PREFS_RESOURCE "/org/gnome/GHex/preferences.ui"
+#define SHADED_BOX_MAX CONFIG_H_SHADED_BOX_MAX
+#define PREFS_RESOURCE RESOURCE_BASE_PATH "/preferences.ui"
/* MACROS */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]