aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib/menuitem.c
diff options
context:
space:
mode:
Diffstat (limited to 'libdbusmenu-glib/menuitem.c')
-rw-r--r--libdbusmenu-glib/menuitem.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c
index c81c36e..0b85193 100644
--- a/libdbusmenu-glib/menuitem.c
+++ b/libdbusmenu-glib/menuitem.c
@@ -192,7 +192,7 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass)
@arg2: The position that the child is being moved to.
@arg3: The position that the child is was in.
- Signaled when the child menuitem has had it's location
+ Signaled when the child menuitem has had its location
in the list change.
*/
signals[CHILD_MOVED] = g_signal_new(DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED,
@@ -270,7 +270,7 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass)
g_object_class_install_property (object_class, PROP_ID,
g_param_spec_int(PROP_ID_S, "ID for the menu item",
"This is a unique indentifier for the menu item.",
- -1, 30000, -1,
+ -1, G_MAXINT, -1,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
/* Check transfer functions for GValue */
@@ -391,7 +391,11 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec)
case PROP_ID:
priv->id = g_value_get_int(value);
if (priv->id > menuitem_next_id) {
- menuitem_next_id = priv->id + 1;
+ if (priv->id == G_MAXINT) {
+ menuitem_next_id = 1;
+ } else {
+ menuitem_next_id = priv->id + 1;
+ }
}
break;
default:
@@ -410,7 +414,12 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec)
switch (id) {
case PROP_ID:
if (priv->id == -1) {
- priv->id = menuitem_next_id++;
+ priv->id = menuitem_next_id;
+ if (menuitem_next_id == G_MAXINT) {
+ menuitem_next_id = 1;
+ } else {
+ menuitem_next_id += 1;
+ }
}
if (dbusmenu_menuitem_get_root(DBUSMENU_MENUITEM(obj))) {
g_value_set_int(value, 0);
@@ -463,7 +472,7 @@ send_about_to_show (DbusmenuMenuitem * mi, void (*cb) (DbusmenuMenuitem * mi, gp
/* A helper function to get the type of the menuitem, this might
be a candidate for optimization in the future. */
static const gchar *
-menuitem_get_type (DbusmenuMenuitem * mi)
+menuitem_get_type (const DbusmenuMenuitem * mi)
{
DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi);
GVariant * currentval = (GVariant *)g_hash_table_lookup(priv->properties, DBUSMENU_MENUITEM_PROP_TYPE);
@@ -800,7 +809,7 @@ dbusmenu_menuitem_child_delete (DbusmenuMenuitem * mi, DbusmenuMenuitem * child)
g_return_val_if_fail(DBUSMENU_IS_MENUITEM(child), FALSE);
if (dbusmenu_menuitem_get_parent(child) != mi) {
- g_warning("Trying to remove a child that doesn't believe we're it's parent.");
+ g_warning("Trying to remove a child that doesn't believe we're its parent.");
return FALSE;
}
@@ -974,7 +983,7 @@ dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, gint id)
}
return mi;
}
- find_id_t find_id = {mi: NULL, id: id};
+ find_id_t find_id = {.mi=NULL, .id=id};
find_id_helper(mi, &find_id);
return find_id.mi;
}
@@ -1287,7 +1296,7 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro
* is not set or is not a string.
*/
const gchar *
-dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property)
+dbusmenu_menuitem_property_get (const DbusmenuMenuitem * mi, const gchar * property)
{
GVariant * variant = dbusmenu_menuitem_property_get_variant(mi, property);
if (variant == NULL) return NULL;
@@ -1307,7 +1316,7 @@ dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property)
* Return value: (transfer none): A GVariant for the property.
*/
GVariant *
-dbusmenu_menuitem_property_get_variant (DbusmenuMenuitem * mi, const gchar * property)
+dbusmenu_menuitem_property_get_variant (const DbusmenuMenuitem * mi, const gchar * property)
{
g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), NULL);
g_return_val_if_fail(property != NULL, NULL);
@@ -1334,7 +1343,7 @@ dbusmenu_menuitem_property_get_variant (DbusmenuMenuitem * mi, const gchar * pro
* Return value: The value of the property or #FALSE.
*/
gboolean
-dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * property)
+dbusmenu_menuitem_property_get_bool (const DbusmenuMenuitem * mi, const gchar * property)
{
GVariant * variant = dbusmenu_menuitem_property_get_variant(mi, property);
if (variant == NULL) return FALSE;
@@ -1368,7 +1377,7 @@ dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * proper
* Return value: The value of the property or zero.
*/
gint
-dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * property)
+dbusmenu_menuitem_property_get_int (const DbusmenuMenuitem * mi, const gchar * property)
{
GVariant * variant = dbusmenu_menuitem_property_get_variant(mi, property);
if (variant == NULL) return 0;
@@ -1401,7 +1410,7 @@ dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * propert
* is not set or is not a byte array.
*/
const guchar *
-dbusmenu_menuitem_property_get_byte_array (DbusmenuMenuitem * mi, const gchar * property, gsize * nelements)
+dbusmenu_menuitem_property_get_byte_array (const DbusmenuMenuitem * mi, const gchar * property, gsize * nelements)
{
GVariant * variant = dbusmenu_menuitem_property_get_variant(mi, property);
if (variant == NULL) {
@@ -1423,7 +1432,7 @@ dbusmenu_menuitem_property_get_byte_array (DbusmenuMenuitem * mi, const gchar *
* Return value: A boolean checking to see if the property is available
*/
gboolean
-dbusmenu_menuitem_property_exist (DbusmenuMenuitem * mi, const gchar * property)
+dbusmenu_menuitem_property_exist (const DbusmenuMenuitem * mi, const gchar * property)
{
g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), FALSE);
g_return_val_if_fail(property != NULL, FALSE);
@@ -1590,8 +1599,6 @@ dbusmenu_menuitem_properties_variant (DbusmenuMenuitem * mi, const gchar ** prop
*
* This function sets the internal value of whether this is a
* root node or not.
- *
- * Return value: None
*/
void
dbusmenu_menuitem_set_root (DbusmenuMenuitem * mi, gboolean root)
@@ -1628,7 +1635,7 @@ dbusmenu_menuitem_get_root (DbusmenuMenuitem * mi)
*
* This function will put at least one entry if this menu item has no children.
* If it has children it will put two for this entry, one representing the
- * start tag and one that is a closing tag. It will allow it's
+ * start tag and one that is a closing tag. It will allow its
* children to place their own tags in the array in between those two.
*
* Return value: (transfer full): Variant representing @properties
@@ -1658,7 +1665,9 @@ dbusmenu_menuitem_build_variant (DbusmenuMenuitem * mi, const gchar ** propertie
if (props != NULL) {
g_variant_builder_add_value(&tupleb, props);
} else {
- g_variant_builder_add_value(&tupleb, g_variant_parse(G_VARIANT_TYPE("a{sv}"), "[ ]", NULL, NULL, NULL));
+ GVariant *empty_props = g_variant_parse(G_VARIANT_TYPE("a{sv}"), "[ ]", NULL, NULL, NULL);
+ g_variant_builder_add_value(&tupleb, empty_props);
+ g_variant_unref(empty_props);
}
/* Pillage the children */
@@ -1712,7 +1721,7 @@ dbusmenu_menuitem_foreach (DbusmenuMenuitem * mi, void (*func) (DbusmenuMenuitem
func(mi, data);
GList * children = dbusmenu_menuitem_get_children(mi);
- foreach_struct_t foreach_data = {func: func, data: data};
+ foreach_struct_t foreach_data = {.func=func, .data=data};
g_list_foreach(children, foreach_helper, &foreach_data);
return;
}