gnome-control-center/capplets/common/theme-common.c
Jonathan Blandford 6f1fa592ec Change gnome2-* to gnome-* ditto ditto ditto ditto ditto ditto ditto ditto
Tue Apr  9 11:43:08 2002  Jonathan Blandford  <jrb@gnome.org>

	* capplets/accessibility/keyboard/Makefile.am: Change gnome2-* to
	gnome-*
	* capplets/default-applications/Makefile.am: ditto
	* capplets/file-types/Makefile.am: ditto
	* capplets/font/Makefile.am: ditto
	* capplets/keyboard/Makefile.am: ditto
	* capplets/mouse/Makefile.am: ditto
	* capplets/sound/Makefile.am: ditto
	* capplets/theme-switcher/Makefile.am: ditto
	* capplets/ui-properties/Makefile.am: ditto
	* control-center/Makefile.am: ditto
	* gnome-settings-daemon/Makefile.am: ditto

	* gnome-keybinding-properties.c (setup_dialog): man, was this code
	silly.  Also, themes are case sensitive.
	(is_metacity_running): Add support for metacity keybindings.  This
	is off by default until I write code to actually detect metacity.

Tue Apr  9 11:58:10 2002  Jonathan Blandford  <jrb@gnome.org>

	* Makefile.am: Add commented out disk support until I finish the code.
2002-04-10 06:08:08 +00:00

135 lines
2.9 KiB
C

#include <config.h>
#include <gnome.h>
#include <glade/glade.h>
#include <gconf/gconf-client.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#include <libgnomevfs/gnome-vfs-ops.h>
#include "theme-common.h"
static GList *
themes_common_list_add_dir (GList *list,
const char *dirname)
{
DIR *dir;
struct dirent *de;
const gchar *suffix = "gtk-2.0";
const gchar *key_suffix = "gtk-2.0-key";
g_return_val_if_fail (dirname != NULL, list);
dir = opendir (dirname);
if (!dir)
return list;
while ((de = readdir (dir)))
{
char *tmp;
ThemeInfo *info = NULL;
if (de->d_name[0] == '.')
continue;
tmp = g_build_filename (dirname, de->d_name, suffix, NULL);
if (g_file_test (tmp, G_FILE_TEST_IS_DIR))
{
info = g_new0 (ThemeInfo, 1);
info->path = g_build_filename (dirname, de->d_name, NULL);
info->name = g_strdup (de->d_name);
info->has_gtk = TRUE;
}
g_free (tmp);
tmp = g_build_filename (dirname, de->d_name, key_suffix, NULL);
if (g_file_test (tmp, G_FILE_TEST_IS_DIR))
{
if (info == NULL)
{
info = g_new0 (ThemeInfo, 1);
info->path = g_build_filename (dirname, de->d_name, NULL);
info->name = g_strdup (de->d_name);
}
info->has_keybinding = TRUE;
}
g_free (tmp);
if (info)
list = g_list_prepend (list, info);
}
closedir (dir);
return list;
}
GList *
theme_common_get_list (void)
{
gchar *dir;
GList *theme_list = NULL;
dir = g_build_filename (g_get_home_dir (), ".themes", NULL);
theme_list = themes_common_list_add_dir (theme_list, dir);
g_free (dir);
dir = gtk_rc_get_theme_dir ();
theme_list = themes_common_list_add_dir (theme_list, dir);
g_free (dir);
return theme_list;
}
void
theme_common_list_free (GList *list)
{
if (list == NULL)
return;
g_list_foreach (list, g_free, NULL);
g_list_free (list);
}
static void
theme_dir_changed_callback (GnomeVFSMonitorHandle *handle,
const gchar *monitor_uri,
const gchar *info_uri,
GnomeVFSMonitorEventType event_type,
gpointer user_data)
{
g_print ("%s\n", monitor_uri);
g_closure_invoke ((GClosure *) user_data, NULL, 0, NULL, NULL);
}
void
theme_common_register_theme_change (GCallback func,
gpointer data)
{
GnomeVFSResult result;
GnomeVFSMonitorHandle *handle = NULL;
gchar *text_uri;
GClosure *closure;
/* We're unlikely to ever need to cancel this with the control center */
closure = g_cclosure_new (func, data, NULL);
text_uri = g_build_filename (g_get_home_dir (), ".themes", NULL);
gnome_vfs_monitor_add (&handle,
text_uri,
GNOME_VFS_MONITOR_DIRECTORY,
theme_dir_changed_callback,
closure);
g_free (text_uri);
text_uri = gtk_rc_get_theme_dir ();
gnome_vfs_monitor_add (&handle,
text_uri,
GNOME_VFS_MONITOR_DIRECTORY,
theme_dir_changed_callback,
closure);
g_free (text_uri);
}