mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-09-20 01:06:15 +02:00
Forgotten commit
svn path=/trunk/; revision=7300
This commit is contained in:
parent
1a9db68e53
commit
001bb527b6
@ -1,3 +1,9 @@
|
|||||||
|
2008-08-04 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* gio/gio.types:
|
||||||
|
* gio/gio-docs.xml:
|
||||||
|
* gio/gio-sections.txt: Add Gemblem
|
||||||
|
|
||||||
2008-08-04 Matthias Clasen <mclasen@redhat.com>
|
2008-08-04 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* === Released 2.17.5 ===
|
* === Released 2.17.5 ===
|
||||||
|
@ -84,6 +84,7 @@
|
|||||||
<xi:include href="xml/gloadableicon.xml"/>
|
<xi:include href="xml/gloadableicon.xml"/>
|
||||||
<xi:include href="xml/gthemedicon.xml"/>
|
<xi:include href="xml/gthemedicon.xml"/>
|
||||||
<xi:include href="xml/gemblemedicon.xml"/>
|
<xi:include href="xml/gemblemedicon.xml"/>
|
||||||
|
<xi:include href="xml/gemblem.xml"/>
|
||||||
</chapter>
|
</chapter>
|
||||||
<chapter id="utils">
|
<chapter id="utils">
|
||||||
<title>Utilities</title>
|
<title>Utilities</title>
|
||||||
|
@ -436,6 +436,18 @@ G_TYPE_EMBLEMED_ICON
|
|||||||
g_emblemed_icon_get_type
|
g_emblemed_icon_get_type
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gemblem</FILE>
|
||||||
|
<TITE>GEmblem</TITLE>
|
||||||
|
GEmblem
|
||||||
|
g_emblem_new
|
||||||
|
g_emblem_new_with_origin
|
||||||
|
g_emblem_get_icon
|
||||||
|
g_emblem_get_origin
|
||||||
|
<SUBSECTION Private>
|
||||||
|
g_emblem_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
<SECTION>
|
<SECTION>
|
||||||
<FILE>ginputstream</FILE>
|
<FILE>ginputstream</FILE>
|
||||||
<TITLE>GInputStream</TITLE>
|
<TITLE>GInputStream</TITLE>
|
||||||
|
@ -13,6 +13,8 @@ g_data_stream_newline_type_get_type
|
|||||||
g_desktop_app_info_get_type
|
g_desktop_app_info_get_type
|
||||||
g_desktop_app_info_lookup_get_type
|
g_desktop_app_info_lookup_get_type
|
||||||
g_drive_get_type
|
g_drive_get_type
|
||||||
|
g_emblemed_icon_get_type
|
||||||
|
g_emblem_get_type
|
||||||
g_file_attribute_info_flags_get_type
|
g_file_attribute_info_flags_get_type
|
||||||
g_file_attribute_status_get_type
|
g_file_attribute_status_get_type
|
||||||
g_file_attribute_type_get_type
|
g_file_attribute_type_get_type
|
||||||
|
@ -174,6 +174,8 @@ libgio_2_0_la_SOURCES = \
|
|||||||
gdrive.c \
|
gdrive.c \
|
||||||
gdummyfile.h \
|
gdummyfile.h \
|
||||||
gdummyfile.c \
|
gdummyfile.c \
|
||||||
|
gemblem.h \
|
||||||
|
gemblem.c \
|
||||||
gemblemedicon.h \
|
gemblemedicon.h \
|
||||||
gemblemedicon.c \
|
gemblemedicon.c \
|
||||||
gfile.c \
|
gfile.c \
|
||||||
@ -277,6 +279,7 @@ gio_headers = \
|
|||||||
gdatainputstream.h \
|
gdatainputstream.h \
|
||||||
gdataoutputstream.h \
|
gdataoutputstream.h \
|
||||||
gdrive.h \
|
gdrive.h \
|
||||||
|
gemblem.h \
|
||||||
gemblemedicon.h \
|
gemblemedicon.h \
|
||||||
gfile.h \
|
gfile.h \
|
||||||
gfileattribute.h \
|
gfileattribute.h \
|
||||||
|
284
gio/gemblem.c
Normal file
284
gio/gemblem.c
Normal file
@ -0,0 +1,284 @@
|
|||||||
|
/* GIO - GLib Input, Output and Streaming Library
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Clemens N. Buss <cebuzz@gmail.com>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General
|
||||||
|
* Public License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include "gemblem.h"
|
||||||
|
#include "glibintl.h"
|
||||||
|
#include "gioenums.h"
|
||||||
|
#include "gioenumtypes.h"
|
||||||
|
|
||||||
|
#include "gioalias.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:gemblem
|
||||||
|
* @short_description: An object for emblems
|
||||||
|
* @include: gio/gio.h
|
||||||
|
* @see_also: #GIcon, #GEmblemedIcon, #GLoadableIcon, #GThemedIcon
|
||||||
|
*
|
||||||
|
* #GEmblem is an implementation of #GIcon that supports
|
||||||
|
* having an emblem, which is an icon with additional properties.
|
||||||
|
* It can than be added to a #GEmblemedIcon.
|
||||||
|
*
|
||||||
|
* Currently, only metainformation about the emblem's origin is
|
||||||
|
* supported. More may be added in the future.
|
||||||
|
**/
|
||||||
|
|
||||||
|
static void g_emblem_iface_init (GIconIface *iface);
|
||||||
|
|
||||||
|
struct _GEmblem
|
||||||
|
{
|
||||||
|
GObject parent_instance;
|
||||||
|
|
||||||
|
GIcon *icon;
|
||||||
|
GEmblemOrigin origin;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GEmblemClass
|
||||||
|
{
|
||||||
|
GObjectClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0_GEMBLEM,
|
||||||
|
PROP_ICON,
|
||||||
|
PROP_ORIGIN
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_WITH_CODE (GEmblem, g_emblem, G_TYPE_OBJECT,
|
||||||
|
G_IMPLEMENT_INTERFACE (G_TYPE_ICON, g_emblem_iface_init))
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_emblem_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GEmblem *emblem = G_EMBLEM (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_ICON:
|
||||||
|
g_value_set_object (value, emblem->icon);
|
||||||
|
|
||||||
|
case PROP_ORIGIN:
|
||||||
|
g_value_set_enum (value, emblem->origin);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_emblem_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GEmblem *emblem = G_EMBLEM (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_ICON:
|
||||||
|
emblem->icon = g_value_get_object (value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_ORIGIN:
|
||||||
|
emblem->origin = g_value_get_enum (value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_emblem_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
GEmblem *emblem = G_EMBLEM (object);
|
||||||
|
|
||||||
|
g_object_unref (emblem->icon);
|
||||||
|
|
||||||
|
(*G_OBJECT_CLASS (g_emblem_parent_class)->finalize) (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_emblem_class_init (GEmblemClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
gobject_class->finalize = g_emblem_finalize;
|
||||||
|
gobject_class->set_property = g_emblem_set_property;
|
||||||
|
gobject_class->get_property = g_emblem_get_property;
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_ORIGIN,
|
||||||
|
g_param_spec_enum ("origin",
|
||||||
|
P_("GEmblem's origin"),
|
||||||
|
P_("Tells which origin the emblem is derived from"),
|
||||||
|
G_TYPE_EMBLEM_ORIGIN,
|
||||||
|
G_EMBLEM_ORIGIN_UNKNOWN,
|
||||||
|
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB | G_PARAM_STATIC_NICK));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_ICON,
|
||||||
|
g_param_spec_object ("icon",
|
||||||
|
P_("The icon of the emblem"),
|
||||||
|
P_("The actual icon of the emblem"),
|
||||||
|
G_TYPE_OBJECT,
|
||||||
|
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB | G_PARAM_STATIC_NICK));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_emblem_init (GEmblem *emblem)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_emblem_new:
|
||||||
|
* @icon: a GIcon containing the icon.
|
||||||
|
*
|
||||||
|
* Creates a new emblem for @icon.
|
||||||
|
*
|
||||||
|
* Returns: a new #GEmblem.
|
||||||
|
*
|
||||||
|
* Since: 2.18
|
||||||
|
**/
|
||||||
|
GEmblem *
|
||||||
|
g_emblem_new (GIcon *icon)
|
||||||
|
{
|
||||||
|
GEmblem* emblem;
|
||||||
|
|
||||||
|
g_return_val_if_fail (icon != NULL, NULL);
|
||||||
|
g_return_val_if_fail (G_IS_ICON (icon), NULL);
|
||||||
|
g_return_val_if_fail (!G_IS_EMBLEM (icon), NULL);
|
||||||
|
|
||||||
|
emblem = g_object_new (G_TYPE_EMBLEM, NULL);
|
||||||
|
emblem->icon = g_object_ref (icon);
|
||||||
|
emblem->origin = G_EMBLEM_ORIGIN_UNKNOWN;
|
||||||
|
|
||||||
|
return emblem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_emblem_new_with_origin:
|
||||||
|
* @icon: a GIcon containing the icon.
|
||||||
|
* @origin: a GEmblemOrigin enum defining the emblem's origin
|
||||||
|
*
|
||||||
|
* Creates a new emblem for @icon.
|
||||||
|
*
|
||||||
|
* Returns: a new #GEmblem.
|
||||||
|
*
|
||||||
|
* Since: 2.18
|
||||||
|
**/
|
||||||
|
GEmblem *
|
||||||
|
g_emblem_new_with_origin (GIcon *icon,
|
||||||
|
GEmblemOrigin origin)
|
||||||
|
{
|
||||||
|
GEmblem* emblem;
|
||||||
|
|
||||||
|
g_return_val_if_fail (icon != NULL, NULL);
|
||||||
|
g_return_val_if_fail (G_IS_ICON (icon), NULL);
|
||||||
|
g_return_val_if_fail (!G_IS_EMBLEM (icon), NULL);
|
||||||
|
|
||||||
|
emblem = g_object_new (G_TYPE_EMBLEM, NULL);
|
||||||
|
emblem->icon = g_object_ref (icon);
|
||||||
|
emblem->origin = origin;
|
||||||
|
|
||||||
|
return emblem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_emblem_get_icon:
|
||||||
|
* @emblem: a #GEmblem from which the icon should be extracted.
|
||||||
|
*
|
||||||
|
* Gives back the icon from @emblem.
|
||||||
|
*
|
||||||
|
* Returns: a #GIcon. The returned object belongs to the emblem
|
||||||
|
* and should not be modified or freed.
|
||||||
|
*
|
||||||
|
* Since: 2.18
|
||||||
|
**/
|
||||||
|
GIcon *
|
||||||
|
g_emblem_get_icon (GEmblem *emblem)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (G_IS_EMBLEM (emblem), NULL);
|
||||||
|
|
||||||
|
return emblem->icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_emblem_get_origin:
|
||||||
|
* @emblem: a #GEmblem
|
||||||
|
*
|
||||||
|
* Gets the origin of the emblem.
|
||||||
|
*
|
||||||
|
* Returns: the origin of the emblem
|
||||||
|
*
|
||||||
|
* Since: 2.18
|
||||||
|
**/
|
||||||
|
GEmblemOrigin
|
||||||
|
g_emblem_get_origin (GEmblem *emblem)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (G_IS_EMBLEM (emblem), G_EMBLEM_ORIGIN_UNKNOWN);
|
||||||
|
|
||||||
|
return emblem->origin;
|
||||||
|
}
|
||||||
|
|
||||||
|
static guint
|
||||||
|
g_emblem_hash (GIcon *icon)
|
||||||
|
{
|
||||||
|
GEmblem *emblem = G_EMBLEM (icon);
|
||||||
|
guint hash;
|
||||||
|
|
||||||
|
hash = g_icon_hash (g_emblem_get_icon (emblem));
|
||||||
|
hash ^= emblem->origin;
|
||||||
|
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
g_emblem_equal (GIcon *icon1,
|
||||||
|
GIcon *icon2)
|
||||||
|
{
|
||||||
|
GEmblem *emblem1 = G_EMBLEM (icon1);
|
||||||
|
GEmblem *emblem2 = G_EMBLEM (icon2);
|
||||||
|
|
||||||
|
return emblem1->origin == emblem2->origin &&
|
||||||
|
g_icon_equal (emblem1->icon, emblem2->icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_emblem_iface_init (GIconIface *iface)
|
||||||
|
{
|
||||||
|
iface->hash = g_emblem_hash;
|
||||||
|
iface->equal = g_emblem_equal;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define __G_EMBLEM_C__
|
||||||
|
#include "gioaliasdef.c"
|
60
gio/gemblem.h
Normal file
60
gio/gemblem.h
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/* GIO - GLib Input, Output and Streaming Library
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Clemens N. Buss <cebuzz@gmail.com>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General
|
||||||
|
* Public License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
|
||||||
|
#error "Only <gio/gio.h> can be included directly."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __G_EMBLEM_H__
|
||||||
|
#define __G_EMBLEM_H__
|
||||||
|
|
||||||
|
#include <gio/gicon.h>
|
||||||
|
#include <gio/gioenums.h>
|
||||||
|
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define G_TYPE_EMBLEM (g_emblem_get_type ())
|
||||||
|
#define G_EMBLEM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_EMBLEM, GEmblem))
|
||||||
|
#define G_EMBLEM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_EMBLEM, GEmblemClass))
|
||||||
|
#define G_IS_EMBLEM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_EMBLEM))
|
||||||
|
#define G_IS_EMBLEM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_EMBLEM))
|
||||||
|
#define G_EMBLEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_EMBLEM, GEmblemClass))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GEmblem:
|
||||||
|
*
|
||||||
|
* An object for Emblems
|
||||||
|
*/
|
||||||
|
typedef struct _GEmblem GEmblem;
|
||||||
|
typedef struct _GEmblemClass GEmblemClass;
|
||||||
|
|
||||||
|
GType g_emblem_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
GEmblem *g_emblem_new (GIcon *icon);
|
||||||
|
GEmblem *g_emblem_new_with_origin (GIcon *icon,
|
||||||
|
GEmblemOrigin origin);
|
||||||
|
GIcon *g_emblem_get_icon (GEmblem *emblem);
|
||||||
|
GEmblemOrigin g_emblem_get_origin (GEmblem *emblem);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __G_EMBLEM_H__ */
|
@ -20,6 +20,7 @@
|
|||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
* Author: Matthias Clasen <mclasen@redhat.com>
|
* Author: Matthias Clasen <mclasen@redhat.com>
|
||||||
|
* Clemens N. Buss <cebuzz@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
@ -35,14 +36,14 @@
|
|||||||
* SECTION:gemblemedicon
|
* SECTION:gemblemedicon
|
||||||
* @short_description: Icon with emblems
|
* @short_description: Icon with emblems
|
||||||
* @include: gio/gio.h
|
* @include: gio/gio.h
|
||||||
* @see_also: #GIcon, #GLoadableIcon, #GThemedIcon
|
* @see_also: #GIcon, #GLoadableIcon, #GThemedIcon, #GEmblem
|
||||||
*
|
*
|
||||||
* #GEmblemedIcon is an implementation of #GIcon that supports
|
* #GEmblemedIcon is an implementation of #GIcon that supports
|
||||||
* adding an emblem to an icon. To add multiple emblems to an
|
* adding an emblem to an icon. Adding multiple emblems to an
|
||||||
* icon, you can create nested #GemblemedIcon<!-- -->s.
|
* icon is ensured via g_emblemed_icon_add_emblem().
|
||||||
*
|
*
|
||||||
* Note that #GEmblemedIcon allows no control over the position
|
* Note that #GEmblemedIcon allows no control over the position
|
||||||
* of the emblems. It is up to the rendering code to pick a position.
|
* of the emblems. See also #GEmblem for more information.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
static void g_emblemed_icon_icon_iface_init (GIconIface *iface);
|
static void g_emblemed_icon_icon_iface_init (GIconIface *iface);
|
||||||
@ -52,7 +53,7 @@ struct _GEmblemedIcon
|
|||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
|
|
||||||
GIcon *icon;
|
GIcon *icon;
|
||||||
GIcon *emblem;
|
GList *emblems;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GEmblemedIconClass
|
struct _GEmblemedIconClass
|
||||||
@ -61,8 +62,8 @@ struct _GEmblemedIconClass
|
|||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE (GEmblemedIcon, g_emblemed_icon, G_TYPE_OBJECT,
|
G_DEFINE_TYPE_WITH_CODE (GEmblemedIcon, g_emblemed_icon, G_TYPE_OBJECT,
|
||||||
G_IMPLEMENT_INTERFACE (G_TYPE_ICON,
|
G_IMPLEMENT_INTERFACE (G_TYPE_ICON,
|
||||||
g_emblemed_icon_icon_iface_init))
|
g_emblemed_icon_icon_iface_init))
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -73,7 +74,7 @@ g_emblemed_icon_finalize (GObject *object)
|
|||||||
emblemed = G_EMBLEMED_ICON (object);
|
emblemed = G_EMBLEMED_ICON (object);
|
||||||
|
|
||||||
g_object_unref (emblemed->icon);
|
g_object_unref (emblemed->icon);
|
||||||
g_object_unref (emblemed->emblem);
|
g_list_foreach (emblemed->emblems, (GFunc) g_object_unref, NULL);
|
||||||
|
|
||||||
(*G_OBJECT_CLASS (g_emblemed_icon_parent_class)->finalize) (object);
|
(*G_OBJECT_CLASS (g_emblemed_icon_parent_class)->finalize) (object);
|
||||||
}
|
}
|
||||||
@ -92,88 +93,150 @@ g_emblemed_icon_init (GEmblemedIcon *emblemed)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* g_emblemed_icon_new:
|
* g_emblemed_icon_new:
|
||||||
* @icon: a #GIcon.
|
* @icon: a #GIcon
|
||||||
* @emblem: a #GIcon
|
* @emblem: a #GEmblem
|
||||||
*
|
*
|
||||||
* Creates a new emblemed icon for @icon with emblem @emblem.
|
* Creates a new emblemed icon for @icon with the emblem @emblem.
|
||||||
*
|
*
|
||||||
* Returns: a new #GEmblemedIcon.
|
* Returns: a new #GIcon
|
||||||
*
|
*
|
||||||
* Since: 2.18
|
* Since: 2.18
|
||||||
**/
|
**/
|
||||||
GIcon *
|
GIcon *
|
||||||
g_emblemed_icon_new (GIcon *icon,
|
g_emblemed_icon_new (GIcon *icon,
|
||||||
GIcon *emblem)
|
GEmblem *emblem)
|
||||||
{
|
{
|
||||||
GEmblemedIcon *emblemed;
|
GEmblemedIcon *emblemed;
|
||||||
|
|
||||||
g_return_val_if_fail (icon != NULL, NULL);
|
g_return_val_if_fail (G_IS_ICON (icon), NULL);
|
||||||
g_return_val_if_fail (emblem != NULL, NULL);
|
g_return_val_if_fail (!G_IS_EMBLEM (icon), NULL);
|
||||||
|
g_return_val_if_fail (G_IS_EMBLEM (emblem), NULL);
|
||||||
|
|
||||||
emblemed = G_EMBLEMED_ICON (g_object_new (G_TYPE_EMBLEMED_ICON, NULL));
|
emblemed = G_EMBLEMED_ICON (g_object_new (G_TYPE_EMBLEMED_ICON, NULL));
|
||||||
emblemed->icon = g_object_ref (icon);
|
emblemed->icon = g_object_ref (icon);
|
||||||
emblemed->emblem = g_object_ref (emblem);
|
|
||||||
|
g_emblemed_icon_add_emblem (emblemed, emblem);
|
||||||
|
|
||||||
return G_ICON (emblemed);
|
return G_ICON (emblemed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_emblemed_icon_get_icon:
|
* g_emblemed_icon_get_icon:
|
||||||
* @icon: a #GEmblemedIcon.
|
* @emblemed: a #GEmblemedIcon
|
||||||
*
|
*
|
||||||
* Gets the main icon for @icon.
|
* Gets the main icon for @emblemed.
|
||||||
*
|
*
|
||||||
* Returns: a #GIcon that is owend by @icon
|
* Returns: a #GIcon that is owned by @emblemed
|
||||||
*
|
*
|
||||||
* Since: 2.18
|
* Since: 2.18
|
||||||
**/
|
**/
|
||||||
GIcon *
|
GIcon *
|
||||||
g_emblemed_icon_get_icon (GEmblemedIcon *icon)
|
g_emblemed_icon_get_icon (GEmblemedIcon *emblemed)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (G_IS_EMBLEMED_ICON (icon), NULL);
|
g_return_val_if_fail (G_IS_EMBLEMED_ICON (emblemed), NULL);
|
||||||
|
|
||||||
return icon->icon;
|
return emblemed->icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_emblemed_icon_get_emblem:
|
* g_emblemed_icon_get_emblems:
|
||||||
* @icon: a #GEmblemedIcon.
|
* @emblemed: a #GEmblemedIcon
|
||||||
*
|
*
|
||||||
* Gets the emblem for @icon.
|
* Gets the list of emblems for the @icon.
|
||||||
*
|
*
|
||||||
* Returns: a #GIcon that is owned by @icon
|
* Returns: a #GList of #GEmblem <!-- -->s that is owned by @emblemed
|
||||||
*
|
*
|
||||||
* Since: 2.18
|
* Since: 2.18
|
||||||
**/
|
**/
|
||||||
GIcon *
|
|
||||||
g_emblemed_icon_get_emblem (GEmblemedIcon *icon)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (G_IS_EMBLEMED_ICON (icon), NULL);
|
|
||||||
|
|
||||||
return icon->emblem;
|
GList *
|
||||||
|
g_emblemed_icon_get_emblems (GEmblemedIcon *emblemed)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (G_IS_EMBLEMED_ICON (emblemed), NULL);
|
||||||
|
|
||||||
|
return emblemed->emblems;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_emblemed_icon_add_emblem:
|
||||||
|
* @emblemed: a #GEmblemedIcon
|
||||||
|
* @emblem: a #GEmblem
|
||||||
|
*
|
||||||
|
* Adds @emblem to the #GList of #GEmblem <!-- -->s.
|
||||||
|
*
|
||||||
|
* Returns: a #GList of #GEmblem <!-- -->s that is owned by @emblemed
|
||||||
|
*
|
||||||
|
* Since: 2.18
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
g_emblemed_icon_add_emblem (GEmblemedIcon *emblemed,
|
||||||
|
GEmblem *emblem)
|
||||||
|
{
|
||||||
|
g_return_if_fail (G_IS_EMBLEMED_ICON (emblemed));
|
||||||
|
g_return_if_fail (G_IS_EMBLEM (emblem));
|
||||||
|
|
||||||
|
g_object_ref (emblem);
|
||||||
|
emblemed->emblems = g_list_append (emblemed->emblems, emblem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
g_emblemed_icon_hash (GIcon *icon)
|
g_emblemed_icon_hash (GIcon *icon)
|
||||||
{
|
{
|
||||||
GEmblemedIcon *emblemed = G_EMBLEMED_ICON (icon);
|
GEmblemedIcon *emblemed = G_EMBLEMED_ICON (icon);
|
||||||
guint hash;
|
GList *list;
|
||||||
|
guint hash = g_icon_hash (emblemed->icon);
|
||||||
|
|
||||||
hash = g_icon_hash (emblemed->icon);
|
for (list = emblemed->emblems; list != NULL; list = list->next)
|
||||||
hash ^= g_icon_hash (emblemed->emblem);
|
hash ^= g_icon_hash (G_ICON (list->data));
|
||||||
|
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
g_emblem_comp (GEmblem *a,
|
||||||
|
GEmblem *b)
|
||||||
|
{
|
||||||
|
guint hash_a = g_icon_hash (G_ICON (a));
|
||||||
|
guint hash_b = g_icon_hash (G_ICON (b));
|
||||||
|
|
||||||
|
if(hash_a < hash_b)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if(hash_a == hash_b)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
g_emblemed_icon_equal (GIcon *icon1,
|
g_emblemed_icon_equal (GIcon *icon1,
|
||||||
GIcon *icon2)
|
GIcon *icon2)
|
||||||
{
|
{
|
||||||
GEmblemedIcon *emblemed1 = G_EMBLEMED_ICON (icon1);
|
GEmblemedIcon *emblemed1 = G_EMBLEMED_ICON (icon1);
|
||||||
GEmblemedIcon *emblemed2 = G_EMBLEMED_ICON (icon2);
|
GEmblemedIcon *emblemed2 = G_EMBLEMED_ICON (icon2);
|
||||||
|
GList *list1, *list2;
|
||||||
|
|
||||||
return g_icon_equal (emblemed1->icon, emblemed2->icon) &&
|
if (!g_icon_equal (emblemed1->icon, emblemed2->icon))
|
||||||
g_icon_equal (emblemed1->emblem, emblemed2->emblem);
|
return FALSE;
|
||||||
|
|
||||||
|
list1 = emblemed1->emblems;
|
||||||
|
list2 = emblemed2->emblems;
|
||||||
|
|
||||||
|
list1 = g_list_sort (list1, (GCompareFunc) g_emblem_comp);
|
||||||
|
list2 = g_list_sort (list2, (GCompareFunc) g_emblem_comp);
|
||||||
|
|
||||||
|
while (list1 && list2)
|
||||||
|
{
|
||||||
|
if (!g_icon_equal (G_ICON (list1->data), G_ICON (list2->data)))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
list1 = list1->next;
|
||||||
|
list2 = list2->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return list1 == NULL && list2 == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
* Author: Matthias Clasen <mclasen@redhat.com>
|
* Author: Matthias Clasen <mclasen@redhat.com>
|
||||||
|
* Clemens N. Buss <cebuzz@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
|
#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
|
||||||
@ -29,6 +30,8 @@
|
|||||||
|
|
||||||
#include <gio/gicon.h>
|
#include <gio/gicon.h>
|
||||||
|
|
||||||
|
#include "gemblem.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define G_TYPE_EMBLEMED_ICON (g_emblemed_icon_get_type ())
|
#define G_TYPE_EMBLEMED_ICON (g_emblemed_icon_get_type ())
|
||||||
@ -46,12 +49,14 @@ G_BEGIN_DECLS
|
|||||||
typedef struct _GEmblemedIcon GEmblemedIcon;
|
typedef struct _GEmblemedIcon GEmblemedIcon;
|
||||||
typedef struct _GEmblemedIconClass GEmblemedIconClass;
|
typedef struct _GEmblemedIconClass GEmblemedIconClass;
|
||||||
|
|
||||||
GType g_emblemed_icon_get_type (void) G_GNUC_CONST;
|
GType g_emblemed_icon_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
GIcon *g_emblemed_icon_new (GIcon *icon,
|
GIcon *g_emblemed_icon_new (GIcon *icon,
|
||||||
GIcon *emblem);
|
GEmblem *emblem);
|
||||||
GIcon *g_emblemed_icon_get_icon (GEmblemedIcon *icon);
|
GIcon *g_emblemed_icon_get_icon (GEmblemedIcon *emblemed);
|
||||||
GIcon *g_emblemed_icon_get_emblem (GEmblemedIcon *icon);
|
GList *g_emblemed_icon_get_emblems (GEmblemedIcon *emblemed);
|
||||||
|
void g_emblemed_icon_add_emblem (GEmblemedIcon *emblemed,
|
||||||
|
GEmblem *emblem);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
#include <gio/gfilteroutputstream.h>
|
#include <gio/gfilteroutputstream.h>
|
||||||
#include <gio/gicon.h>
|
#include <gio/gicon.h>
|
||||||
#include <gio/ginputstream.h>
|
#include <gio/ginputstream.h>
|
||||||
|
#include <gio/gioenums.h>
|
||||||
#include <gio/gioenumtypes.h>
|
#include <gio/gioenumtypes.h>
|
||||||
#include <gio/gioerror.h>
|
#include <gio/gioerror.h>
|
||||||
#include <gio/giomodule.h>
|
#include <gio/giomodule.h>
|
||||||
|
@ -802,6 +802,7 @@ g_mount_operation_result_get_type G_GNUC_CONST
|
|||||||
g_output_stream_splice_flags_get_type G_GNUC_CONST
|
g_output_stream_splice_flags_get_type G_GNUC_CONST
|
||||||
g_ask_password_flags_get_type G_GNUC_CONST
|
g_ask_password_flags_get_type G_GNUC_CONST
|
||||||
g_password_save_get_type G_GNUC_CONST
|
g_password_save_get_type G_GNUC_CONST
|
||||||
|
g_emblem_origin_get_type G_GNUC_CONST
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -811,6 +812,18 @@ g_password_save_get_type G_GNUC_CONST
|
|||||||
g_emblemed_icon_get_type G_GNUC_CONST
|
g_emblemed_icon_get_type G_GNUC_CONST
|
||||||
g_emblemed_icon_new
|
g_emblemed_icon_new
|
||||||
g_emblemed_icon_get_icon
|
g_emblemed_icon_get_icon
|
||||||
g_emblemed_icon_get_emblem
|
g_emblemed_icon_get_emblems
|
||||||
|
g_emblemed_icon_add_emblem
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if IN_HEADER(__G_EMBLEM_H__)
|
||||||
|
#if IN_FILE(__G_EMBLEM_C__)
|
||||||
|
g_emblem_get_type G_GNUC_CONST
|
||||||
|
g_emblem_new
|
||||||
|
g_emblem_new_with_origin
|
||||||
|
g_emblem_get_icon
|
||||||
|
g_emblem_get_origin
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@ -441,6 +441,25 @@ typedef enum {
|
|||||||
} GOutputStreamSpliceFlags;
|
} GOutputStreamSpliceFlags;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GEmblemOrigin:
|
||||||
|
* @G_EMBLEM_ORIGIN_UNKNOWN: Emblem of unknown origin
|
||||||
|
* @G_EMBLEM_ORIGIN_DEVICE: Embleme adds device-specific information
|
||||||
|
* @G_EMBLEM_ORIGIN_LIVEMETADATA: Emblem depicts live metadata, such as "readonly"
|
||||||
|
* @G_EMBLEM_ORIGIN_TAG: Emblem comes from a user-defined tag, e.g. set by nautilus (in the future)
|
||||||
|
*
|
||||||
|
* GEmblemOrigin is used to add information about the origin of the emblem
|
||||||
|
* to #GEmblem.
|
||||||
|
*
|
||||||
|
* Since: 2.18
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
G_EMBLEM_ORIGIN_UNKNOWN,
|
||||||
|
G_EMBLEM_ORIGIN_DEVICE,
|
||||||
|
G_EMBLEM_ORIGIN_LIVEMETADATA,
|
||||||
|
G_EMBLEM_ORIGIN_TAG
|
||||||
|
} GEmblemOrigin;
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user