Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Commit

Permalink
Add g_themed_icon_new_with_default_fallbacks
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alexlarsson authored and Alexander Larsson committed Jan 9, 2008
1 parent e00f20f commit 47b8809
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 5 deletions.
9 changes: 9 additions & 0 deletions gio/ChangeLog
@@ -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:
Expand Down
7 changes: 4 additions & 3 deletions gio/gio.symbols
Expand Up @@ -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

Expand Down
37 changes: 37 additions & 0 deletions gio/gthemedicon.c
Expand Up @@ -22,6 +22,8 @@

#include <config.h>

#include <string.h>

#include "gthemedicon.h"

#include "gioalias.h"
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions gio/gthemedicon.h
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions gio/gunixmounts.c
Expand Up @@ -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));
}

/**
Expand Down Expand Up @@ -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));
}

/**
Expand Down

0 comments on commit 47b8809

Please sign in to comment.