r1012@localhost: muntyan | 2005-11-25 16:43:13 -0600
Continuing working on drop destination support
This commit is contained in:
parent
827f25e224
commit
3ca3dcf643
@ -50,7 +50,6 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
MooFileView base;
|
MooFileView base;
|
||||||
MooEditWindow *window;
|
MooEditWindow *window;
|
||||||
|
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
guint open_pane_timeout;
|
guint open_pane_timeout;
|
||||||
} MooFileSelector;
|
} MooFileSelector;
|
||||||
@ -93,23 +92,23 @@ static GObject *moo_file_selector_constructor (GType type,
|
|||||||
guint n_props,
|
guint n_props,
|
||||||
GObjectConstructParam *props);
|
GObjectConstructParam *props);
|
||||||
|
|
||||||
static gboolean moo_file_selector_chdir (MooFileView *fileview,
|
static gboolean moo_file_selector_chdir (MooFileView *fileview,
|
||||||
const char *dir,
|
const char *dir,
|
||||||
GError **error);
|
GError **error);
|
||||||
static void moo_file_selector_activate (MooFileView *fileview,
|
static void moo_file_selector_activate (MooFileView *fileview,
|
||||||
const char *path);
|
const char *path);
|
||||||
|
|
||||||
|
|
||||||
static void button_drag_leave (GtkWidget *button,
|
static void button_drag_leave (GtkWidget *button,
|
||||||
GdkDragContext *context,
|
GdkDragContext *context,
|
||||||
guint time,
|
guint time,
|
||||||
MooFileSelector *filesel);
|
MooFileSelector *filesel);
|
||||||
static gboolean button_drag_motion (GtkWidget *button,
|
static gboolean button_drag_motion (GtkWidget *button,
|
||||||
GdkDragContext *context,
|
GdkDragContext *context,
|
||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
guint time,
|
guint time,
|
||||||
MooFileSelector *filesel);
|
MooFileSelector *filesel);
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -62,6 +62,10 @@ static GtkTargetEntry source_targets[] = {
|
|||||||
{(char*) "text/uri-list", 0, 0}
|
{(char*) "text/uri-list", 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static GtkTargetEntry dest_targets[] = {
|
||||||
|
{(char*) "text/uri-list", 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef struct _History History;
|
typedef struct _History History;
|
||||||
typedef struct _Typeahead Typeahead;
|
typedef struct _Typeahead Typeahead;
|
||||||
@ -255,8 +259,47 @@ static void icon_drag_data_get (MooFileView *fileview,
|
|||||||
guint info,
|
guint info,
|
||||||
guint time,
|
guint time,
|
||||||
MooIconView *iconview);
|
MooIconView *iconview);
|
||||||
|
static void icon_drag_end (MooFileView *fileview,
|
||||||
|
GdkDragContext *context,
|
||||||
|
MooIconView *iconview);
|
||||||
|
|
||||||
|
static void icon_drag_data_received (MooFileView *fileview,
|
||||||
|
GdkDragContext *context,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
GtkSelectionData *data,
|
||||||
|
guint info,
|
||||||
|
guint time,
|
||||||
|
MooIconView *iconview);
|
||||||
|
static gboolean icon_drag_drop (MooFileView *fileview,
|
||||||
|
GdkDragContext *context,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
guint time,
|
||||||
|
MooIconView *iconview);
|
||||||
|
static void icon_drag_leave (MooFileView *fileview,
|
||||||
|
GdkDragContext *context,
|
||||||
|
guint time,
|
||||||
|
MooIconView *iconview);
|
||||||
|
static gboolean icon_drag_motion (MooIconView *iconview,
|
||||||
|
GdkDragContext *context,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
guint time,
|
||||||
|
MooFileView *fileview);
|
||||||
|
static gboolean moo_file_view_drop (MooFileView *fileview,
|
||||||
|
const char *path,
|
||||||
|
GtkWidget *widget,
|
||||||
|
GdkDragContext *context,
|
||||||
|
guint time);
|
||||||
|
static gboolean moo_file_view_drop_data_received
|
||||||
|
(MooFileView *fileview,
|
||||||
|
const char *path,
|
||||||
|
GtkWidget *widget,
|
||||||
|
GdkDragContext *context,
|
||||||
|
GtkSelectionData *data,
|
||||||
|
guint info,
|
||||||
|
guint time);
|
||||||
|
|
||||||
|
|
||||||
/* MOO_TYPE_FILE_VIEW */
|
/* MOO_TYPE_FILE_VIEW */
|
||||||
@ -294,6 +337,8 @@ enum {
|
|||||||
PROPERTIES_DIALOG,
|
PROPERTIES_DIALOG,
|
||||||
DELETE_SELECTED,
|
DELETE_SELECTED,
|
||||||
CREATE_FOLDER,
|
CREATE_FOLDER,
|
||||||
|
DROP,
|
||||||
|
DROP_DATA_RECEIVED,
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -312,6 +357,8 @@ static void moo_file_view_class_init (MooFileViewClass *klass)
|
|||||||
widget_class->popup_menu = moo_file_view_popup_menu;
|
widget_class->popup_menu = moo_file_view_popup_menu;
|
||||||
|
|
||||||
klass->chdir = moo_file_view_chdir_real;
|
klass->chdir = moo_file_view_chdir_real;
|
||||||
|
klass->drop = moo_file_view_drop;
|
||||||
|
klass->drop_data_received = moo_file_view_drop_data_received;
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_HAS_SELECTION,
|
PROP_HAS_SELECTION,
|
||||||
@ -537,6 +584,34 @@ static void moo_file_view_class_init (MooFileViewClass *klass)
|
|||||||
_moo_marshal_VOID__VOID,
|
_moo_marshal_VOID__VOID,
|
||||||
G_TYPE_NONE, 0);
|
G_TYPE_NONE, 0);
|
||||||
|
|
||||||
|
signals[DROP] =
|
||||||
|
g_signal_new ("drop",
|
||||||
|
G_OBJECT_CLASS_TYPE (klass),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
G_STRUCT_OFFSET (MooFileViewClass, drop),
|
||||||
|
g_signal_accumulator_true_handled, NULL,
|
||||||
|
_moo_marshal_BOOLEAN__STRING_OBJECT_OBJECT_UINT,
|
||||||
|
G_TYPE_BOOLEAN, 4,
|
||||||
|
G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
|
||||||
|
GTK_TYPE_WIDGET,
|
||||||
|
GDK_TYPE_DRAG_CONTEXT,
|
||||||
|
G_TYPE_UINT);
|
||||||
|
|
||||||
|
signals[DROP_DATA_RECEIVED] =
|
||||||
|
g_signal_new ("drop-data-received",
|
||||||
|
G_OBJECT_CLASS_TYPE (klass),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
G_STRUCT_OFFSET (MooFileViewClass, drop_data_received),
|
||||||
|
g_signal_accumulator_true_handled, NULL,
|
||||||
|
_moo_marshal_BOOLEAN__STRING_OBJECT_OBJECT_POINTER_UINT_UINT,
|
||||||
|
G_TYPE_BOOLEAN, 6,
|
||||||
|
G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
|
||||||
|
GTK_TYPE_WIDGET,
|
||||||
|
GDK_TYPE_DRAG_CONTEXT,
|
||||||
|
G_TYPE_POINTER,
|
||||||
|
G_TYPE_UINT,
|
||||||
|
G_TYPE_UINT);
|
||||||
|
|
||||||
binding_set = gtk_binding_set_by_class (klass);
|
binding_set = gtk_binding_set_by_class (klass);
|
||||||
|
|
||||||
gtk_binding_entry_add_signal (binding_set,
|
gtk_binding_entry_add_signal (binding_set,
|
||||||
@ -1257,14 +1332,31 @@ create_iconview (MooFileView *fileview)
|
|||||||
source_targets,
|
source_targets,
|
||||||
G_N_ELEMENTS (source_targets),
|
G_N_ELEMENTS (source_targets),
|
||||||
GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
|
GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
|
||||||
|
moo_icon_view_enable_drag_dest (MOO_ICON_VIEW (iconview),
|
||||||
|
dest_targets,
|
||||||
|
G_N_ELEMENTS (dest_targets),
|
||||||
|
GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
|
||||||
g_signal_connect_swapped (iconview, "drag-begin",
|
g_signal_connect_swapped (iconview, "drag-begin",
|
||||||
G_CALLBACK (icon_drag_begin),
|
G_CALLBACK (icon_drag_begin),
|
||||||
fileview);
|
fileview);
|
||||||
g_signal_connect_swapped (iconview, "drag-data-get",
|
g_signal_connect_swapped (iconview, "drag-data-get",
|
||||||
G_CALLBACK (icon_drag_data_get),
|
G_CALLBACK (icon_drag_data_get),
|
||||||
fileview);
|
fileview);
|
||||||
|
g_signal_connect_swapped (iconview, "drag-end",
|
||||||
// targets = moo_icon_view_get_source_targets (MOO_ICON_VIEW (iconview));
|
G_CALLBACK (icon_drag_end),
|
||||||
|
fileview);
|
||||||
|
g_signal_connect_swapped (iconview, "drag-data-received",
|
||||||
|
G_CALLBACK (icon_drag_data_received),
|
||||||
|
fileview);
|
||||||
|
g_signal_connect_swapped (iconview, "drag-drop",
|
||||||
|
G_CALLBACK (icon_drag_drop),
|
||||||
|
fileview);
|
||||||
|
g_signal_connect_swapped (iconview, "drag-leave",
|
||||||
|
G_CALLBACK (icon_drag_leave),
|
||||||
|
fileview);
|
||||||
|
g_signal_connect_after (iconview, "drag-motion",
|
||||||
|
G_CALLBACK (icon_drag_motion),
|
||||||
|
fileview);
|
||||||
|
|
||||||
return iconview;
|
return iconview;
|
||||||
}
|
}
|
||||||
@ -2091,6 +2183,23 @@ static void fileview_set_use_filter (MooFileView *fileview,
|
|||||||
/* File manager functionality
|
/* File manager functionality
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* path in the filter model; result must be unrefed */
|
||||||
|
static MooFile *
|
||||||
|
file_view_get_file_at_path (MooFileView *fileview,
|
||||||
|
GtkTreePath *path)
|
||||||
|
{
|
||||||
|
GtkTreeIter iter;
|
||||||
|
MooFile *file = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (path != NULL, NULL);
|
||||||
|
|
||||||
|
gtk_tree_model_get_iter (fileview->priv->filter_model, &iter, path);
|
||||||
|
gtk_tree_model_get (fileview->priv->filter_model, &iter, COLUMN_FILE, &file, -1);
|
||||||
|
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* returned files must be unrefed and list freed */
|
/* returned files must be unrefed and list freed */
|
||||||
static GList *file_view_get_selected_files (MooFileView *fileview)
|
static GList *file_view_get_selected_files (MooFileView *fileview)
|
||||||
{
|
{
|
||||||
@ -3914,12 +4023,12 @@ static gboolean typeahead_find_match_hidden (MooFileView *fileview,
|
|||||||
|
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
/* Drag'n'drop
|
/* Drag source
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
icon_drag_begin (MooFileView *fileview,
|
icon_drag_begin (MooFileView *fileview,
|
||||||
GdkDragContext *context,
|
G_GNUC_UNUSED GdkDragContext *context,
|
||||||
G_GNUC_UNUSED MooIconView *iconview)
|
G_GNUC_UNUSED MooIconView *iconview)
|
||||||
{
|
{
|
||||||
GList *files, *l;
|
GList *files, *l;
|
||||||
@ -3942,8 +4051,10 @@ icon_drag_begin (MooFileView *fileview,
|
|||||||
uris[i] = moo_folder_get_file_uri (folder, file);
|
uris[i] = moo_folder_get_file_uri (folder, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_set_data_full (G_OBJECT (context), "moo-file-view-source-files",
|
g_object_set_data_full (G_OBJECT (fileview), "moo-file-view-source-uris",
|
||||||
uris, (GDestroyNotify) g_strfreev);
|
uris, (GDestroyNotify) g_strfreev);
|
||||||
|
g_object_set_data_full (G_OBJECT (fileview), "moo-file-view-source-dir",
|
||||||
|
g_object_ref (folder), g_object_unref);
|
||||||
|
|
||||||
g_list_foreach (files, (GFunc) moo_file_unref, NULL);
|
g_list_foreach (files, (GFunc) moo_file_unref, NULL);
|
||||||
g_list_free (files);
|
g_list_free (files);
|
||||||
@ -3951,8 +4062,8 @@ icon_drag_begin (MooFileView *fileview,
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
icon_drag_data_get (G_GNUC_UNUSED MooFileView *fileview,
|
icon_drag_data_get (MooFileView *fileview,
|
||||||
GdkDragContext *context,
|
G_GNUC_UNUSED GdkDragContext *context,
|
||||||
GtkSelectionData *data,
|
GtkSelectionData *data,
|
||||||
G_GNUC_UNUSED guint info,
|
G_GNUC_UNUSED guint info,
|
||||||
G_GNUC_UNUSED guint time,
|
G_GNUC_UNUSED guint time,
|
||||||
@ -3960,8 +4071,197 @@ icon_drag_data_get (G_GNUC_UNUSED MooFileView *fileview,
|
|||||||
{
|
{
|
||||||
char **uris;
|
char **uris;
|
||||||
|
|
||||||
uris = g_object_get_data (G_OBJECT (context), "moo-file-view-source-files");
|
uris = g_object_get_data (G_OBJECT (fileview), "moo-file-view-source-uris");
|
||||||
g_return_if_fail (uris && *uris);
|
g_return_if_fail (uris && *uris);
|
||||||
|
|
||||||
gtk_selection_data_set_uris (data, uris);
|
gtk_selection_data_set_uris (data, uris);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
icon_drag_end (MooFileView *fileview,
|
||||||
|
G_GNUC_UNUSED GdkDragContext *context,
|
||||||
|
G_GNUC_UNUSED MooIconView *iconview)
|
||||||
|
{
|
||||||
|
g_object_set_data (G_OBJECT (fileview), "moo-file-view-source-uris", NULL);
|
||||||
|
g_object_set_data (G_OBJECT (fileview), "moo-file-view-source-dir", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************/
|
||||||
|
/* Drag destination
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
icon_drag_data_received (MooFileView *fileview,
|
||||||
|
GdkDragContext *context,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
GtkSelectionData *data,
|
||||||
|
guint info,
|
||||||
|
guint time,
|
||||||
|
MooIconView *iconview)
|
||||||
|
{
|
||||||
|
gboolean dummy;
|
||||||
|
char *dir = NULL;
|
||||||
|
GtkTreePath *path = NULL;
|
||||||
|
MooFolder *current_dir;
|
||||||
|
|
||||||
|
current_dir = fileview->priv->current_dir;
|
||||||
|
|
||||||
|
if (!current_dir)
|
||||||
|
{
|
||||||
|
g_critical ("%s: oops", G_STRLOC);
|
||||||
|
gtk_drag_finish (context, FALSE, FALSE, time);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (moo_icon_view_get_path_at_pos (iconview, x, y, &path, NULL, NULL, NULL))
|
||||||
|
{
|
||||||
|
MooFile *file = file_view_get_file_at_path (fileview, path);
|
||||||
|
|
||||||
|
if (MOO_FILE_IS_DIR (file))
|
||||||
|
dir = moo_folder_get_file_path (current_dir, file);
|
||||||
|
|
||||||
|
moo_file_unref (file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dir)
|
||||||
|
dir = g_strdup (moo_folder_get_path (current_dir));
|
||||||
|
|
||||||
|
g_signal_emit (fileview, signals[DROP_DATA_RECEIVED], 0,
|
||||||
|
dir, iconview, context, data, info, time, &dummy);
|
||||||
|
|
||||||
|
gtk_tree_path_free (path);
|
||||||
|
g_free (dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
icon_drag_drop (MooFileView *fileview,
|
||||||
|
GdkDragContext *context,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
guint time,
|
||||||
|
MooIconView *iconview)
|
||||||
|
{
|
||||||
|
gboolean dummy;
|
||||||
|
|
||||||
|
char *dir = NULL;
|
||||||
|
GtkTreePath *path = NULL;
|
||||||
|
MooFolder *current_dir;
|
||||||
|
|
||||||
|
current_dir = fileview->priv->current_dir;
|
||||||
|
|
||||||
|
if (!current_dir)
|
||||||
|
{
|
||||||
|
g_critical ("%s: oops", G_STRLOC);
|
||||||
|
gtk_drag_finish (context, FALSE, FALSE, time);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (moo_icon_view_get_path_at_pos (iconview, x, y, &path, NULL, NULL, NULL))
|
||||||
|
{
|
||||||
|
MooFile *file = file_view_get_file_at_path (fileview, path);
|
||||||
|
|
||||||
|
if (MOO_FILE_IS_DIR (file))
|
||||||
|
dir = moo_folder_get_file_path (current_dir, file);
|
||||||
|
|
||||||
|
moo_file_unref (file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dir)
|
||||||
|
dir = g_strdup (moo_folder_get_path (current_dir));
|
||||||
|
|
||||||
|
g_signal_emit (fileview, signals[DROP], 0, dir, iconview, context, time, &dummy);
|
||||||
|
moo_icon_view_set_drag_dest_row (iconview, NULL);
|
||||||
|
|
||||||
|
gtk_tree_path_free (path);
|
||||||
|
g_free (dir);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
moo_file_view_drop (G_GNUC_UNUSED MooFileView *fileview,
|
||||||
|
G_GNUC_UNUSED const char *path,
|
||||||
|
GtkWidget *widget,
|
||||||
|
GdkDragContext *context,
|
||||||
|
guint time)
|
||||||
|
{
|
||||||
|
gtk_drag_get_data (widget, context,
|
||||||
|
gdk_atom_intern ("text/uri-list", FALSE),
|
||||||
|
time);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
moo_file_view_drop_data_received (MooFileView *fileview,
|
||||||
|
const char *path,
|
||||||
|
GtkWidget *widget,
|
||||||
|
GdkDragContext *context,
|
||||||
|
GtkSelectionData *data,
|
||||||
|
guint info,
|
||||||
|
guint time)
|
||||||
|
{
|
||||||
|
g_print ("got uris dropped to %s!!!\n", path);
|
||||||
|
gtk_drag_finish (context, FALSE, FALSE, time);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
icon_drag_leave (G_GNUC_UNUSED MooFileView *fileview,
|
||||||
|
G_GNUC_UNUSED GdkDragContext *context,
|
||||||
|
G_GNUC_UNUSED guint time,
|
||||||
|
MooIconView *iconview)
|
||||||
|
{
|
||||||
|
moo_icon_view_set_drag_dest_row (iconview, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
icon_drag_motion (MooIconView *iconview,
|
||||||
|
GdkDragContext *context,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
guint time,
|
||||||
|
MooFileView *fileview)
|
||||||
|
{
|
||||||
|
MooFolder *source_dir;
|
||||||
|
MooFolder *current_dir;
|
||||||
|
GtkTreePath *path = NULL;
|
||||||
|
gboolean drag_to_current_dir = TRUE;
|
||||||
|
|
||||||
|
current_dir = fileview->priv->current_dir;
|
||||||
|
source_dir = g_object_get_data (G_OBJECT (fileview), "moo-file-view-source-dir");
|
||||||
|
|
||||||
|
if (!current_dir)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (moo_icon_view_get_path_at_pos (iconview, x, y, &path, NULL, NULL, NULL))
|
||||||
|
{
|
||||||
|
MooFile *file = file_view_get_file_at_path (fileview, path);
|
||||||
|
|
||||||
|
if (MOO_FILE_IS_DIR (file))
|
||||||
|
drag_to_current_dir = FALSE;
|
||||||
|
|
||||||
|
moo_file_unref (file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (drag_to_current_dir)
|
||||||
|
moo_icon_view_set_drag_dest_row (iconview, NULL);
|
||||||
|
else
|
||||||
|
moo_icon_view_set_drag_dest_row (iconview, path);
|
||||||
|
|
||||||
|
if (!drag_to_current_dir || source_dir != current_dir)
|
||||||
|
gdk_drag_status (context, context->suggested_action, time);
|
||||||
|
else
|
||||||
|
gdk_drag_status (context, 0, time);
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (path)
|
||||||
|
gtk_tree_path_free (path);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
@ -41,8 +41,8 @@ typedef struct _MooFileViewClass MooFileViewClass;
|
|||||||
|
|
||||||
struct _MooFileView
|
struct _MooFileView
|
||||||
{
|
{
|
||||||
GtkVBox vbox;
|
GtkVBox vbox;
|
||||||
GtkWidget *toolbar;
|
GtkWidget *toolbar;
|
||||||
MooFileViewPrivate *priv;
|
MooFileViewPrivate *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -50,17 +50,27 @@ struct _MooFileViewClass
|
|||||||
{
|
{
|
||||||
GtkVBoxClass vbox_class;
|
GtkVBoxClass vbox_class;
|
||||||
|
|
||||||
/* methods */
|
|
||||||
gboolean (*chdir) (MooFileView *fileview,
|
gboolean (*chdir) (MooFileView *fileview,
|
||||||
const char *dir,
|
const char *dir,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
/* signals */
|
|
||||||
void (*populate_popup) (MooFileView *fileview,
|
void (*populate_popup) (MooFileView *fileview,
|
||||||
GList *selected,
|
GList *selected,
|
||||||
GtkMenu *menu);
|
GtkMenu *menu);
|
||||||
void (*activate) (MooFileView *fileview,
|
void (*activate) (MooFileView *fileview,
|
||||||
const char *path);
|
const char *path);
|
||||||
|
|
||||||
|
gboolean (*drop) (MooFileView *fileview,
|
||||||
|
const char *path,
|
||||||
|
GtkWidget *widget,
|
||||||
|
GdkDragContext *context,
|
||||||
|
guint time);
|
||||||
|
gboolean (*drop_data_received) (MooFileView *fileview,
|
||||||
|
const char *path,
|
||||||
|
GtkWidget *widget,
|
||||||
|
GdkDragContext *context,
|
||||||
|
GtkSelectionData *data,
|
||||||
|
guint info,
|
||||||
|
guint time);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,6 +68,9 @@ struct _DndInfo {
|
|||||||
GtkTargetList *source_targets;
|
GtkTargetList *source_targets;
|
||||||
GdkDragAction source_actions;
|
GdkDragAction source_actions;
|
||||||
|
|
||||||
|
guint scroll_timeout;
|
||||||
|
|
||||||
|
guint drag_dest_inside : 1;
|
||||||
guint source_enabled : 1;
|
guint source_enabled : 1;
|
||||||
guint dest_enabled : 1;
|
guint dest_enabled : 1;
|
||||||
};
|
};
|
||||||
@ -90,6 +93,7 @@ struct _MooIconViewPrivate {
|
|||||||
Layout *layout;
|
Layout *layout;
|
||||||
Selection *selection;
|
Selection *selection;
|
||||||
GtkTreeRowReference *cursor;
|
GtkTreeRowReference *cursor;
|
||||||
|
GtkTreeRowReference *drop_dest;
|
||||||
|
|
||||||
gboolean mapped;
|
gboolean mapped;
|
||||||
|
|
||||||
@ -155,6 +159,7 @@ static gboolean moo_icon_view_drag_motion (GtkWidget *widget,
|
|||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
guint time);
|
guint time);
|
||||||
|
static void drag_scroll_stop (MooIconView *view);
|
||||||
|
|
||||||
static void row_changed (GtkTreeModel *model,
|
static void row_changed (GtkTreeModel *model,
|
||||||
GtkTreePath *path,
|
GtkTreePath *path,
|
||||||
@ -262,10 +267,10 @@ static void moo_icon_view_class_init (MooIconViewClass *klass)
|
|||||||
widget_class->motion_notify_event = moo_icon_view_motion_notify;
|
widget_class->motion_notify_event = moo_icon_view_motion_notify;
|
||||||
widget_class->drag_begin = moo_icon_view_drag_begin;
|
widget_class->drag_begin = moo_icon_view_drag_begin;
|
||||||
widget_class->drag_end = moo_icon_view_drag_end;
|
widget_class->drag_end = moo_icon_view_drag_end;
|
||||||
// widget_class->drag_data_received = moo_icon_drag_data_received;
|
widget_class->drag_data_received = moo_icon_drag_data_received;
|
||||||
// widget_class->drag_drop = moo_icon_view_drag_drop;
|
widget_class->drag_drop = moo_icon_view_drag_drop;
|
||||||
// widget_class->drag_leave = moo_icon_view_drag_leave;
|
widget_class->drag_leave = moo_icon_view_drag_leave;
|
||||||
// widget_class->drag_motion = moo_icon_view_drag_motion;
|
widget_class->drag_motion = moo_icon_view_drag_motion;
|
||||||
|
|
||||||
klass->set_scroll_adjustments = moo_icon_view_set_scroll_adjustments;
|
klass->set_scroll_adjustments = moo_icon_view_set_scroll_adjustments;
|
||||||
|
|
||||||
@ -448,8 +453,6 @@ static void moo_icon_view_init (MooIconView *view)
|
|||||||
|
|
||||||
view->priv = g_new0 (MooIconViewPrivate, 1);
|
view->priv = g_new0 (MooIconViewPrivate, 1);
|
||||||
|
|
||||||
view->priv->model = NULL;
|
|
||||||
|
|
||||||
view->priv->pixbuf.cell = gtk_cell_renderer_pixbuf_new ();
|
view->priv->pixbuf.cell = gtk_cell_renderer_pixbuf_new ();
|
||||||
gtk_object_sink (g_object_ref (view->priv->pixbuf.cell));
|
gtk_object_sink (g_object_ref (view->priv->pixbuf.cell));
|
||||||
view->priv->pixbuf.attributes = NULL;
|
view->priv->pixbuf.attributes = NULL;
|
||||||
@ -476,7 +479,6 @@ static void moo_icon_view_init (MooIconView *view)
|
|||||||
|
|
||||||
init_layout (view);
|
init_layout (view);
|
||||||
init_selection (view);
|
init_selection (view);
|
||||||
view->priv->cursor = NULL;
|
|
||||||
|
|
||||||
view->priv->dnd_info = g_new0 (DndInfo, 1);
|
view->priv->dnd_info = g_new0 (DndInfo, 1);
|
||||||
}
|
}
|
||||||
@ -506,6 +508,7 @@ static void moo_icon_view_finalize (GObject *object)
|
|||||||
free_selection (view);
|
free_selection (view);
|
||||||
gtk_tree_row_reference_free (view->priv->cursor);
|
gtk_tree_row_reference_free (view->priv->cursor);
|
||||||
gtk_tree_row_reference_free (view->priv->scroll_to);
|
gtk_tree_row_reference_free (view->priv->scroll_to);
|
||||||
|
gtk_tree_row_reference_free (view->priv->drop_dest);
|
||||||
|
|
||||||
if (view->priv->dnd_info->source_targets)
|
if (view->priv->dnd_info->source_targets)
|
||||||
gtk_target_list_unref (view->priv->dnd_info->source_targets);
|
gtk_target_list_unref (view->priv->dnd_info->source_targets);
|
||||||
@ -634,9 +637,12 @@ void moo_icon_view_set_model (MooIconView *view,
|
|||||||
|
|
||||||
selection_clear (view);
|
selection_clear (view);
|
||||||
|
|
||||||
if (view->priv->cursor)
|
gtk_tree_row_reference_free (view->priv->cursor);
|
||||||
gtk_tree_row_reference_free (view->priv->cursor);
|
gtk_tree_row_reference_free (view->priv->drop_dest);
|
||||||
|
gtk_tree_row_reference_free (view->priv->scroll_to);
|
||||||
view->priv->cursor = NULL;
|
view->priv->cursor = NULL;
|
||||||
|
view->priv->drop_dest = NULL;
|
||||||
|
view->priv->scroll_to = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model)
|
if (model)
|
||||||
@ -1057,19 +1063,24 @@ static void draw_entry (MooIconView *view,
|
|||||||
GtkWidget *widget = GTK_WIDGET (view);
|
GtkWidget *widget = GTK_WIDGET (view);
|
||||||
GdkRectangle cell_area = *entry_rect;
|
GdkRectangle cell_area = *entry_rect;
|
||||||
GtkCellRendererState state = 0;
|
GtkCellRendererState state = 0;
|
||||||
GtkTreePath *cursor_path;
|
GtkTreePath *cursor_path, *drop_path;
|
||||||
gboolean selected, cursor;
|
gboolean selected, cursor, drop;
|
||||||
|
|
||||||
selected = moo_icon_view_path_is_selected (view, path);
|
selected = moo_icon_view_path_is_selected (view, path);
|
||||||
|
|
||||||
cursor_path = moo_icon_view_get_cursor (view);
|
cursor_path = moo_icon_view_get_cursor (view);
|
||||||
cursor = (cursor_path != NULL && !gtk_tree_path_compare (cursor_path, path));
|
cursor = cursor_path != NULL && !gtk_tree_path_compare (cursor_path, path);
|
||||||
gtk_tree_path_free (cursor_path);
|
gtk_tree_path_free (cursor_path);
|
||||||
|
|
||||||
if (selected)
|
drop_path = moo_icon_view_get_drop_dest_row (view);
|
||||||
|
drop = drop_path != NULL && !gtk_tree_path_compare (drop_path, path);
|
||||||
|
gtk_tree_path_free (drop_path);
|
||||||
|
|
||||||
|
if (selected || drop)
|
||||||
{
|
{
|
||||||
GdkGC *selection_gc;
|
GdkGC *selection_gc;
|
||||||
|
|
||||||
if (GTK_WIDGET_HAS_FOCUS (widget))
|
if (GTK_WIDGET_HAS_FOCUS (widget) || drop)
|
||||||
{
|
{
|
||||||
selection_gc = widget->style->base_gc [GTK_STATE_SELECTED];
|
selection_gc = widget->style->base_gc [GTK_STATE_SELECTED];
|
||||||
state = GTK_CELL_RENDERER_SELECTED | GTK_CELL_RENDERER_FOCUSED;
|
state = GTK_CELL_RENDERER_SELECTED | GTK_CELL_RENDERER_FOCUSED;
|
||||||
@ -1122,7 +1133,7 @@ static void draw_entry (MooIconView *view,
|
|||||||
state);
|
state);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cursor)
|
if (cursor || drop)
|
||||||
{
|
{
|
||||||
gtk_paint_focus (widget->style,
|
gtk_paint_focus (widget->style,
|
||||||
widget->window,
|
widget->window,
|
||||||
@ -1461,6 +1472,7 @@ static void row_changed (G_GNUC_UNUSED GtkTreeModel *model,
|
|||||||
if (gtk_tree_path_get_depth (path) != 1)
|
if (gtk_tree_path_get_depth (path) != 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
drag_scroll_stop (view);
|
||||||
moo_icon_view_invalidate_layout (view);
|
moo_icon_view_invalidate_layout (view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1479,6 +1491,7 @@ static void row_deleted (G_GNUC_UNUSED GtkTreeModel *model,
|
|||||||
!GTK_WIDGET_MAPPED (view))
|
!GTK_WIDGET_MAPPED (view))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
drag_scroll_stop (view);
|
||||||
moo_icon_view_invalidate_layout (view);
|
moo_icon_view_invalidate_layout (view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1495,6 +1508,7 @@ static void row_inserted (G_GNUC_UNUSED GtkTreeModel *model,
|
|||||||
if (gtk_tree_path_get_depth (path) != 1)
|
if (gtk_tree_path_get_depth (path) != 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
drag_scroll_stop (view);
|
||||||
moo_icon_view_invalidate_layout (view);
|
moo_icon_view_invalidate_layout (view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1512,6 +1526,7 @@ static void rows_reordered (G_GNUC_UNUSED GtkTreeModel *model,
|
|||||||
if (gtk_tree_path_get_depth (path) != 0)
|
if (gtk_tree_path_get_depth (path) != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
drag_scroll_stop (view);
|
||||||
moo_icon_view_invalidate_layout (view);
|
moo_icon_view_invalidate_layout (view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1687,6 +1702,7 @@ moo_icon_view_motion_notify (GtkWidget *widget,
|
|||||||
GdkEventMotion *event)
|
GdkEventMotion *event)
|
||||||
{
|
{
|
||||||
MooIconView *view = MOO_ICON_VIEW (widget);
|
MooIconView *view = MOO_ICON_VIEW (widget);
|
||||||
|
drag_scroll_stop (view);
|
||||||
return moo_icon_view_maybe_drag (view, event);
|
return moo_icon_view_maybe_drag (view, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2357,15 +2373,15 @@ moo_icon_view_set_selection_mode (MooIconView *view,
|
|||||||
if (!view->priv->model || model_empty (view->priv->model))
|
if (!view->priv->model || model_empty (view->priv->model))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (mode == GTK_SELECTION_MULTIPLE)
|
||||||
|
return;
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case GTK_SELECTION_NONE:
|
case GTK_SELECTION_NONE:
|
||||||
moo_icon_view_unselect_all (view);
|
moo_icon_view_unselect_all (view);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case GTK_SELECTION_MULTIPLE:
|
|
||||||
return;
|
|
||||||
|
|
||||||
case GTK_SELECTION_BROWSE:
|
case GTK_SELECTION_BROWSE:
|
||||||
case GTK_SELECTION_SINGLE:
|
case GTK_SELECTION_SINGLE:
|
||||||
break;
|
break;
|
||||||
@ -2988,7 +3004,6 @@ static void
|
|||||||
moo_icon_view_drag_end (G_GNUC_UNUSED GtkWidget *widget,
|
moo_icon_view_drag_end (G_GNUC_UNUSED GtkWidget *widget,
|
||||||
G_GNUC_UNUSED GdkDragContext *context)
|
G_GNUC_UNUSED GdkDragContext *context)
|
||||||
{
|
{
|
||||||
g_print ("drag-end!!!!\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3041,42 +3056,144 @@ moo_icon_view_disable_drag_dest (MooIconView *view)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// static void
|
static void
|
||||||
// moo_icon_drag_data_received (G_GNUC_UNUSED GtkWidget *widget,
|
moo_icon_drag_data_received (G_GNUC_UNUSED GtkWidget *widget,
|
||||||
// G_GNUC_UNUSED GdkDragContext *context,
|
G_GNUC_UNUSED GdkDragContext *context,
|
||||||
// G_GNUC_UNUSED int x,
|
G_GNUC_UNUSED int x,
|
||||||
// G_GNUC_UNUSED int y,
|
G_GNUC_UNUSED int y,
|
||||||
// G_GNUC_UNUSED GtkSelectionData *data,
|
G_GNUC_UNUSED GtkSelectionData *data,
|
||||||
// G_GNUC_UNUSED guint info,
|
G_GNUC_UNUSED guint info,
|
||||||
// G_GNUC_UNUSED guint time)
|
G_GNUC_UNUSED guint time)
|
||||||
// {
|
{
|
||||||
// }
|
g_print ("drag-data-received\n");
|
||||||
//
|
}
|
||||||
//
|
|
||||||
// static gboolean
|
|
||||||
// moo_icon_view_drag_drop (GtkWidget *widget,
|
static gboolean
|
||||||
// GdkDragContext *context,
|
moo_icon_view_drag_drop (G_GNUC_UNUSED GtkWidget *widget,
|
||||||
// int x,
|
G_GNUC_UNUSED GdkDragContext *context,
|
||||||
// int y,
|
G_GNUC_UNUSED int x,
|
||||||
// guint time)
|
G_GNUC_UNUSED int y,
|
||||||
// {
|
G_GNUC_UNUSED guint time)
|
||||||
// return FALSE;
|
{
|
||||||
// }
|
g_print ("drag-drop\n");
|
||||||
//
|
return FALSE;
|
||||||
//
|
}
|
||||||
// static void
|
|
||||||
// moo_icon_view_drag_leave (GtkWidget *widget,
|
|
||||||
// GdkDragContext *context,
|
static void
|
||||||
// guint time)
|
moo_icon_view_drag_leave (G_GNUC_UNUSED GtkWidget *widget,
|
||||||
// {
|
G_GNUC_UNUSED GdkDragContext *context,
|
||||||
// }
|
G_GNUC_UNUSED guint time)
|
||||||
//
|
{
|
||||||
//
|
DndInfo *info;
|
||||||
// static gboolean
|
MooIconView *view = MOO_ICON_VIEW (widget);
|
||||||
// moo_icon_view_drag_motion (GtkWidget *widget,
|
|
||||||
// GdkDragContext *context,
|
info = view->priv->dnd_info;
|
||||||
// int x,
|
|
||||||
// int y,
|
if (!info->drag_dest_inside)
|
||||||
// guint time)
|
g_warning ("drag_leave: oops\n");
|
||||||
// {
|
|
||||||
// }
|
info->drag_dest_inside = FALSE;
|
||||||
|
drag_scroll_stop (view);
|
||||||
|
|
||||||
|
g_print ("drag-leave\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
drag_scroll_check (G_GNUC_UNUSED MooIconView *view,
|
||||||
|
G_GNUC_UNUSED int x,
|
||||||
|
G_GNUC_UNUSED int y)
|
||||||
|
{
|
||||||
|
g_print ("drag_scroll_check\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
moo_icon_view_drag_motion (GtkWidget *widget,
|
||||||
|
G_GNUC_UNUSED GdkDragContext *context,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
G_GNUC_UNUSED guint time)
|
||||||
|
{
|
||||||
|
DndInfo *info;
|
||||||
|
MooIconView *view = MOO_ICON_VIEW (widget);
|
||||||
|
|
||||||
|
info = view->priv->dnd_info;
|
||||||
|
|
||||||
|
if (!info->drag_dest_inside)
|
||||||
|
{
|
||||||
|
info->drag_dest_inside = TRUE;
|
||||||
|
g_print ("drag-enter\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
drag_scroll_check (view, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_print ("drag-motion\n");
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
drag_scroll_stop (MooIconView *view)
|
||||||
|
{
|
||||||
|
DndInfo *info = view->priv->dnd_info;
|
||||||
|
|
||||||
|
if (info->scroll_timeout)
|
||||||
|
{
|
||||||
|
g_source_remove (info->scroll_timeout);
|
||||||
|
info->scroll_timeout = 0;
|
||||||
|
g_print ("drag_scroll_stop\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
moo_icon_view_set_drag_dest_row (MooIconView *view,
|
||||||
|
GtkTreePath *path)
|
||||||
|
{
|
||||||
|
GtkTreeRowReference *ref = NULL;
|
||||||
|
|
||||||
|
g_return_if_fail (MOO_IS_ICON_VIEW (view));
|
||||||
|
|
||||||
|
if (path)
|
||||||
|
ref = gtk_tree_row_reference_new (view->priv->model, path);
|
||||||
|
|
||||||
|
if (view->priv->drop_dest)
|
||||||
|
{
|
||||||
|
GtkTreePath *old_path;
|
||||||
|
|
||||||
|
old_path = gtk_tree_row_reference_get_path (view->priv->drop_dest);
|
||||||
|
|
||||||
|
if (old_path)
|
||||||
|
{
|
||||||
|
invalidate_path_rectangle (view, old_path);
|
||||||
|
gtk_tree_path_free (old_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_tree_row_reference_free (view->priv->drop_dest);
|
||||||
|
view->priv->drop_dest = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ref)
|
||||||
|
{
|
||||||
|
view->priv->drop_dest = ref;
|
||||||
|
invalidate_path_rectangle (view, path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GtkTreePath *
|
||||||
|
moo_icon_view_get_drop_dest_row (MooIconView *view)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MOO_IS_ICON_VIEW (view), NULL);
|
||||||
|
|
||||||
|
if (view->priv->drop_dest)
|
||||||
|
return gtk_tree_row_reference_get_path (view->priv->drop_dest);
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
@ -158,6 +158,9 @@ void moo_icon_view_enable_drag_dest (MooIconView *view,
|
|||||||
GdkDragAction actions);
|
GdkDragAction actions);
|
||||||
GtkTargetList *moo_icon_view_get_dest_targets (MooIconView *view);
|
GtkTargetList *moo_icon_view_get_dest_targets (MooIconView *view);
|
||||||
void moo_icon_view_disable_drag_dest (MooIconView *view);
|
void moo_icon_view_disable_drag_dest (MooIconView *view);
|
||||||
|
void moo_icon_view_set_drag_dest_row (MooIconView *view,
|
||||||
|
GtkTreePath *path);
|
||||||
|
GtkTreePath *moo_icon_view_get_drop_dest_row (MooIconView *view);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
@ -5,6 +5,8 @@ BOOL:INT
|
|||||||
BOOL:OBJECT,OBJECT
|
BOOL:OBJECT,OBJECT
|
||||||
BOOL:STRING
|
BOOL:STRING
|
||||||
BOOL:STRING,BOOL
|
BOOL:STRING,BOOL
|
||||||
|
BOOL:STRING,OBJECT,OBJECT,UINT
|
||||||
|
BOOL:STRING,OBJECT,OBJECT,POINTER,UINT,UINT
|
||||||
BOOL:STRING,POINTER
|
BOOL:STRING,POINTER
|
||||||
BOOL:VOID
|
BOOL:VOID
|
||||||
BOOL:VOID
|
BOOL:VOID
|
||||||
|
Loading…
x
Reference in New Issue
Block a user