forked from AuroraMiddleware/gtk
Test DND.
2005-05-06 Matthias Clasen <mclasen@redhat.com> * tests/testiconview.c: Test DND. * gtk/gtk.symbols: * gtk/gtkiconview.[hc]: Add DND support similar to the DND support in the tree view. (#150270)
This commit is contained in:
parent
f8e922f9ec
commit
3e77a18b4a
@ -1,3 +1,9 @@
|
||||
2005-05-06 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtk.symbols:
|
||||
* gtk/gtkiconview.[hc]: Add DND support similar to the DND
|
||||
support in the tree view. (#150270)
|
||||
|
||||
2005-05-05 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtktreednd.h:
|
||||
|
@ -1,3 +1,9 @@
|
||||
2005-05-06 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtk.symbols:
|
||||
* gtk/gtkiconview.[hc]: Add DND support similar to the DND
|
||||
support in the tree view. (#150270)
|
||||
|
||||
2005-05-05 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtktreednd.h:
|
||||
|
@ -1,3 +1,9 @@
|
||||
2005-05-06 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtk.symbols:
|
||||
* gtk/gtkiconview.[hc]: Add DND support similar to the DND
|
||||
support in the tree view. (#150270)
|
||||
|
||||
2005-05-05 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtktreednd.h:
|
||||
|
@ -1,3 +1,7 @@
|
||||
2005-05-06 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtk-sections.txt: Add new icon view API.
|
||||
|
||||
2005-05-05 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/tmpl/gtkmenutoolbutton.sgml: Trivial fix (#303168,
|
||||
|
@ -1670,6 +1670,18 @@ gtk_icon_view_get_selected_items
|
||||
gtk_icon_view_select_all
|
||||
gtk_icon_view_unselect_all
|
||||
gtk_icon_view_item_activated
|
||||
<SUBSECTION Dnd>
|
||||
gtk_icon_view_enable_model_drag_source
|
||||
gtk_icon_view_enable_model_drag_dest
|
||||
gtk_icon_view_unset_model_drag_source
|
||||
gtk_icon_view_unset_model_drag_dest
|
||||
gtk_icon_view_set_reorderable
|
||||
gtk_icon_view_get_reorderable
|
||||
gtk_icon_view_set_drag_dest_item
|
||||
gtk_icon_view_get_drag_dest_item
|
||||
gtk_icon_view_get_dest_item_at_pos
|
||||
gtk_icon_view_create_drag_icon
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_ICON_VIEW_CLASS
|
||||
GTK_IS_ICON_VIEW
|
||||
|
@ -1692,6 +1692,16 @@ gtk_icon_view_set_spacing
|
||||
gtk_icon_view_set_text_column
|
||||
gtk_icon_view_unselect_all
|
||||
gtk_icon_view_unselect_path
|
||||
gtk_icon_view_enable_model_drag_source
|
||||
gtk_icon_view_enable_model_drag_dest
|
||||
gtk_icon_view_unset_model_drag_source
|
||||
gtk_icon_view_unset_model_drag_dest
|
||||
gtk_icon_view_set_reorderable
|
||||
gtk_icon_view_get_reorderable
|
||||
gtk_icon_view_set_drag_dest_item
|
||||
gtk_icon_view_get_drag_dest_item
|
||||
gtk_icon_view_get_dest_item_at_pos
|
||||
gtk_icon_view_create_drag_icon
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
1622
gtk/gtkiconview.c
1622
gtk/gtkiconview.c
File diff suppressed because it is too large
Load Diff
@ -22,6 +22,7 @@
|
||||
#include <gtk/gtkcontainer.h>
|
||||
#include <gtk/gtktreemodel.h>
|
||||
#include <gtk/gtkcellrenderer.h>
|
||||
#include <gtk/gtkselection.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -40,6 +41,16 @@ typedef void (* GtkIconViewForeachFunc) (GtkIconView *icon_view,
|
||||
GtkTreePath *path,
|
||||
gpointer data);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GTK_ICON_VIEW_NO_DROP,
|
||||
GTK_ICON_VIEW_DROP_INTO,
|
||||
GTK_ICON_VIEW_DROP_LEFT,
|
||||
GTK_ICON_VIEW_DROP_RIGHT,
|
||||
GTK_ICON_VIEW_DROP_ABOVE,
|
||||
GTK_ICON_VIEW_DROP_BELOW
|
||||
} GtkIconViewDropPosition;
|
||||
|
||||
struct _GtkIconView
|
||||
{
|
||||
GtkContainer parent;
|
||||
@ -144,6 +155,39 @@ gboolean gtk_icon_view_get_cursor (GtkIconView *icon_
|
||||
GtkTreePath **path,
|
||||
GtkCellRenderer **cell);
|
||||
|
||||
/* Drag-and-Drop support */
|
||||
void gtk_icon_view_enable_model_drag_source (GtkIconView *icon_view,
|
||||
GdkModifierType start_button_mask,
|
||||
const GtkTargetEntry *targets,
|
||||
gint n_targets,
|
||||
GdkDragAction actions);
|
||||
void gtk_icon_view_enable_model_drag_dest (GtkIconView *icon_view,
|
||||
const GtkTargetEntry *targets,
|
||||
gint n_targets,
|
||||
GdkDragAction actions);
|
||||
void gtk_icon_view_unset_model_drag_source (GtkIconView *icon_view);
|
||||
void gtk_icon_view_unset_model_drag_dest (GtkIconView *icon_view);
|
||||
void gtk_icon_view_set_reorderable (GtkIconView *icon_view,
|
||||
gboolean reorderable);
|
||||
gboolean gtk_icon_view_get_reorderable (GtkIconView *icon_view);
|
||||
|
||||
|
||||
/* These are useful to implement your own custom stuff. */
|
||||
void gtk_icon_view_set_drag_dest_item (GtkIconView *icon_view,
|
||||
GtkTreePath *path,
|
||||
GtkIconViewDropPosition pos);
|
||||
void gtk_icon_view_get_drag_dest_item (GtkIconView *icon_view,
|
||||
GtkTreePath **path,
|
||||
GtkIconViewDropPosition *pos);
|
||||
gboolean gtk_icon_view_get_dest_item_at_pos (GtkIconView *icon_view,
|
||||
gint drag_x,
|
||||
gint drag_y,
|
||||
GtkTreePath **path,
|
||||
GtkIconViewDropPosition *pos);
|
||||
GdkPixmap *gtk_icon_view_create_drag_icon (GtkIconView *icon_view,
|
||||
GtkTreePath *path);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_ICON_VIEW_H__ */
|
||||
|
@ -66,7 +66,7 @@ fill_model (GtkTreeModel *model)
|
||||
i++;
|
||||
}
|
||||
|
||||
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), 2, GTK_SORT_ASCENDING);
|
||||
// gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), 2, GTK_SORT_ASCENDING);
|
||||
}
|
||||
|
||||
static GtkTreeModel *
|
||||
@ -390,16 +390,21 @@ popup_menu_handler (GtkWidget *widget)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static const GtkTargetEntry item_targets[] = {
|
||||
{ "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_APP, 0 }
|
||||
};
|
||||
|
||||
gint
|
||||
main (gint argc, gchar **argv)
|
||||
{
|
||||
GtkWidget *paned;
|
||||
GtkWidget *paned, *tv;
|
||||
GtkWidget *window, *icon_list, *scrolled_window;
|
||||
GtkWidget *vbox, *bbox;
|
||||
GtkWidget *button;
|
||||
GtkWidget *prop_editor;
|
||||
GtkTreeModel *model;
|
||||
GtkCellRenderer *cell;
|
||||
GtkTreeViewColumn *tvc;
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
@ -419,6 +424,10 @@ main (gint argc, gchar **argv)
|
||||
icon_list = gtk_icon_view_new ();
|
||||
gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (icon_list), GTK_SELECTION_MULTIPLE);
|
||||
|
||||
tv = gtk_tree_view_new ();
|
||||
tvc = gtk_tree_view_column_new ();
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (tv), tvc);
|
||||
|
||||
g_signal_connect_after (icon_list, "button_press_event",
|
||||
G_CALLBACK (button_press_event_handler), NULL);
|
||||
g_signal_connect (icon_list, "selection_changed",
|
||||
@ -431,6 +440,7 @@ main (gint argc, gchar **argv)
|
||||
|
||||
model = create_model ();
|
||||
gtk_icon_view_set_model (GTK_ICON_VIEW (icon_list), model);
|
||||
gtk_tree_view_set_model (GTK_TREE_VIEW (tv), model);
|
||||
fill_model (model);
|
||||
|
||||
#if 0
|
||||
@ -466,7 +476,52 @@ main (gint argc, gchar **argv)
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (icon_list),
|
||||
cell, "text", 1, NULL);
|
||||
g_signal_connect (cell, "edited", G_CALLBACK (edited), model);
|
||||
|
||||
/* now the tree view... */
|
||||
cell = gtk_cell_renderer_toggle_new ();
|
||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (tvc), cell, FALSE);
|
||||
g_object_set (cell, "activatable", TRUE, NULL);
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (tvc),
|
||||
cell, "active", 4, NULL);
|
||||
g_signal_connect (cell, "toggled", G_CALLBACK (toggled), model);
|
||||
|
||||
cell = gtk_cell_renderer_pixbuf_new ();
|
||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (tvc), cell, FALSE);
|
||||
g_object_set (cell,
|
||||
"follow-state", TRUE,
|
||||
NULL);
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (tvc),
|
||||
cell, "pixbuf", 0, NULL);
|
||||
|
||||
cell = gtk_cell_renderer_text_new ();
|
||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (tvc), cell, FALSE);
|
||||
g_object_set (cell, "editable", TRUE, NULL);
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (tvc),
|
||||
cell, "text", 1, NULL);
|
||||
g_signal_connect (cell, "edited", G_CALLBACK (edited), model);
|
||||
#endif
|
||||
/* Allow DND between the icon view and the tree view */
|
||||
|
||||
gtk_icon_view_enable_model_drag_source (icon_list,
|
||||
GDK_BUTTON1_MASK,
|
||||
item_targets,
|
||||
G_N_ELEMENTS (item_targets),
|
||||
GDK_ACTION_MOVE);
|
||||
gtk_icon_view_enable_model_drag_dest (icon_list,
|
||||
item_targets,
|
||||
G_N_ELEMENTS (item_targets),
|
||||
GDK_ACTION_MOVE);
|
||||
|
||||
gtk_tree_view_enable_model_drag_source (tv,
|
||||
GDK_BUTTON1_MASK,
|
||||
item_targets,
|
||||
G_N_ELEMENTS (item_targets),
|
||||
GDK_ACTION_MOVE);
|
||||
gtk_tree_view_enable_model_drag_dest (tv,
|
||||
item_targets,
|
||||
G_N_ELEMENTS (item_targets),
|
||||
GDK_ACTION_MOVE);
|
||||
|
||||
|
||||
prop_editor = create_prop_editor (G_OBJECT (icon_list), 0);
|
||||
gtk_widget_show_all (prop_editor);
|
||||
@ -478,6 +533,13 @@ main (gint argc, gchar **argv)
|
||||
|
||||
gtk_paned_add1 (GTK_PANED (paned), scrolled_window);
|
||||
|
||||
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (scrolled_window), tv);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
|
||||
gtk_paned_add2 (GTK_PANED (paned), scrolled_window);
|
||||
|
||||
bbox = gtk_hbutton_box_new ();
|
||||
gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_START);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user