figure out where GTK+ expects its theme engines and make that info

2008-04-19  Jens Granseuer  <jensgr@gmx.net>

	* configure.in: figure out where GTK+ expects its theme engines and
	make that info available to interested capplets

2008-04-19  Jens Granseuer  <jensgr@gmx.net>

	* gtkrc-utils.c: (gtkrc_get_details): accept NULL for the
	symbolic_colors parameter if the caller doesn't want that information

2008-04-19  Jens Granseuer  <jensgr@gmx.net>

	* Makefile.am:
	* appearance-themes.c: (theme_validate),
	(theme_message_area_update), (themes_init):
	* appearance.h: show a warning message when the selected theme is
	incomplete (e.g. missing icon theme or gtk theme engine)

svn path=/trunk/; revision=8658
This commit is contained in:
Jens Granseuer 2008-04-19 10:30:34 +00:00 committed by Jens Granseuer
parent 6a084df8d1
commit 6cfdc46460
8 changed files with 164 additions and 54 deletions

View file

@ -1,3 +1,8 @@
2008-04-19 Jens Granseuer <jensgr@gmx.net>
* configure.in: figure out where GTK+ expects its theme engines and
make that info available to interested capplets
2008-03-31 Bastien Nocera <hadess@hadess.net> 2008-03-31 Bastien Nocera <hadess@hadess.net>
* configure.in: Up the version to 2.23.0 to avoid confusion * configure.in: Up the version to 2.23.0 to avoid confusion

View file

@ -1,3 +1,11 @@
2008-04-19 Jens Granseuer <jensgr@gmx.net>
* Makefile.am:
* appearance-themes.c: (theme_validate),
(theme_message_area_update), (themes_init):
* appearance.h: show a warning message when the selected theme is
incomplete (e.g. missing icon theme or gtk theme engine)
2008-04-17 Jens Granseuer <jensgr@gmx.net> 2008-04-17 Jens Granseuer <jensgr@gmx.net>
Patch by: Lincoln de Sousa <lincoln@minaslivre.org> Patch by: Lincoln de Sousa <lincoln@minaslivre.org>

View file

@ -57,6 +57,7 @@ INCLUDES = \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \ -DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
-DGNOMECC_GLADE_DIR="\"$(gladedir)\"" \ -DGNOMECC_GLADE_DIR="\"$(gladedir)\"" \
-DGNOMECC_PIXMAP_DIR="\"$(pixmapdir)\"" \ -DGNOMECC_PIXMAP_DIR="\"$(pixmapdir)\"" \
-DGTK_ENGINE_DIR="\"$(GTK_ENGINE_DIR)\"" \
-DWALLPAPER_DATADIR="\"$(wallpaperdir)\"" -DWALLPAPER_DATADIR="\"$(wallpaperdir)\""
CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES) CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES)

View file

@ -351,6 +351,67 @@ theme_is_equal (const GnomeThemeMetaInfo *a, const GnomeThemeMetaInfo *b)
return TRUE; return TRUE;
} }
static gchar *
theme_validate (const GnomeThemeMetaInfo *info)
{
GnomeThemeInfo *theme;
gchar *gtkrc;
theme = gnome_theme_info_find (info->gtk_theme_name);
if (!theme || !theme->has_gtk) {
return g_strdup_printf (
_("This theme will not look as intended because the required GTK+ theme '%s' is not installed."),
info->gtk_theme_name);
}
theme = gnome_theme_info_find (info->metacity_theme_name);
if (!theme || !theme->has_metacity) {
return g_strdup_printf (
_("This theme will not look as intended because the required window manager theme '%s' is not installed."),
info->metacity_theme_name);
}
if (!gnome_theme_icon_info_find (info->icon_theme_name)) {
return g_strdup_printf (
_("This theme will not look as intended because the required icon theme '%s' is not installed."),
info->gtk_theme_name);
}
/* check for gtk theme engines */
gtkrc = gtkrc_find_named (info->gtk_theme_name);
if (gtkrc) {
GSList *engines = NULL, *l;
gchar *msg = NULL;
gboolean found;
gtkrc_get_details (gtkrc, &engines, NULL);
g_free (gtkrc);
for (l = engines; l; l = l->next) {
gchar *lib = g_strconcat ("lib", l->data, ".so", NULL);
gchar *full = g_build_filename (GTK_ENGINE_DIR, lib, NULL);
g_free (lib);
found = g_file_test (full, G_FILE_TEST_EXISTS);
g_free (full);
if (!found) {
msg = g_strdup_printf (
_("This theme will not look as intended because the required GTK+ theme engine '%s' is not installed."),
(gchar *) l->data);
break;
}
}
g_slist_foreach (engines, (GFunc) g_free, NULL);
g_slist_free (engines);
return msg;
}
return NULL;
}
static void static void
theme_set_custom_from_theme (const GnomeThemeMetaInfo *info, AppearanceData *data) theme_set_custom_from_theme (const GnomeThemeMetaInfo *info, AppearanceData *data)
{ {
@ -574,8 +635,10 @@ theme_message_area_update (AppearanceData *data)
const GnomeThemeMetaInfo *theme; const GnomeThemeMetaInfo *theme;
gboolean show_apply_background = FALSE; gboolean show_apply_background = FALSE;
gboolean show_apply_font = FALSE; gboolean show_apply_font = FALSE;
gboolean show_revert_font; gboolean show_revert_font = FALSE;
gboolean show_error;
const gchar *message; const gchar *message;
gchar *error_message;
gchar *font; gchar *font;
theme = theme_get_selected (GTK_ICON_VIEW (glade_xml_get_widget (data->xml, "theme_list")), data); theme = theme_get_selected (GTK_ICON_VIEW (glade_xml_get_widget (data->xml, "theme_list")), data);
@ -583,6 +646,10 @@ theme_message_area_update (AppearanceData *data)
if (!theme) if (!theme)
return; return;
error_message = theme_validate (theme);
show_error = (error_message != NULL);
if (!show_error) {
if (theme->background_image != NULL) { if (theme->background_image != NULL) {
gchar *background; gchar *background;
@ -630,13 +697,13 @@ theme_message_area_update (AppearanceData *data)
show_revert_font = (data->revert_application_font != NULL || show_revert_font = (data->revert_application_font != NULL ||
data->revert_documents_font != NULL || data->revert_desktop_font != NULL || data->revert_documents_font != NULL || data->revert_desktop_font != NULL ||
data->revert_windowtitle_font != NULL || data->revert_monospace_font != NULL); data->revert_windowtitle_font != NULL || data->revert_monospace_font != NULL);
}
if (data->theme_message_area == NULL) { if (data->theme_message_area == NULL) {
GtkWidget *hbox; GtkWidget *hbox;
GtkWidget *icon;
GtkWidget *parent; GtkWidget *parent;
if (!show_apply_background && !show_revert_font && !show_apply_font) if (!show_apply_background && !show_revert_font && !show_apply_font && !show_error)
return; return;
data->theme_message_area = gedit_message_area_new (); data->theme_message_area = gedit_message_area_new ();
@ -665,10 +732,12 @@ theme_message_area_update (AppearanceData *data)
hbox = gtk_hbox_new (FALSE, 9); hbox = gtk_hbox_new (FALSE, 9);
gtk_widget_show (hbox); gtk_widget_show (hbox);
icon = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG); data->theme_info_icon = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
gtk_widget_show (icon); data->theme_error_icon = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
gtk_misc_set_alignment (GTK_MISC (icon), 0.5, 0); gtk_misc_set_alignment (GTK_MISC (data->theme_info_icon), 0.5, 0);
gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0); gtk_misc_set_alignment (GTK_MISC (data->theme_error_icon), 0.5, 0);
gtk_box_pack_start (GTK_BOX (hbox), data->theme_info_icon, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), data->theme_error_icon, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), data->theme_message_label, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), data->theme_message_label, TRUE, TRUE, 0);
gedit_message_area_set_contents (GEDIT_MESSAGE_AREA (data->theme_message_area), hbox); gedit_message_area_set_contents (GEDIT_MESSAGE_AREA (data->theme_message_area), hbox);
@ -676,7 +745,9 @@ theme_message_area_update (AppearanceData *data)
gtk_box_pack_start (GTK_BOX (parent), data->theme_message_area, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (parent), data->theme_message_area, FALSE, FALSE, 0);
} }
if (show_apply_background && show_apply_font && show_revert_font) if (show_error)
message = error_message;
else if (show_apply_background && show_apply_font && show_revert_font)
message = _("The current theme suggests a background and a font. Also, the last applied font suggestion can be reverted."); message = _("The current theme suggests a background and a font. Also, the last applied font suggestion can be reverted.");
else if (show_apply_background && show_revert_font) else if (show_apply_background && show_revert_font)
message = _("The current theme suggests a background. Also, the last applied font suggestion can be reverted."); message = _("The current theme suggests a background. Also, the last applied font suggestion can be reverted.");
@ -708,14 +779,23 @@ theme_message_area_update (AppearanceData *data)
else else
gtk_widget_hide (data->revert_font_button); gtk_widget_hide (data->revert_font_button);
if (show_apply_background || show_apply_font || show_revert_font) { if (show_error || show_apply_background || show_apply_font || show_revert_font) {
gtk_widget_show (data->theme_message_area); gtk_widget_show (data->theme_message_area);
gtk_widget_queue_draw (data->theme_message_area); gtk_widget_queue_draw (data->theme_message_area);
if (show_error) {
gtk_widget_show (data->theme_error_icon);
gtk_widget_hide (data->theme_info_icon);
} else {
gtk_widget_show (data->theme_info_icon);
gtk_widget_hide (data->theme_error_icon);
}
} else { } else {
gtk_widget_hide (data->theme_message_area); gtk_widget_hide (data->theme_message_area);
} }
gtk_label_set_text (GTK_LABEL (data->theme_message_label), message); gtk_label_set_text (GTK_LABEL (data->theme_message_label), message);
g_free (error_message);
} }
static void static void
@ -987,6 +1067,8 @@ themes_init (AppearanceData *data)
data->revert_monospace_font = NULL; data->revert_monospace_font = NULL;
data->theme_save_dialog = NULL; data->theme_save_dialog = NULL;
data->theme_message_area = NULL; data->theme_message_area = NULL;
data->theme_info_icon = NULL;
data->theme_error_icon = NULL;
data->theme_custom = gnome_theme_meta_info_new (); data->theme_custom = gnome_theme_meta_info_new ();
data->theme_icon = gdk_pixbuf_new_from_file (GNOMECC_PIXMAP_DIR "/theme-thumbnailing.png", NULL); data->theme_icon = gdk_pixbuf_new_from_file (GNOMECC_PIXMAP_DIR "/theme-thumbnailing.png", NULL);
data->theme_store = theme_store = data->theme_store = theme_store =

View file

@ -62,6 +62,8 @@ typedef struct {
GtkWidget *apply_background_button; GtkWidget *apply_background_button;
GtkWidget *revert_font_button; GtkWidget *revert_font_button;
GtkWidget *apply_font_button; GtkWidget *apply_font_button;
GtkWidget *theme_info_icon;
GtkWidget *theme_error_icon;
gchar *revert_application_font; gchar *revert_application_font;
gchar *revert_documents_font; gchar *revert_documents_font;
gchar *revert_desktop_font; gchar *revert_desktop_font;

View file

@ -1,3 +1,8 @@
2008-04-19 Jens Granseuer <jensgr@gmx.net>
* gtkrc-utils.c: (gtkrc_get_details): accept NULL for the
symbolic_colors parameter if the caller doesn't want that information
2008-04-13 Jens Granseuer <jensgr@gmx.net> 2008-04-13 Jens Granseuer <jensgr@gmx.net>
Disable theme thumbnailing on MacOS. Some CoreFoundation functionality Disable theme thumbnailing on MacOS. Some CoreFoundation functionality

View file

@ -117,6 +117,8 @@ gtkrc_get_details (gchar *filename, GSList **engines, GSList **symbolic_colors)
GTokenType string_token; GTokenType string_token;
if (token == '@') if (token == '@')
{ {
if (symbolic_colors == NULL)
continue;
token = g_scanner_get_next_token (scanner); token = g_scanner_get_next_token (scanner);
if (token != G_TOKEN_IDENTIFIER) if (token != G_TOKEN_IDENTIFIER)
continue; continue;

View file

@ -111,6 +111,11 @@ PKG_CHECK_MODULES(LIBBACKGROUND, glib-2.0 gobject-2.0 gdk-2.0 gconf-2.0)
PKG_CHECK_MODULES(LIBSOUNDS, gio-2.0 libgnome-2.0 libgnomeui-2.0) PKG_CHECK_MODULES(LIBSOUNDS, gio-2.0 libgnome-2.0 libgnomeui-2.0)
PKG_CHECK_MODULES(GSD_DBUS, gnome-settings-daemon) PKG_CHECK_MODULES(GSD_DBUS, gnome-settings-daemon)
gtk_lib_dir=`$PKG_CONFIG --variable libdir gtk+-2.0`
gtk_binary_version=`$PKG_CONFIG --variable gtk_binary_version gtk+-2.0`
GTK_ENGINE_DIR="$gtk_lib_dir/gtk-2.0/$gtk_binary_version/engines"
AC_SUBST(GTK_ENGINE_DIR)
dnl dnl
dnl Check for Xft version 2; we build in extra functionality to the font capplet dnl Check for Xft version 2; we build in extra functionality to the font capplet
dnl when we have it. dnl when we have it.