From dc477f32c21a116d6358841f46d1c3cabb882469 Mon Sep 17 00:00:00 2001 From: sid Date: Mon, 3 Jun 2024 09:29:16 +0100 Subject: [PATCH] Remove libegg multidrag treeview support for in-built 'GtkFileChooser' This fixes the following message while using the 'GtkFileChooser' within brasero. (brasero:571263): GLib-GObject-CRITICAL **: 11:29:32.207: attempting to add an interface (EggTreeMultiDragSource) to class (GtkFileSystemModel) after class_init This is due to the fact that GLib removed support for adding interfaces to object types after the class has been initialized ( around GLib 2.35 / 2.36 ). Since then, this code never worked. And the model used by 'GtkFileChooser' ('GtkFileSystemModel') is private to GLib. So, any attempts to add libegg multidrag interface to 'GtkFileSystemModel' via 'g_type_add_interface_static ()' before class initialization is not possible anymore. So, we remove the non-working code. With this change, single row drag works as expected. So, atleast it would be consistent with 'GtkFileChooser' behaviour elsewhere. Refer: https://gitlab.gnome.org/GNOME/glib/-/issues/624 Refer: https://gitlab.gnome.org/GNOME/gtk/-/issues/217 --- src/brasero-file-chooser.c | 52 +------------------------------------- src/brasero-multi-dnd.c | 9 ------- src/brasero-multi-dnd.h | 3 --- 3 files changed, 1 insertion(+), 63 deletions(-) diff --git a/src/brasero-file-chooser.c b/src/brasero-file-chooser.c index b658dafea..124295ad2 100644 --- a/src/brasero-file-chooser.c +++ b/src/brasero-file-chooser.c @@ -211,60 +211,10 @@ brasero_file_chooser_allocation_changed (GtkWidget *widget, brasero_file_chooser_position_percent (G_OBJECT (widget), width, position); } -static void -brasero_file_chooser_notify_model (GtkTreeView *treeview, - GParamSpec *pspec, - gpointer NULL_data) -{ - GtkTreeModel *model; - - model = gtk_tree_view_get_model (treeview); - if (model && !EGG_IS_TREE_MULTI_DRAG_SOURCE (model)) { - GType type; - - type = G_OBJECT_TYPE (model); - brasero_enable_multi_DND_for_model_type (type); - } -} - void brasero_file_chooser_customize (GtkWidget *widget, gpointer null_data) { - /* we explore everything until we reach a treeview (there are two) */ - if (GTK_IS_TREE_VIEW (widget)) { - GtkTargetList *list; - GdkAtom target; - gboolean found; - guint num; - - list = gtk_drag_source_get_target_list (widget); - target = gdk_atom_intern ("text/uri-list", TRUE); - found = gtk_target_list_find (list, target, &num); - /* FIXME: should we unref them ? apparently not according to - * the warning messages we get if we do */ - - if (found - && gtk_tree_selection_get_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (widget))) == GTK_SELECTION_MULTIPLE) { - GtkTreeModel *model; - - /* This is done because GtkFileChooser does not use a - * GtkListStore or GtkTreeStore any more. */ - egg_tree_multi_drag_add_drag_support (GTK_TREE_VIEW (widget)); - model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); - if (model) { - GType type; - - type = G_OBJECT_TYPE (model); - brasero_enable_multi_DND_for_model_type (type); - } - else - g_signal_connect (widget, - "notify::model", - G_CALLBACK (brasero_file_chooser_notify_model), - NULL); - } - } - else if (GTK_IS_BUTTON (widget)) { + if (GTK_IS_BUTTON (widget)) { GtkWidget *image; gchar *stock_id = NULL; diff --git a/src/brasero-multi-dnd.c b/src/brasero-multi-dnd.c index bf7b6a2d8..bf8fe9ce2 100644 --- a/src/brasero-multi-dnd.c +++ b/src/brasero-multi-dnd.c @@ -200,15 +200,6 @@ static const GInterfaceInfo brasero_data_track_cfg_multi_DND_drag_source_info = NULL }; -gboolean -brasero_enable_multi_DND_for_model_type (GType type) -{ - g_type_add_interface_static (type, - EGG_TYPE_TREE_MULTI_DRAG_SOURCE, - &multi_DND_drag_source_info); - return TRUE; -} - void brasero_enable_multi_DND (void) { diff --git a/src/brasero-multi-dnd.h b/src/brasero-multi-dnd.h index 8a37637c3..507d93e8c 100644 --- a/src/brasero-multi-dnd.h +++ b/src/brasero-multi-dnd.h @@ -33,9 +33,6 @@ G_BEGIN_DECLS void brasero_enable_multi_DND (void); -gboolean -brasero_enable_multi_DND_for_model_type (GType type); - G_END_DECLS #endif /* _MULTI_DND_H */ -- GitLab