inspector: Use theme apis

We can now use gtk_theme_get_available_themes instead
of our own copy of that code.
This commit is contained in:
Matthias Clasen
2020-04-12 00:29:05 -04:00
parent 37c151ce0f
commit b16b44f1ae
2 changed files with 7 additions and 74 deletions

View File

@@ -42,6 +42,7 @@
#include "gskrendererprivate.h"
#include "gtknative.h"
#include "gtkbinlayout.h"
#include "gtktheme.h"
#include "fallback-c89.c"
@@ -473,30 +474,6 @@ focus_activate (GtkSwitch *sw,
redraw_everything ();
}
static void
fill_gtk (const gchar *path,
GHashTable *t)
{
const gchar *dir_entry;
GDir *dir = g_dir_open (path, 0, NULL);
if (!dir)
return;
while ((dir_entry = g_dir_read_name (dir)))
{
gchar *filename = g_build_filename (path, dir_entry, "gtk-4.0", "gtk.css", NULL);
if (g_file_test (filename, G_FILE_TEST_IS_REGULAR) &&
!g_hash_table_contains (t, dir_entry))
g_hash_table_add (t, g_strdup (dir_entry));
g_free (filename);
}
g_dir_close (dir);
}
static gchar*
get_data_path (const gchar *subdir)
{
@@ -514,57 +491,14 @@ get_data_path (const gchar *subdir)
static void
init_theme (GtkInspectorVisual *vis)
{
GHashTable *t;
GHashTableIter iter;
gchar *theme, *path;
gchar **builtin_themes;
GList *list, *l;
guint i;
const gchar * const *dirs;
char **themes;
int i;
t = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
/* Builtin themes */
builtin_themes = g_resources_enumerate_children ("/org/gtk/libgtk/theme", 0, NULL);
for (i = 0; builtin_themes[i] != NULL; i++)
{
if (g_str_has_suffix (builtin_themes[i], "/"))
g_hash_table_add (t, g_strndup (builtin_themes[i], strlen (builtin_themes[i]) - 1));
}
g_strfreev (builtin_themes);
themes = gtk_theme_get_available_themes ();
for (i = 0; themes[i]; i++)
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (vis->priv->theme_combo), themes[i], themes[i]);
path = _gtk_get_theme_dir ();
fill_gtk (path, t);
g_free (path);
path = g_build_filename (g_get_user_data_dir (), "themes", NULL);
fill_gtk (path, t);
g_free (path);
path = g_build_filename (g_get_home_dir (), ".themes", NULL);
fill_gtk (path, t);
g_free (path);
dirs = g_get_system_data_dirs ();
for (i = 0; dirs[i]; i++)
{
path = g_build_filename (dirs[i], "themes", NULL);
fill_gtk (path, t);
g_free (path);
}
list = NULL;
g_hash_table_iter_init (&iter, t);
while (g_hash_table_iter_next (&iter, (gpointer *)&theme, NULL))
list = g_list_insert_sorted (list, theme, (GCompareFunc)strcmp);
for (l = list; l; l = l->next)
{
theme = l->data;
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (vis->priv->theme_combo), theme, theme);
}
g_list_free (list);
g_hash_table_destroy (t);
g_strfreev (themes);
g_object_bind_property (gtk_settings_get_for_display (vis->priv->display),
"gtk-theme-name",

View File

@@ -663,7 +663,6 @@
<object class="GtkSizeGroup">
<widgets>
<widget name="theme_label"/>
<widget name="dark_label"/>
<widget name="icon_label"/>
<widget name="cursor_label"/>
<widget name="cursor_size_label"/>