Add g_themed_icon_new_with_default_fallbacks

2008-01-09  Alexander Larsson  <alexl@redhat.com>

        * gio.symbols:
        * gthemedicon.[ch]:
        Add g_themed_icon_new_with_default_fallbacks
	
        * gunixmounts.c:
	Use default fallbacks for icons



svn path=/trunk/; revision=6284
This commit is contained in:
Alexander Larsson 2008-01-09 15:20:49 +00:00 committed by Alexander Larsson
parent e00f20fae7
commit 47b8809e17
5 changed files with 53 additions and 5 deletions

View File

@ -1,3 +1,12 @@
2008-01-09 Alexander Larsson <alexl@redhat.com>
* gio.symbols:
* gthemedicon.[ch]:
Add g_themed_icon_new_with_default_fallbacks
* gunixmounts.c:
Use default fallbacks for icons
2008-01-09 Alexander Larsson <alexl@redhat.com>
* gio-marshal.list:

View File

@ -609,9 +609,10 @@ g_simple_async_report_gerror_in_idle
#if IN_HEADER(__G_THEMED_ICON_H__)
#if IN_FILE(__G_THEMED_ICON_C__)
g_themed_icon_get_type G_GNUC_CONST
g_themed_icon_new
g_themed_icon_new_from_names
g_themed_icon_get_names
g_themed_icon_new
g_themed_icon_new_with_default_fallbacks
g_themed_icon_new_from_names
g_themed_icon_get_names
#endif
#endif

View File

@ -22,6 +22,8 @@
#include <config.h>
#include <string.h>
#include "gthemedicon.h"
#include "gioalias.h"
@ -141,6 +143,41 @@ g_themed_icon_new_from_names (char **iconnames,
return G_ICON (themed);
}
GIcon *
g_themed_icon_new_with_default_fallbacks (const char *iconname)
{
GThemedIcon *themed;
int i, dashes;
const char *p;
char *dashp;
char *last;
g_return_val_if_fail (iconname != NULL, NULL);
themed = g_object_new (G_TYPE_THEMED_ICON, NULL);
dashes = 0;
p = iconname;
while (*p)
{
if (*p == '-')
dashes++;
p++;
}
themed->names = g_new (char *, dashes + 1 + 1);
i = 0;
themed->names[i++] = last = g_strdup (iconname);
while ((dashp = strrchr (last, '-')) != NULL)
themed->names[i++] = last = g_strndup (last, dashp - last);
themed->names[i++] = NULL;
return G_ICON (themed);
}
/**
* g_themed_icon_get_names:
* @icon: a #GThemedIcon.

View File

@ -49,6 +49,7 @@ typedef struct _GThemedIconClass GThemedIconClass;
GType g_themed_icon_get_type (void) G_GNUC_CONST;
GIcon *g_themed_icon_new (const char *iconname);
GIcon *g_themed_icon_new_with_default_fallbacks (const char *iconname);
GIcon *g_themed_icon_new_from_names (char **iconnames, int len);
const char * const *g_themed_icon_get_names (GThemedIcon *icon);

View File

@ -1769,7 +1769,7 @@ g_unix_mount_guess_name (GUnixMountEntry *mount_entry)
GIcon *
g_unix_mount_guess_icon (GUnixMountEntry *mount_entry)
{
return g_themed_icon_new (type_to_icon (g_unix_mount_guess_type (mount_entry), FALSE));
return g_themed_icon_new_with_default_fallbacks (type_to_icon (g_unix_mount_guess_type (mount_entry), FALSE));
}
/**
@ -1806,7 +1806,7 @@ g_unix_mount_point_guess_name (GUnixMountPoint *mount_point)
GIcon *
g_unix_mount_point_guess_icon (GUnixMountPoint *mount_point)
{
return g_themed_icon_new (type_to_icon (g_unix_mount_point_guess_type (mount_point), TRUE));
return g_themed_icon_new_with_default_fallbacks (type_to_icon (g_unix_mount_point_guess_type (mount_point), TRUE));
}
/**