• Bug#1103872: Bug#1103871: unblock: vala-panel/24.05-3 (5/10)

    From Mike Gabriel@21:1/5 to Paul Gevers on Sat Apr 26 07:40:01 2025
    [continued from previous message]

    - if (item->action_type == DBUS_MENU_ACTION_SECTION)
    - {
    - // dbus_menu_model_update_layout(menu);
    - }
    - else
    - {
    - is_item_updated = !is_removal
    - ? dbus_menu_item_update_props(item, props)
    - : dbus_menu_item_remove_props(item, props);
    - if (is_item_updated)
    - add_signal_to_queue(menu,
    - signal_queue,
    - item->section_num, - item->place,
    - 1,
    - 1);
    - }
    - }
    - }
    -}
    -
    -static void items_properties_updated_cb(DBusMenuXml *proxy, GVariant *updated_props,
    - GVariant *removed_props, DBusMenuModel *menu)
    -{
    - if (!DBUS_MENU_IS_XML(proxy))
    - return;
    - if (menu->layout_update_in_progress == true)
    - return;
    - g_autoptr(GQueue) signal_queue = g_queue_new();
    - items_properties_loop(menu, updated_props, signal_queue, false);
    - items_properties_loop(menu, removed_props, signal_queue, true);
    - queue_emit_all(signal_queue);
    -}
    -
    -static void on_xml_property_changed(DBusMenuModel *model)
    -{
    - if (!DBUS_MENU_IS_XML(model->xml))
    - return;
    - g_signal_connect(model->xml,
    - "items-properties-updated",
    - G_CALLBACK(items_properties_updated_cb),
    - model);
    - g_signal_connect(model->xml, "layout-updated", G_CALLBACK(layout_updated_cb), model);
    - g_signal_connect(model->xml,
    - "item-activation-requested",
    - G_CALLBACK(item_activation_requested_cb),
    - model);
    - if (model->parent_id == 0)
    - dbus_menu_model_update_layout(model);
    -}
    -
    -G_GNUC_INTERNAL DBusMenuModel *dbus_menu_model_new(uint parent_id, DBusMenuModel *parent,
    - DBusMenuXml *xml, GActionGroup *action_group)
    -{
    - DBusMenuModel *ret = (DBusMenuModel *)g_object_new(dbus_menu_model_get_type(),
    - "parent-id",
    - parent_id,
    - "xml",
    - xml,
    - "action-group",
    - action_group,
    - NULL);
    - if (parent != NULL)
    - g_object_bind_property(parent, "xml", ret, "xml", G_BINDING_SYNC_CREATE);
    - return ret;
    -}
    -
    -static void dbus_menu_model_set_property(GObject *object, guint property_id, const GValue *value,
    - GParamSpec *pspec)
    -{
    - DBusMenuModel *menu = (DBusMenuModel *)(object);
    - void *old_xml = menu->xml;
    -
    - switch (property_id)
    - {
    - case PROP_XML:
    - menu->xml = DBUS_MENU_XML(g_value_get_object(value));
    - if (menu->xml != NULL && old_xml != menu->xml)
    - {
    - if (old_xml != NULL)
    - g_signal_handlers_disconnect_by_data(old_xml, menu);
    - on_xml_property_changed(menu);
    - }
    - break;
    - case PROP_ACTION_GROUP:
    - menu->received_action_group = G_ACTION_GROUP(g_value_get_object(value));
    - break;
    - case PROP_PARENT_ID:
    - menu->layout_update_required = true;
    - menu->parent_id = g_value_get_uint(value);
    - break;
    - default:
    - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break;
    - }
    -}
    -
    -static void dbus_menu_model_get_property(GObject *object, guint property_id, GValue *value,
    - GParamSpec *pspec)
    -{
    - DBusMenuModel *menu;
    -
    - menu = (DBusMenuModel *)(object);
    -
    - switch (property_id)
    - {
    - case PROP_XML:
    - g_value_set_object(value, menu->xml);
    - break;
    - case PROP_PARENT_ID:
    - g_value_set_uint(value, menu->parent_id);
    - break;
    - case PROP_ACTION_GROUP:
    - g_value_set_object(value, menu->received_action_group);
    - break;
    - default:
    - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break;
    - }
    -}
    -
    -G_GNUC_INTERNAL bool dbus_menu_model_is_layout_update_required(DBusMenuModel *model)
    -{
    - return model->layout_update_required;
    -}
    -
    -G_GNUC_INTERNAL void dbus_menu_model_set_layout_update_required(DBusMenuModel *model, bool required)
    -{
    - model->layout_update_required = required;
    -}
    -
    -static DBusMenuItem *dbus_menu_model_find(DBusMenuModel *menu, uint item_id) -{
    - for (GSequenceIter *iter = g_sequence_get_begin_iter(menu->items);
    - !g_sequence_iter_is_end(iter);
    - iter = g_sequence_iter_next(iter))
    - {
    - DBusMenuItem *item = (DBusMenuItem *)g_sequence_get(iter);
    - if (item->id == item_id)
    - return item;
    - }
    - return NULL;
    -}
    -
    -static GSequenceIter *dbus_menu_model_find_place(DBusMenuModel *menu, uint section_num, int place)
    -{
    - for (GSequenceIter *iter = g_sequence_get_begin_iter(menu->items);
    - !g_sequence_iter_is_end(iter);
    - iter = g_sequence_iter_next(iter))
    - {
    - DBusMenuItem *item = (DBusMenuItem *)g_sequence_get(iter);
    - if (item->section_num == section_num && item->place == place)
    - return iter;
    - }
    - return NULL;
    -}
    -
    -static DBusMenuItem *dbus_menu_model_find_section(DBusMenuModel *menu, uint section_num)
    -{
    - return (DBusMenuItem *)g_sequence_get(dbus_menu_model_find_place(menu, section_num, -1));
    -}
    -
    -static void dbus_menu_model_init(DBusMenuModel *menu)
    -{
    - menu->cancellable = g_cancellable_new();
    - menu->parent_id = UINT_MAX;
    - menu->items = g_sequence_new(dbus_menu_item_free); - menu->layout_update_required = true;
    - menu->layout_update_in_progress = false;
    - menu->current_revision = 0;
    -}
    -
    -static void dbus_menu_model_constructed(GObject *object)
    -{
    - G_OBJECT_CLASS(dbus_menu_model_parent_class)->constructed(object);
    - DBusMenuModel *menu = DBUS_MENU_MODEL(object);
    -
    - DBusMenuItem *first_section =
    - dbus_menu_item_new_first_section(menu->parent_id, menu->received_action_group);
    - first_section->section_num = 0;
    - first_section->place = -1;
    - g_hash_table_insert(first_section->links,
    - G_MENU_LINK_SECTION,
    - dbus_menu_section_model_new(menu, 0));
    - g_sequence_insert_sorted(menu->items, first_section, dbus_menu_model_sort_func, NULL);
    -}
    -
    -static void dbus_menu_model_finalize(GObject *object)
    -{
    - DBusMenuModel *menu = (DBusMenuModel *)(object);
    - if (menu->xml)
    - g_signal_handlers_disconnect_by_data(menu->xml, menu);
    - g_cancellable_cancel(menu->cancellable);
    - g_clear_object(&menu->cancellable);
    - g_clear_pointer(&menu->items, g_sequence_free);
    -
    - G_OBJECT_CLASS(dbus_menu_model_parent_class)->finalize(object);
    -}
    -
    -static void install_properties(GObjectClass *object_class)
    -{
    - properties[PROP_XML] =
    - g_param_spec_object("xml",
    - "xml",
    - "xml",
    - dbus_menu_xml_get_type(),
    - (GParamFlags)(G_PARAM_CONSTRUCT | G_PARAM_READABLE |
    - G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
    -
    - properties[PROP_ACTION_GROUP] =
    - g_param_spec_object("action-group",
    - "action-group",
    - "action-group",
    - g_action_group_get_type(),
    - (GParamFlags)(G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE |
    - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
    - properties[PROP_PARENT_ID] =
    - g_param_spec_uint("parent-id",
    - "parent-id",
    - "parent-id",
    - 0,
    - UINT_MAX,
    - 0,
    - (GParamFlags)(G_PARAM_CONSTRUCT | G_PARAM_WRITABLE |
    - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
    -
    - g_object_class_install_properties(object_class, NUM_PROPS, properties); -}
    -
    -static void dbus_menu_model_class_init(DBusMenuModelClass *klass)
    -{
    - GMenuModelClass *model_class = G_MENU_MODEL_CLASS(klass);
    - GObjectClass *object_class = G_OBJECT_CLASS(klass);
    -
    - object_class->finalize = dbus_menu_model_finalize;
    - object_class->set_property = dbus_menu_model_set_property;
    - object_class->get_property = dbus_menu_model_get_property;
    - object_class->constructed = dbus_menu_model_constructed;
    -
    - model_class->is_mutable = dbus_menu_model_is_mutable;
    - model_class->get_n_items = dbus_menu_model_get_n_items;
    - model_class->get_item_attributes = dbus_menu_model_get_item_attributes; - model_class->get_item_links = dbus_menu_model_get_item_links;
    - install_properties(object_class);
    -}
    diff -Nru -w vala-panel-appmenu-0.7.6+dfsg1/lib/dbusmenu-importer/model.h vala-panel-appmenu-24.05+dfsg/lib/dbusmenu-importer/model.h
    --- vala-panel-appmenu-0.7.6+dfsg1/lib/dbusmenu-importer/model.h 2020-10-28 22:08:48.000000000 +0100
    +++ vala-panel-appmenu-24.05+dfsg/lib/dbusmenu-importer/model.h 1970-01-01 01:00:00.000000000 +0100
    @@ -1,41 +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