From: Jim Evins Date: Sat, 7 Aug 2004 22:37:04 +0000 (+0000) Subject: 2004-08-07 Jim Evins X-Git-Tag: glabels-2_3_0~459 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d4ecd627e9dbeb831a9751c67d3e4bd983f73ccd;p=glabels 2004-08-07 Jim Evins * src/recent-files/*: Re-synced to latest libegg/recent-files. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@438 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index ce2592e2..62118535 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,8 @@ +2004-08-07 Jim Evins + + * src/recent-files/*: + Re-synced to latest libegg/recent-files. + 2004-08-07 Jim Evins * Makefile.am: diff --git a/glabels2/src/recent-files/Makefile.am b/glabels2/src/recent-files/Makefile.am index 5d4b02a7..fc33632b 100644 --- a/glabels2/src/recent-files/Makefile.am +++ b/glabels2/src/recent-files/Makefile.am @@ -3,26 +3,21 @@ INCLUDES = \ EGG_FILES = \ - egg-recent-model.c \ + egg-recent.h \ egg-recent-item.c \ - egg-recent-view.c \ - egg-recent-view-bonobo.c \ - egg-recent-view-gtk.c \ - egg-recent-vfs-utils.c \ - egg-recent-util.c \ - egg-recent-model.h \ egg-recent-item.h \ - egg-recent-view.h \ + egg-recent-model.c \ + egg-recent-model.h \ + egg-recent-util.c \ + egg-recent-util.h \ + egg-recent-view-bonobo.c \ egg-recent-view-bonobo.h \ - egg-recent-view-gtk.h \ - egg-recent-vfs-utils.h \ - egg-recent-util.h + egg-recent-view.c \ + egg-recent-view.h \ + egg-recent-view-gtk.c \ + egg-recent-view-gtk.h noinst_LTLIBRARIES = librecent.la librecent_la_SOURCES = $(EGG_FILES) -EGGDIR=$(srcdir)/../../../libegg/libegg/recent-files -regenerate-built-sources: - EGGFILES="$(EGG_FILES)" EGGDIR="$(EGGDIR)" $(srcdir)/update-from-egg.sh - diff --git a/glabels2/src/recent-files/egg-recent-item.c b/glabels2/src/recent-files/egg-recent-item.c index 139b637e..e61c1f81 100644 --- a/glabels2/src/recent-files/egg-recent-item.c +++ b/glabels2/src/recent-files/egg-recent-item.c @@ -36,7 +36,7 @@ egg_recent_item_new (void) item = g_new (EggRecentItem, 1); item->groups = NULL; - item->private = FALSE; + item->private_data = FALSE; item->uri = NULL; item->mime_type = NULL; @@ -133,7 +133,7 @@ egg_recent_item_copy (const EggRecentItem *item) if (item->mime_type) newitem->mime_type = g_strdup (item->mime_type); newitem->timestamp = item->timestamp; - newitem->private = item->private; + newitem->private_data = item->private_data; newitem->groups = egg_recent_item_copy_groups (item->groups); return newitem; @@ -238,6 +238,98 @@ egg_recent_item_get_uri_for_display (const EggRecentItem *item) return gnome_vfs_format_uri_for_display (item->uri); } +/* Stolen from gnome_vfs_make_valid_utf8() */ +static char * +make_valid_utf8 (const char *name) +{ + GString *string; + const char *remainder, *invalid; + int remaining_bytes, valid_bytes; + + string = NULL; + remainder = name; + remaining_bytes = strlen (name); + + while (remaining_bytes != 0) { + if (g_utf8_validate (remainder, remaining_bytes, &invalid)) + break; + + valid_bytes = invalid - remainder; + + if (string == NULL) + string = g_string_sized_new (remaining_bytes); + + g_string_append_len (string, remainder, valid_bytes); + g_string_append_c (string, '?'); + + remaining_bytes -= valid_bytes + 1; + remainder = invalid + 1; + } + + if (string == NULL) + return g_strdup (name); + + g_string_append (string, remainder); +/* g_string_append (string, _(" (invalid file name)")); */ + g_assert (g_utf8_validate (string->str, -1, NULL)); + + return g_string_free (string, FALSE); +} + +/** + * egg_recent_item_get_short_name: + * @item: an #EggRecentItem + * + * Computes a valid UTF-8 string that can be used as the name of the item in a + * menu or list. For example, calling this function on an item that refers to + * "file:///foo/bar.txt" will yield "bar.txt". + * + * Return value: A newly-allocated string in UTF-8 encoding; free it with + * g_free(). + **/ +gchar * +egg_recent_item_get_short_name (const EggRecentItem *item) +{ + GnomeVFSURI *uri; + char *short_name; + gboolean valid; + + g_return_val_if_fail (item != NULL, NULL); + + if (item->uri == NULL) + return NULL; + + uri = gnome_vfs_uri_new (item->uri); + g_assert (uri != NULL); /* We already checked this in egg_recent_item_set_uri() */ + + short_name = gnome_vfs_uri_extract_short_name (uri); + valid = FALSE; + + if (strcmp (gnome_vfs_uri_get_scheme (uri), "file") == 0) { + char *tmp; + + tmp = g_filename_to_utf8 (short_name, -1, NULL, NULL, NULL); + if (tmp) { + g_free (short_name); + short_name = tmp; + valid = TRUE; + } + } + + if (!valid) { + char *tmp; + + tmp = make_valid_utf8 (short_name); + g_assert (tmp != NULL); + g_free (short_name); + short_name = tmp; + } + + g_free (uri); + + return short_name; +} + void egg_recent_item_set_mime_type (EggRecentItem *item, const gchar *mime) { @@ -323,13 +415,13 @@ egg_recent_item_remove_group (EggRecentItem *item, const gchar *group_name) void egg_recent_item_set_private (EggRecentItem *item, gboolean priv) { - item->private = priv; + item->private_data = priv; } gboolean egg_recent_item_get_private (const EggRecentItem *item) { - return item->private; + return item->private_data; } GType diff --git a/glabels2/src/recent-files/egg-recent-item.h b/glabels2/src/recent-files/egg-recent-item.h index 556c31e2..5b3b405c 100644 --- a/glabels2/src/recent-files/egg-recent-item.h +++ b/glabels2/src/recent-files/egg-recent-item.h @@ -22,7 +22,7 @@ struct _EggRecentItem { gchar *mime_type; time_t timestamp; - gboolean private; + gboolean private_data; GList *groups; @@ -44,6 +44,7 @@ gboolean egg_recent_item_set_uri (EggRecentItem *item, const gchar *uri); gchar * egg_recent_item_get_uri (const EggRecentItem *item); gchar * egg_recent_item_get_uri_utf8 (const EggRecentItem *item); gchar * egg_recent_item_get_uri_for_display (const EggRecentItem *item); +gchar * egg_recent_item_get_short_name (const EggRecentItem *item); void egg_recent_item_set_mime_type (EggRecentItem *item, const gchar *mime); gchar * egg_recent_item_get_mime_type (const EggRecentItem *item); diff --git a/glabels2/src/recent-files/egg-recent-model.c b/glabels2/src/recent-files/egg-recent-model.c index cc82e9b9..d5079492 100644 --- a/glabels2/src/recent-files/egg-recent-model.c +++ b/glabels2/src/recent-files/egg-recent-model.c @@ -875,11 +875,34 @@ static gboolean egg_recent_model_lock_file (FILE *file) { int fd; + gint try = 5; rewind (file); fd = fileno (file); - return lockf (fd, F_LOCK, 0) == 0 ? TRUE : FALSE; + /* Attempt to lock the file 5 times, + * waiting a random interval (< 1 second) + * in between attempts. + * We should really be doing asynchronous + * locking, but requires substantially larger + * changes. + */ + + while (try > 0) + { + int rand_interval; + + if (lockf (fd, F_TLOCK, 0) == 0) + return TRUE; + + rand_interval = 1 + (int) (10.0 * rand()/(RAND_MAX + 1.0)); + + g_usleep (100000 * rand_interval); + + --try; + } + + return FALSE; } static gboolean @@ -890,7 +913,7 @@ egg_recent_model_unlock_file (FILE *file) rewind (file); fd = fileno (file); - return lockf (fd, F_ULOCK, 0) < 0 ? FALSE : TRUE; + return (lockf (fd, F_ULOCK, 0) == 0) ? TRUE : FALSE; } static void diff --git a/glabels2/src/recent-files/egg-recent-util.c b/glabels2/src/recent-files/egg-recent-util.c index 91c0c686..cb30e053 100644 --- a/glabels2/src/recent-files/egg-recent-util.c +++ b/glabels2/src/recent-files/egg-recent-util.c @@ -29,30 +29,31 @@ egg_recent_util_escape_underlines (const gchar* text) str = g_string_new (""); - p = text; - end = text + length; + p = text; + end = text + length; - while (p != end) - { - const gchar *next; - next = g_utf8_next_char (p); + while (p != end) + { + const gchar *next; + next = g_utf8_next_char (p); switch (*p) - { - case '_': - g_string_append (str, "__"); - break; - default: - g_string_append_len (str, p, next - p); - break; - } - - p = next; - } + { + case '_': + g_string_append (str, "__"); + break; + default: + g_string_append_len (str, p, next - p); + break; + } + + p = next; + } return g_string_free (str, FALSE); } +#ifndef USE_STABLE_LIBGNOMEUI static GdkPixbuf * scale_icon (GdkPixbuf *pixbuf, double *scale) @@ -105,7 +106,6 @@ load_icon_file (char *filename, return pixbuf; } -#ifndef USE_STABLE_LIBGNOMEUI GdkPixbuf * egg_recent_util_get_icon (GnomeIconTheme *theme, const gchar *uri, const gchar *mime_type, int size) @@ -128,6 +128,10 @@ egg_recent_util_get_icon (GnomeIconTheme *theme, const gchar *uri, &base_size); g_free (icon); + if (filename == NULL) { + return NULL; + } + pixbuf = load_icon_file (filename, base_size, size); g_free (filename); diff --git a/glabels2/src/recent-files/egg-recent-vfs-utils.c b/glabels2/src/recent-files/egg-recent-vfs-utils.c deleted file mode 100644 index 51083dd9..00000000 --- a/glabels2/src/recent-files/egg-recent-vfs-utils.c +++ /dev/null @@ -1,570 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* gnome-vfs-utils.c - Utility gnome-vfs methods. Will use gnome-vfs - HEAD in time. - - Copyright (C) 1999 Free Software Foundation - Copyright (C) 2000, 2001 Eazel, Inc. - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Authors: Ettore Perazzoli - John Sullivan - Darin Adler -*/ - -#include - -#include "egg-recent-vfs-utils.h" - -#include -#include -#include - -#ifdef ENABLE_NLS -#include - -#include -#define _(String) gettext(String) - -#ifdef gettext_noop -#define N_(String) gettext_noop(String) -#else -#define N_(String) (String) -#endif -#else /* NLS is disabled */ -#define _(String) (String) -#define N_(String) (String) -#define textdomain(String) (String) -#define gettext(String) (String) -#define dgettext(Domain,String) (String) -#define dcgettext(Domain,String,Type) (String) -#define bindtextdomain(Domain,Directory) (Domain) -#endif - -static char * -make_valid_utf8 (const char *name) -{ - GString *string; - const char *remainder, *invalid; - int remaining_bytes, valid_bytes; - - string = NULL; - remainder = name; - remaining_bytes = strlen (name); - - while (remaining_bytes != 0) { - if (g_utf8_validate (remainder, remaining_bytes, &invalid)) { - break; - } - valid_bytes = invalid - remainder; - - if (string == NULL) { - string = g_string_sized_new (remaining_bytes); - } - g_string_append_len (string, remainder, valid_bytes); - g_string_append_c (string, '?'); - - remaining_bytes -= valid_bytes + 1; - remainder = invalid + 1; - } - - if (string == NULL) { - return g_strdup (name); - } - - g_string_append (string, remainder); - g_string_append (string, _(" (invalid Unicode)")); - g_assert (g_utf8_validate (string->str, -1, NULL)); - - return g_string_free (string, FALSE); -} - -static gboolean -istr_has_prefix (const char *haystack, const char *needle) -{ - const char *h, *n; - char hc, nc; - - /* Eat one character at a time. */ - h = haystack == NULL ? "" : haystack; - n = needle == NULL ? "" : needle; - do { - if (*n == '\0') { - return TRUE; - } - if (*h == '\0') { - return FALSE; - } - hc = *h++; - nc = *n++; - hc = g_ascii_tolower (hc); - nc = g_ascii_tolower (nc); - } while (hc == nc); - return FALSE; -} - -static gboolean -str_has_prefix (const char *haystack, const char *needle) -{ - const char *h, *n; - - /* Eat one character at a time. */ - h = haystack == NULL ? "" : haystack; - n = needle == NULL ? "" : needle; - do { - if (*n == '\0') { - return TRUE; - } - if (*h == '\0') { - return FALSE; - } - } while (*h++ == *n++); - return FALSE; -} - -static gboolean -uri_is_local_scheme (const char *uri) -{ - gboolean is_local_scheme; - char *temp_scheme; - int i; - char *local_schemes[] = {"file:", "help:", "ghelp:", "gnome-help:", - "trash:", "man:", "info:", - "hardware:", "search:", "pipe:", - "gnome-trash:", NULL}; - - is_local_scheme = FALSE; - for (temp_scheme = *local_schemes, i = 0; temp_scheme != NULL; i++, temp_scheme = local_schemes[i]) { - is_local_scheme = istr_has_prefix (uri, temp_scheme); - if (is_local_scheme) { - break; - } - } - - return is_local_scheme; -} - -static char * -handle_trailing_slashes (const char *uri) -{ - char *temp, *uri_copy; - gboolean previous_char_is_column, previous_chars_are_slashes_without_column; - gboolean previous_chars_are_slashes_with_column; - gboolean is_local_scheme; - - g_assert (uri != NULL); - - uri_copy = g_strdup (uri); - if (strlen (uri_copy) <= 2) { - return uri_copy; - } - - is_local_scheme = uri_is_local_scheme (uri); - - previous_char_is_column = FALSE; - previous_chars_are_slashes_without_column = FALSE; - previous_chars_are_slashes_with_column = FALSE; - - /* remove multiple trailing slashes */ - for (temp = uri_copy; *temp != '\0'; temp++) { - if (*temp == '/' && !previous_char_is_column) { - previous_chars_are_slashes_without_column = TRUE; - } else if (*temp == '/' && previous_char_is_column) { - previous_chars_are_slashes_without_column = FALSE; - previous_char_is_column = TRUE; - previous_chars_are_slashes_with_column = TRUE; - } else { - previous_chars_are_slashes_without_column = FALSE; - previous_char_is_column = FALSE; - previous_chars_are_slashes_with_column = FALSE; - } - - if (*temp == ':') { - previous_char_is_column = TRUE; - } - } - - if (*temp == '\0' && previous_chars_are_slashes_without_column) { - if (is_local_scheme) { - /* go back till you remove them all. */ - for (temp--; *(temp) == '/'; temp--) { - *temp = '\0'; - } - } else { - /* go back till you remove them all but one. */ - for (temp--; *(temp - 1) == '/'; temp--) { - *temp = '\0'; - } - } - } - - if (*temp == '\0' && previous_chars_are_slashes_with_column) { - /* go back till you remove them all but three. */ - for (temp--; *(temp - 3) != ':' && *(temp - 2) != ':' && *(temp - 1) != ':'; temp--) { - *temp = '\0'; - } - } - - - return uri_copy; -} - -static char * -make_uri_canonical (const char *uri) -{ - char *canonical_uri, *old_uri, *p; - gboolean relative_uri; - - relative_uri = FALSE; - - if (uri == NULL) { - return NULL; - } - - /* FIXME bugzilla.eazel.com 648: - * This currently ignores the issue of two uris that are not identical but point - * to the same data except for the specific cases of trailing '/' characters, - * file:/ and file:///, and "lack of file:". - */ - - canonical_uri = handle_trailing_slashes (uri); - - /* Note: In some cases, a trailing slash means nothing, and can - * be considered equivalent to no trailing slash. But this is - * not true in every case; specifically not for web addresses passed - * to a web-browser. So we don't have the trailing-slash-equivalence - * logic here, but we do use that logic in EelDirectory where - * the rules are more strict. - */ - - /* Add file: if there is no scheme. */ - if (strchr (canonical_uri, ':') == NULL) { - old_uri = canonical_uri; - - if (old_uri[0] != '/') { - /* FIXME bugzilla.eazel.com 5069: - * bandaid alert. Is this really the right thing to do? - * - * We got what really is a relative path. We do a little bit of - * a stretch here and assume it was meant to be a cryptic absolute path, - * and convert it to one. Since we can't call gnome_vfs_uri_new and - * gnome_vfs_uri_to_string to do the right make-canonical conversion, - * we have to do it ourselves. - */ - relative_uri = TRUE; - canonical_uri = gnome_vfs_make_path_name_canonical (old_uri); - g_free (old_uri); - old_uri = canonical_uri; - canonical_uri = g_strconcat ("file:///", old_uri, NULL); - } else { - canonical_uri = g_strconcat ("file:", old_uri, NULL); - } - g_free (old_uri); - } - - /* Lower-case the scheme. */ - for (p = canonical_uri; *p != ':'; p++) { - g_assert (*p != '\0'); - *p = g_ascii_tolower (*p); - } - - if (!relative_uri) { - old_uri = canonical_uri; - canonical_uri = gnome_vfs_make_uri_canonical (canonical_uri); - if (canonical_uri != NULL) { - g_free (old_uri); - } else { - canonical_uri = old_uri; - } - } - - /* FIXME bugzilla.eazel.com 2802: - * Work around gnome-vfs's desire to convert file:foo into file://foo - * by converting to file:///foo here. When you remove this, check that - * typing "foo" into location bar does not crash and returns an error - * rather than displaying the contents of / - */ - if (str_has_prefix (canonical_uri, "file://") - && !str_has_prefix (canonical_uri, "file:///")) { - old_uri = canonical_uri; - canonical_uri = g_strconcat ("file:/", old_uri + 5, NULL); - g_free (old_uri); - } - - return canonical_uri; -} - -static char * -format_uri_for_display (const char *uri, gboolean filenames_are_locale_encoded) -{ - char *canonical_uri, *path, *utf8_path; - - g_return_val_if_fail (uri != NULL, g_strdup ("")); - - canonical_uri = make_uri_canonical (uri); - - /* If there's no fragment and it's a local path. */ - path = gnome_vfs_get_local_path_from_uri (canonical_uri); - - if (path != NULL) { - if (filenames_are_locale_encoded) { - utf8_path = g_locale_to_utf8 (path, -1, NULL, NULL, NULL); - if (utf8_path) { - g_free (canonical_uri); - g_free (path); - return utf8_path; - } - } else if (g_utf8_validate (path, -1, NULL)) { - g_free (canonical_uri); - return path; - } - } - - if (canonical_uri && !g_utf8_validate (canonical_uri, -1, NULL)) { - utf8_path = make_valid_utf8 (canonical_uri); - g_free (canonical_uri); - canonical_uri = utf8_path; - } - - g_free (path); - return canonical_uri; -} - -char * -egg_recent_vfs_format_uri_for_display (const char *uri) -{ - static gboolean broken_filenames; - - broken_filenames = g_getenv ("G_BROKEN_FILENAMES") != NULL; - - return format_uri_for_display (uri, broken_filenames); -} - -static gboolean -is_valid_scheme_character (char c) -{ - return g_ascii_isalnum (c) || c == '+' || c == '-' || c == '.'; -} - -static gboolean -has_valid_scheme (const char *uri) -{ - const char *p; - - p = uri; - - if (!is_valid_scheme_character (*p)) { - return FALSE; - } - - do { - p++; - } while (is_valid_scheme_character (*p)); - - return *p == ':'; -} - -static char * -escape_high_chars (const guchar *string) -{ - char *result; - const guchar *scanner; - guchar *result_scanner; - int escape_count; - static const gchar hex[16] = "0123456789ABCDEF"; - -#define ACCEPTABLE(a) ((a)>=32 && (a)<128) - - escape_count = 0; - - if (string == NULL) { - return NULL; - } - - for (scanner = string; *scanner != '\0'; scanner++) { - if (!ACCEPTABLE(*scanner)) { - escape_count++; - } - } - - if (escape_count == 0) { - return g_strdup (string); - } - - /* allocate two extra characters for every character that - * needs escaping and space for a trailing zero - */ - result = g_malloc (scanner - string + escape_count * 2 + 1); - for (scanner = string, result_scanner = result; *scanner != '\0'; scanner++) { - if (!ACCEPTABLE(*scanner)) { - *result_scanner++ = '%'; - *result_scanner++ = hex[*scanner >> 4]; - *result_scanner++ = hex[*scanner & 15]; - - } else { - *result_scanner++ = *scanner; - } - } - - *result_scanner = '\0'; - - return result; -} - -static char * -make_uri_from_input_internal (const char *text, - gboolean filenames_are_locale_encoded, - gboolean strip_trailing_whitespace) -{ - char *stripped, *path, *uri, *locale_path, *filesystem_path, *escaped; - - g_return_val_if_fail (text != NULL, g_strdup ("")); - - /* Strip off leading whitespaces (since they can't be part of a valid - uri). Only strip off trailing whitespaces when requested since - they might be part of a valid uri. - */ - if (strip_trailing_whitespace) { - stripped = g_strstrip (g_strdup (text)); - } else { - stripped = g_strchug (g_strdup (text)); - } - - switch (stripped[0]) { - case '\0': - uri = g_strdup (""); - break; - case '/': - if (filenames_are_locale_encoded) { - GError *error = NULL; - locale_path = g_locale_from_utf8 (stripped, -1, NULL, NULL, &error); - if (locale_path != NULL) { - uri = gnome_vfs_get_uri_from_local_path (locale_path); - g_free (locale_path); - } else { - /* We couldn't convert to the locale. */ - /* FIXME: We should probably give a user-visible error here. */ - uri = g_strdup(""); - } - } else { - uri = gnome_vfs_get_uri_from_local_path (stripped); - } - break; - case '~': - if (filenames_are_locale_encoded) { - filesystem_path = g_locale_from_utf8 (stripped, -1, NULL, NULL, NULL); - } else { - filesystem_path = g_strdup (stripped); - } - /* deliberately falling into default case on fail */ - if (filesystem_path != NULL) { - path = gnome_vfs_expand_initial_tilde (filesystem_path); - g_free (filesystem_path); - if (*path == '/') { - uri = gnome_vfs_get_uri_from_local_path (path); - g_free (path); - break; - } - g_free (path); - } - /* don't insert break here, read above comment */ - default: - if (has_valid_scheme (stripped)) { - uri = escape_high_chars (stripped); - } else { - escaped = escape_high_chars (stripped); - uri = g_strconcat ("http://", escaped, NULL); - g_free (escaped); - } - } - - g_free (stripped); - - return uri; - -} - -char * -egg_recent_vfs_make_uri_from_input (const char *uri) -{ - static gboolean broken_filenames; - - broken_filenames = g_getenv ("G_BROKEN_FILENAMES") != NULL; - - return make_uri_from_input_internal (uri, broken_filenames, TRUE); -} - -static char * -make_uri_canonical_strip_fragment (const char *uri) -{ - const char *fragment; - char *without_fragment, *canonical; - - fragment = strchr (uri, '#'); - if (fragment == NULL) { - return make_uri_canonical (uri); - } - - without_fragment = g_strndup (uri, fragment - uri); - canonical = make_uri_canonical (without_fragment); - g_free (without_fragment); - return canonical; -} - -static gboolean -uris_match (const char *uri_1, const char *uri_2, gboolean ignore_fragments) -{ - char *canonical_1, *canonical_2; - gboolean result; - - if (ignore_fragments) { - canonical_1 = make_uri_canonical_strip_fragment (uri_1); - canonical_2 = make_uri_canonical_strip_fragment (uri_2); - } else { - canonical_1 = make_uri_canonical (uri_1); - canonical_2 = make_uri_canonical (uri_2); - } - - result = strcmp (canonical_1, canonical_2) == 0; - - g_free (canonical_1); - g_free (canonical_2); - - return result; -} - -gboolean -egg_recent_vfs_uris_match (const char *uri_1, const char *uri_2) -{ - return uris_match (uri_1, uri_2, FALSE); -} - -char * -egg_recent_vfs_get_uri_scheme (const char *uri) -{ - char *colon; - - g_return_val_if_fail (uri != NULL, NULL); - - colon = strchr (uri, ':'); - - if (colon == NULL) { - return NULL; - } - - return g_strndup (uri, colon - uri); -} diff --git a/glabels2/src/recent-files/egg-recent-vfs-utils.h b/glabels2/src/recent-files/egg-recent-vfs-utils.h deleted file mode 100644 index 619b25b4..00000000 --- a/glabels2/src/recent-files/egg-recent-vfs-utils.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* gnome-vfs-utils.h - Utility gnome-vfs methods. Will use gnome-vfs - HEAD in time. - - Copyright (C) 1999 Free Software Foundation - Copyright (C) 2000 Eazel, Inc. - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Authors: Ettore Perazzoli - John Sullivan -*/ - -#ifndef EGG_RECENT_VFS_UTILS_H -#define EGG_RECENT_VFS_UTILS_H - -#include - -G_BEGIN_DECLS - -char *egg_recent_vfs_format_uri_for_display (const char *uri); -char *egg_recent_vfs_make_uri_from_input (const char *uri); -gboolean egg_recent_vfs_uris_match (const char *uri_1, - const char *uri_2); -char *egg_recent_vfs_get_uri_scheme (const char *uri); - -G_END_DECLS - -#endif /* GNOME_VFS_UTILS_H */ diff --git a/glabels2/src/recent-files/egg-recent-view-gtk.c b/glabels2/src/recent-files/egg-recent-view-gtk.c index 8fefd326..6e6bac0a 100644 --- a/glabels2/src/recent-files/egg-recent-view-gtk.c +++ b/glabels2/src/recent-files/egg-recent-view-gtk.c @@ -188,10 +188,6 @@ egg_recent_view_gtk_new_menu_item (EggRecentViewGtk *view, { GtkWidget *menu_item; EggRecentViewGtkMenuData *md=(EggRecentViewGtkMenuData *)g_malloc (sizeof (EggRecentViewGtkMenuData)); - gchar *text; - gchar *basename; - gchar *escaped; - gchar *uri; g_return_val_if_fail (view, NULL); @@ -199,15 +195,13 @@ egg_recent_view_gtk_new_menu_item (EggRecentViewGtk *view, gchar *mime_type; GtkWidget *image; GdkPixbuf *pixbuf; + gchar *text; + gchar *short_name; + gchar *escaped; - uri = egg_recent_item_get_uri_for_display (item); - if (uri == NULL) - return NULL; - - basename = g_path_get_basename (uri); - escaped = egg_recent_util_escape_underlines (basename); - g_free (basename); - g_free (uri); + short_name = egg_recent_item_get_short_name (item); + escaped = egg_recent_util_escape_underlines (short_name); + g_free (short_name); if (view->show_numbers) { /* avoid having conflicting mnemonics */ @@ -227,15 +221,18 @@ egg_recent_view_gtk_new_menu_item (EggRecentViewGtk *view, #ifndef USE_STABLE_LIBGNOMEUI { int width, height; + gchar *uri; gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (view->menu), view->icon_size, &width, &height); + uri = egg_recent_item_get_uri (item); pixbuf = egg_recent_util_get_icon (view->theme, uri, mime_type, height); + g_free (uri); } #else pixbuf = NULL; diff --git a/glabels2/src/recent-files/egg-recent-view.h b/glabels2/src/recent-files/egg-recent-view.h index 48f2a19b..79f03469 100644 --- a/glabels2/src/recent-files/egg-recent-view.h +++ b/glabels2/src/recent-files/egg-recent-view.h @@ -7,6 +7,8 @@ #include "egg-recent-model.h" #include "egg-recent-item.h" +G_BEGIN_DECLS + #define EGG_TYPE_RECENT_VIEW (egg_recent_view_get_type ()) #define EGG_RECENT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_RECENT_VIEW, EggRecentView)) #define EGG_RECENT_VIEW_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), EGG_TYPE_RECENT_VIEW, EggRecentViewClass)) @@ -36,5 +38,6 @@ EggRecentModel *egg_recent_view_get_model (EggRecentView *view); void egg_recent_view_set_model (EggRecentView *view, EggRecentModel *model); +G_END_DECLS #endif /* __EGG_RECENT_VIEW_H__ */ diff --git a/glabels2/src/recent-files/egg-recent.h b/glabels2/src/recent-files/egg-recent.h new file mode 100644 index 00000000..686b91c3 --- /dev/null +++ b/glabels2/src/recent-files/egg-recent.h @@ -0,0 +1,5 @@ +#include "egg-recent-item.h" +#include "egg-recent-model.h" +#include "egg-recent-view.h" +#include "egg-recent-view-bonobo.h" +#include "egg-recent-view-gtk.h"