diff options
-rw-r--r-- | libdbusmenu-glib/client.c | 12 | ||||
-rw-r--r-- | libdbusmenu-gtk/client.c | 4 | ||||
-rw-r--r-- | libdbusmenu-gtk/menuitem.c | 7 | ||||
-rw-r--r-- | libdbusmenu-gtk/parser.c | 30 |
4 files changed, 40 insertions, 13 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index b9c50ee..16e832d 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1242,7 +1242,9 @@ menuproxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVarian while (g_variant_iter_next(&properties, "s", &property)) { /* g_debug("Removing property '%s' on %d", property, id); */ dbusmenu_menuitem_property_remove(menuitem, property); + g_free(property); } + g_variant_unref(ritem); } GVariantIter items; @@ -1333,12 +1335,11 @@ menuitem_get_properties_replace_cb (GVariant * properties, GError * error, gpoin have_error = TRUE; } - GList * current_props = NULL; + GList * current_props = dbusmenu_menuitem_properties_list(DBUSMENU_MENUITEM(data)); + GList * tmp = NULL; - for (current_props = dbusmenu_menuitem_properties_list(DBUSMENU_MENUITEM(data)); - current_props != NULL && have_error == FALSE; - current_props = g_list_next(current_props)) { - dbusmenu_menuitem_property_remove(DBUSMENU_MENUITEM(data), (const gchar *)current_props->data); + for (tmp = current_props; tmp != NULL && have_error == FALSE; tmp = g_list_next(tmp)) { + dbusmenu_menuitem_property_remove(DBUSMENU_MENUITEM(data), (const gchar *)tmp->data); } g_list_free(current_props); @@ -1852,6 +1853,7 @@ static void update_layout (DbusmenuClient * client) { DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + g_return_if_fail(priv->layout_props != NULL); if (priv->menuproxy == NULL) { return; diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index de7a752..510e74e 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -869,6 +869,7 @@ new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusmenu if (gmi != NULL) { dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); + g_object_unref(gmi); } else { return FALSE; } @@ -1042,6 +1043,9 @@ image_property_handle (DbusmenuMenuitem * item, const gchar * property, GVariant } else { gtk_image_set_from_pixbuf(GTK_IMAGE(gtkimage), image); } + if (image) { + g_object_unref(image); + } } } diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 370dbf2..b3358fe 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -119,12 +119,7 @@ dbusmenu_menuitem_property_get_image (DbusmenuMenuitem * menuitem, const gchar * g_error_free(error); } - error = NULL; - g_input_stream_close(input, NULL, &error); - if (error != NULL) { - g_warning("Unable to close input stream: %s", error->message); - g_error_free(error); - } + g_object_unref(input); g_free(icondata); return icon; diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 8954d64..a890543 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -362,6 +362,32 @@ sanitize_label_text (const gchar * label) } } +static gchar * +sanitize_label (GtkLabel * label) +{ + gchar * text; + + if (gtk_label_get_use_markup (label)) { + text = sanitize_label_text (gtk_label_get_label (label)); + } + else { + text = g_strdup (gtk_label_get_label (label)); + } + + if (!gtk_label_get_use_underline (label)) { + /* Insert extra underscores */ + GRegex * regex = g_regex_new ("_", 0, 0, NULL); + gchar * escaped = g_regex_replace_literal (regex, text, -1, 0, "__", 0, NULL); + + g_regex_unref (regex); + g_free (text); + + text = escaped; + } + + return text; +} + /* Turn a widget into a dbusmenu item depending on the type of GTK object that it is. */ static DbusmenuMenuitem * @@ -445,7 +471,7 @@ construct_dbusmenu_for_widget (GtkWidget * widget) { // Sometimes, an app will directly find and modify the label // (like empathy), so watch the label especially for that. - gchar * text = sanitize_label_text (gtk_label_get_label (GTK_LABEL (label))); + gchar * text = sanitize_label (GTK_LABEL (label)); dbusmenu_menuitem_property_set (mi, "label", text); g_free (text); @@ -690,7 +716,7 @@ label_notify_cb (GtkWidget *widget, if (pspec->name == g_intern_static_string ("label")) { - gchar * text = sanitize_label_text (gtk_label_get_label (GTK_LABEL (widget))); + gchar * text = sanitize_label (GTK_LABEL (widget)); dbusmenu_menuitem_property_set (child, DBUSMENU_MENUITEM_PROP_LABEL, text); |