From 9040c932b3a261afba98a362e57a3b0304f53339 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 20 Jan 2002 16:42:29 +0000 Subject: [PATCH] r1107: Added a configure check for iconv.h. Use double instead of long for file sizes in find.c (Bernard Jungen). --- ROX-Filer/src/config.h.in | 1 + ROX-Filer/src/configure.in | 2 +- ROX-Filer/src/dnd.c | 9 ++++++++- ROX-Filer/src/find.c | 22 +++++++++++----------- ROX-Filer/src/gconvert.c | 24 ++++++++++++++---------- ROX-Filer/src/main.c | 11 +++++++++++ ROX-Filer/src/pinboard.c | 7 +++++-- ROX-Filer/src/pixmaps.c | 8 +++++--- 8 files changed, 56 insertions(+), 28 deletions(-) diff --git a/ROX-Filer/src/config.h.in b/ROX-Filer/src/config.h.in index 81f4167e..df4505fa 100644 --- a/ROX-Filer/src/config.h.in +++ b/ROX-Filer/src/config.h.in @@ -13,6 +13,7 @@ #undef FILE_B_FLAG #undef HAVE_LIBVFS #undef HAVE_VFS_H +#undef HAVE_ICONV_H #undef HAVE_LIBPNG #undef GTK2 diff --git a/ROX-Filer/src/configure.in b/ROX-Filer/src/configure.in index cd61020b..8fd29c8f 100644 --- a/ROX-Filer/src/configure.in +++ b/ROX-Filer/src/configure.in @@ -163,7 +163,7 @@ AC_HEADER_DIRENT AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h mntent.h sys/ucred.h sys/mntent.h) -AC_CHECK_HEADERS(regex.h) +AC_CHECK_HEADERS(regex.h iconv.h) rox_ARG_WITH(vfs, [ --with-vfs[=prefix] use libvfs for virtual file system [search it in prefix/include and prefix/lib]]) diff --git a/ROX-Filer/src/dnd.c b/ROX-Filer/src/dnd.c index b09ddc46..5005db35 100644 --- a/ROX-Filer/src/dnd.c +++ b/ROX-Filer/src/dnd.c @@ -927,6 +927,14 @@ static void got_data_raw(GtkWidget *widget, dest_path = g_dataset_get_data(context, "drop_dest_path"); + if (context->action == GDK_ACTION_ASK) + { + gtk_drag_finish(context, FALSE, FALSE, time); /* Failure */ + delayed_error(_("Sorry, can't display a menu of actions " + "for a remote file / raw data.")); + return; + } + if (g_dataset_get_data(context, "drop_dest_type") == drop_dest_prog) { /* The data needs to be sent to an application */ @@ -1004,7 +1012,6 @@ static void got_uri_list(GtkWidget *widget, /* There is one URI in the list, and it's not on the local * machine. Get it via the X server if possible. */ - /* XXX: Action ask? */ if (provides(context, application_octet_stream)) { diff --git a/ROX-Filer/src/find.c b/ROX-Filer/src/find.c index 3dadee3f..c0a41c7d 100644 --- a/ROX-Filer/src/find.c +++ b/ROX-Filer/src/find.c @@ -102,7 +102,7 @@ enum FLAG_HENCE = 1 << 1, }; -typedef long (*EvalCalc)(Eval *eval, FindInfo *info); +typedef double (*EvalCalc)(Eval *eval, FindInfo *info); typedef void (*EvalFree)(Eval *eval); struct _FindCondition @@ -112,7 +112,7 @@ struct _FindCondition /* These next three depend on the first two... */ gpointer data1; gpointer data2; - gint value; + double value; }; struct _Eval @@ -367,7 +367,7 @@ static gboolean test_comp(FindCondition *condition, FindInfo *info) { Eval *first = (Eval *) condition->data1; Eval *second = (Eval *) condition->data2; - long a, b; + double a, b; a = first->calc(first, info); b = second->calc(second, info); @@ -831,9 +831,9 @@ out: /* CALCULATIONS */ -static long get_constant(Eval *eval, FindInfo *info) +static double get_constant(Eval *eval, FindInfo *info) { - long value = *((long *) (eval->data1)); + double value = *((double *) (eval->data1)); gint flags = GPOINTER_TO_INT(eval->data2); if (flags & FLAG_AGO) @@ -844,7 +844,7 @@ static long get_constant(Eval *eval, FindInfo *info) return value; } -static long get_var(Eval *eval, FindInfo *info) +static double get_var(Eval *eval, FindInfo *info) { switch ((VarType) eval->data1) { @@ -868,7 +868,7 @@ static long get_var(Eval *eval, FindInfo *info) return info->stats.st_blocks; } - return 0L; + return 0; } /* FREEING */ @@ -888,7 +888,7 @@ static void free_constant(Eval *eval) static Eval *parse_eval(guchar **expression) { char *start, *end; - long value; + double value; Eval *eval; gint flags = 0; @@ -914,11 +914,11 @@ static Eval *parse_eval(guchar **expression) if (MATCH(_("Byte")) || MATCH(_("Bytes"))) ; else if (MATCH("Kb")) - value <<= 10; + value *= 1<<10; else if (MATCH("Mb")) - value <<= 20; + value *= 1<<20; else if (MATCH("Gb")) - value <<= 30; + value *= 1<<30; else if (MATCH(_("Sec")) || MATCH(_("Secs"))) ; else if (MATCH(_("Min")) || MATCH(_("Mins"))) diff --git a/ROX-Filer/src/gconvert.c b/ROX-Filer/src/gconvert.c index 2978ae39..db97104b 100644 --- a/ROX-Filer/src/gconvert.c +++ b/ROX-Filer/src/gconvert.c @@ -32,7 +32,11 @@ #ifndef GTK2 #include "gunicode.h" -#include + +#ifdef HAVE_ICONV_H +# include +#endif + #include #include #include @@ -85,14 +89,7 @@ g_get_charset (const char **charset) /* unicode_strchr */ - -#if defined(USE_LIBICONV) && !defined (_LIBICONV_H) -#error libiconv in use but included iconv.h not from libiconv -#endif -#if !defined(USE_LIBICONV) && defined (_LIBICONV_H) -#error libiconv not in use but included iconv.h is from libiconv -#endif - +#ifdef HAVE_ICONV_H size_t g_iconv (GIConv converter, gchar **inbuf, @@ -134,6 +131,7 @@ open_converter (const gchar *to_codeset, return cd; } +#endif gchar* g_convert (const gchar *str, @@ -145,12 +143,13 @@ g_convert (const gchar *str, GError **error) { gchar *res; +#ifdef HAVE_ICONV_H GIConv cd; g_return_val_if_fail (str != NULL, NULL); g_return_val_if_fail (to_codeset != NULL, NULL); g_return_val_if_fail (from_codeset != NULL, NULL); - + cd = open_converter (to_codeset, from_codeset, error); if (cd == (GIConv) -1) @@ -169,10 +168,14 @@ g_convert (const gchar *str, error); g_iconv_close (cd); +#else + res = g_strdup(str); +#endif return res; } +#ifdef HAVE_ICONV_H gchar* g_convert_with_iconv (const gchar *str, gssize len, @@ -264,6 +267,7 @@ g_convert_with_iconv (const gchar *str, else return dest; } +#endif gchar * g_locale_to_utf8 (const gchar *opsysstring, diff --git a/ROX-Filer/src/main.c b/ROX-Filer/src/main.c index e1f4d962..61b760a9 100644 --- a/ROX-Filer/src/main.c +++ b/ROX-Filer/src/main.c @@ -586,6 +586,17 @@ static void show_features(void) _("No (needs libpng or Gtk+-2.0)") #endif ); + g_printerr("%s... %s\n", _("Character set translations"), +#ifdef GTK2 + _("Yes (using Gtk+-2.0)") +#else +# ifdef HAVE_ICONV_H + _("Yes (using libiconv)") +# else + _("No (needs libiconv or Gtk+-2.0)") +# endif +#endif + ); } static void soap_add(xmlNodePtr body, diff --git a/ROX-Filer/src/pinboard.c b/ROX-Filer/src/pinboard.c index 7c8ed9f7..8f1c39b8 100644 --- a/ROX-Filer/src/pinboard.c +++ b/ROX-Filer/src/pinboard.c @@ -1546,10 +1546,13 @@ static gboolean bg_drag_motion(GtkWidget *widget, if (!provides(context, text_uri_list)) return FALSE; - + pinboard_set_shadow(TRUE); - gdk_drag_status(context, context->suggested_action, time); + gdk_drag_status(context, + context->suggested_action == GDK_ACTION_ASK + ? GDK_ACTION_LINK : context->suggested_action, + time); return TRUE; } diff --git a/ROX-Filer/src/pixmaps.c b/ROX-Filer/src/pixmaps.c index 456505eb..ef45b561 100644 --- a/ROX-Filer/src/pixmaps.c +++ b/ROX-Filer/src/pixmaps.c @@ -636,6 +636,7 @@ static void save_thumbnail(char *path, GdkPixbuf *full, MaskedPixmap *image) GString *to; char *md5, *swidth, *sheight, *ssize, *smtime, *uri; mode_t old_mask; + int name_len; /* If the source image was very small, don't bother saving */ if (gdk_pixbuf_get_width(full) * gdk_pixbuf_get_height(full) < @@ -664,7 +665,8 @@ static void save_thumbnail(char *path, GdkPixbuf *full, MaskedPixmap *image) g_string_append(to, "/96x96/"); mkdir(to->str, 0700); g_string_append(to, md5); - g_string_append(to, ".png.new"); + name_len = to->len + 4; /* Truncate to this length when renaming */ + g_string_sprintfa(to, ".png.ROX-Filer-%ld", (long) getpid()); g_free(md5); @@ -694,14 +696,14 @@ static void save_thumbnail(char *path, GdkPixbuf *full, MaskedPixmap *image) #endif umask(old_mask); - /* We create the file ###.png.new and rename it to avoid + /* We create the file ###.png.ROX-Filer-PID and rename it to avoid * a race condition if two program create the same thumb at * once. */ { gchar *final; - final = g_strndup(to->str, to->len - 4); + final = g_strndup(to->str, name_len); if (rename(to->str, final)) g_warning("Failed to rename '%s' to '%s': %s", to->str, final, g_strerror(errno)); -- 2.11.4.GIT