mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 15:56:23 +01:00
Add a GIcon implementation that can add an emblem to another icon.
2008-07-28 Matthias Clasen <mclasen@redhat.com> * gemblemedicon.[hc]: Add a GIcon implementation that can add an emblem to another icon. * gio.h: * Makefile.am: * gio.symbols: Glue * gloadableicon.c: * gfileicon.c: Small documenatation additions. svn path=/trunk/; revision=7263
This commit is contained in:
parent
6f84cab2a8
commit
a2b61b1e46
@ -1,3 +1,8 @@
|
|||||||
|
2008-07-28 Matthias Clasen <mclasen2redhat.com>
|
||||||
|
|
||||||
|
* gio/gio-sections.txt:
|
||||||
|
* gio/gio-docs.xml: Add GEmblemedIcon
|
||||||
|
|
||||||
2008-07-21 Matthias Clasen <mclasen2redhat.com>
|
2008-07-21 Matthias Clasen <mclasen2redhat.com>
|
||||||
|
|
||||||
* === Released 2.17.4 ===
|
* === Released 2.17.4 ===
|
||||||
|
@ -83,6 +83,7 @@
|
|||||||
<xi:include href="xml/gfileicon.xml"/>
|
<xi:include href="xml/gfileicon.xml"/>
|
||||||
<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"/>
|
||||||
</chapter>
|
</chapter>
|
||||||
<chapter id="utils">
|
<chapter id="utils">
|
||||||
<title>Utilities</title>
|
<title>Utilities</title>
|
||||||
|
@ -416,6 +416,17 @@ G_FILE_ICON_GET_CLASS
|
|||||||
g_file_icon_get_type
|
g_file_icon_get_type
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gemblemedicon</FILE>
|
||||||
|
<TITLE>GEmblemedIcon</TITLE>
|
||||||
|
GEmblemedIcon
|
||||||
|
g_emblemed_icon_new
|
||||||
|
g_emblemed_icon_get_icon
|
||||||
|
g_emblemed_icon_get_emblem
|
||||||
|
<SUBSECTION Private>
|
||||||
|
g_emblemed_icon_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
<SECTION>
|
<SECTION>
|
||||||
<FILE>ginputstream</FILE>
|
<FILE>ginputstream</FILE>
|
||||||
<TITLE>GInputStream</TITLE>
|
<TITLE>GInputStream</TITLE>
|
||||||
|
@ -174,6 +174,8 @@ libgio_2_0_la_SOURCES = \
|
|||||||
gdrive.c \
|
gdrive.c \
|
||||||
gdummyfile.h \
|
gdummyfile.h \
|
||||||
gdummyfile.c \
|
gdummyfile.c \
|
||||||
|
gemblemedicon.h \
|
||||||
|
gemblemedicon.c \
|
||||||
gfile.c \
|
gfile.c \
|
||||||
gfileattribute.c \
|
gfileattribute.c \
|
||||||
gfileattribute-priv.h \
|
gfileattribute-priv.h \
|
||||||
|
187
gio/gemblemedicon.c
Normal file
187
gio/gemblemedicon.c
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||||
|
|
||||||
|
/* GIO - GLib Input, Output and Streaming Library
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Author: Matthias Clasen <mclasen@redhat.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "gemblemedicon.h"
|
||||||
|
#include "glibintl.h"
|
||||||
|
|
||||||
|
#include "gioalias.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:gemblemedicon
|
||||||
|
* @short_description: Icon with emblems
|
||||||
|
* @include: gio/gio.h
|
||||||
|
* @see_also: #GIcon, #GLoadableIcon, #GThemedIcon
|
||||||
|
*
|
||||||
|
* #GEmblemedIcon is an implementation of #GIcon that supports
|
||||||
|
* adding an emblem to an icon. To add multiple emblems to an
|
||||||
|
* icon, you can create nested #GemblemedIcon<!-- -->s.
|
||||||
|
*
|
||||||
|
* Note that #GEmblemedIcon allows no control over the position
|
||||||
|
* of the emblems. It is up to the rendering code to pick a position.
|
||||||
|
**/
|
||||||
|
|
||||||
|
static void g_emblemed_icon_icon_iface_init (GIconIface *iface);
|
||||||
|
|
||||||
|
struct _GEmblemedIcon
|
||||||
|
{
|
||||||
|
GObject parent_instance;
|
||||||
|
|
||||||
|
GIcon *icon;
|
||||||
|
GIcon *emblem;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GEmblemedIconClass
|
||||||
|
{
|
||||||
|
GObjectClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_WITH_CODE (GEmblemedIcon, g_emblemed_icon, G_TYPE_OBJECT,
|
||||||
|
G_IMPLEMENT_INTERFACE (G_TYPE_ICON,
|
||||||
|
g_emblemed_icon_icon_iface_init))
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_emblemed_icon_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
GEmblemedIcon *emblemed;
|
||||||
|
|
||||||
|
emblemed = G_EMBLEMED_ICON (object);
|
||||||
|
|
||||||
|
g_object_unref (emblemed->icon);
|
||||||
|
g_object_unref (emblemed->emblem);
|
||||||
|
|
||||||
|
(*G_OBJECT_CLASS (g_emblemed_icon_parent_class)->finalize) (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_emblemed_icon_class_init (GEmblemedIconClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
gobject_class->finalize = g_emblemed_icon_finalize;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_emblemed_icon_init (GEmblemedIcon *emblemed)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_emblemed_icon_new:
|
||||||
|
* @icon: a #GIcon.
|
||||||
|
* @emblem: a #GIcon
|
||||||
|
*
|
||||||
|
* Creates a new emblemed icon for @icon with emblem @emblem.
|
||||||
|
*
|
||||||
|
* Returns: a new #GEmblemedIcon.
|
||||||
|
*
|
||||||
|
* Since: 2.18
|
||||||
|
**/
|
||||||
|
GIcon *
|
||||||
|
g_emblemed_icon_new (GIcon *icon,
|
||||||
|
GIcon *emblem)
|
||||||
|
{
|
||||||
|
GEmblemedIcon *emblemed;
|
||||||
|
|
||||||
|
g_return_val_if_fail (icon != NULL, NULL);
|
||||||
|
g_return_val_if_fail (emblem != NULL, NULL);
|
||||||
|
|
||||||
|
emblemed = G_EMBLEMED_ICON (g_object_new (G_TYPE_EMBLEMED_ICON, NULL));
|
||||||
|
emblemed->icon = g_object_ref (icon);
|
||||||
|
emblemed->emblem = g_object_ref (emblem);
|
||||||
|
|
||||||
|
return G_ICON (emblemed);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_emblemed_icon_get_icon:
|
||||||
|
* @icon: a #GEmblemedIcon.
|
||||||
|
*
|
||||||
|
* Gets the main icon for @icon.
|
||||||
|
*
|
||||||
|
* Returns: a #GIcon that is owend by @icon
|
||||||
|
*
|
||||||
|
* Since: 2.18
|
||||||
|
**/
|
||||||
|
GIcon *
|
||||||
|
g_emblemed_icon_get_icon (GEmblemedIcon *icon)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (G_IS_EMBLEMED_ICON (icon), NULL);
|
||||||
|
|
||||||
|
return icon->icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_emblemed_icon_get_emblem:
|
||||||
|
* @icon: a #GEmblemedIcon.
|
||||||
|
*
|
||||||
|
* Gets the emblem for @icon.
|
||||||
|
*
|
||||||
|
* Returns: a #GIcon that is owned by @icon
|
||||||
|
*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
static guint
|
||||||
|
g_emblemed_icon_hash (GIcon *icon)
|
||||||
|
{
|
||||||
|
GEmblemedIcon *emblemed = G_EMBLEMED_ICON (icon);
|
||||||
|
guint hash;
|
||||||
|
|
||||||
|
hash = g_icon_hash (emblemed->icon);
|
||||||
|
hash ^= g_icon_hash (emblemed->emblem);
|
||||||
|
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
g_emblemed_icon_equal (GIcon *icon1,
|
||||||
|
GIcon *icon2)
|
||||||
|
{
|
||||||
|
GEmblemedIcon *emblemed1 = G_EMBLEMED_ICON (icon1);
|
||||||
|
GEmblemedIcon *emblemed2 = G_EMBLEMED_ICON (icon2);
|
||||||
|
|
||||||
|
return g_icon_equal (emblemed1->icon, emblemed2->icon) &&
|
||||||
|
g_icon_equal (emblemed1->emblem, emblemed2->emblem);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_emblemed_icon_icon_iface_init (GIconIface *iface)
|
||||||
|
{
|
||||||
|
iface->hash = g_emblemed_icon_hash;
|
||||||
|
iface->equal = g_emblemed_icon_equal;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define __G_EMBLEMED_ICON_C__
|
||||||
|
#include "gioaliasdef.c"
|
59
gio/gemblemedicon.h
Normal file
59
gio/gemblemedicon.h
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/* Gio - GLib Input, Output and Streaming Library
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006-2007 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Author: Matthias Clasen <mclasen@redhat.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
|
||||||
|
#error "Only <gio/gio.h> can be included directly."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __G_EMBLEMED_ICON_H__
|
||||||
|
#define __G_EMBLEMED_ICON_H__
|
||||||
|
|
||||||
|
#include <gio/gicon.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define G_TYPE_EMBLEMED_ICON (g_emblemed_icon_get_type ())
|
||||||
|
#define G_EMBLEMED_ICON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_EMBLEMED_ICON, GEmblemedIcon))
|
||||||
|
#define G_EMBLEMED_ICON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_EMBLEMED_ICON, GEmblemedIconClass))
|
||||||
|
#define G_IS_EMBLEMED_ICON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_EMBLEMED_ICON))
|
||||||
|
#define G_IS_EMBLEMED_ICON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_EMBLEMED_ICON))
|
||||||
|
#define G_EMBLEMED_ICON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_EMBLEMED_ICON, GEmblemedIconClass))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GEmblemedIcon:
|
||||||
|
*
|
||||||
|
* An implementation of #GIcon for icons with emblems.
|
||||||
|
**/
|
||||||
|
typedef struct _GEmblemedIcon GEmblemedIcon;
|
||||||
|
typedef struct _GEmblemedIconClass GEmblemedIconClass;
|
||||||
|
|
||||||
|
GType g_emblemed_icon_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
GIcon *g_emblemed_icon_new (GIcon *icon,
|
||||||
|
GIcon *emblem);
|
||||||
|
GIcon *g_emblemed_icon_get_icon (GEmblemedIcon *icon);
|
||||||
|
GIcon *g_emblemed_icon_get_emblem (GEmblemedIcon *icon);
|
||||||
|
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __G_EMBLEMED_ICON_H__ */
|
@ -36,6 +36,7 @@
|
|||||||
#include <gio/gdatainputstream.h>
|
#include <gio/gdatainputstream.h>
|
||||||
#include <gio/gdataoutputstream.h>
|
#include <gio/gdataoutputstream.h>
|
||||||
#include <gio/gdrive.h>
|
#include <gio/gdrive.h>
|
||||||
|
#include <gio/gemblemedicon.h>
|
||||||
#include <gio/gfile.h>
|
#include <gio/gfile.h>
|
||||||
#include <gio/gfileattribute.h>
|
#include <gio/gfileattribute.h>
|
||||||
#include <gio/gfileenumerator.h>
|
#include <gio/gfileenumerator.h>
|
||||||
|
@ -804,3 +804,13 @@ 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
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if IN_HEADER(__G_EMBLEMED_ICON_H__)
|
||||||
|
#if IN_FILE(__G_EMBLEMED_ICON_C__)
|
||||||
|
g_emblemed_icon_get_type G_GNUC_CONST
|
||||||
|
g_emblemed_icon_new
|
||||||
|
g_emblemed_icon_get_icon
|
||||||
|
g_emblemed_icon_get_emblem
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user