Skip to content

Commit

Permalink
common: Fix compilation warnings replace deprecated functions gtk_rc_…
Browse files Browse the repository at this point in the history
…get_theme_dir and gtk_rc_scanner_new
  • Loading branch information
zhuyaliang authored and raveit65 committed Oct 25, 2023
1 parent f27d27e commit bf491e0
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
1 change: 1 addition & 0 deletions capplets/common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)\" \
Expand Down
47 changes: 46 additions & 1 deletion capplets/common/gtkrc-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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 (&gtk_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);
Expand Down
18 changes: 17 additions & 1 deletion capplets/common/mate-theme-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
#include <string.h>
#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[])
{
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit bf491e0

Please sign in to comment.