From b1331ef7978fdaa11049d9958e4ed279103af570 Mon Sep 17 00:00:00 2001 From: zhuyaliang <15132211195@163.com> Date: Mon, 23 Oct 2023 16:47:38 +0800 Subject: common: Fix compilation warnings replace deprecated functions gtk_rc_get_theme_dir and gtk_rc_scanner_new --- capplets/common/Makefile.am | 1 + capplets/common/gtkrc-utils.c | 47 ++++++++++++++++++++++++++++++++++++++- capplets/common/mate-theme-test.c | 18 ++++++++++++++- 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/capplets/common/Makefile.am b/capplets/common/Makefile.am index 5362f2e2..d7815b88 100644 --- a/capplets/common/Makefile.am +++ b/capplets/common/Makefile.am @@ -3,6 +3,7 @@ EXTRA_DIST = AM_CPPFLAGS = \ -DMATECC_DATA_DIR="\"$(pkgdatadir)\"" \ -DMATELOCALEDIR="\"$(datadir)/locale\"" \ + -DMATEDATADIR="\"$(datadir)\"" \ -DGTK_ENGINE_DIR="\"$(GTK_ENGINE_DIR)\"" \ -DG_LOG_DOMAIN=\"capplet-common\" \ -DINSTALL_PREFIX=\"$(prefix)\" \ diff --git a/capplets/common/gtkrc-utils.c b/capplets/common/gtkrc-utils.c index 4b5ac0e1..2fac2e93 100644 --- a/capplets/common/gtkrc-utils.c +++ b/capplets/common/gtkrc-utils.c @@ -176,6 +176,51 @@ void gtkrc_get_details(gchar* filename, GSList** engines, GSList** symbolic_colo g_scanner_destroy (scanner); } +static const GScannerConfig gtk_rc_scanner_config = +{ + ( + " \t\r\n" + ) /* cset_skip_characters */, + ( + "_" + G_CSET_a_2_z + G_CSET_A_2_Z + ) /* cset_identifier_first */, + ( + G_CSET_DIGITS + "-_" + G_CSET_a_2_z + G_CSET_A_2_Z + ) /* cset_identifier_nth */, + ( "#\n" ) /* cpair_comment_single */, + + TRUE /* case_sensitive */, + + TRUE /* skip_comment_multi */, + TRUE /* skip_comment_single */, + TRUE /* scan_comment_multi */, + TRUE /* scan_identifier */, + FALSE /* scan_identifier_1char */, + FALSE /* scan_identifier_NULL */, + TRUE /* scan_symbols */, + TRUE /* scan_binary */, + TRUE /* scan_octal */, + TRUE /* scan_float */, + TRUE /* scan_hex */, + TRUE /* scan_hex_dollar */, + TRUE /* scan_string_sq */, + TRUE /* scan_string_dq */, + TRUE /* numbers_2_int */, + FALSE /* int_2_float */, + FALSE /* identifier_2_string */, + TRUE /* char_2_token */, + TRUE /* symbol_2_token */, + FALSE /* scope_0_fallback */, + FALSE /* store_int64 */, + + 0 /* < private > padding_dummy*/, +}; + gchar * gtkrc_get_color_scheme (const gchar *gtkrc_file) { @@ -184,7 +229,7 @@ gtkrc_get_color_scheme (const gchar *gtkrc_file) GSList *files = NULL; GSList *read_files = NULL; GTokenType token; - GScanner *scanner = gtk_rc_scanner_new (); + GScanner *scanner = g_scanner_new (>k_rc_scanner_config); g_scanner_scope_add_symbol (scanner, 0, "include", INCLUDE_SYMBOL); g_scanner_scope_add_symbol (scanner, 0, "gtk_color_scheme", COLOR_SCHEME_SYMBOL); diff --git a/capplets/common/mate-theme-test.c b/capplets/common/mate-theme-test.c index 8e5ed73c..aef052d1 100644 --- a/capplets/common/mate-theme-test.c +++ b/capplets/common/mate-theme-test.c @@ -3,6 +3,22 @@ #include #include "mate-theme-info.h" +static gchar * +mate_rc_get_theme_dir (void) +{ + const gchar *var; + gchar *path; + + var = g_getenv ("GTK_DATA_PREFIX"); + + if (var) + path = g_build_filename (var, "share", "themes", NULL); + else + path = g_build_filename (MATEDATADIR, "share", "themes", NULL); + + return path; +} + int main (int argc, char *argv[]) { @@ -71,7 +87,7 @@ main (int argc, char *argv[]) gchar *str; g_print ("No gtk-2 themes were found. The following directories were tested:\n"); - str = gtk_rc_get_theme_dir (); + str = mate_rc_get_theme_dir (); g_print ("\t%s\n", str); g_free (str); str = g_build_filename (g_get_home_dir (), ".themes", NULL); -- cgit v1.2.1