From 3fc7db08f097ce704fc1f3fb74a1ea74894ee8bf Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 14 Jan 2024 19:33:04 +0100 Subject: [PATCH] YTK: do no parse gtkrc and theme files --- libs/tk/ytk/gtkaliasdef.c | 26 ---- libs/tk/ytk/gtkrc.c | 273 --------------------------------- libs/tk/ytk/ytk/gtk/gtkalias.h | 26 ---- libs/tk/ytk/ytk/gtk/gtkrc.h | 6 - libs/tk/ytkmm/rc.cc | 26 ---- libs/tk/ytkmm/ytkmm/gtkmm/rc.h | 19 --- 6 files changed, 376 deletions(-) diff --git a/libs/tk/ytk/gtkaliasdef.c b/libs/tk/ytk/gtkaliasdef.c index 309a6073d9..49829c597e 100644 --- a/libs/tk/ytk/gtkaliasdef.c +++ b/libs/tk/ytk/gtkaliasdef.c @@ -8080,16 +8080,6 @@ extern __typeof (gtk_rc_add_widget_class_style) gtk_rc_add_widget_class_style __ #undef gtk_rc_add_widget_name_style extern __typeof (gtk_rc_add_widget_name_style) gtk_rc_add_widget_name_style __attribute((alias("IA__gtk_rc_add_widget_name_style"), visibility("default"))); -#endif -#ifndef _WIN64 -#undef gtk_rc_add_default_file -extern __typeof (gtk_rc_add_default_file) gtk_rc_add_default_file __attribute((alias("IA__gtk_rc_add_default_file"), visibility("default"))); - -#endif -#ifdef G_OS_WIN32 -#undef gtk_rc_add_default_file_utf8 -extern __typeof (gtk_rc_add_default_file_utf8) gtk_rc_add_default_file_utf8 __attribute((alias("IA__gtk_rc_add_default_file_utf8"), visibility("default"))); - #endif #undef gtk_rc_find_module_in_path extern __typeof (gtk_rc_find_module_in_path) gtk_rc_find_module_in_path __attribute((alias("IA__gtk_rc_find_module_in_path"), visibility("default"))); @@ -8097,9 +8087,6 @@ extern __typeof (gtk_rc_find_module_in_path) gtk_rc_find_module_in_path __attrib #undef gtk_rc_find_pixmap_in_path extern __typeof (gtk_rc_find_pixmap_in_path) gtk_rc_find_pixmap_in_path __attribute((alias("IA__gtk_rc_find_pixmap_in_path"), visibility("default"))); -#undef gtk_rc_get_default_files -extern __typeof (gtk_rc_get_default_files) gtk_rc_get_default_files __attribute((alias("IA__gtk_rc_get_default_files"), visibility("default"))); - #undef gtk_rc_get_im_module_file extern __typeof (gtk_rc_get_im_module_file) gtk_rc_get_im_module_file __attribute((alias("IA__gtk_rc_get_im_module_file"), visibility("default"))); @@ -8115,9 +8102,6 @@ extern __typeof (gtk_rc_get_style) gtk_rc_get_style __attribute((alias("IA__gtk_ #undef gtk_rc_get_style_by_paths extern __typeof (gtk_rc_get_style_by_paths) gtk_rc_get_style_by_paths __attribute((alias("IA__gtk_rc_get_style_by_paths"), visibility("default"))); -#undef gtk_rc_get_theme_dir -extern __typeof (gtk_rc_get_theme_dir) gtk_rc_get_theme_dir __attribute((alias("IA__gtk_rc_get_theme_dir"), visibility("default"))); - #ifndef _WIN64 #undef gtk_rc_parse extern __typeof (gtk_rc_parse) gtk_rc_parse __attribute((alias("IA__gtk_rc_parse"), visibility("default"))); @@ -8155,16 +8139,6 @@ extern __typeof (gtk_rc_reset_styles) gtk_rc_reset_styles __attribute((alias("IA #undef gtk_rc_scanner_new extern __typeof (gtk_rc_scanner_new) gtk_rc_scanner_new __attribute((alias("IA__gtk_rc_scanner_new"), visibility("default"))); -#ifndef _WIN64 -#undef gtk_rc_set_default_files -extern __typeof (gtk_rc_set_default_files) gtk_rc_set_default_files __attribute((alias("IA__gtk_rc_set_default_files"), visibility("default"))); - -#endif -#ifdef G_OS_WIN32 -#undef gtk_rc_set_default_files_utf8 -extern __typeof (gtk_rc_set_default_files_utf8) gtk_rc_set_default_files_utf8 __attribute((alias("IA__gtk_rc_set_default_files_utf8"), visibility("default"))); - -#endif #undef gtk_rc_style_copy extern __typeof (gtk_rc_style_copy) gtk_rc_style_copy __attribute((alias("IA__gtk_rc_style_copy"), visibility("default"))); diff --git a/libs/tk/ytk/gtkrc.c b/libs/tk/ytk/gtkrc.c index cffaf659cc..5e6f8d907c 100644 --- a/libs/tk/ytk/gtkrc.c +++ b/libs/tk/ytk/gtkrc.c @@ -159,10 +159,6 @@ static GtkStyle * gtk_rc_style_to_style (GtkRcContext *context, GtkRcStyle *rc_style); static GtkStyle* gtk_rc_init_style (GtkRcContext *context, GSList *rc_styles); -static void gtk_rc_parse_default_files (GtkRcContext *context); -static void gtk_rc_parse_named (GtkRcContext *context, - const gchar *name, - const gchar *type); static void gtk_rc_context_parse_file (GtkRcContext *context, const gchar *filename, gint priority, @@ -223,7 +219,6 @@ static void gtk_rc_clear_hash_node (gpointer key, gpointer data, gpointer user_data); static void gtk_rc_clear_styles (GtkRcContext *context); -static void gtk_rc_add_initial_default_files (void); static void gtk_rc_style_finalize (GObject *object); static void gtk_rc_style_real_merge (GtkRcStyle *dest, @@ -456,22 +451,6 @@ gtk_rc_get_im_module_file (void) return result; } -gchar * -gtk_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 (GTK_DATA_PREFIX, "share", "themes", NULL); - - return path; -} - /** * gtk_rc_get_module_dir: * @@ -488,150 +467,6 @@ gtk_rc_get_module_dir (void) return gtk_rc_make_default_dir ("engines"); } -static void -gtk_rc_add_initial_default_files (void) -{ - static gint init = FALSE; - const gchar *var; - gchar *str; - gchar **files; - gint i; - - if (init) - return; - - gtk_rc_default_files = g_new (gchar*, 10); - max_default_files = 10; - - gtk_rc_default_files[0] = NULL; - init = TRUE; - - var = g_getenv ("GTK2_RC_FILES"); - - if (var) - { - files = g_strsplit (var, G_SEARCHPATH_SEPARATOR_S, -1); - i=0; - while (files[i]) - { - gtk_rc_add_default_file (files[i]); - i++; - } - g_strfreev (files); - } - else - { - const gchar *home; - const gchar * const *config_dirs; - const gchar *config_dir; - - str = g_build_filename (GTK_DATA_PREFIX, "share", "gtk-2.0", "gtkrc", NULL); - gtk_rc_add_default_file (str); - g_free (str); - - config_dirs = g_get_system_config_dirs (); - for (config_dir = *config_dirs; *config_dirs != NULL; config_dirs++) - { - str = g_build_filename (config_dir, "gtk-2.0", "gtkrc", NULL); - gtk_rc_add_default_file (str); - g_free (str); - } - - str = g_build_filename (GTK_SYSCONFDIR, "gtk-2.0", "gtkrc", NULL); - gtk_rc_add_default_file (str); - g_free (str); - - home = g_get_home_dir (); - if (home) - { - str = g_build_filename (home, ".gtkrc-2.0", NULL); - gtk_rc_add_default_file (str); - g_free (str); - } - } -} - -/** - * gtk_rc_add_default_file: - * @filename: the pathname to the file. If @filename is not absolute, it - * is searched in the current directory. - * - * Adds a file to the list of files to be parsed at the - * end of gtk_init(). - **/ -void -gtk_rc_add_default_file (const gchar *filename) -{ - guint n; - - gtk_rc_add_initial_default_files (); - - for (n = 0; n < max_default_files; n++) - { - if (gtk_rc_default_files[n] == NULL) - break; - } - - if (n == max_default_files) - { - max_default_files += 10; - gtk_rc_default_files = g_renew (gchar*, gtk_rc_default_files, max_default_files); - } - - gtk_rc_default_files[n++] = g_strdup (filename); - gtk_rc_default_files[n] = NULL; -} - -/** - * gtk_rc_set_default_files: - * @filenames: A %NULL-terminated list of filenames. - * - * Sets the list of files that GTK+ will read at the - * end of gtk_init(). - **/ -void -gtk_rc_set_default_files (gchar **filenames) -{ - gint i; - - gtk_rc_add_initial_default_files (); - - i = 0; - while (gtk_rc_default_files[i]) - { - g_free (gtk_rc_default_files[i]); - i++; - } - - gtk_rc_default_files[0] = NULL; - - i = 0; - while (filenames[i] != NULL) - { - gtk_rc_add_default_file (filenames[i]); - i++; - } -} - -/** - * gtk_rc_get_default_files: - * - * Retrieves the current list of RC files that will be parsed - * at the end of gtk_init(). - * - * Return value: (transfer none) (array zero-terminated=1) (element-type filename): - * A %NULL-terminated array of filenames. - * This memory is owned by GTK+ and must not be freed by the application. - * If you want to store this information, you should make a copy. - **/ -gchar ** -gtk_rc_get_default_files (void) -{ - gtk_rc_add_initial_default_files (); - - return gtk_rc_default_files; -} - static void gtk_rc_settings_changed (GtkSettings *settings, GParamSpec *pspec, @@ -800,68 +635,6 @@ _gtk_rc_context_destroy (GtkSettings *settings) settings->rc_context = NULL; } -static void -gtk_rc_parse_named (GtkRcContext *context, - const gchar *name, - const gchar *type) -{ - gchar *path = NULL; - const gchar *home_dir; - gchar *subpath; - - if (type) - subpath = g_strconcat ("gtk-2.0-", type, - G_DIR_SEPARATOR_S "gtkrc", - NULL); - else - subpath = g_strdup ("gtk-2.0" G_DIR_SEPARATOR_S "gtkrc"); - - /* First look in the users home directory - */ - home_dir = g_get_home_dir (); - if (home_dir) - { - path = g_build_filename (home_dir, ".themes", name, subpath, NULL); - if (!g_file_test (path, G_FILE_TEST_EXISTS)) - { - g_free (path); - path = NULL; - } - } - - if (!path) - { - gchar *theme_dir = gtk_rc_get_theme_dir (); - path = g_build_filename (theme_dir, name, subpath, NULL); - g_free (theme_dir); - - if (!g_file_test (path, G_FILE_TEST_EXISTS)) - { - g_free (path); - path = NULL; - } - } - - if (path) - { - gtk_rc_context_parse_file (context, path, GTK_PATH_PRIO_THEME, FALSE); - g_free (path); - } - - g_free (subpath); -} - -static void -gtk_rc_parse_default_files (GtkRcContext *context) -{ - gint i; - - gtk_rc_add_initial_default_files (); - - for (i = 0; gtk_rc_default_files[i] != NULL; i++) - gtk_rc_context_parse_file (context, gtk_rc_default_files[i], GTK_PATH_PRIO_RC, FALSE); -} - void _gtk_rc_init (void) { @@ -870,8 +643,6 @@ _gtk_rc_init (void) if (!initialized) { initialized = TRUE; - - gtk_rc_add_initial_default_files (); } /* Default RC string */ @@ -1806,8 +1577,6 @@ gtk_rc_reparse_all_for_settings (GtkSettings *settings, _gtk_settings_reset_rc_values (context->settings); gtk_rc_clear_rc_files (context); - gtk_rc_parse_default_files (context); - tmp_list = global_rc_files; while (tmp_list) { @@ -1829,11 +1598,6 @@ gtk_rc_reparse_all_for_settings (GtkSettings *settings, "gtk-key-theme-name", &context->key_theme_name, NULL); - if (context->theme_name && context->theme_name[0]) - gtk_rc_parse_named (context, context->theme_name, NULL); - if (context->key_theme_name && context->key_theme_name[0]) - gtk_rc_parse_named (context, context->key_theme_name, "key"); - context->reloading = FALSE; gtk_rc_reset_widgets (context->settings); @@ -4899,43 +4663,6 @@ _gtk_rc_match_widget_class (GSList *list, #if defined (G_OS_WIN32) && !defined (_WIN64) -/* DLL ABI stability backward compatibility versions */ - -#undef gtk_rc_add_default_file - -void -gtk_rc_add_default_file (const gchar *filename) -{ - gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL); - - gtk_rc_add_default_file_utf8 (utf8_filename); - - g_free (utf8_filename); -} - -#undef gtk_rc_set_default_files - -void -gtk_rc_set_default_files (gchar **filenames) -{ - gchar **utf8_filenames; - int n = 0, i; - - while (filenames[n++] != NULL) - ; - - utf8_filenames = g_new (gchar *, n + 1); - - for (i = 0; i < n; i++) - utf8_filenames[i] = g_locale_to_utf8 (filenames[i], -1, NULL, NULL, NULL); - - utf8_filenames[n] = NULL; - - gtk_rc_set_default_files_utf8 (utf8_filenames); - - g_strfreev (utf8_filenames); -} - #undef gtk_rc_parse void diff --git a/libs/tk/ytk/ytk/gtk/gtkalias.h b/libs/tk/ytk/ytk/gtk/gtkalias.h index b708f73485..f54cf7553a 100644 --- a/libs/tk/ytk/ytk/gtk/gtkalias.h +++ b/libs/tk/ytk/ytk/gtk/gtkalias.h @@ -8077,16 +8077,6 @@ extern __typeof (gtk_rc_add_widget_class_style) IA__gtk_rc_add_widget_class_styl extern __typeof (gtk_rc_add_widget_name_style) IA__gtk_rc_add_widget_name_style __attribute((visibility("hidden"))); #define gtk_rc_add_widget_name_style IA__gtk_rc_add_widget_name_style -#endif -#ifndef _WIN64 -extern __typeof (gtk_rc_add_default_file) IA__gtk_rc_add_default_file __attribute((visibility("hidden"))); -#define gtk_rc_add_default_file IA__gtk_rc_add_default_file - -#endif -#ifdef G_OS_WIN32 -extern __typeof (gtk_rc_add_default_file_utf8) IA__gtk_rc_add_default_file_utf8 __attribute((visibility("hidden"))); -#define gtk_rc_add_default_file_utf8 IA__gtk_rc_add_default_file_utf8 - #endif extern __typeof (gtk_rc_find_module_in_path) IA__gtk_rc_find_module_in_path __attribute((visibility("hidden"))); #define gtk_rc_find_module_in_path IA__gtk_rc_find_module_in_path @@ -8094,9 +8084,6 @@ extern __typeof (gtk_rc_find_module_in_path) IA__gtk_rc_find_module_in_path __at extern __typeof (gtk_rc_find_pixmap_in_path) IA__gtk_rc_find_pixmap_in_path __attribute((visibility("hidden"))); #define gtk_rc_find_pixmap_in_path IA__gtk_rc_find_pixmap_in_path -extern __typeof (gtk_rc_get_default_files) IA__gtk_rc_get_default_files __attribute((visibility("hidden"))); -#define gtk_rc_get_default_files IA__gtk_rc_get_default_files - extern __typeof (gtk_rc_get_im_module_file) IA__gtk_rc_get_im_module_file __attribute((visibility("hidden"))); #define gtk_rc_get_im_module_file IA__gtk_rc_get_im_module_file @@ -8112,9 +8099,6 @@ extern __typeof (gtk_rc_get_style) IA__gtk_rc_get_style __attribute((visibility( extern __typeof (gtk_rc_get_style_by_paths) IA__gtk_rc_get_style_by_paths __attribute((visibility("hidden"))); #define gtk_rc_get_style_by_paths IA__gtk_rc_get_style_by_paths -extern __typeof (gtk_rc_get_theme_dir) IA__gtk_rc_get_theme_dir __attribute((visibility("hidden"))); -#define gtk_rc_get_theme_dir IA__gtk_rc_get_theme_dir - #ifndef _WIN64 extern __typeof (gtk_rc_parse) IA__gtk_rc_parse __attribute((visibility("hidden"))); #define gtk_rc_parse IA__gtk_rc_parse @@ -8152,16 +8136,6 @@ extern __typeof (gtk_rc_reset_styles) IA__gtk_rc_reset_styles __attribute((visib extern __typeof (gtk_rc_scanner_new) IA__gtk_rc_scanner_new __attribute((visibility("hidden"))); #define gtk_rc_scanner_new IA__gtk_rc_scanner_new -#ifndef _WIN64 -extern __typeof (gtk_rc_set_default_files) IA__gtk_rc_set_default_files __attribute((visibility("hidden"))); -#define gtk_rc_set_default_files IA__gtk_rc_set_default_files - -#endif -#ifdef G_OS_WIN32 -extern __typeof (gtk_rc_set_default_files_utf8) IA__gtk_rc_set_default_files_utf8 __attribute((visibility("hidden"))); -#define gtk_rc_set_default_files_utf8 IA__gtk_rc_set_default_files_utf8 - -#endif extern __typeof (gtk_rc_style_copy) IA__gtk_rc_style_copy __attribute((visibility("hidden"))); #define gtk_rc_style_copy IA__gtk_rc_style_copy diff --git a/libs/tk/ytk/ytk/gtk/gtkrc.h b/libs/tk/ytk/ytk/gtk/gtkrc.h index d1e19e9fa6..46547c1bbb 100644 --- a/libs/tk/ytk/ytk/gtk/gtkrc.h +++ b/libs/tk/ytk/ytk/gtk/gtkrc.h @@ -125,8 +125,6 @@ struct _GtkRcStyleClass #ifdef G_OS_WIN32 /* Reserve old names for DLL ABI backward compatibility */ -#define gtk_rc_add_default_file gtk_rc_add_default_file_utf8 -#define gtk_rc_set_default_files gtk_rc_set_default_files_utf8 #define gtk_rc_parse gtk_rc_parse_utf8 #endif @@ -138,9 +136,6 @@ gboolean _gtk_rc_match_widget_class (GSList *list, gchar *path, gchar *path_reversed); -void gtk_rc_add_default_file (const gchar *filename); -void gtk_rc_set_default_files (gchar **filenames); -gchar** gtk_rc_get_default_files (void); GtkStyle* gtk_rc_get_style (GtkWidget *widget); GtkStyle* gtk_rc_get_style_by_paths (GtkSettings *settings, const char *widget_path, @@ -179,7 +174,6 @@ void gtk_rc_style_unref (GtkRcStyle *rc_style); #endif gchar* gtk_rc_find_module_in_path (const gchar *module_file); -gchar* gtk_rc_get_theme_dir (void); gchar* gtk_rc_get_module_dir (void); gchar* gtk_rc_get_im_module_path (void); gchar* gtk_rc_get_im_module_file (void); diff --git a/libs/tk/ytkmm/rc.cc b/libs/tk/ytkmm/rc.cc index 4c2b4666f6..560bb47f60 100644 --- a/libs/tk/ytkmm/rc.cc +++ b/libs/tk/ytkmm/rc.cc @@ -114,26 +114,6 @@ RC::parse_string(const Glib::ustring& rc_string) gtk_rc_parse_string(const_cast(rc_string.c_str())); } - -void -RC::add_default_file(const Glib::ustring& filename) -{ - gtk_rc_add_default_file(const_cast(filename.c_str())); -} - -void -RC::set_default_files(const Glib::ArrayHandle& filenames) -{ - gtk_rc_set_default_files(const_cast(filenames.data())); -} - -Glib::ArrayHandle -RC::get_default_files() -{ - return Glib::ArrayHandle( - const_cast(gtk_rc_get_default_files()), Glib::OWNERSHIP_NONE); -} - bool RC::reparse_all() { return gtk_rc_reparse_all(); @@ -170,12 +150,6 @@ RC::find_module_in_path(const Glib::ustring& module_file) gtk_rc_find_module_in_path(const_cast(module_file.c_str()))); } -Glib::ustring -RC::get_theme_dir() -{ - return Glib::convert_return_gchar_ptr_to_ustring(gtk_rc_get_theme_dir()); -} - Glib::ustring RC::get_module_dir() { diff --git a/libs/tk/ytkmm/ytkmm/gtkmm/rc.h b/libs/tk/ytkmm/ytkmm/gtkmm/rc.h index b83fc342c4..730b3e91fc 100644 --- a/libs/tk/ytkmm/ytkmm/gtkmm/rc.h +++ b/libs/tk/ytkmm/ytkmm/gtkmm/rc.h @@ -251,25 +251,6 @@ public: static void parse_string(const Glib::ustring &rc_string); - /** Adds a file to the list of files to be parsed at the end of gtk_init(). - * - * @param filename the pathname to the file. If @a filename is not absolute, it is searched in the current directory. - */ - static void add_default_file(const Glib::ustring& filename); - - /** Sets the list of files that GTK+ will read at the end of gtk_init(). - * - * @param filenames A list of filenames. - */ - static void set_default_files(const Glib::StringArrayHandle& filenames); - - /** Retrieves the current list of RC files that will be parsed - * at the end of gtk_init(). - * - * @result An array of filenames. - */ - static Glib::StringArrayHandle get_default_files(); - /** If the modification time on any previously read file for the * default Gtk::Settings has changed, discard all style information * and then reread all previously read RC files.