aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib
diff options
context:
space:
mode:
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r--libdbusmenu-glib/Makefile.am6
-rw-r--r--libdbusmenu-glib/client.c29
-rw-r--r--libdbusmenu-glib/defaults.c2
-rw-r--r--libdbusmenu-glib/enum-types.h.in2
-rw-r--r--libdbusmenu-glib/menuitem.c45
-rw-r--r--libdbusmenu-glib/menuitem.h20
-rw-r--r--libdbusmenu-glib/server.c29
7 files changed, 88 insertions, 45 deletions
diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am
index 36b5152..26d900c 100644
--- a/libdbusmenu-glib/Makefile.am
+++ b/libdbusmenu-glib/Makefile.am
@@ -213,10 +213,10 @@ if HAVE_VALA
if HAVE_INTROSPECTION
vapidir = $(datadir)/vala/vapi
-vapi_DATA = dbusmenu-glib-0.4.vapi
+vapi_DATA = Dbusmenu-0.4.vapi
-dbusmenu-glib-0.4.vapi: Dbusmenu-0.4.gir
- $(VALA_API_GEN) --library=dbusmenu-glib-0.4 $<
+Dbusmenu-0.4.vapi: Dbusmenu-0.4.gir
+ $(VALA_API_GEN) --library=Dbusmenu-0.4 $<
CLEANFILES += $(vapi_DATA)
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c
index b6e7204..4bb3217 100644
--- a/libdbusmenu-glib/client.c
+++ b/libdbusmenu-glib/client.c
@@ -2160,8 +2160,29 @@ parse_layout_xml(DbusmenuClient * client, GVariant * layout, DbusmenuMenuitem *
for (childsearch = oldchildren; childsearch != NULL; childsearch = g_list_next(childsearch)) {
DbusmenuMenuitem * cs_mi = DBUSMENU_MENUITEM(childsearch->data);
if (childid == dbusmenu_menuitem_get_id(cs_mi)) {
- oldchildren = g_list_remove(oldchildren, cs_mi);
- childmi = cs_mi;
+ GVariantIter iter;
+ gchar * prop;
+ GVariant * value;
+ GVariant * child_props;
+ GVariant * new_type = NULL;
+ GVariant * old_type = NULL;
+
+ child_props = g_variant_get_child_value(child, 1);
+ g_variant_iter_init(&iter, child_props);
+ while (g_variant_iter_loop(&iter, "{sv}", &prop, &value)) {
+ if (g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_TYPE) == 0) {
+ new_type = value;
+ break;
+ }
+ }
+ g_variant_unref(child_props);
+
+ old_type = dbusmenu_menuitem_property_get_variant(cs_mi, DBUSMENU_MENUITEM_PROP_TYPE);
+ if ((old_type == NULL && new_type == NULL) || (old_type != NULL && new_type != NULL && g_variant_compare(old_type, new_type) == 0)) {
+ // Only recycle the menu item if it's of the same type
+ oldchildren = g_list_remove(oldchildren, cs_mi);
+ childmi = cs_mi;
+ }
break;
}
}
@@ -2511,7 +2532,7 @@ type_handler_destroy (gpointer user_data)
* items when they come in.
*
* This function connects into the type handling of the #DbusmenuClient.
- * Every new menuitem that comes in immediately gets asked for it's
+ * Every new menuitem that comes in immediately gets asked for its
* properties. When we get those properties we check the 'type'
* property and look to see if it matches a handler that is known
* by the client. If so, the @newfunc function is executed on that
@@ -2542,7 +2563,7 @@ dbusmenu_client_add_type_handler (DbusmenuClient * client, const gchar * type, D
* the resources in @user_data.
*
* This function connects into the type handling of the #DbusmenuClient.
- * Every new menuitem that comes in immediately gets asked for it's
+ * Every new menuitem that comes in immediately gets asked for its
* properties. When we get those properties we check the 'type'
* property and look to see if it matches a handler that is known
* by the client. If so, the @newfunc function is executed on that
diff --git a/libdbusmenu-glib/defaults.c b/libdbusmenu-glib/defaults.c
index d6ee7cc..a0a78a5 100644
--- a/libdbusmenu-glib/defaults.c
+++ b/libdbusmenu-glib/defaults.c
@@ -228,7 +228,7 @@ dbusmenu_defaults_default_set (DbusmenuDefaults * defaults, const gchar * type,
* Gets an entry in the database for a give @property and @type.
*
* Return value: (transfer none): Returns a variant that does not
- * have it's ref count increased. If you want to keep it, you should
+ * have its ref count increased. If you want to keep it, you should
* do that.
*/
GVariant *
diff --git a/libdbusmenu-glib/enum-types.h.in b/libdbusmenu-glib/enum-types.h.in
index 5758438..afd9132 100644
--- a/libdbusmenu-glib/enum-types.h.in
+++ b/libdbusmenu-glib/enum-types.h.in
@@ -43,7 +43,7 @@ G_END_DECLS
/*** END file-tail ***/
/*** BEGIN file-production ***/
-/* Enumerations from file: "@filename@" */
+/* Enumerations from file: "@basename@" */
#include "@basename@"
/*** END file-production ***/
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;
}
diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h
index 76422f9..97682db 100644
--- a/libdbusmenu-glib/menuitem.h
+++ b/libdbusmenu-glib/menuitem.h
@@ -409,9 +409,9 @@ typedef void (*dbusmenu_menuitem_about_to_show_cb) (DbusmenuMenuitem * mi, gpoin
* @properties: (allow-none): A list of properties that should be the only ones in the resulting variant structure
*
* This is the function that is called to represent this menu item
- * as a variant. Should call it's own children.
+ * as a variant. Should call its own children.
*
- * Return value: (transfer full): A variant representing this item and it's children
+ * Return value: (transfer full): A variant representing this item and its children
*/
typedef GVariant * (*dbusmenu_menuitem_buildvariant_slot_t) (DbusmenuMenuitem * mi, gchar ** properties);
@@ -455,7 +455,7 @@ struct _DbusmenuMenuitemClass
/* Virtual functions */
dbusmenu_menuitem_buildvariant_slot_t buildvariant;
void (*handle_event) (DbusmenuMenuitem * mi, const gchar * name, GVariant * variant, guint timestamp);
- void (*send_about_to_show) (DbusmenuMenuitem * mi, void (*cb) (DbusmenuMenuitem * mi, gpointer user_data), gpointer cb_data);
+ void (*send_about_to_show) (DbusmenuMenuitem * mi, dbusmenu_menuitem_about_to_show_cb cb, gpointer cb_data);
void (*show_to_user) (DbusmenuMenuitem * mi, guint timestamp, gpointer cb_data);
gboolean (*about_to_show) (void);
@@ -498,12 +498,12 @@ gboolean dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gc
gboolean dbusmenu_menuitem_property_set_bool (DbusmenuMenuitem * mi, const gchar * property, const gboolean value);
gboolean dbusmenu_menuitem_property_set_int (DbusmenuMenuitem * mi, const gchar * property, const gint value);
gboolean dbusmenu_menuitem_property_set_byte_array (DbusmenuMenuitem * mi, const gchar * property, const guchar * value, gsize nelements);
-const gchar * dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property);
-GVariant * dbusmenu_menuitem_property_get_variant (DbusmenuMenuitem * mi, const gchar * property);
-gboolean dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * property);
-gint dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * property);
-const guchar * dbusmenu_menuitem_property_get_byte_array (DbusmenuMenuitem * mi, const gchar * property, gsize * nelements);
-gboolean dbusmenu_menuitem_property_exist (DbusmenuMenuitem * mi, const gchar * property);
+const gchar * dbusmenu_menuitem_property_get (const DbusmenuMenuitem * mi, const gchar * property);
+GVariant * dbusmenu_menuitem_property_get_variant (const DbusmenuMenuitem * mi, const gchar * property);
+gboolean dbusmenu_menuitem_property_get_bool (const DbusmenuMenuitem * mi, const gchar * property);
+gint dbusmenu_menuitem_property_get_int (const DbusmenuMenuitem * mi, const gchar * property);
+const guchar * dbusmenu_menuitem_property_get_byte_array (const DbusmenuMenuitem * mi, const gchar * property, gsize * nelements);
+gboolean dbusmenu_menuitem_property_exist (const DbusmenuMenuitem * mi, const gchar * property);
GList * dbusmenu_menuitem_properties_list (DbusmenuMenuitem * mi) G_GNUC_WARN_UNUSED_RESULT;
GHashTable * dbusmenu_menuitem_properties_copy (DbusmenuMenuitem * mi);
void dbusmenu_menuitem_property_remove (DbusmenuMenuitem * mi, const gchar * property);
@@ -528,7 +528,7 @@ void dbusmenu_menuitem_show_to_user (DbusmenuMenuitem * mi, guint timestamp);
* and copied over to the client side where it gets rendered. As
* the server starts to change it, and grow it, and do all kinds
* of fun stuff that information is transfered over DBus and the
- * client updates it's understanding of the object model.
+ * client updates its understanding of the object model.
*
* Most people using either the client or the server should be
* able to deal mostly with #DbusmenuMenuitem objects. These
diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c
index f47bb5d..e07af27 100644
--- a/libdbusmenu-glib/server.c
+++ b/libdbusmenu-glib/server.c
@@ -215,9 +215,9 @@ static gboolean layout_update_idle (gpointer user_data);
static GDBusNodeInfo * dbusmenu_node_info = NULL;
static GDBusInterfaceInfo * dbusmenu_interface_info = NULL;
static const GDBusInterfaceVTable dbusmenu_interface_table = {
- method_call: bus_method_call,
- get_property: bus_get_prop,
- set_property: NULL /* No properties that can be set */
+ .method_call = bus_method_call,
+ .get_property = bus_get_prop,
+ .set_property = NULL /* No properties that can be set */
};
static method_table_t dbusmenu_method_table[METHOD_COUNT];
@@ -292,7 +292,7 @@ dbusmenu_server_class_init (DbusmenuServerClass *class)
@arg2: The timestamp of when the event happened
This is signaled when a menuitem under this server
- sends it's activate signal.
+ sends its activate signal.
*/
signals[ITEM_ACTIVATION] = g_signal_new(DBUSMENU_SERVER_SIGNAL_ITEM_ACTIVATION,
G_TYPE_FROM_CLASS(class),
@@ -1070,8 +1070,6 @@ menuitem_property_idle (gpointer user_data)
g_error_free(error);
megadata[0] = NULL;
error_nosend = TRUE;
- } else {
- g_variant_ref_sink(megadata[0]);
}
}
@@ -1088,8 +1086,6 @@ menuitem_property_idle (gpointer user_data)
g_error_free(error);
megadata[1] = NULL;
error_nosend = TRUE;
- } else {
- g_variant_ref_sink(megadata[1]);
}
}
@@ -1331,6 +1327,9 @@ bus_get_layout (DbusmenuServer * server, GVariant * params, GDBusMethodInvocatio
if (mi != NULL) {
items = dbusmenu_menuitem_build_variant(mi, props, recurse);
+ if (items) {
+ g_variant_ref_sink(items);
+ }
}
}
g_free(props);
@@ -1360,6 +1359,8 @@ bus_get_layout (DbusmenuServer * server, GVariant * params, GDBusMethodInvocatio
g_variant_builder_add_value(&tuplebuilder, g_variant_new_uint32(revision));
g_variant_builder_add_value(&tuplebuilder, items);
+ g_variant_unref(items);
+
GVariant * retval = g_variant_builder_end(&tuplebuilder);
// g_debug("Sending layout type: %s", g_variant_get_type_string(retval));
g_dbus_method_invocation_return_value(invocation,
@@ -1504,6 +1505,9 @@ bus_get_group_properties (DbusmenuServer * server, GVariant * params, GDBusMetho
g_variant_builder_init(&wbuilder, G_VARIANT_TYPE_TUPLE);
g_variant_builder_add(&wbuilder, "i", id);
GVariant * props = dbusmenu_menuitem_properties_variant(mi, NULL);
+ if (props != NULL) {
+ g_variant_ref(props);
+ }
if (props == NULL) {
GError * error = NULL;
@@ -1516,6 +1520,7 @@ bus_get_group_properties (DbusmenuServer * server, GVariant * params, GDBusMetho
}
g_variant_builder_add_value(&wbuilder, props);
+ g_variant_unref(props);
GVariant * mi_data = g_variant_builder_end(&wbuilder);
g_variant_builder_add_value(&builder, mi_data);
@@ -1613,6 +1618,7 @@ bus_get_children (DbusmenuServer * server, GVariant * params, GDBusMethodInvocat
GVariant * end = g_variant_builder_end(&builder);
ret = g_variant_new_tuple(&end, 1);
+ g_variant_ref_sink(ret);
} else {
GError * error = NULL;
ret = g_variant_parse(G_VARIANT_TYPE("(a(ia{sv}))"), "([(0, {})],)", NULL, NULL, &error);
@@ -1624,6 +1630,7 @@ bus_get_children (DbusmenuServer * server, GVariant * params, GDBusMethodInvocat
}
g_dbus_method_invocation_return_value(invocation, ret);
+ g_variant_unref(ret);
return;
}
@@ -1705,6 +1712,8 @@ bus_event (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * i
} else {
if (~g_dbus_message_get_flags (g_dbus_method_invocation_get_message (invocation)) & G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED) {
g_dbus_method_invocation_return_value(invocation, NULL);
+ } else {
+ g_object_unref(invocation);
}
}
@@ -1755,6 +1764,8 @@ bus_event_group (DbusmenuServer * server, GVariant * params, GDBusMethodInvocati
if (gotone) {
if (~g_dbus_message_get_flags (g_dbus_method_invocation_get_message (invocation)) & G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED) {
g_dbus_method_invocation_return_value(invocation, g_variant_new_tuple(&errors, 1));
+ } else {
+ g_object_unref(invocation);
}
} else {
gchar * ids = g_variant_print(errors, FALSE);
@@ -1867,6 +1878,8 @@ bus_about_to_show_group (DbusmenuServer * server, GVariant * params, GDBusMethod
g_variant_builder_add_value(&tuple, errors);
g_dbus_method_invocation_return_value(invocation, g_variant_builder_end(&tuple));
+ } else {
+ g_object_unref(invocation);
}
} else {
gchar * ids = g_variant_print(errors, FALSE);