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
scale_icon (GdkPixbuf *pixbuf,
63
width = gdk_pixbuf_get_width (pixbuf);
64
height = gdk_pixbuf_get_height (pixbuf);
66
width = floor (width * *scale + 0.5);
67
height = floor (height * *scale + 0.5);
69
return gdk_pixbuf_scale_simple (pixbuf, width, height, GDK_INTERP_BILINEAR);
73
load_icon_file (char *filename,
77
GdkPixbuf *pixbuf, *scaled_pixbuf;
78
guint width, height, size;
81
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
88
width = gdk_pixbuf_get_width (pixbuf);
89
height = gdk_pixbuf_get_height (pixbuf);
90
size = MAX (width, height);
91
if (size > nominal_size) {
94
/* Don't scale up small icons */
95
base_size = nominal_size;
99
if (base_size != nominal_size) {
100
scale = (double)nominal_size/base_size;
101
scaled_pixbuf = scale_icon (pixbuf, &scale);
102
g_object_unref (pixbuf);
103
pixbuf = scaled_pixbuf;
110
egg_recent_util_get_icon (GnomeIconTheme *theme, const gchar *uri,
111
const gchar *mime_type, int size)
115
const GnomeIconData *icon_data;
119
icon = gnome_icon_lookup (theme, NULL, uri, NULL, NULL,
123
g_return_val_if_fail (icon != NULL, NULL);
125
filename = gnome_icon_theme_lookup_icon (theme, icon,
131
if (filename == NULL) {
135
pixbuf = load_icon_file (filename, base_size, size);
141
#endif /* !USE_STABLE_LIBGNOMEUI */
144
egg_recent_util_get_unique_id (void)
146
char hostname[EGG_RECENT_UTIL_HOSTNAME_SIZE];
151
gethostname (hostname, EGG_RECENT_UTIL_HOSTNAME_SIZE);
154
rand = g_random_int ();
157
return g_strdup_printf ("%s-%d-%d-%d", hostname, (int)time, (int)rand, (int)pid);