From 72dd6bbfd7b7799a88edf74ce0dae809ea5a435b Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Fri, 14 Apr 2000 13:11:00 +0000 Subject: [PATCH] r240: Tidied up the pixmap code - now uses ImLib functions if possible. Fixed ref problems in pixmap caching (stuff never freed). --- ROX-Filer/src/Docs/Manual.lyx | 40 +++++++-- ROX-Filer/src/dir.c | 42 +++++----- ROX-Filer/src/dnd.c | 2 +- ROX-Filer/src/filer.c | 27 +++--- ROX-Filer/src/menu.c | 2 +- ROX-Filer/src/minibuffer.c | 51 +++++++++++- ROX-Filer/src/minibuffer.h | 1 + ROX-Filer/src/pixmaps.c | 186 ++++++++++++++++++++++++++++-------------- ROX-Filer/src/pixmaps.h | 21 +++-- ROX-Filer/src/type.c | 4 +- 10 files changed, 270 insertions(+), 106 deletions(-) diff --git a/ROX-Filer/src/Docs/Manual.lyx b/ROX-Filer/src/Docs/Manual.lyx index 880426f0..38bd0ff2 100644 --- a/ROX-Filer/src/Docs/Manual.lyx +++ b/ROX-Filer/src/Docs/Manual.lyx @@ -1,4 +1,4 @@ -#This file was created by Sun Apr 9 18:10:38 2000 +#This file was created by Fri Apr 14 10:40:15 2000 #LyX 0.12 (C) 1995-1998 Matthias Ettrich and the LyX Team \lyxformat 2.15 \textclass article @@ -1257,7 +1257,7 @@ Open the minibuffer by choosing 'Enter Path' from the Window menu. I usually bind this function to the slash (`/') key. \layout Enumerate -Press CTRL-U to delete the existing contents - this moves you to the root +Press CTRL-U to delete the existing contents --- this moves you to the root directory. \layout Enumerate @@ -1294,20 +1294,50 @@ This provides a quick way of entering shell commands if you don't want to Just type in the command and press Return to execute it. Up and Down arrows move through previously entered commands. + Clicking on an item inserts its name into the minibuffer. If some items are selected then they are assigned to the positional parameters - $1, $2, etc. + +\family typewriter +$1 +\family default +, +\family typewriter +$2 +\family default +, etc. \layout Subsubsection* -Example +Examples \layout Standard -To print all the selected files: +To untar a +\family typewriter +.tgz +\family default + archive: \layout Enumerate Open the minibuffer by choosing `Shell Command' from the Window menu. I usually bind this to the bang (`!') key. \layout Enumerate +Type ` +\family typewriter +tar xzf +\family default +' and click on the file. + The leading space is automatically inserted. +\layout Enumerate + +Press Return to execute it. +\layout Standard + +To print all the selected files: +\layout Enumerate + +Open the shell command minibuffer. +\layout Enumerate + Type \family typewriter `lpr $* diff --git a/ROX-Filer/src/dir.c b/ROX-Filer/src/dir.c index fa43fa63..4b46506a 100644 --- a/ROX-Filer/src/dir.c +++ b/ROX-Filer/src/dir.c @@ -434,17 +434,17 @@ static void insert_item(Directory *dir, struct dirent *ent) new.flags |= ITEM_FLAG_TEMP_ICON; } else - new.image = default_pixmap + TYPE_APPDIR; + new.image = default_pixmap[TYPE_APPDIR]; } else - new.image = default_pixmap + TYPE_DIRECTORY; + new.image = default_pixmap[TYPE_DIRECTORY]; } else if (new.base_type == TYPE_FILE) { /* Note: for symlinks we use need the mode of the target */ if (info.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) { - new.image = default_pixmap + TYPE_EXEC_FILE; + new.image = default_pixmap[TYPE_EXEC_FILE]; new.flags |= ITEM_FLAG_EXEC_FILE; } else @@ -455,7 +455,7 @@ static void insert_item(Directory *dir, struct dirent *ent) } } else - new.image = default_pixmap + new.base_type; + new.image = default_pixmap[new.base_type]; for (i = 0; i < array->len; i++) { @@ -478,21 +478,26 @@ update: new.leafname = item->leafname; new.details_width = gdk_string_width(fixed_font, details(&new)); - if (is_new == FALSE - && item->lstat_errno == new.lstat_errno - && item->base_type == new.base_type - && item->flags == new.flags - && item->size == new.size - && item->mode == new.mode - && item->mtime == new.mtime - && item->uid == new.uid - && item->gid == new.gid - && item->image == new.image - && item->mime_type == new.mime_type - && item->name_width == new.name_width - && item->details_width == new.details_width) - return; + if (is_new == FALSE) + { + if (item->flags & ITEM_FLAG_TEMP_ICON) + pixmap_unref(item->image); + if (item->lstat_errno == new.lstat_errno + && item->base_type == new.base_type + && item->flags == new.flags + && item->size == new.size + && item->mode == new.mode + && item->mtime == new.mtime + && item->uid == new.uid + && item->gid == new.gid + && item->image == new.image + && item->mime_type == new.mime_type + && item->name_width == new.name_width + && item->details_width == new.details_width) + return; + } + item->image = new.image; item->lstat_errno = new.lstat_errno; item->base_type = new.base_type; item->flags = new.flags; @@ -501,7 +506,6 @@ update: item->uid = new.uid; item->gid = new.gid; item->mtime = new.mtime; - item->image = new.image; item->mime_type = new.mime_type; item->name_width = new.name_width; item->details_width = new.details_width; diff --git a/ROX-Filer/src/dnd.c b/ROX-Filer/src/dnd.c index cd2e4ff8..8896f569 100644 --- a/ROX-Filer/src/dnd.c +++ b/ROX-Filer/src/dnd.c @@ -373,7 +373,7 @@ void drag_selection(Collection *collection, (GdkEvent *) event); g_dataset_set_data(context, "filer_window", filer_window); - image = item ? item->image : &default_pixmap[TYPE_MULTIPLE]; + image = item ? item->image : default_pixmap[TYPE_MULTIPLE]; gtk_drag_set_icon_pixmap(context, gtk_widget_get_colormap(widget), diff --git a/ROX-Filer/src/filer.c b/ROX-Filer/src/filer.c index 800b8b66..67e15aef 100644 --- a/ROX-Filer/src/filer.c +++ b/ROX-Filer/src/filer.c @@ -520,9 +520,9 @@ static void draw_small_icon(GtkWidget *widget, { gdk_gc_set_clip_origin(gc, image_x, area->y + 8); gdk_gc_set_clip_mask(gc, - default_pixmap[TYPE_SYMLINK].mask); + default_pixmap[TYPE_SYMLINK]->mask); gdk_draw_pixmap(widget->window, gc, - default_pixmap[TYPE_SYMLINK].pixmap, + default_pixmap[TYPE_SYMLINK]->pixmap, 0, 0, /* Source x,y */ image_x, area->y + 8, /* Dest x,y */ -1, -1); @@ -534,9 +534,9 @@ static void draw_small_icon(GtkWidget *widget, : TYPE_UNMOUNTED; gdk_gc_set_clip_origin(gc, image_x, area->y + 8); gdk_gc_set_clip_mask(gc, - default_pixmap[type].mask); + default_pixmap[type]->mask); gdk_draw_pixmap(widget->window, gc, - default_pixmap[type].pixmap, + default_pixmap[type]->pixmap, 0, 0, /* Source x,y */ image_x, area->y + 8, /* Dest x,y */ -1, -1); @@ -583,9 +583,9 @@ static void draw_large_icon(GtkWidget *widget, { gdk_gc_set_clip_origin(gc, image_x, area->y + 8); gdk_gc_set_clip_mask(gc, - default_pixmap[TYPE_SYMLINK].mask); + default_pixmap[TYPE_SYMLINK]->mask); gdk_draw_pixmap(widget->window, gc, - default_pixmap[TYPE_SYMLINK].pixmap, + default_pixmap[TYPE_SYMLINK]->pixmap, 0, 0, /* Source x,y */ image_x, area->y + 8, /* Dest x,y */ -1, -1); @@ -597,9 +597,9 @@ static void draw_large_icon(GtkWidget *widget, : TYPE_UNMOUNTED; gdk_gc_set_clip_origin(gc, image_x, area->y + 8); gdk_gc_set_clip_mask(gc, - default_pixmap[type].mask); + default_pixmap[type]->mask); gdk_draw_pixmap(widget->window, gc, - default_pixmap[type].pixmap, + default_pixmap[type]->pixmap, 0, 0, /* Source x,y */ image_x, area->y + 8, /* Dest x,y */ -1, -1); @@ -1040,6 +1040,7 @@ static void follow_symlink(FilerWindow *filer_window, char *path, g_free(real); } +/* Open the item (or add it to the shell command minibuffer) */ void filer_openitem(FilerWindow *filer_window, int item_number, OpenFlags flags) { gboolean shift = (flags & OPEN_SHIFT) != 0; @@ -1055,6 +1056,12 @@ void filer_openitem(FilerWindow *filer_window, int item_number, OpenFlags flags) gboolean wink = TRUE, destroy = FALSE; widget = filer_window->window; + if (filer_window->mini_type == MINI_SHELL) + { + minibuffer_add(filer_window, item->leafname); + return; + } + full_path = make_path(filer_window->path, item->leafname)->str; @@ -1691,8 +1698,8 @@ static void add_button(GtkWidget *box, int pixmap, { GtkWidget *button, *icon; - icon = gtk_pixmap_new(default_pixmap[pixmap].pixmap, - default_pixmap[pixmap].mask); + icon = gtk_pixmap_new(default_pixmap[pixmap]->pixmap, + default_pixmap[pixmap]->mask); if (o_toolbar == TOOLBAR_GNOME) { diff --git a/ROX-Filer/src/menu.c b/ROX-Filer/src/menu.c index 305443ba..624d31c4 100644 --- a/ROX-Filer/src/menu.c +++ b/ROX-Filer/src/menu.c @@ -1289,7 +1289,7 @@ static void new_directory(gpointer data, guint action, GtkWidget *widget) savebox_show("New Directory", make_path(window_with_focus->path, "NewDir")->str, - default_pixmap + TYPE_DIRECTORY, + default_pixmap[TYPE_DIRECTORY], new_directory_cb); } diff --git a/ROX-Filer/src/minibuffer.c b/ROX-Filer/src/minibuffer.c index 157268fc..4ccf70f5 100644 --- a/ROX-Filer/src/minibuffer.c +++ b/ROX-Filer/src/minibuffer.c @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -58,6 +59,7 @@ GtkWidget *create_minibuffer(FilerWindow *filer_window) GtkWidget *mini; mini = gtk_entry_new(); + gtk_widget_set_style(mini, fixed_style); gtk_signal_connect(GTK_OBJECT(mini), "key_press_event", GTK_SIGNAL_FUNC(key_press_event), filer_window); gtk_signal_connect(GTK_OBJECT(mini), "changed", @@ -115,6 +117,30 @@ void minibuffer_hide(FilerWindow *filer_window) GTK_WIDGET(filer_window->collection)); } +/* Insert this leafname at the cursor (replacing the selection, if any). + * Must be in SHELL mode. + */ +void minibuffer_add(FilerWindow *filer_window, guchar *leafname) +{ + guchar *esc; + GtkEditable *edit = GTK_EDITABLE(filer_window->minibuffer); + int pos; + + g_return_if_fail(filer_window->mini_type == MINI_SHELL); + + if (strchr(leafname, ' ')) + esc = g_strdup_printf(" \"%s\"", leafname); + else + esc = g_strdup_printf(" %s", leafname); + + gtk_editable_delete_selection(edit); + pos = gtk_editable_get_position(edit); + gtk_editable_insert_text(edit, esc, strlen(esc), &pos); + gtk_editable_set_position(edit, pos); + + g_free(esc); +} + /**************************************************************** * INTERNAL FUNCTIONS * @@ -348,6 +374,26 @@ static void search_in_dir(FilerWindow *filer_window, int dir) /* SHELL COMMANDS */ +static void add_to_history(FilerWindow *filer_window) +{ + guchar *line, *last, *c; + + line = gtk_entry_get_text(GTK_ENTRY(filer_window->minibuffer)); + + for (c = line; *c && isspace(*c); c++) + ; + + if (!*c) + return; + + last = shell_history ? (guchar *) shell_history->data : NULL; + + if (last && strcmp(last, line) == 0) + return; /* Duplicating last entry */ + + shell_history = g_list_prepend(shell_history, g_strdup(line)); +} + static void shell_return_pressed(FilerWindow *filer_window, GdkEventKey *event) { GPtrArray *argv; @@ -355,8 +401,9 @@ static void shell_return_pressed(FilerWindow *filer_window, GdkEventKey *event) guchar *entry; Collection *collection = filer_window->collection; + add_to_history(filer_window); + entry = gtk_entry_get_text(GTK_ENTRY(filer_window->minibuffer)); - shell_history = g_list_prepend(shell_history, g_strdup(entry)); argv = g_ptr_array_new(); g_ptr_array_add(argv, "sh"); @@ -432,6 +479,8 @@ static gint key_press_event(GtkWidget *widget, { if (event->keyval == GDK_Escape) { + if (filer_window->mini_type == MINI_SHELL) + add_to_history(filer_window); minibuffer_hide(filer_window); return TRUE; } diff --git a/ROX-Filer/src/minibuffer.h b/ROX-Filer/src/minibuffer.h index 0fa258f3..4a57ecce 100644 --- a/ROX-Filer/src/minibuffer.h +++ b/ROX-Filer/src/minibuffer.h @@ -16,5 +16,6 @@ typedef enum {MINI_NONE, MINI_PATH, MINI_SHELL} MiniType; GtkWidget *create_minibuffer(FilerWindow *filer_window); void minibuffer_show(FilerWindow *filer_window, MiniType mini_type); void minibuffer_hide(FilerWindow *filer_window); +void minibuffer_add(FilerWindow *filer_window, guchar *leafname); #endif /* _MINIBUFFER_H */ diff --git a/ROX-Filer/src/pixmaps.c b/ROX-Filer/src/pixmaps.c index e33c7137..f1693841 100644 --- a/ROX-Filer/src/pixmaps.c +++ b/ROX-Filer/src/pixmaps.c @@ -21,7 +21,13 @@ /* pixmaps.c - code for handling pixmaps */ +/* + * 2000/04/11 Imlib support added + * Christiansen Merel + */ + #include "config.h" +#define PIXMAPS_C /* Remove pixmaps from the cache when they haven't been accessed for * this period of time (seconds). @@ -36,6 +42,9 @@ #include #include /* XXX - find another way to do this */ #include "collection.h" +#ifdef HAVE_IMLIB +# include +#endif #include "fscache.h" #include "support.h" @@ -62,16 +71,19 @@ static char * bad_xpm[] = { " ..XXXXXX.. ", " "}; -MaskedPixmap default_pixmap[LAST_DEFAULT_PIXMAP]; +MaskedPixmap *default_pixmap[LAST_DEFAULT_PIXMAP]; /* Static prototypes */ +static MaskedPixmap *load_pixmap(char *name); static void load_default_pixmaps(void); static MaskedPixmap *load(char *pathname, gpointer data); static void ref(MaskedPixmap *mp, gpointer data); static void unref(MaskedPixmap *mp, gpointer data); static int getref(MaskedPixmap *mp); static gint purge(gpointer data); +static MaskedPixmap *image_from_file(char *path); +static MaskedPixmap *get_bad_image(void); /**************************************************************** @@ -80,6 +92,10 @@ static gint purge(gpointer data); void pixmaps_init(void) { +#ifdef HAVE_IMLIB + gdk_imlib_init(); +#endif + pixmap_cache = g_fscache_new((GFSLoadFunc) load, (GFSRefFunc) ref, (GFSRefFunc) unref, @@ -92,50 +108,40 @@ void pixmaps_init(void) load_default_pixmaps(); } -void load_pixmap(char *name, MaskedPixmap *image) +/* 'name' is relative to APP_DIR. Always returns with a valid image. */ +MaskedPixmap *load_pixmap(char *name) { - image->pixmap = gdk_pixmap_colormap_create_from_xpm(NULL, - gtk_widget_get_default_colormap(), - &image->mask, - 0, - make_path(getenv("APP_DIR"), name)->str); - - if (!image->pixmap) - { - image->pixmap= gdk_pixmap_colormap_create_from_xpm_d(NULL, - gtk_widget_get_default_colormap(), - &image->mask, NULL, bad_xpm); - } + MaskedPixmap *retval; - image->ref = 1; - /* XXX: ugly */ - image->width = ((GdkPixmapPrivate *) image->pixmap)->width; - image->height = ((GdkPixmapPrivate *) image->pixmap)->height; + retval = image_from_file(make_path(getenv("APP_DIR"), name)->str); + if (!retval) + retval = get_bad_image(); + return retval; } /* Load all the standard pixmaps */ static void load_default_pixmaps(void) { - load_pixmap("pixmaps/error.xpm", default_pixmap + TYPE_ERROR); - load_pixmap("pixmaps/unknown.xpm", default_pixmap + TYPE_UNKNOWN); - load_pixmap("pixmaps/symlink.xpm", default_pixmap + TYPE_SYMLINK); - load_pixmap("pixmaps/file.xpm", default_pixmap + TYPE_FILE); - load_pixmap("pixmaps/directory.xpm", default_pixmap + TYPE_DIRECTORY); - load_pixmap("pixmaps/char.xpm", default_pixmap + TYPE_CHAR_DEVICE); - load_pixmap("pixmaps/block.xpm", default_pixmap + TYPE_BLOCK_DEVICE); - load_pixmap("pixmaps/pipe.xpm", default_pixmap + TYPE_PIPE); - load_pixmap("pixmaps/socket.xpm", default_pixmap + TYPE_SOCKET); - - load_pixmap("pixmaps/mount.xpm", default_pixmap + TYPE_UNMOUNTED); - load_pixmap("pixmaps/mounted.xpm", default_pixmap + TYPE_MOUNTED); - load_pixmap("pixmaps/multiple.xpm", default_pixmap + TYPE_MULTIPLE); - load_pixmap("pixmaps/exec.xpm", default_pixmap + TYPE_EXEC_FILE); - load_pixmap("pixmaps/application.xpm", default_pixmap + TYPE_APPDIR); - - load_pixmap("pixmaps/up.xpm", default_pixmap + TOOLBAR_UP_ICON); - load_pixmap("pixmaps/home.xpm", default_pixmap + TOOLBAR_HOME_ICON); - load_pixmap("pixmaps/refresh.xpm", default_pixmap + - TOOLBAR_REFRESH_ICON); + default_pixmap[TYPE_ERROR] = load_pixmap("pixmaps/error.xpm"); + default_pixmap[TYPE_UNKNOWN] = load_pixmap("pixmaps/unknown.xpm"); + default_pixmap[TYPE_SYMLINK] = load_pixmap("pixmaps/symlink.xpm"); + default_pixmap[TYPE_FILE] = load_pixmap("pixmaps/file.xpm"); + default_pixmap[TYPE_DIRECTORY] = load_pixmap("pixmaps/directory.xpm"); + default_pixmap[TYPE_CHAR_DEVICE] = load_pixmap("pixmaps/char.xpm"); + default_pixmap[TYPE_BLOCK_DEVICE] = load_pixmap("pixmaps/block.xpm"); + default_pixmap[TYPE_PIPE] = load_pixmap("pixmaps/pipe.xpm"); + default_pixmap[TYPE_SOCKET] = load_pixmap("pixmaps/socket.xpm"); + + default_pixmap[TYPE_UNMOUNTED] = load_pixmap("pixmaps/mount.xpm"); + default_pixmap[TYPE_MOUNTED] = load_pixmap("pixmaps/mounted.xpm"); + default_pixmap[TYPE_MULTIPLE] = load_pixmap("pixmaps/multiple.xpm"); + default_pixmap[TYPE_EXEC_FILE] = load_pixmap("pixmaps/exec.xpm"); + default_pixmap[TYPE_APPDIR] = load_pixmap("pixmaps/application.xpm"); + + default_pixmap[TOOLBAR_UP_ICON] = load_pixmap("pixmaps/up.xpm"); + default_pixmap[TOOLBAR_HOME_ICON] = load_pixmap("pixmaps/home.xpm"); + default_pixmap[TOOLBAR_REFRESH_ICON] = + load_pixmap("pixmaps/refresh.xpm"); } void pixmap_ref(MaskedPixmap *mp) @@ -152,32 +158,89 @@ void pixmap_unref(MaskedPixmap *mp) * INTERNAL FUNCTIONS * ****************************************************************/ -/* Try to load the pixmap from the given path, allocate a MaskedPixmap - * structure for it and return a pointer to the structure. NULL on failure. +/* Load the image 'path' and return a pointer to the resulting + * MaskedPixmap. NULL on failure. */ -static MaskedPixmap *load(char *pathname, gpointer user_data) +static MaskedPixmap *image_from_file(char *path) { + MaskedPixmap *mp; GdkPixmap *pixmap; GdkBitmap *mask; - MaskedPixmap *masked_pixmap; + int width; + int height; +#ifdef HAVE_IMLIB + GdkImlibImage *image; + + image = gdk_imlib_load_image(path); + if (!image) + return NULL; + if (!gdk_imlib_render(image, image->rgb_width, image->rgb_height)) + { + gdk_imlib_kill_image(image); + return NULL; + } + + pixmap = image->pixmap; + mask = image->shape_mask; + width = image->width; + height = image->height; +#else pixmap = gdk_pixmap_colormap_create_from_xpm(NULL, - gtk_widget_get_default_colormap(), - &mask, - 0, - pathname); + gtk_widget_get_default_colormap(), + &mask, + 0, + path); + if (!pixmap) return NULL; + width = ((GdkPixmapPrivate *) mp->pixmap)->width; + height = ((GdkPixmapPrivate *) mp->pixmap)->height; +#endif + + mp = g_new(MaskedPixmap, 1); + mp->ref = 1; +#ifdef HAVE_IMLIB + mp->image = image; +#endif + mp->pixmap = pixmap; + mp->mask = mask; + mp->width = width; + mp->height = height; + + return mp; +} - masked_pixmap = g_new(MaskedPixmap, 1); - masked_pixmap->pixmap = pixmap; - masked_pixmap->mask = mask; - masked_pixmap->ref = 1; - /* XXX: ugly */ - masked_pixmap->width = ((GdkPixmapPrivate *) pixmap)->width; - masked_pixmap->height = ((GdkPixmapPrivate *) pixmap)->height; +/* Return a pointer to the (static) bad image. The ref counter will ensure + * that the image is never freed. + */ +static MaskedPixmap *get_bad_image(void) +{ + static MaskedPixmap *image = NULL; - return masked_pixmap; + if (!image) + { + image = g_new(MaskedPixmap, 1); + image->ref = 1; + + image->pixmap= gdk_pixmap_colormap_create_from_xpm_d(NULL, + gtk_widget_get_default_colormap(), + &image->mask, NULL, bad_xpm); +#ifdef HAVE_IMLIB + image->image = NULL; +#endif + } + + image->ref++; + image->width = ((GdkPixmapPrivate *) image->pixmap)->width; + image->height = ((GdkPixmapPrivate *) image->pixmap)->height; + + return image; +} + +static MaskedPixmap *load(char *pathname, gpointer user_data) +{ + return image_from_file(pathname); } static void ref(MaskedPixmap *mp, gpointer data) @@ -185,11 +248,7 @@ static void ref(MaskedPixmap *mp, gpointer data) /* printf("[ ref %p %d->%d ]\n", mp, mp->ref, mp->ref + 1); */ if (mp) - { - gdk_pixmap_ref(mp->pixmap); - gdk_bitmap_ref(mp->mask); mp->ref++; - } } static void unref(MaskedPixmap *mp, gpointer data) @@ -198,8 +257,15 @@ static void unref(MaskedPixmap *mp, gpointer data) if (mp && --mp->ref == 0) { - gdk_pixmap_unref(mp->pixmap); - gdk_bitmap_unref(mp->mask); +#ifdef HAVE_IMLIB + if (mp->image) + gdk_imlib_destroy_image(mp->image); + else +#endif + { + gdk_pixmap_unref(mp->pixmap); + gdk_bitmap_unref(mp->mask); + } g_free(mp); } } diff --git a/ROX-Filer/src/pixmaps.h b/ROX-Filer/src/pixmaps.h index e6a7a8d7..92e216b4 100644 --- a/ROX-Filer/src/pixmaps.h +++ b/ROX-Filer/src/pixmaps.h @@ -42,24 +42,31 @@ enum LAST_DEFAULT_PIXMAP }; - typedef struct _MaskedPixmap MaskedPixmap; +#ifdef HAVE_IMLIB +# ifdef PIXMAPS_C +# define IMLIB_T GdkImlibImage +# else +# define IMLIB_T gpointer +# endif +#endif + struct _MaskedPixmap { - GdkPixmap *pixmap; - GdkBitmap *mask; int ref; +#ifdef HAVE_IMLIB + IMLIB_T *image; +#endif + GdkPixmap *pixmap; /* Full size image */ + GdkBitmap *mask; int width; int height; }; - -extern MaskedPixmap default_pixmap[LAST_DEFAULT_PIXMAP]; - +extern MaskedPixmap *default_pixmap[LAST_DEFAULT_PIXMAP]; void pixmaps_init(void); -void load_pixmap(char *name, MaskedPixmap *image); void pixmap_ref(MaskedPixmap *mp); void pixmap_unref(MaskedPixmap *mp); diff --git a/ROX-Filer/src/type.c b/ROX-Filer/src/type.c index d0ad3674..95c170f0 100644 --- a/ROX-Filer/src/type.c +++ b/ROX-Filer/src/type.c @@ -276,7 +276,7 @@ MaskedPixmap *type_to_icon(MIME_type *type) char *type_name; time_t now; - g_return_val_if_fail(type != NULL, default_pixmap + TYPE_UNKNOWN); + g_return_val_if_fail(type != NULL, default_pixmap[TYPE_UNKNOWN]); now = time(NULL); /* Already got an image? */ @@ -308,7 +308,7 @@ MaskedPixmap *type_to_icon(MIME_type *type) if (!type->image) { - type->image = default_pixmap + TYPE_UNKNOWN; + type->image = default_pixmap[TYPE_UNKNOWN]; pixmap_ref(type->image); } -- 2.11.4.GIT