X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=cut-n-paste%2Frecent-files%2Fegg-recent-util.c;h=4597f03c2d7aa280910143036289e6841f73c190;hb=07ae50430dd7dda3d9304f3836d2a58f011b9d4d;hp=cb30e053fb1554450576cea155b38afbb9635f9e;hpb=69d92c409d333e5dd9cc82537c0834b201487c60;p=evince.git diff --git a/cut-n-paste/recent-files/egg-recent-util.c b/cut-n-paste/recent-files/egg-recent-util.c index cb30e053..4597f03c 100644 --- a/cut-n-paste/recent-files/egg-recent-util.c +++ b/cut-n-paste/recent-files/egg-recent-util.c @@ -2,16 +2,19 @@ #include #include #include -#include -#include -#include #ifndef USE_STABLE_LIBGNOMEUI -#include #include #endif +#include +#include +#include #include #include "egg-recent-util.h" +#ifdef G_OS_WIN32 +#include +#endif + #define EGG_RECENT_UTIL_HOSTNAME_SIZE 512 /* ripped out of gedit2 */ @@ -53,92 +56,26 @@ egg_recent_util_escape_underlines (const gchar* text) return g_string_free (str, FALSE); } -#ifndef USE_STABLE_LIBGNOMEUI -static GdkPixbuf * -scale_icon (GdkPixbuf *pixbuf, - double *scale) -{ - guint width, height; - - width = gdk_pixbuf_get_width (pixbuf); - height = gdk_pixbuf_get_height (pixbuf); - - width = floor (width * *scale + 0.5); - height = floor (height * *scale + 0.5); - - return gdk_pixbuf_scale_simple (pixbuf, width, height, GDK_INTERP_BILINEAR); -} - -static GdkPixbuf * -load_icon_file (char *filename, - guint base_size, - guint nominal_size) -{ - GdkPixbuf *pixbuf, *scaled_pixbuf; - guint width, height, size; - double scale; - - pixbuf = gdk_pixbuf_new_from_file (filename, NULL); - - if (pixbuf == NULL) { - return NULL; - } - - if (base_size == 0) { - width = gdk_pixbuf_get_width (pixbuf); - height = gdk_pixbuf_get_height (pixbuf); - size = MAX (width, height); - if (size > nominal_size) { - base_size = size; - } else { - /* Don't scale up small icons */ - base_size = nominal_size; - } - } - - if (base_size != nominal_size) { - scale = (double)nominal_size/base_size; - scaled_pixbuf = scale_icon (pixbuf, &scale); - g_object_unref (pixbuf); - pixbuf = scaled_pixbuf; - } - - return pixbuf; -} - GdkPixbuf * -egg_recent_util_get_icon (GnomeIconTheme *theme, const gchar *uri, +egg_recent_util_get_icon (GtkIconTheme *theme, const gchar *uri, const gchar *mime_type, int size) { +#ifndef USE_STABLE_LIBGNOMEUI gchar *icon; - gchar *filename; - const GnomeIconData *icon_data; - int base_size; GdkPixbuf *pixbuf; icon = gnome_icon_lookup (theme, NULL, uri, NULL, NULL, mime_type, 0, NULL); - g_return_val_if_fail (icon != NULL, NULL); - filename = gnome_icon_theme_lookup_icon (theme, icon, - size, - &icon_data, - &base_size); + pixbuf = gtk_icon_theme_load_icon (theme, icon, size, 0, NULL); g_free (icon); - if (filename == NULL) { - return NULL; - } - - pixbuf = load_icon_file (filename, base_size, size); - g_free (filename); - - return pixbuf; +#endif + return NULL; } -#endif /* !USE_STABLE_LIBGNOMEUI */ gchar * egg_recent_util_get_unique_id (void) @@ -148,7 +85,14 @@ egg_recent_util_get_unique_id (void) guint32 rand; int pid; +#ifndef G_OS_WIN32 gethostname (hostname, EGG_RECENT_UTIL_HOSTNAME_SIZE); +#else + { + DWORD size = EGG_RECENT_UTIL_HOSTNAME_SIZE; + GetComputerName (hostname, &size); + } +#endif time (&the_time); rand = g_random_int ();