Commit c4f886f8 authored by Pavel Cisler's avatar Pavel Cisler Committed by Pavel Cisler
Browse files

Fixed 1095 - need to draw dragged icon when dragging from list view.

2000-07-05  Pavel Cisler  <pavel@eazel.com>

	* libnautilus-extensions/nautilus-list.c:
	(nautilus_list_initialize_class), (nautilus_list_button_press),
	(nautilus_list_button_release), (nautilus_list_drag_start):
	* libnautilus-extensions/nautilus-list.h:
	* src/file-manager/fm-list-view.c: (fm_list_drag_data_get),
	(fm_list_get_drag_pixmap), (create_list):
	Fixed 1095 - need to draw dragged icon when dragging from list view.

	* libnautilus-extensions/nautilus-gtk-extensions.c:
	* libnautilus-extensions/nautilus-gtk-extensions.h:
	(nautilus_gtk_marshal_NONE__POINTER_INT_POINTER_POINTER):
	I swore the next time I need a new marshaling function, I'll
	set Nautilus to auto-generate them like the gtk build and here
	I am adding another one manually.
parent 00e2f4e2
2000-07-05 Pavel Cisler <pavel@eazel.com>
* libnautilus-extensions/nautilus-list.c:
(nautilus_list_initialize_class), (nautilus_list_button_press),
(nautilus_list_button_release), (nautilus_list_drag_start):
* libnautilus-extensions/nautilus-list.h:
* src/file-manager/fm-list-view.c: (fm_list_drag_data_get),
(fm_list_get_drag_pixmap), (create_list):
Fixed 1095 - need to draw dragged icon when dragging from list view.
* libnautilus-extensions/nautilus-gtk-extensions.c:
* libnautilus-extensions/nautilus-gtk-extensions.h:
(nautilus_gtk_marshal_NONE__POINTER_INT_POINTER_POINTER):
I swore the next time I need a new marshaling function, I'll
set Nautilus to auto-generate them like the gtk build and here
I am adding another one manually.
2000-07-05 Maciej Stachowiak <mjs@eazel.com>
* libnautilus-extensions/nautilus-search-async.c: include
......
......@@ -453,6 +453,21 @@ nautilus_gtk_marshal_NONE__POINTER_INT_INT_INT (GtkObject *object,
func_data);
}
void
nautilus_gtk_marshal_NONE__POINTER_INT_POINTER_POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args)
{
(* (void (*)(GtkObject *, gpointer, int, gpointer, gpointer, gpointer)) func)
(object,
GTK_VALUE_POINTER (args[0]),
GTK_VALUE_INT (args[1]),
GTK_VALUE_POINTER (args[2]),
GTK_VALUE_POINTER (args[3]),
func_data);
}
void
nautilus_gtk_marshal_NONE__POINTER_POINTER_INT_INT_INT (GtkObject *object,
GtkSignalFunc func,
......
......@@ -155,6 +155,10 @@ void nautilus_gtk_marshal_NONE__POINTER_POINTER_POINTER
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_NONE__POINTER_INT_POINTER_POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_NONE__POINTER_POINTER_POINTER_POINTER_POINTER_POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
......
......@@ -85,6 +85,7 @@ struct NautilusListDetails
/* Drag state */
NautilusDragInfo *drag_info;
gboolean drag_started;
int clicked_row;
/* Delayed selection information */
int dnd_select_pending;
......@@ -159,6 +160,7 @@ enum {
SELECT_PREVIOUS_NAME,
SELECT_NEXT_NAME,
HANDLE_DROPPED_ICONS,
GET_DRAG_PIXMAP,
LAST_SIGNAL
};
......@@ -354,6 +356,17 @@ nautilus_list_initialize_class (NautilusListClass *klass)
GTK_TYPE_INT,
GTK_TYPE_INT,
GTK_TYPE_INT);
list_signals[GET_DRAG_PIXMAP] =
gtk_signal_new ("get_drag_pixmap",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusListClass, get_drag_pixmap),
nautilus_gtk_marshal_NONE__POINTER_INT_POINTER_POINTER,
GTK_TYPE_NONE, 4,
GTK_TYPE_POINTER,
GTK_TYPE_INT,
GTK_TYPE_POINTER,
GTK_TYPE_POINTER);
gtk_object_class_add_signals (object_class, list_signals, LAST_SIGNAL);
......@@ -740,7 +753,8 @@ nautilus_list_button_press (GtkWidget *widget, GdkEventButton *event)
on_row = gtk_clist_get_selection_info (clist, event->x, event->y, &row_index, &column_index);
list->details->button_down_time = event->time;
list->details->drag_started = FALSE;
list->details->clicked_row = -1;
switch (event->type) {
case GDK_BUTTON_PRESS:
if (event->button == 1 || event->button == 2) {
......@@ -771,6 +785,7 @@ nautilus_list_button_press (GtkWidget *widget, GdkEventButton *event)
if (!list->details->dnd_select_pending) {
select_row_from_mouse (list, row_index, event->state);
list->details->clicked_row = row_index;
}
} else {
gtk_clist_unselect_all (clist);
......@@ -855,6 +870,7 @@ nautilus_list_button_release (GtkWidget *widget, GdkEventButton *event)
list->details->dnd_press_x = 0;
list->details->dnd_press_y = 0;
list->details->drag_started = TRUE;
list->details->clicked_row = -1;
if (on_row) {
/* Clean up after abortive drag-and-drop attempt (since user can't
......@@ -2107,11 +2123,6 @@ nautilus_list_resize_column (GtkCList *clist, int column_index, int width)
}
/* Macros borrowed from gtkclist.c */
/* returns the GList item for the nth row */
#define ROW_ELEMENT(clist, row) (((row) == (clist)->rows - 1) ? \
(clist)->row_list_end : \
g_list_nth ((clist)->row_list, (row)))
#define GTK_CLIST_CLASS_FW(_widget_) GTK_CLIST_CLASS (((GtkObject*) (_widget_))->klass)
......@@ -2288,15 +2299,12 @@ nautilus_list_drag_start (GtkWidget *widget, GdkEventMotion *event)
{
NautilusList *list;
GdkDragContext *context;
GdkPixbuf *pixbuf;
GdkPixmap *pixmap_for_dragged_file;
GdkBitmap *mask_for_dragged_file;
int x_offset, y_offset;
g_return_if_fail (NAUTILUS_IS_LIST (widget));
list = NAUTILUS_LIST (widget);
pixbuf = NULL;
list->details->drag_started = TRUE;
list->details->dnd_select_pending = FALSE;
......@@ -2308,12 +2316,11 @@ nautilus_list_drag_start (GtkWidget *widget, GdkEventMotion *event)
x_offset = 10;
y_offset = 10;
if (pixbuf) {
gdk_pixbuf_render_pixmap_and_mask (pixbuf,
&pixmap_for_dragged_file,
&mask_for_dragged_file,
2);
gtk_signal_emit (GTK_OBJECT (list), list_signals[GET_DRAG_PIXMAP],
list->details->clicked_row, &pixmap_for_dragged_file,
&mask_for_dragged_file);
if (pixmap_for_dragged_file) {
/* set the pixmap and mask for dragging */
gtk_drag_set_icon_pixmap (context,
gtk_widget_get_colormap (widget),
......
......@@ -56,6 +56,11 @@ typedef enum
#define NAUTILUS_CELL_PIXBUF_LIST(cell) ((NautilusCellPixbufList *) &(cell))
/* no #define for NAUTILUS_CELL_LINK_TEXT, use GTK_CELL_TEXT instead */
/* returns the GList item for the nth row */
#define ROW_ELEMENT(clist, row) (((row) == (clist)->rows - 1) ? \
(clist)->row_list_end : \
g_list_nth ((clist)->row_list, (row)))
typedef struct NautilusCellPixbufList NautilusCellPixbufList;
/* no struct for NautilusCellLinkText, use GtkCellText instead */
......@@ -113,6 +118,7 @@ struct NautilusListClass {
void (* select_previous_name) (GtkWidget *widget);
void (* select_next_name) (GtkWidget *widget);
void (* handle_dropped_icons) (GtkWidget *widget, GList *icons, int x, int y, int action);
void (* get_drag_pixmap) (GtkWidget *widget, int row_index, GdkPixmap **pixmap, GdkBitmap **mask);
};
typedef gboolean (* NautilusEachRowFunction) (GtkCListRow *, gpointer);
......
......@@ -453,6 +453,21 @@ nautilus_gtk_marshal_NONE__POINTER_INT_INT_INT (GtkObject *object,
func_data);
}
void
nautilus_gtk_marshal_NONE__POINTER_INT_POINTER_POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args)
{
(* (void (*)(GtkObject *, gpointer, int, gpointer, gpointer, gpointer)) func)
(object,
GTK_VALUE_POINTER (args[0]),
GTK_VALUE_INT (args[1]),
GTK_VALUE_POINTER (args[2]),
GTK_VALUE_POINTER (args[3]),
func_data);
}
void
nautilus_gtk_marshal_NONE__POINTER_POINTER_INT_INT_INT (GtkObject *object,
GtkSignalFunc func,
......
......@@ -155,6 +155,10 @@ void nautilus_gtk_marshal_NONE__POINTER_POINTER_POINTER
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_NONE__POINTER_INT_POINTER_POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
void nautilus_gtk_marshal_NONE__POINTER_POINTER_POINTER_POINTER_POINTER_POINTER (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
......
......@@ -85,6 +85,7 @@ struct NautilusListDetails
/* Drag state */
NautilusDragInfo *drag_info;
gboolean drag_started;
int clicked_row;
/* Delayed selection information */
int dnd_select_pending;
......@@ -159,6 +160,7 @@ enum {
SELECT_PREVIOUS_NAME,
SELECT_NEXT_NAME,
HANDLE_DROPPED_ICONS,
GET_DRAG_PIXMAP,
LAST_SIGNAL
};
......@@ -354,6 +356,17 @@ nautilus_list_initialize_class (NautilusListClass *klass)
GTK_TYPE_INT,
GTK_TYPE_INT,
GTK_TYPE_INT);
list_signals[GET_DRAG_PIXMAP] =
gtk_signal_new ("get_drag_pixmap",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusListClass, get_drag_pixmap),
nautilus_gtk_marshal_NONE__POINTER_INT_POINTER_POINTER,
GTK_TYPE_NONE, 4,
GTK_TYPE_POINTER,
GTK_TYPE_INT,
GTK_TYPE_POINTER,
GTK_TYPE_POINTER);
gtk_object_class_add_signals (object_class, list_signals, LAST_SIGNAL);
......@@ -740,7 +753,8 @@ nautilus_list_button_press (GtkWidget *widget, GdkEventButton *event)
on_row = gtk_clist_get_selection_info (clist, event->x, event->y, &row_index, &column_index);
list->details->button_down_time = event->time;
list->details->drag_started = FALSE;
list->details->clicked_row = -1;
switch (event->type) {
case GDK_BUTTON_PRESS:
if (event->button == 1 || event->button == 2) {
......@@ -771,6 +785,7 @@ nautilus_list_button_press (GtkWidget *widget, GdkEventButton *event)
if (!list->details->dnd_select_pending) {
select_row_from_mouse (list, row_index, event->state);
list->details->clicked_row = row_index;
}
} else {
gtk_clist_unselect_all (clist);
......@@ -855,6 +870,7 @@ nautilus_list_button_release (GtkWidget *widget, GdkEventButton *event)
list->details->dnd_press_x = 0;
list->details->dnd_press_y = 0;
list->details->drag_started = TRUE;
list->details->clicked_row = -1;
if (on_row) {
/* Clean up after abortive drag-and-drop attempt (since user can't
......@@ -2107,11 +2123,6 @@ nautilus_list_resize_column (GtkCList *clist, int column_index, int width)
}
/* Macros borrowed from gtkclist.c */
/* returns the GList item for the nth row */
#define ROW_ELEMENT(clist, row) (((row) == (clist)->rows - 1) ? \
(clist)->row_list_end : \
g_list_nth ((clist)->row_list, (row)))
#define GTK_CLIST_CLASS_FW(_widget_) GTK_CLIST_CLASS (((GtkObject*) (_widget_))->klass)
......@@ -2288,15 +2299,12 @@ nautilus_list_drag_start (GtkWidget *widget, GdkEventMotion *event)
{
NautilusList *list;
GdkDragContext *context;
GdkPixbuf *pixbuf;
GdkPixmap *pixmap_for_dragged_file;
GdkBitmap *mask_for_dragged_file;
int x_offset, y_offset;
g_return_if_fail (NAUTILUS_IS_LIST (widget));
list = NAUTILUS_LIST (widget);
pixbuf = NULL;
list->details->drag_started = TRUE;
list->details->dnd_select_pending = FALSE;
......@@ -2308,12 +2316,11 @@ nautilus_list_drag_start (GtkWidget *widget, GdkEventMotion *event)
x_offset = 10;
y_offset = 10;
if (pixbuf) {
gdk_pixbuf_render_pixmap_and_mask (pixbuf,
&pixmap_for_dragged_file,
&mask_for_dragged_file,
2);
gtk_signal_emit (GTK_OBJECT (list), list_signals[GET_DRAG_PIXMAP],
list->details->clicked_row, &pixmap_for_dragged_file,
&mask_for_dragged_file);
if (pixmap_for_dragged_file) {
/* set the pixmap and mask for dragging */
gtk_drag_set_icon_pixmap (context,
gtk_widget_get_colormap (widget),
......
......@@ -56,6 +56,11 @@ typedef enum
#define NAUTILUS_CELL_PIXBUF_LIST(cell) ((NautilusCellPixbufList *) &(cell))
/* no #define for NAUTILUS_CELL_LINK_TEXT, use GTK_CELL_TEXT instead */
/* returns the GList item for the nth row */
#define ROW_ELEMENT(clist, row) (((row) == (clist)->rows - 1) ? \
(clist)->row_list_end : \
g_list_nth ((clist)->row_list, (row)))
typedef struct NautilusCellPixbufList NautilusCellPixbufList;
/* no struct for NautilusCellLinkText, use GtkCellText instead */
......@@ -113,6 +118,7 @@ struct NautilusListClass {
void (* select_previous_name) (GtkWidget *widget);
void (* select_next_name) (GtkWidget *widget);
void (* handle_dropped_icons) (GtkWidget *widget, GList *icons, int x, int y, int action);
void (* get_drag_pixmap) (GtkWidget *widget, int row_index, GdkPixmap **pixmap, GdkBitmap **mask);
};
typedef gboolean (* NautilusEachRowFunction) (GtkCListRow *, gpointer);
......
......@@ -610,8 +610,8 @@ each_icon_get_data_binder (NautilusDragEachSelectedItemDataGet iteratee,
static void
fm_list_drag_data_get (GtkWidget *widget, GdkDragContext *context,
GtkSelectionData *selection_data, guint info, guint time,
FMListView *list_view)
GtkSelectionData *selection_data, guint info, guint time,
FMListView *list_view)
{
g_assert (widget != NULL);
g_assert (NAUTILUS_IS_LIST (widget));
......@@ -625,6 +625,26 @@ fm_list_drag_data_get (GtkWidget *widget, GdkDragContext *context,
info, time, widget, each_icon_get_data_binder);
}
static void
fm_list_get_drag_pixmap (GtkWidget *widget, int row_index, GdkPixmap **pixmap,
GdkBitmap **mask, FMListView *list_view)
{
GtkCList *clist;
GtkCListRow *row;
g_assert (widget != NULL);
g_assert (NAUTILUS_IS_LIST (widget));
clist = GTK_CLIST (widget);
row = ROW_ELEMENT (clist, row_index)->data;
g_assert (row != NULL);
*pixmap = GTK_CELL_PIXMAP (row->cell[LIST_VIEW_COLUMN_ICON])->pixmap;
*mask = GTK_CELL_PIXMAP (row->cell[LIST_VIEW_COLUMN_ICON])->mask;
}
static void
create_list (FMListView *list_view)
{
......@@ -754,7 +774,10 @@ create_list (FMListView *list_view)
"drag_data_get",
fm_list_drag_data_get,
list_view);
gtk_signal_connect (GTK_OBJECT (list),
"get_drag_pixmap",
fm_list_get_drag_pixmap,
list_view);
gtk_container_add (GTK_CONTAINER (list_view), GTK_WIDGET (list));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment