Allow user to set a custom image loading routine for loading bg_pixmap's

Allow user to set a custom image loading routine for loading bg_pixmap's specified in the
gtkrc's.
This commit is contained in:
Elliot Lee 1998-05-21 19:24:01 +00:00
parent aed9cf77fa
commit cefd52f52f
2 changed files with 36 additions and 3 deletions

View File

@ -228,6 +228,8 @@ static gchar *pixmap_path[GTK_RC_MAX_PIXMAP_PATHS];
/* The files we have parsed, to reread later if necessary */ /* The files we have parsed, to reread later if necessary */
GSList *rc_files = NULL; GSList *rc_files = NULL;
static GtkImageLoader image_loader = NULL;
void void
gtk_rc_init (void) gtk_rc_init (void)
{ {
@ -759,6 +761,12 @@ gtk_rc_style_init (GtkRcStyle *rc_style, GdkColormap *cmap)
{ {
if (strcmp (rc_style->bg_pixmap_name[i], "<parent>") == 0) if (strcmp (rc_style->bg_pixmap_name[i], "<parent>") == 0)
style->bg_pixmap[i] = (GdkPixmap*) GDK_PARENT_RELATIVE; style->bg_pixmap[i] = (GdkPixmap*) GDK_PARENT_RELATIVE;
else
{
if(image_loader)
style->bg_pixmap[i] = image_loader(NULL, cmap, NULL,
&style->bg[i],
rc_style->bg_pixmap_name[i]);
else else
style->bg_pixmap[i] = style->bg_pixmap[i] =
gdk_pixmap_colormap_create_from_xpm (NULL, cmap, gdk_pixmap_colormap_create_from_xpm (NULL, cmap,
@ -766,6 +774,7 @@ gtk_rc_style_init (GtkRcStyle *rc_style, GdkColormap *cmap)
&style->bg[i], &style->bg[i],
rc_style->bg_pixmap_name[i]); rc_style->bg_pixmap_name[i]);
} }
}
rc_style->styles = g_list_append (rc_style->styles, node); rc_style->styles = g_list_append (rc_style->styles, node);
} }
@ -1646,3 +1655,18 @@ gtk_rc_widget_class_path (GtkWidget *widget)
return path; return path;
} }
/*
typedef GdkPixmap * (*GtkImageLoader) (GdkWindow *window,
GdkColormap *colormap,
GdkBitmap **mask,
GdkColor *transparent_color,
const gchar *filename);
*/
void
gtk_rc_set_loader(GtkImageLoader loader)
{
image_loader = loader;
}

View File

@ -39,6 +39,15 @@ void gtk_rc_add_widget_name_style (GtkStyle *style,
void gtk_rc_add_widget_class_style (GtkStyle *style, void gtk_rc_add_widget_class_style (GtkStyle *style,
const gchar *pattern); const gchar *pattern);
/* Tell gtkrc to use a custom routine to load images specified in rc files instead of
the default xpm-only loader */
typedef GdkPixmap * (*GtkImageLoader) (GdkWindow *window,
GdkColormap *colormap,
GdkBitmap **mask,
GdkColor *transparent_color,
const gchar *filename);
void gtk_rc_set_loader(GtkImageLoader loader);
#ifdef __cplusplus #ifdef __cplusplus
} }