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"
19 #define EGG_RECENT_UTIL_HOSTNAME_SIZE 512
21 /* ripped out of gedit2 */
23 egg_recent_util_escape_underlines (const gchar* text)
30 g_return_val_if_fail (text != NULL, NULL);
32 length = strlen (text);
34 str = g_string_new ("");
42 next = g_utf8_next_char (p);
47 g_string_append (str, "__");
50 g_string_append_len (str, p, next - p);
57 return g_string_free (str, FALSE);
60 #ifndef USE_STABLE_LIBGNOMEUI
62 load_icon_file (char *filename,
65 GdkPixbuf *pixbuf, *scaled_pixbuf;
68 pixbuf = gdk_pixbuf_new_from_file_at_size (filename, nominal_size, nominal_size, NULL);
74 width = gdk_pixbuf_get_width (pixbuf);
75 height = gdk_pixbuf_get_height (pixbuf);
76 /* if the icon is larger than the nominal size, scale down */
77 if (MAX (width, height) > nominal_size) {
79 height = height * nominal_size / width;
82 width = width * nominal_size / height;
83 height = nominal_size;
85 scaled_pixbuf = gdk_pixbuf_scale_simple
86 (pixbuf, width, height, GDK_INTERP_BILINEAR);
87 g_object_unref (pixbuf);
88 pixbuf = scaled_pixbuf;
95 egg_recent_util_get_icon (GnomeIconTheme *theme, const gchar *uri,
96 const gchar *mime_type, int size)
100 const GnomeIconData *icon_data;
103 icon = gnome_icon_lookup (theme, NULL, uri, NULL, NULL,
107 g_return_val_if_fail (icon != NULL, NULL);
109 filename = gnome_icon_theme_lookup_icon (theme, icon,
115 if (filename == NULL) {
119 pixbuf = load_icon_file (filename, size);
125 #endif /* !USE_STABLE_LIBGNOMEUI */
128 egg_recent_util_get_unique_id (void)
130 char hostname[EGG_RECENT_UTIL_HOSTNAME_SIZE];
136 gethostname (hostname, EGG_RECENT_UTIL_HOSTNAME_SIZE);
139 DWORD size = EGG_RECENT_UTIL_HOSTNAME_SIZE;
140 GetComputerName (hostname, &size);
145 rand = g_random_int ();
148 return g_strdup_printf ("%s-%d-%d-%d", hostname, (int)time, (int)rand, (int)pid);