[gnome-shell] st-entry: Add API to set an actor as primary/secondary icon
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] st-entry: Add API to set an actor as primary/secondary icon
- Date: Mon, 21 Feb 2011 16:54:43 +0000 (UTC)
commit bffe7964131e84adc70a9ee05493d22669d514fc
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Feb 10 19:40:01 2011 +0100
st-entry: Add API to set an actor as primary/secondary icon
Currently an entry's primary/secondary icon can only be set by
filename. In order to allow using themed icons, add API to set
a generic ClutterActor as icon.
https://bugzilla.gnome.org/show_bug.cgi?id=642333
src/st/st-entry.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++------
src/st/st-entry.h | 4 +++
2 files changed, 68 insertions(+), 9 deletions(-)
---
diff --git a/src/st/st-entry.c b/src/st/st-entry.c
index 0cded5a..c963c98 100644
--- a/src/st/st-entry.c
+++ b/src/st/st-entry.c
@@ -868,9 +868,9 @@ _st_entry_icon_press_cb (ClutterActor *actor,
}
static void
-_st_entry_set_icon_from_file (StEntry *entry,
- ClutterActor **icon,
- const gchar *filename)
+_st_entry_set_icon (StEntry *entry,
+ ClutterActor **icon,
+ ClutterActor *new_icon)
{
if (*icon)
{
@@ -881,13 +881,9 @@ _st_entry_set_icon_from_file (StEntry *entry,
*icon = NULL;
}
- if (filename)
+ if (new_icon)
{
- StTextureCache *cache;
-
- cache = st_texture_cache_get_default ();
-
- *icon = (ClutterActor*) st_texture_cache_load_file_simple (cache, filename);
+ *icon = g_object_ref (new_icon);
clutter_actor_set_reactive (*icon, TRUE);
clutter_actor_set_parent (*icon, CLUTTER_ACTOR (entry));
@@ -898,6 +894,65 @@ _st_entry_set_icon_from_file (StEntry *entry,
clutter_actor_queue_relayout (CLUTTER_ACTOR (entry));
}
+static void
+_st_entry_set_icon_from_file (StEntry *entry,
+ ClutterActor **icon,
+ const gchar *filename)
+{
+ ClutterActor *new_icon = NULL;
+
+ if (filename)
+ {
+ StTextureCache *cache;
+
+ cache = st_texture_cache_get_default ();
+
+ new_icon = (ClutterActor*) st_texture_cache_load_file_simple (cache, filename);
+ }
+
+ _st_entry_set_icon (entry, icon, new_icon);
+}
+
+/**
+ * st_entry_set_primary_icon:
+ * @entry: a #StEntry
+ * @icon: (allow-none): a #ClutterActor
+ *
+ * Set the primary icon of the entry to @icon
+ */
+void
+st_entry_set_primary_icon (StEntry *entry,
+ ClutterActor *icon)
+{
+ StEntryPrivate *priv;
+
+ g_return_if_fail (ST_IS_ENTRY (entry));
+
+ priv = entry->priv;
+
+ _st_entry_set_icon (entry, &priv->primary_icon, icon);
+}
+
+/**
+ * st_entry_set_secondary_icon:
+ * @entry: a #StEntry
+ * @icon: (allow-none): an #ClutterActor
+ *
+ * Set the secondary icon of the entry to @icon
+ */
+void
+st_entry_set_secondary_icon (StEntry *entry,
+ ClutterActor *icon)
+{
+ StEntryPrivate *priv;
+
+ g_return_if_fail (ST_IS_ENTRY (entry));
+
+ priv = entry->priv;
+
+ _st_entry_set_icon (entry, &priv->secondary_icon, icon);
+}
+
/**
* st_entry_set_primary_icon_from_file:
* @entry: a #StEntry
diff --git a/src/st/st-entry.h b/src/st/st-entry.h
index 581ad4d..9477054 100644
--- a/src/st/st-entry.h
+++ b/src/st/st-entry.h
@@ -74,6 +74,10 @@ void st_entry_set_hint_text (StEntry *entry,
const gchar *text);
G_CONST_RETURN gchar *st_entry_get_hint_text (StEntry *entry);
+void st_entry_set_primary_icon (StEntry *entry,
+ ClutterActor *icon);
+void st_entry_set_secondary_icon (StEntry *entry,
+ ClutterActor *icon);
void st_entry_set_primary_icon_from_file (StEntry *entry,
const gchar *filename);
void st_entry_set_secondary_icon_from_file (StEntry *entry,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]