8 #ifndef USE_STABLE_LIBGNOMEUI
9 #include <libgnomeui/gnome-icon-theme.h>
10 #include <libgnomeui/gnome-icon-lookup.h>
13 #include "egg-recent-util.h"
15 #define EGG_RECENT_UTIL_HOSTNAME_SIZE 512
17 /* ripped out of gedit2 */
19 egg_recent_util_escape_underlines (const gchar* text)
26 g_return_val_if_fail (text != NULL, NULL);
28 length = strlen (text);
30 str = g_string_new ("");
38 next = g_utf8_next_char (p);
43 g_string_append (str, "__");
46 g_string_append_len (str, p, next - p);
53 return g_string_free (str, FALSE);
56 #ifndef USE_STABLE_LIBGNOMEUI
58 load_icon_file (char *filename,
61 GdkPixbuf *pixbuf, *scaled_pixbuf;
64 pixbuf = gdk_pixbuf_new_from_file_at_size (filename, nominal_size, nominal_size, NULL);
70 width = gdk_pixbuf_get_width (pixbuf);
71 height = gdk_pixbuf_get_height (pixbuf);
72 /* if the icon is larger than the nominal size, scale down */
73 if (MAX (width, height) > nominal_size) {
75 height = height * nominal_size / width;
78 width = width * nominal_size / height;
79 height = nominal_size;
81 scaled_pixbuf = gdk_pixbuf_scale_simple
82 (pixbuf, width, height, GDK_INTERP_BILINEAR);
83 g_object_unref (pixbuf);
84 pixbuf = scaled_pixbuf;
91 egg_recent_util_get_icon (GnomeIconTheme *theme, const gchar *uri,
92 const gchar *mime_type, int size)
96 const GnomeIconData *icon_data;
99 icon = gnome_icon_lookup (theme, NULL, uri, NULL, NULL,
103 g_return_val_if_fail (icon != NULL, NULL);
105 filename = gnome_icon_theme_lookup_icon (theme, icon,
111 if (filename == NULL) {
115 pixbuf = load_icon_file (filename, size);
121 #endif /* !USE_STABLE_LIBGNOMEUI */
124 egg_recent_util_get_unique_id (void)
126 char hostname[EGG_RECENT_UTIL_HOSTNAME_SIZE];
131 gethostname (hostname, EGG_RECENT_UTIL_HOSTNAME_SIZE);
134 rand = g_random_int ();
137 return g_strdup_printf ("%s-%d-%d-%d", hostname, (int)time, (int)rand, (int)pid);