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
This commit is contained in:
parent
6b4c497800
commit
bffe796413
@ -868,9 +868,9 @@ _st_entry_icon_press_cb (ClutterActor *actor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_st_entry_set_icon_from_file (StEntry *entry,
|
_st_entry_set_icon (StEntry *entry,
|
||||||
ClutterActor **icon,
|
ClutterActor **icon,
|
||||||
const gchar *filename)
|
ClutterActor *new_icon)
|
||||||
{
|
{
|
||||||
if (*icon)
|
if (*icon)
|
||||||
{
|
{
|
||||||
@ -881,13 +881,9 @@ _st_entry_set_icon_from_file (StEntry *entry,
|
|||||||
*icon = NULL;
|
*icon = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filename)
|
if (new_icon)
|
||||||
{
|
{
|
||||||
StTextureCache *cache;
|
*icon = g_object_ref (new_icon);
|
||||||
|
|
||||||
cache = st_texture_cache_get_default ();
|
|
||||||
|
|
||||||
*icon = (ClutterActor*) st_texture_cache_load_file_simple (cache, filename);
|
|
||||||
|
|
||||||
clutter_actor_set_reactive (*icon, TRUE);
|
clutter_actor_set_reactive (*icon, TRUE);
|
||||||
clutter_actor_set_parent (*icon, CLUTTER_ACTOR (entry));
|
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));
|
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:
|
* st_entry_set_primary_icon_from_file:
|
||||||
* @entry: a #StEntry
|
* @entry: a #StEntry
|
||||||
|
@ -74,6 +74,10 @@ void st_entry_set_hint_text (StEntry *entry,
|
|||||||
const gchar *text);
|
const gchar *text);
|
||||||
G_CONST_RETURN gchar *st_entry_get_hint_text (StEntry *entry);
|
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,
|
void st_entry_set_primary_icon_from_file (StEntry *entry,
|
||||||
const gchar *filename);
|
const gchar *filename);
|
||||||
void st_entry_set_secondary_icon_from_file (StEntry *entry,
|
void st_entry_set_secondary_icon_from_file (StEntry *entry,
|
||||||
|
Loading…
Reference in New Issue
Block a user