X-Git-Url: https://git.distorted.org.uk/~mdw/disorder/blobdiff_plain/043d60b14ea6b3a5aa20b541e0db31433564e662..0fde64f3f61ad3d2f88d59e63bba2b9850bd9864:/disobedience/misc.c diff --git a/disobedience/misc.c b/disobedience/misc.c index c268654..7e44cc2 100644 --- a/disobedience/misc.c +++ b/disobedience/misc.c @@ -22,6 +22,14 @@ */ #include "disobedience.h" +#include "table.h" + +struct image { + const char *name; + const guint8 *data; +}; + +#include "images.h" /* Miscellaneous GTK+ stuff ------------------------------------------------ */ @@ -31,11 +39,9 @@ WT(cached_image); /** @brief Put scrollbars around a widget * @param child Widget to surround - * @param widgetname Name for (both) widgets * @return Scroll widget */ -GtkWidget *scroll_widget(GtkWidget *child, - const char *widgetname) { +GtkWidget *scroll_widget(GtkWidget *child) { GtkWidget *scroller = gtk_scrolled_window_new(0, 0); GtkAdjustment *adj; @@ -59,9 +65,8 @@ GtkWidget *scroll_widget(GtkWidget *child, gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroller), child); } - /* Apply a name to the widget so it can be recolored */ - gtk_widget_set_name(GTK_BIN(scroller)->child, widgetname); - gtk_widget_set_name(scroller, widgetname); + set_slider_colors(GTK_SCROLLED_WINDOW(scroller)->hscrollbar); + set_slider_colors(GTK_SCROLLED_WINDOW(scroller)->vscrollbar); return scroller; } @@ -80,12 +85,22 @@ GdkPixbuf *find_image(const char *name) { GdkPixbuf *pb; char *path; GError *err = 0; + int n; if(!(pb = (GdkPixbuf *)cache_get(&image_cache_type, name))) { - byte_xasprintf(&path, "%s/static/%s", pkgdatadir, name); - if(!(pb = gdk_pixbuf_new_from_file(path, &err))) { - error(0, "%s", err->message); - return 0; + if((n = TABLE_FIND(images, struct image, name, name)) >= 0) { + /* Use the built-in copy */ + if(!(pb = gdk_pixbuf_new_from_inline(-1, images[n].data, FALSE, &err))) { + error(0, "%s", err->message); + return 0; + } + } else { + /* See if there's a copy on disk */ + byte_xasprintf(&path, "%s/static/%s", pkgdatadir, name); + if(!(pb = gdk_pixbuf_new_from_file(path, &err))) { + error(0, "%s", err->message); + return 0; + } } NW(cached_image); cache_put(&image_cache_type, name, pb);