From fd1a917a0ca74063ed52f9798c9491556b08c8f4 Mon Sep 17 00:00:00 2001 From: rbuj Date: Sat, 18 Jul 2020 23:59:25 +0200 Subject: cpufreq: Load menu and ui file from resources --- cpufreq/src/Makefile.am | 19 +++++++++++++++++-- cpufreq/src/cpufreq-applet.c | 8 +++----- cpufreq/src/cpufreq-prefs.c | 3 +-- 3 files changed, 21 insertions(+), 9 deletions(-) (limited to 'cpufreq/src') diff --git a/cpufreq/src/Makefile.am b/cpufreq/src/Makefile.am index 83ed7faa..cd64db9e 100644 --- a/cpufreq/src/Makefile.am +++ b/cpufreq/src/Makefile.am @@ -5,7 +5,7 @@ endif SUBDIRS = $(selector_SUBDIR) AM_CPPFLAGS = \ - -DCPUFREQ_MENU_UI_DIR=\""$(datadir)/mate/ui"\" \ + -DCPUFREQ_RESOURCE_PATH=\""/org/mate/mate-applets/cpufreq/"\" \ $(MATE_APPLETS4_CFLAGS) libexec_PROGRAMS = mate-cpufreq-applet @@ -14,7 +14,13 @@ if HAVE_LIBCPUFREQ cpufreq_files=cpufreq-monitor-libcpufreq.c cpufreq-monitor-libcpufreq.h endif -mate_cpufreq_applet_SOURCES = \ +BUILT_SOURCES = \ + cpufreq-resources.c cpufreq-resources.h + +nodist_mate_cpufreq_applet_SOURCES = \ + $(BUILT_SOURCES) + +mate_cpufreq_applet_SOURCES = \ cpufreq-applet.c cpufreq-applet.h \ cpufreq-utils.c cpufreq-utils.h \ cpufreq-prefs.c cpufreq-prefs.h \ @@ -34,4 +40,13 @@ mate_cpufreq_applet_LDADD = \ $(MATE_APPLETS4_LIBS) \ $(LIBCPUFREQ_LIBS) +cpufreq-resources.c: $(top_srcdir)/cpufreq/cpufreq-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(top_srcdir)/cpufreq --generate-dependencies $(top_srcdir)/cpufreq/cpufreq-resources.gresource.xml) + $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(top_srcdir)/cpufreq --generate --c-name cpufreq $< + +cpufreq-resources.h: $(top_srcdir)/cpufreq/cpufreq-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(top_srcdir)/cpufreq --generate-dependencies $(top_srcdir)/cpufreq/cpufreq-resources.gresource.xml) + $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(top_srcdir)/cpufreq --generate --c-name cpufreq $< + +CLEANFILES = \ + $(BUILT_SOURCES) + -include $(top_srcdir)/git.mk diff --git a/cpufreq/src/cpufreq-applet.c b/cpufreq/src/cpufreq-applet.c index a93d5fea..8412b17e 100644 --- a/cpufreq/src/cpufreq-applet.c +++ b/cpufreq/src/cpufreq-applet.c @@ -787,7 +787,6 @@ static void cpufreq_applet_setup (CPUFreqApplet *applet) { GtkActionGroup *action_group; - gchar *ui_path; AtkObject *atk_obj; GSettings *settings; @@ -830,10 +829,9 @@ cpufreq_applet_setup (CPUFreqApplet *applet) cpufreq_applet_menu_actions, G_N_ELEMENTS (cpufreq_applet_menu_actions), applet); - ui_path = g_build_filename (CPUFREQ_MENU_UI_DIR, "cpufreq-applet-menu.xml", NULL); - mate_panel_applet_setup_menu_from_file (MATE_PANEL_APPLET (applet), - ui_path, action_group); - g_free (ui_path); + mate_panel_applet_setup_menu_from_resource (MATE_PANEL_APPLET (applet), + CPUFREQ_RESOURCE_PATH "cpufreq-applet-menu.xml", + action_group); if (mate_panel_applet_get_locked_down (MATE_PANEL_APPLET (applet))) { GtkAction *action; diff --git a/cpufreq/src/cpufreq-prefs.c b/cpufreq/src/cpufreq-prefs.c index dfa6128a..0f425021 100644 --- a/cpufreq/src/cpufreq-prefs.c +++ b/cpufreq/src/cpufreq-prefs.c @@ -520,8 +520,7 @@ cpufreq_prefs_dialog_create (CPUFreqPrefs *prefs) { GtkBuilder *builder; - builder = gtk_builder_new (); - gtk_builder_add_from_file (builder, GTK_BUILDERDIR "/cpufreq-preferences.ui", NULL); + builder = gtk_builder_new_from_resource (CPUFREQ_RESOURCE_PATH "cpufreq-preferences.ui"); prefs->priv->dialog = GTK_WIDGET (gtk_builder_get_object (builder, "prefs_dialog")); -- cgit v1.2.1