From 259988e8e0f97df591120d0fd6629273a30a15aa Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Thu, 1 Jun 2000 12:38:29 +0000 Subject: [PATCH] r287: Removed the DEFAULT_PIXMAP array - the new type system makes in unnecessary and it's messy. Should move the type enum into types.h at some point. --- ROX-Filer/Help/Changes | 5 ++++ ROX-Filer/Help/README | 2 +- ROX-Filer/Help/TODO | 2 -- ROX-Filer/pixmaps/help.xpm | 29 ++++++++++++++++++++++ ROX-Filer/src/dir.c | 4 ++-- ROX-Filer/src/dnd.c | 2 +- ROX-Filer/src/filer.c | 60 ++++++++++++++++++++++++---------------------- ROX-Filer/src/minibuffer.c | 6 +---- ROX-Filer/src/pixmaps.c | 43 +++++++++++++++++++++------------ ROX-Filer/src/pixmaps.h | 25 +++++++++++-------- ROX-Filer/src/type.c | 4 ++-- 11 files changed, 115 insertions(+), 67 deletions(-) create mode 100644 ROX-Filer/pixmaps/help.xpm diff --git a/ROX-Filer/Help/Changes b/ROX-Filer/Help/Changes index dbeedcdd..476ec95e 100644 --- a/ROX-Filer/Help/Changes +++ b/ROX-Filer/Help/Changes @@ -3,6 +3,11 @@ by Thomas Leonard +25-May-2000 +~~~~~~~~~~~ +Started adding some code to truncate long filenames (not finished yet). +Fixed a bug which could cause directories to appear empty when using VFS. + 21-May-2000 ~~~~~~~~~~~ Moved most of the icons from pixmaps to MIME-icons (outside ROX-Filer). diff --git a/ROX-Filer/Help/README b/ROX-Filer/Help/README index c786bc99..80e946a1 100644 --- a/ROX-Filer/Help/README +++ b/ROX-Filer/Help/README @@ -47,7 +47,7 @@ If you think you should be included here then write and tell me ;-) First, a few people/projects whose work I've used: - Andrew Clover most of the good file icons + Andrew Clover most of the file icons David MacKenzie the code for parsing Permissions commands John Lindal co-author of the XDS protocol Midnight Commander the Virtual File System library diff --git a/ROX-Filer/Help/TODO b/ROX-Filer/Help/TODO index f274598f..ac992f4c 100644 --- a/ROX-Filer/Help/TODO +++ b/ROX-Filer/Help/TODO @@ -52,8 +52,6 @@ People sometimes forget to save the key bindings - remind them somehow? Enable (temporarily) single-click navigation when a special key (e.g. Alt) is pressed? -'Other Action' should work on either 'other' button. - Improve MIME-type guessing: - Try to find longest extension match (eg .ps.gz, then .gz) - Try again ignoring case (so .BMP matches .bmp) (.C must still work!) diff --git a/ROX-Filer/pixmaps/help.xpm b/ROX-Filer/pixmaps/help.xpm new file mode 100644 index 00000000..9aa10951 --- /dev/null +++ b/ROX-Filer/pixmaps/help.xpm @@ -0,0 +1,29 @@ +/* XPM */ +static char * help_xpm[] = { +"14 14 12 1", +" c None", +". c #0091FF", +"+ c #38A9FF", +"@ c #219FFF", +"# c #FFFFFF", +"$ c #C6E6FF", +"% c #1C9DFF", +"& c #71C1FF", +"* c #E2F2FF", +"= c #AADAFF", +"- c #55B5FF", +"; c #8DCDFF", +" ...+@. ", +" ...+#$%. ", +" ....&#*+.. ", +" ......&+.... ", +"..............", +"....&=##-.....", +".....=##-.....", +".....=##......", +".....##;......", +"....+##-+%....", +" ...=##%=+... ", +" ..=##;-... ", +" .+==&... ", +" ...... "}; diff --git a/ROX-Filer/src/dir.c b/ROX-Filer/src/dir.c index 24913533..8b4ffef0 100644 --- a/ROX-Filer/src/dir.c +++ b/ROX-Filer/src/dir.c @@ -435,7 +435,7 @@ static void insert_item(Directory *dir, struct dirent *ent) new.flags |= ITEM_FLAG_TEMP_ICON; } else - new.image = default_pixmap[TYPE_APPDIR]; + new.image = im_appdir; } } else if (new.base_type == TYPE_FILE) @@ -443,7 +443,7 @@ static void insert_item(Directory *dir, struct dirent *ent) /* 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 = im_exec_file; new.flags |= ITEM_FLAG_EXEC_FILE; } else diff --git a/ROX-Filer/src/dnd.c b/ROX-Filer/src/dnd.c index 6fc32050..c1f248c3 100644 --- a/ROX-Filer/src/dnd.c +++ b/ROX-Filer/src/dnd.c @@ -404,7 +404,7 @@ void drag_selection(Collection *collection, (event->state & GDK_BUTTON2_MASK) ? 2 : 3, (GdkEvent *) event); - image = item ? item->image : default_pixmap[TYPE_MULTIPLE]; + image = item ? item->image : im_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 43d539f6..d6d1adea 100644 --- a/ROX-Filer/src/filer.c +++ b/ROX-Filer/src/filer.c @@ -149,7 +149,7 @@ static gint focus_out(GtkWidget *widget, static void add_item(FilerWindow *filer_window, DirItem *item); static void toolbar_up_clicked(GtkWidget *widget, FilerWindow *filer_window); static void toolbar_home_clicked(GtkWidget *widget, FilerWindow *filer_window); -static void add_button(GtkWidget *box, int pixmap, +static void add_button(GtkWidget *box, MaskedPixmap *icon, GtkSignalFunc cb, FilerWindow *filer_window, char *label, char *tip); static GtkWidget *create_toolbar(FilerWindow *filer_window); @@ -543,20 +543,17 @@ static void draw_small_icon(GtkWidget *widget, if (item->flags & ITEM_FLAG_SYMLINK) { gdk_gc_set_clip_origin(gc, image_x, area->y + 8); - gdk_gc_set_clip_mask(gc, - default_pixmap[TYPE_SYMLINK]->mask); - gdk_draw_pixmap(widget->window, gc, - default_pixmap[TYPE_SYMLINK]->pixmap, + gdk_gc_set_clip_mask(gc, im_symlink->mask); + gdk_draw_pixmap(widget->window, gc, im_symlink->pixmap, 0, 0, /* Source x,y */ image_x, area->y + 8, /* Dest x,y */ -1, -1); } else if (item->flags & ITEM_FLAG_MOUNT_POINT) { - int type = item->flags & ITEM_FLAG_MOUNTED - ? TYPE_MOUNTED - : TYPE_UNMOUNTED; - MaskedPixmap *mp = default_pixmap[type]; + MaskedPixmap *mp = item->flags & ITEM_FLAG_MOUNTED + ? im_mounted + : im_unmounted; if (!mp->sm_pixmap) pixmap_make_small(mp); @@ -609,24 +606,21 @@ static void draw_large_icon(GtkWidget *widget, if (item->flags & ITEM_FLAG_SYMLINK) { gdk_gc_set_clip_origin(gc, image_x, area->y + 8); - gdk_gc_set_clip_mask(gc, - default_pixmap[TYPE_SYMLINK]->mask); - gdk_draw_pixmap(widget->window, gc, - default_pixmap[TYPE_SYMLINK]->pixmap, + gdk_gc_set_clip_mask(gc, im_symlink->mask); + gdk_draw_pixmap(widget->window, gc, im_symlink->pixmap, 0, 0, /* Source x,y */ image_x, area->y + 8, /* Dest x,y */ -1, -1); } else if (item->flags & ITEM_FLAG_MOUNT_POINT) { - int type = item->flags & ITEM_FLAG_MOUNTED - ? TYPE_MOUNTED - : TYPE_UNMOUNTED; + MaskedPixmap *mp = item->flags & ITEM_FLAG_MOUNTED + ? im_mounted + : im_unmounted; + gdk_gc_set_clip_origin(gc, image_x, area->y + 8); - gdk_gc_set_clip_mask(gc, - default_pixmap[type]->mask); - gdk_draw_pixmap(widget->window, gc, - default_pixmap[type]->pixmap, + gdk_gc_set_clip_mask(gc, mp->mask); + gdk_draw_pixmap(widget->window, gc, mp->pixmap, 0, 0, /* Source x,y */ image_x, area->y + 8, /* Dest x,y */ -1, -1); @@ -1283,6 +1277,11 @@ static gint key_press_event(GtkWidget *widget, return TRUE; } +static void toolbar_help_clicked(GtkWidget *widget, FilerWindow *filer_window) +{ + filer_opendir(make_path(getenv("APP_DIR"), "Help")->str, PANEL_NO); +} + static void toolbar_refresh_clicked(GtkWidget *widget, FilerWindow *filer_window) { @@ -1795,18 +1794,22 @@ static GtkWidget *create_toolbar(FilerWindow *filer_window) gtk_container_add(GTK_CONTAINER(frame), box); - add_button(box, TOOLBAR_UP_ICON, + add_button(box, im_up_icon, GTK_SIGNAL_FUNC(toolbar_up_clicked), filer_window, _("Up"), _("Change to parent directory")); - add_button(box, TOOLBAR_HOME_ICON, + add_button(box, im_home_icon, GTK_SIGNAL_FUNC(toolbar_home_clicked), filer_window, _("Home"), _("Change to home directory")); - add_button(box, TOOLBAR_REFRESH_ICON, + add_button(box, im_refresh_icon, GTK_SIGNAL_FUNC(toolbar_refresh_clicked), filer_window, _("Rescan"), _("Rescan directory contents")); + add_button(box, im_help, + GTK_SIGNAL_FUNC(toolbar_help_clicked), + filer_window, + _("Help"), _("Show ROX-Filer Help")); return frame; } @@ -1846,14 +1849,13 @@ static gint toolbar_adjust_released(GtkButton *button, return TRUE; } -static void add_button(GtkWidget *box, int pixmap, +static void add_button(GtkWidget *box, MaskedPixmap *icon, GtkSignalFunc cb, FilerWindow *filer_window, char *label, char *tip) { - GtkWidget *button, *icon; + GtkWidget *button, *icon_widget; - icon = gtk_pixmap_new(default_pixmap[pixmap]->pixmap, - default_pixmap[pixmap]->mask); + icon_widget = gtk_pixmap_new(icon->pixmap, icon->mask); if (o_toolbar == TOOLBAR_GNOME) { @@ -1862,7 +1864,7 @@ static void add_button(GtkWidget *box, int pixmap, NULL, label, tip, NULL, - icon, + icon_widget, cb, filer_window); } else @@ -1870,7 +1872,7 @@ static void add_button(GtkWidget *box, int pixmap, button = gtk_button_new(); GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS); - gtk_container_add(GTK_CONTAINER(button), icon); + gtk_container_add(GTK_CONTAINER(button), icon_widget); gtk_signal_connect(GTK_OBJECT(button), "button_press_event", GTK_SIGNAL_FUNC(toolbar_adjust_pressed), filer_window); gtk_signal_connect(GTK_OBJECT(button), "button_release_event", diff --git a/ROX-Filer/src/minibuffer.c b/ROX-Filer/src/minibuffer.c index 56958237..d758ecda 100644 --- a/ROX-Filer/src/minibuffer.c +++ b/ROX-Filer/src/minibuffer.c @@ -65,15 +65,11 @@ static void show_help(FilerWindow *filer_window); */ void create_minibuffer(FilerWindow *filer_window) { - MaskedPixmap *mp; GtkWidget *hbox, *label, *mini, *help, *icon; hbox = gtk_hbox_new(FALSE, 0); - mp = g_fscache_lookup(pixmap_cache, - make_path(getenv("APP_DIR"), "pixmaps/help.xpm")->str); - icon = gtk_pixmap_new(mp->pixmap, mp->mask); - g_fscache_data_unref(pixmap_cache, mp); + icon = gtk_pixmap_new(im_help->pixmap, im_help->mask); help = gtk_button_new(); gtk_container_add(GTK_CONTAINER(help), icon); gtk_box_pack_start(GTK_BOX(hbox), help, FALSE, TRUE, 0); diff --git a/ROX-Filer/src/pixmaps.c b/ROX-Filer/src/pixmaps.c index ff75ad55..f2b804bd 100644 --- a/ROX-Filer/src/pixmaps.c +++ b/ROX-Filer/src/pixmaps.c @@ -71,7 +71,20 @@ static char * bad_xpm[] = { " ..XXXXXX.. ", " "}; -MaskedPixmap *default_pixmap[LAST_DEFAULT_PIXMAP]; +MaskedPixmap *im_error; +MaskedPixmap *im_unknown; +MaskedPixmap *im_symlink; + +MaskedPixmap *im_unmounted; +MaskedPixmap *im_mounted; +MaskedPixmap *im_multiple; +MaskedPixmap *im_exec_file; +MaskedPixmap *im_appdir; + +MaskedPixmap *im_up_icon; +MaskedPixmap *im_home_icon; +MaskedPixmap *im_refresh_icon; +MaskedPixmap *im_help; /* Static prototypes */ @@ -125,20 +138,20 @@ MaskedPixmap *load_pixmap(char *name) /* Load all the standard pixmaps */ static void load_default_pixmaps(void) { - 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_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"); + im_error = load_pixmap("pixmaps/error.xpm"); + im_unknown = load_pixmap("pixmaps/unknown.xpm"); + im_symlink = load_pixmap("pixmaps/symlink.xpm"); + + im_unmounted = load_pixmap("pixmaps/mount.xpm"); + im_mounted = load_pixmap("pixmaps/mounted.xpm"); + im_multiple = load_pixmap("pixmaps/multiple.xpm"); + im_exec_file = load_pixmap("pixmaps/exec.xpm"); + im_appdir = load_pixmap("pixmaps/application.xpm"); + + im_up_icon = load_pixmap("pixmaps/up.xpm"); + im_home_icon = load_pixmap("pixmaps/home.xpm"); + im_refresh_icon = load_pixmap("pixmaps/refresh.xpm"); + im_help = load_pixmap("pixmaps/help.xpm"); } void pixmap_ref(MaskedPixmap *mp) diff --git a/ROX-Filer/src/pixmaps.h b/ROX-Filer/src/pixmaps.h index f7e546ad..89b16fe9 100644 --- a/ROX-Filer/src/pixmaps.h +++ b/ROX-Filer/src/pixmaps.h @@ -32,18 +32,25 @@ enum TYPE_EXEC_FILE, TYPE_MULTIPLE, TYPE_APPDIR, - - /* Toolbar */ - TOOLBAR_UP_ICON, - TOOLBAR_HOME_ICON, - TOOLBAR_REFRESH_ICON, - - /* End of list */ - LAST_DEFAULT_PIXMAP }; typedef struct _MaskedPixmap MaskedPixmap; +extern MaskedPixmap *im_error; +extern MaskedPixmap *im_unknown; +extern MaskedPixmap *im_symlink; + +extern MaskedPixmap *im_unmounted; +extern MaskedPixmap *im_mounted; +extern MaskedPixmap *im_multiple; +extern MaskedPixmap *im_exec_file; +extern MaskedPixmap *im_appdir; + +extern MaskedPixmap *im_up_icon; +extern MaskedPixmap *im_home_icon; +extern MaskedPixmap *im_refresh_icon; +extern MaskedPixmap *im_help; + #ifdef HAVE_IMLIB # ifdef PIXMAPS_C # define IMLIB_T GdkImlibImage @@ -70,8 +77,6 @@ struct _MaskedPixmap int sm_height; }; -extern MaskedPixmap *default_pixmap[LAST_DEFAULT_PIXMAP]; - void pixmaps_init(void); 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 00c13349..b7e5ed0c 100644 --- a/ROX-Filer/src/type.c +++ b/ROX-Filer/src/type.c @@ -285,7 +285,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, im_unknown); now = time(NULL); /* Already got an image? */ @@ -317,7 +317,7 @@ MaskedPixmap *type_to_icon(MIME_type *type) if (!type->image) { - type->image = default_pixmap[TYPE_UNKNOWN]; + type->image = im_unknown; pixmap_ref(type->image); } -- 2.11.4.GIT