parasite: Don't show hicolor as an icon theme

It really isn't.
This commit is contained in:
Matthias Clasen 2014-05-04 09:27:17 -04:00
parent 9bc7cfa6ba
commit 828acee981

View File

@ -147,6 +147,92 @@ create_gtk (ParasiteThemes *pt)
return b;
}
static void
fill_icons (const char *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)))
{
char *filename = g_build_filename (path, dir_entry, "index.theme", NULL);
if (g_file_test (filename, G_FILE_TEST_IS_REGULAR) &&
g_strcmp0 (dir_entry, "hicolor") != 0 &&
!g_hash_table_contains (t, dir_entry))
g_hash_table_add (t, g_strdup (dir_entry));
g_free (filename);
}
}
static void
icons_changed (GtkComboBox *c, ParasiteThemes *pt)
{
char *theme = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (c));
g_object_set (gtk_settings_get_default (),
"gtk-icon-theme-name", theme,
NULL);
g_free (theme);
}
static GtkWidget *
create_icons (ParasiteThemes *pt)
{
GtkWidget *b, *l, *c;
GHashTable *t;
char *theme, *default_theme, *path;
GHashTableIter iter;
int i, pos;
GSettings *settings;
b = g_object_new (GTK_TYPE_BOX,
"orientation", GTK_ORIENTATION_HORIZONTAL,
"margin", 10,
NULL);
l = g_object_new (GTK_TYPE_LABEL,
"label", "Icon Theme",
"hexpand", TRUE,
"xalign", 0.0,
NULL);
gtk_container_add (GTK_CONTAINER (b), l);
t = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
fill_icons (GTK_DATADIR "/icons", t);
path = g_build_filename (g_get_user_data_dir (), "icons", NULL);
fill_icons (path, t);
g_free (path);
c = gtk_combo_box_text_new ();
gtk_container_add (GTK_CONTAINER (b), c);
settings = g_settings_new ("org.gnome.desktop.interface");
default_theme = g_settings_get_string (settings, "icon-theme");
g_object_unref (settings);
g_hash_table_iter_init (&iter, t);
pos = i = 0;
while (g_hash_table_iter_next (&iter, (gpointer *)&theme, NULL))
{
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (c), theme);
if (g_strcmp0 (theme, default_theme) == 0)
pos = i;
i++;
}
g_hash_table_destroy (t);
gtk_combo_box_set_active (GTK_COMBO_BOX (c), pos);
g_signal_connect (c, "changed", G_CALLBACK (icons_changed), pt);
return b;
}
static void
constructed (GObject *object)
{
@ -159,6 +245,7 @@ constructed (GObject *object)
gtk_container_add (box, create_dark (pt));
gtk_container_add (box, create_gtk (pt));
gtk_container_add (box, create_icons (pt));
}
static void