- Sample Codes
Sample Code 459: How to drag and drop between two thumbnail images using GtkIconView with GtkTreeModelFilter - Part 1 - left to right append?
|Written by kksou|
|Last Update: Friday, 21 March 2008|
This is in response to Wim Stockman's post titled "Drag Drop between 2 filtered GtkIconViews".
This solution is similar to that of How to drag and drop between two thumbnail images using GtkIconView - Part 1 - left to right append?
The only difference is that this one uses GtkTreeModelFilter on top of a GtkListStore. This allows filtering of selected thumbnail images in the GtkIconView as shown below.
In this Part 1, I'll show how to drag and drop images from left to right only. Also, in this example, the dropped images will be appended to the end of the dropped view. In Part 2, I'll show you how to insert image at the dropped location.
The following image files are required by the sample code below. Please save a copy of the image files and put them in the same directory where you store the sample code.
This example make use of the techniques from the following two articles:
What's new here:
Gtk-WARNING **: You must override the default 'drag_data_received' handler on GtkIconView when using models that don't support the GtkTreeDragDest interface and enabling drag-and-drop. The simplest way to do this is to connect to 'drag_data_received' and call g_signal_stop_emission_by_name() in your signal handler to prevent the default handler from running. Look at the source code for the default handler in gtkiconview.c to get an idea what your handler should do. (gtkiconview.c is in the GTK+ source code.) If you're using GTK+ from a language other than C, there may be a more natural way to override default handlers, e.g. via derivation.
What a long error message!
|< Prev||Next >|