[continued from previous message]
- else if (g_strcmp0(prop, "toggle-state") == 0)
- {
- item->toggled = g_variant_get_int32(value) > 0;
- act_props_try_update(item);
- }
- else if (g_strcmp0(prop, "visible") == 0)
- {
- bool vis = g_variant_get_boolean(value);
- if (item->action_type == DBUS_MENU_ACTION_SECTION)
- {
- item->toggled = !vis;
- }
- else if (vis)
- {
- g_autofree char *name =
- dbus_menu_action_get_name(item->id, item->action_type, true);
- bool found =
- g_hash_table_remove(item->attrs, G_MENU_ATTRIBUTE_HIDDEN_WHEN);
- if (found)
- {
- g_hash_table_insert(item->attrs,
- g_strdup(G_MENU_ATTRIBUTE_ACTION),
- g_variant_new_string(name));
- properties_is_updated = true;
- }
- }
- else
- {
- bool found = g_hash_table_contains(item->attrs, - G_MENU_ATTRIBUTE_HIDDEN_WHEN);
- if (!found)
- {
- g_hash_table_insert(item->attrs,
- g_strdup(G_MENU_ATTRIBUTE_HIDDEN_WHEN),
- g_variant_new_string(
- G_MENU_HIDDEN_WHEN_ACTION_MISSING));
- g_hash_table_insert(item->attrs,
- g_strdup(G_MENU_ATTRIBUTE_ACTION),
- g_variant_new_string(
- DBUS_MENU_DISABLED_ACTION));
- properties_is_updated = true;
- }
- }
- }
- else
- {
- g_debug("updating unsupported property - '%s'", prop); - }
- }
- return properties_is_updated;
-}
-
-G_GNUC_INTERNAL bool dbus_menu_item_remove_props(DBusMenuItem *item, GVariant *props)
-{
- GVariantIter iter;
- const char *prop;
- bool properties_is_updated = false;
-
- g_variant_iter_init(&iter, props);
- while (g_variant_iter_next(&iter, "&s", &prop))
- {
- if (g_strcmp0(prop, "accessible-desc") == 0)
- {
- // TODO: Can we support this property?
- // properties_is_updated = true;
- }
- else if (g_strcmp0(prop, "enabled") == 0)
- {
- bool enabled = true;
- dbus_menu_item_update_enabled(item, enabled);
- }
- else if (g_strcmp0(prop, "icon-name") == 0)
- {
- if (g_hash_table_lookup(item->attrs, HAS_ICON_NAME))
- {
- g_hash_table_remove(item->attrs, G_MENU_ATTRIBUTE_ICON);
- g_hash_table_remove(item->attrs, G_MENU_ATTRIBUTE_VERB_ICON);
- g_hash_table_remove(item->attrs, HAS_ICON_NAME);
- properties_is_updated = true;
- }
- }
- else if (g_strcmp0(prop, "icon-data") == 0)
- {
- if (!g_hash_table_lookup(item->attrs, HAS_ICON_NAME))
- {
- g_hash_table_remove(item->attrs, G_MENU_ATTRIBUTE_ICON);
- g_hash_table_remove(item->attrs, G_MENU_ATTRIBUTE_VERB_ICON);
- properties_is_updated = true;
- }
- }
- else if (g_strcmp0(prop, "label") == 0)
- {
- g_hash_table_remove(item->attrs, G_MENU_ATTRIBUTE_LABEL);
- properties_is_updated = true;
- }
- else if (g_strcmp0(prop, "shortcut") == 0)
- {
- g_hash_table_remove(item->attrs, G_MENU_ATTRIBUTE_ACCEL);
- properties_is_updated = true;
- }
- else if (g_strcmp0(prop, "visible") == 0)
- {
- g_autofree char *name =
- dbus_menu_action_get_name(item->id, item->action_type, false);
- g_hash_table_remove(item->attrs, G_MENU_ATTRIBUTE_HIDDEN_WHEN);
- g_hash_table_insert(item->attrs,
- g_strdup(G_MENU_ATTRIBUTE_ACTION), - g_variant_new_string(name));
- properties_is_updated = true;
- }
- else
- {
- g_debug("removing unsupported property - '%s'", prop); - }
- }
- return properties_is_updated;
-}
-
-G_GNUC_INTERNAL int dbus_menu_item_compare_func(const DBusMenuItem *a, const DBusMenuItem *b,
- gpointer user_data)
-{
- return b->id - a->id;
-}
-
-G_GNUC_INTERNAL int dbus_menu_item_id_compare_func(const DBusMenuItem *a, gconstpointer b,
- gpointer user_data)
-{
- return GPOINTER_TO_UINT(b) - a->id;
-}
-
-G_GNUC_INTERNAL bool dbus_menu_item_compare_immutable(DBusMenuItem *a, DBusMenuItem *b)
-{
- if (a->id != b->id)
- return false;
- if (a->ref_action_group != b->ref_action_group)
- return false;
- if (a->action_type != b->action_type)
- return false;
- return true;
-}
-
-static bool dbus_menu_item_is_submenu(DBusMenuItem *item)
-{
- if (!item)
- return false;
- if (item->action_type != DBUS_MENU_ACTION_SUBMENU)
- return false;
- return true;
-}
-
-G_GNUC_INTERNAL void dbus_menu_item_copy_submenu(DBusMenuItem *src, DBusMenuItem *dst,
- DBusMenuModel *parent)
-{
- DBusMenuXml *xml;
- DBusMenuModel *submenu = NULL;
- g_object_get(parent, "xml", &xml, NULL);
- if (!dbus_menu_item_is_submenu(src))
- {
- if (dst->action_type == DBUS_MENU_ACTION_SUBMENU)
- {
- if (dst->toggled)
- dst->enabled = true;
- submenu = dbus_menu_model_new(dst->id, parent, xml, dst->ref_action_group);
- g_hash_table_insert(dst->links, submenu_str(dst->enabled), submenu);
- }
- return;
- }
- if (dst->action_type == DBUS_MENU_ACTION_SUBMENU &&
- src->action_type == DBUS_MENU_ACTION_SUBMENU)
- {
- if (src->toggled || dst->toggled)
- dst->enabled = dst->toggled = true;
- submenu =
- DBUS_MENU_MODEL(g_hash_table_lookup(src->links, submenu_str(src->enabled)));
- g_hash_table_insert(dst->links, submenu_str(dst->enabled), g_object_ref(submenu));
- g_object_set(submenu, "parent-id", dst->id, NULL);
- }
-}
-
-G_GNUC_INTERNAL void dbus_menu_item_generate_action(DBusMenuItem *item, DBusMenuModel *parent)
-{
- if (item->action_type == DBUS_MENU_ACTION_SECTION)
- return;
- DBusMenuXml *xml;
- DBusMenuModel *submenu = g_hash_table_lookup(item->links, submenu_str(item->enabled));
- g_object_get(parent, "xml", &xml, NULL);
- item->ref_action = dbus_menu_action_reference(item->id,
- xml,
- submenu,
- G_ACTION_MAP(item->ref_action_group),
- item->action_type);
- act_props_try_update(item);
-}
diff -Nru -w vala-panel-appmenu-0.7.6+dfsg1/lib/dbusmenu-importer/item.h vala-panel-appmenu-24.05+dfsg/lib/dbusmenu-importer/item.h
--- vala-panel-appmenu-0.7.6+dfsg1/lib/dbusmenu-importer/item.h 2020-10-28 22:08:48.000000000 +0100
+++ vala-panel-appmenu-24.05+dfsg/lib/dbusmenu-importer/item.h 1970-01-01 01:00:00.000000000 +0100
@@ -1,81 +0,0 @@
-/*
- * vala-panel-appmenu
- * Copyright (C) 2018 Konstantin Pugin <
ria.freelander@gmail.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <
http://www.gnu.org/licenses/>.
- */
-
-#ifndef I