Add "parent" property to KatzeItem
This commit is contained in:
parent
394eb4b002
commit
7c3cb9a1bd
1 changed files with 32 additions and 5 deletions
|
@ -35,7 +35,8 @@ enum
|
||||||
PROP_URI,
|
PROP_URI,
|
||||||
PROP_ICON,
|
PROP_ICON,
|
||||||
PROP_TOKEN,
|
PROP_TOKEN,
|
||||||
PROP_ADDED
|
PROP_ADDED,
|
||||||
|
PROP_PARENT
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -122,6 +123,21 @@ katze_item_class_init (KatzeItemClass* class)
|
||||||
0,
|
0,
|
||||||
flags));
|
flags));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* KatzeItem:parent:
|
||||||
|
*
|
||||||
|
* The parent of the item.
|
||||||
|
*
|
||||||
|
* Since: 0.1.2
|
||||||
|
*/
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_PARENT,
|
||||||
|
g_param_spec_object (
|
||||||
|
"parent",
|
||||||
|
"Parent",
|
||||||
|
"The parent of the item",
|
||||||
|
G_TYPE_OBJECT,
|
||||||
|
flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,6 +190,9 @@ katze_item_set_property (GObject* object,
|
||||||
case PROP_ADDED:
|
case PROP_ADDED:
|
||||||
item->added = g_value_get_int64 (value);
|
item->added = g_value_get_int64 (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_PARENT:
|
||||||
|
katze_item_set_parent (item, g_value_get_object (value));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -208,6 +227,9 @@ katze_item_get_property (GObject* object,
|
||||||
case PROP_ADDED:
|
case PROP_ADDED:
|
||||||
g_value_set_int64 (value, item->added);
|
g_value_set_int64 (value, item->added);
|
||||||
break;
|
break;
|
||||||
|
case PROP_PARENT:
|
||||||
|
g_value_set_object (value, item->parent);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -433,6 +455,8 @@ katze_item_set_added (KatzeItem* item,
|
||||||
*
|
*
|
||||||
* Determines the parent of @item.
|
* Determines the parent of @item.
|
||||||
*
|
*
|
||||||
|
* Since 0.1.2 you can monitor the "parent" property.
|
||||||
|
*
|
||||||
* Return value: the parent of the item
|
* Return value: the parent of the item
|
||||||
**/
|
**/
|
||||||
gpointer
|
gpointer
|
||||||
|
@ -450,18 +474,21 @@ katze_item_get_parent (KatzeItem* item)
|
||||||
*
|
*
|
||||||
* Sets the parent of @item.
|
* Sets the parent of @item.
|
||||||
*
|
*
|
||||||
* This is intended for item container implementations and
|
* This is intended for item container implementations. Notably
|
||||||
* should not be used otherwise.
|
* the new parent will not be notified of the change.
|
||||||
|
*
|
||||||
|
* Since 0.1.2 you can monitor the "parent" property, so unsetting
|
||||||
|
* the parent is actually safe if the parent supports it.
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
katze_item_set_parent (KatzeItem* item,
|
katze_item_set_parent (KatzeItem* item,
|
||||||
gpointer parent)
|
gpointer parent)
|
||||||
{
|
{
|
||||||
g_return_if_fail (KATZE_IS_ITEM (item));
|
g_return_if_fail (KATZE_IS_ITEM (item));
|
||||||
|
g_return_if_fail (!parent || G_IS_OBJECT (parent));
|
||||||
|
|
||||||
if (parent)
|
if (parent)
|
||||||
g_object_ref (parent);
|
g_object_ref (parent);
|
||||||
katze_object_assign (item->parent, parent);
|
katze_object_assign (item->parent, parent);
|
||||||
/* g_object_notify (G_OBJECT (item), "parent"); */
|
g_object_notify (G_OBJECT (item), "parent");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue