mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-10 05:23:03 +03:00
- Make input handling work nicely on the icon list.
- First pass at the new drag and drop protocol, using the default handlers, more work on this tomorrow.
This commit is contained in:
parent
215cd45d16
commit
e591c91db2
@ -1,3 +1,16 @@
|
|||||||
|
1998-10-20 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||||
|
|
||||||
|
|
||||||
|
1998-10-19 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||||
|
|
||||||
|
* gscreen.c (panel_drag_data_get): New routine to provide data
|
||||||
|
with the new DnD protocol.
|
||||||
|
|
||||||
|
* gmain.c (dialog_key_pressed): If an icon has the focus, then do
|
||||||
|
not process any of our events.
|
||||||
|
Only stop the signal if we actually handled the event.
|
||||||
|
(dialog_key_pressed):
|
||||||
|
|
||||||
1998-10-14 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
1998-10-14 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||||
|
|
||||||
* gscreen.c (panel_icon_renamed): Add support for renaming files.
|
* gscreen.c (panel_icon_renamed): Add support for renaming files.
|
||||||
|
@ -781,7 +781,9 @@ static void
|
|||||||
start_icon_drag (GtkWidget *wi, GdkEventMotion *event)
|
start_icon_drag (GtkWidget *wi, GdkEventMotion *event)
|
||||||
{
|
{
|
||||||
printf ("MOTION NOTIF!\n");
|
printf ("MOTION NOTIF!\n");
|
||||||
|
#ifdef OLD_DND
|
||||||
artificial_drag_start (wi->window, event->x, event->y);
|
artificial_drag_start (wi->window, event->x, event->y);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkPoint root_icon_drag_hotspot = { 15, 15 };
|
GdkPoint root_icon_drag_hotspot = { 15, 15 };
|
||||||
@ -1058,6 +1060,7 @@ post_setup_desktop_icon (desktop_icon_t *di, int show)
|
|||||||
|
|
||||||
/* Setup the widget to make it useful: */
|
/* Setup the widget to make it useful: */
|
||||||
|
|
||||||
|
#ifdef OLD_DND
|
||||||
/* 1. Drag and drop functionality */
|
/* 1. Drag and drop functionality */
|
||||||
|
|
||||||
child = gtk_container_children(GTK_CONTAINER(di->widget));
|
child = gtk_container_children(GTK_CONTAINER(di->widget));
|
||||||
@ -1070,6 +1073,7 @@ post_setup_desktop_icon (desktop_icon_t *di, int show)
|
|||||||
if (show)
|
if (show)
|
||||||
gtk_widget_show (di->widget);
|
gtk_widget_show (di->widget);
|
||||||
|
|
||||||
|
#endif
|
||||||
/* lower the window */
|
/* lower the window */
|
||||||
gdk_window_lower (di->widget->window);
|
gdk_window_lower (di->widget->window);
|
||||||
}
|
}
|
||||||
@ -1438,9 +1442,11 @@ desktop_root (void)
|
|||||||
GtkWidget *rw;
|
GtkWidget *rw;
|
||||||
|
|
||||||
rw = gnome_rootwin_new ();
|
rw = gnome_rootwin_new ();
|
||||||
|
#ifdef OLD_DND
|
||||||
connect_drop_signals (rw, NULL);
|
connect_drop_signals (rw, NULL);
|
||||||
gtk_widget_realize (rw);
|
gtk_widget_realize (rw);
|
||||||
gtk_widget_dnd_drop_set (rw, TRUE, root_drop_types, ELEMENTS (root_drop_types), FALSE);
|
gtk_widget_dnd_drop_set (rw, TRUE, root_drop_types, ELEMENTS (root_drop_types), FALSE);
|
||||||
|
#endif
|
||||||
gtk_widget_show (rw);
|
gtk_widget_show (rw);
|
||||||
root_window = GNOME_ROOTWIN (rw);
|
root_window = GNOME_ROOTWIN (rw);
|
||||||
}
|
}
|
||||||
|
@ -103,9 +103,8 @@ xtoolkit_init (int *argc, char *argv [])
|
|||||||
"so dont even report them, when the major design has finished\n"
|
"so dont even report them, when the major design has finished\n"
|
||||||
"I will remove this notice\n");
|
"I will remove this notice\n");
|
||||||
|
|
||||||
/* gnome_init ("gmc", NULL, *argc, argv, 0, NULL); */
|
|
||||||
gmc_color_init ();
|
gmc_color_init ();
|
||||||
/* FIXME: Maybe this should return something from gnome_init() */
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,12 +114,39 @@ xtoolkit_end (void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Keystroke event handler for all of the Gtk widgets created by
|
||||||
|
* the GNOME Midnight Commander. A special case is handled at
|
||||||
|
* the top
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
dialog_key_pressed (GtkWidget *win, GdkEventKey *event, Dlg_head *h)
|
dialog_key_pressed (GtkWidget *win, GdkEventKey *event, Dlg_head *h)
|
||||||
{
|
{
|
||||||
|
GtkWidget *w;
|
||||||
static int on_escape;
|
static int on_escape;
|
||||||
int key;
|
int key;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Find out if the focused widget is an IconList and
|
||||||
|
* if so, check if it has a currently focused item is
|
||||||
|
* on editing mode as we do not want to handle key
|
||||||
|
* events while the icon name is being edited.
|
||||||
|
*/
|
||||||
|
w = win;
|
||||||
|
while (w && (GTK_IS_CONTAINER (w) && !GNOME_IS_ICON_LIST (w)))
|
||||||
|
w = GTK_CONTAINER (w)->focus_child;
|
||||||
|
|
||||||
|
if (w && GNOME_IS_ICON_LIST (w)){
|
||||||
|
GnomeCanvas *c = GNOME_CANVAS (w);
|
||||||
|
|
||||||
|
if (GNOME_IS_ICON_TEXT_ITEM (c->focused_item)){
|
||||||
|
GnomeIconTextItem *i = GNOME_ICON_TEXT_ITEM (c->focused_item);
|
||||||
|
|
||||||
|
if (i->editing)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
key = translate_gdk_keysym_to_curses (event);
|
key = translate_gdk_keysym_to_curses (event);
|
||||||
if (key == -1)
|
if (key == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -146,10 +172,10 @@ dialog_key_pressed (GtkWidget *win, GdkEventKey *event, Dlg_head *h)
|
|||||||
on_escape = 0;
|
on_escape = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dlg_key_event (h, key)){
|
||||||
gtk_signal_emit_stop_by_name (GTK_OBJECT (win), "key_press_event");
|
gtk_signal_emit_stop_by_name (GTK_OBJECT (win), "key_press_event");
|
||||||
if (dlg_key_event (h, key))
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
else
|
} else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,8 +59,22 @@ static GdkImlibImage *icon_view_regular;
|
|||||||
static GdkImlibImage *icon_view_core;
|
static GdkImlibImage *icon_view_core;
|
||||||
static GdkImlibImage *icon_view_sock;
|
static GdkImlibImage *icon_view_sock;
|
||||||
|
|
||||||
|
#ifdef OLD_DND
|
||||||
static char *drag_types [] = { "text/plain", "file:ALL", "url:ALL" };
|
static char *drag_types [] = { "text/plain", "file:ALL", "url:ALL" };
|
||||||
static char *drop_types [] = { "url:ALL" };
|
static char *drop_types [] = { "url:ALL" };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
enum {
|
||||||
|
TARGET_URI_LIST,
|
||||||
|
TARGET_URL_LIST,
|
||||||
|
TARGET_TEXT_PLAIN,
|
||||||
|
};
|
||||||
|
|
||||||
|
static GtkTargetEntry drag_types [] = {
|
||||||
|
{ "text/uri-list", 0, TARGET_URI_LIST },
|
||||||
|
{ "text/url-list", 0, TARGET_URL_LIST },
|
||||||
|
{ "text/plain", 0, TARGET_TEXT_PLAIN },
|
||||||
|
};
|
||||||
|
|
||||||
#define ELEMENTS(x) (sizeof (x) / sizeof (x[0]))
|
#define ELEMENTS(x) (sizeof (x) / sizeof (x[0]))
|
||||||
|
|
||||||
@ -931,34 +945,81 @@ panel_configure_file_list (WPanel *panel, GtkWidget *file_list)
|
|||||||
GTK_SIGNAL_FUNC (panel_file_list_scrolled), panel);
|
GTK_SIGNAL_FUNC (panel_file_list_scrolled), panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates an uri list to be transfered during a drop operation.
|
||||||
|
*/
|
||||||
static void *
|
static void *
|
||||||
panel_build_selected_file_list (WPanel *panel, int *file_list_len)
|
panel_build_selected_file_list (WPanel *panel, int *file_list_len)
|
||||||
{
|
{
|
||||||
if (panel->marked){
|
if (panel->marked){
|
||||||
|
char *sep = "\r\n";
|
||||||
char *data, *copy;
|
char *data, *copy;
|
||||||
int i, total_len = 0;
|
int i, total_len;
|
||||||
int cwdlen = strlen (panel->cwd) + 1;
|
int cwdlen = strlen (panel->cwd) + 1;
|
||||||
|
int filelen = strlen ("file:");
|
||||||
|
int seplen = strlen ("\r\n");
|
||||||
|
|
||||||
/* first pass, compute the length */
|
/* first pass, compute the length */
|
||||||
|
total_len = 0;
|
||||||
for (i = 0; i < panel->count; i++)
|
for (i = 0; i < panel->count; i++)
|
||||||
if (panel->dir.list [i].f.marked)
|
if (panel->dir.list [i].f.marked)
|
||||||
total_len += (cwdlen + panel->dir.list [i].fnamelen + 1);
|
total_len += (filelen + cwdlen + panel->dir.list [i].fnamelen + seplen);
|
||||||
|
|
||||||
|
total_len++;
|
||||||
data = copy = xmalloc (total_len, "build_selected_file_list");
|
data = copy = xmalloc (total_len, "build_selected_file_list");
|
||||||
for (i = 0; i < panel->count; i++)
|
for (i = 0; i < panel->count; i++)
|
||||||
if (panel->dir.list [i].f.marked){
|
if (panel->dir.list [i].f.marked){
|
||||||
strcpy (copy, panel->cwd);
|
strcpy (copy, "file:");
|
||||||
copy [cwdlen-1] = '/';
|
strcpy (© [filelen], panel->cwd);
|
||||||
strcpy (© [cwdlen], panel->dir.list [i].fname);
|
copy [filelen+cwdlen-1] = '/';
|
||||||
copy += panel->dir.list [i].fnamelen + 1 + cwdlen;
|
strcpy (© [filelen + cwdlen], panel->dir.list [i].fname);
|
||||||
|
strcpy (© [filelen + cwdlen + panel->dir.list [i].fnamelen], sep);
|
||||||
|
copy += filelen + cwdlen + panel->dir.list [i].fnamelen + seplen;
|
||||||
}
|
}
|
||||||
|
data [total_len] = 0;
|
||||||
*file_list_len = total_len;
|
*file_list_len = total_len;
|
||||||
return data;
|
return data;
|
||||||
} else {
|
} else {
|
||||||
char *fullname = concat_dir_and_file (panel->cwd, panel->dir.list [panel->selected].fname);
|
char *fullname, *uri;
|
||||||
|
|
||||||
*file_list_len = strlen (fullname) + 1;
|
fullname = concat_dir_and_file (panel->cwd, panel->dir.list [panel->selected].fname);
|
||||||
return fullname;
|
|
||||||
|
uri = copy_strings ("file:", fullname, NULL);
|
||||||
|
free (fullname);
|
||||||
|
|
||||||
|
*file_list_len = strlen (uri) + 1;
|
||||||
|
return uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* panel_drag_data_get:
|
||||||
|
*
|
||||||
|
* Invoked when a drag operation has been performed, this routine
|
||||||
|
* provides the data to be transfered
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
panel_drag_data_get (GtkWidget *widget,
|
||||||
|
GdkDragContext *context,
|
||||||
|
GtkSelectionData *selection_data,
|
||||||
|
guint info,
|
||||||
|
guint32 time,
|
||||||
|
WPanel *panel)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
char *data;
|
||||||
|
|
||||||
|
switch (info){
|
||||||
|
case TARGET_URL_LIST:
|
||||||
|
case TARGET_URI_LIST:
|
||||||
|
case TARGET_TEXT_PLAIN:
|
||||||
|
data = panel_build_selected_file_list (panel, &len);
|
||||||
|
|
||||||
|
printf ("TRANSFERING: %s\n", data);
|
||||||
|
gtk_selection_data_set (
|
||||||
|
selection_data, selection_data->target, 8,
|
||||||
|
data, len);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1165,14 +1226,18 @@ load_dnd_icons (void)
|
|||||||
if (!drag_multiple_ok)
|
if (!drag_multiple_ok)
|
||||||
drag_multiple_ok = gnome_stock_transparent_window (GNOME_STOCK_PIXMAP_MULTIPLE, NULL);
|
drag_multiple_ok = gnome_stock_transparent_window (GNOME_STOCK_PIXMAP_MULTIPLE, NULL);
|
||||||
|
|
||||||
|
#if OLD_DND
|
||||||
if (drag_directory && drag_directory_ok)
|
if (drag_directory && drag_directory_ok)
|
||||||
gdk_dnd_set_drag_shape (drag_directory->window, &hotspot,
|
gdk_dnd_set_drag_shape (drag_directory->window, &hotspot,
|
||||||
drag_directory_ok->window, &hotspot);
|
drag_directory_ok->window, &hotspot);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pixmaps can only be loaded once the window has been realized, so
|
* Pixmaps can only be loaded once the window has been realized, so
|
||||||
* this is why this hook is here
|
* this is why this hook is here
|
||||||
|
*
|
||||||
|
* FIXME: We no longer need to configure DnD on the realize handler
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
panel_realized (GtkWidget *file_list, WPanel *panel)
|
panel_realized (GtkWidget *file_list, WPanel *panel)
|
||||||
@ -1181,6 +1246,12 @@ panel_realized (GtkWidget *file_list, WPanel *panel)
|
|||||||
|
|
||||||
load_dnd_icons ();
|
load_dnd_icons ();
|
||||||
|
|
||||||
|
gtk_drag_source_set (GTK_WIDGET (file_list), GDK_BUTTON1_MASK,
|
||||||
|
drag_types, ELEMENTS (drag_types), GDK_ACTION_COPY);
|
||||||
|
|
||||||
|
gtk_signal_connect (obj, "drag_data_get",
|
||||||
|
GTK_SIGNAL_FUNC (panel_drag_data_get), panel);
|
||||||
|
|
||||||
#if OLD_DND
|
#if OLD_DND
|
||||||
/* DND: Drag setup */
|
/* DND: Drag setup */
|
||||||
gtk_signal_connect (obj, "drag_request_event", GTK_SIGNAL_FUNC (panel_clist_drag_request), panel);
|
gtk_signal_connect (obj, "drag_request_event", GTK_SIGNAL_FUNC (panel_clist_drag_request), panel);
|
||||||
@ -1391,6 +1462,12 @@ panel_icon_list_realized (GtkObject *obj, WPanel *panel)
|
|||||||
load_imlib_icons ();
|
load_imlib_icons ();
|
||||||
load_dnd_icons ();
|
load_dnd_icons ();
|
||||||
|
|
||||||
|
gtk_drag_source_set (GTK_WIDGET (icon), GDK_BUTTON1_MASK,
|
||||||
|
drag_types, ELEMENTS (drag_types), GDK_ACTION_COPY);
|
||||||
|
|
||||||
|
gtk_signal_connect (obj, "drag_data_get",
|
||||||
|
GTK_SIGNAL_FUNC (panel_drag_data_get), panel);
|
||||||
|
|
||||||
#ifdef OLD_DND
|
#ifdef OLD_DND
|
||||||
/* DND: Drag setup */
|
/* DND: Drag setup */
|
||||||
gtk_signal_connect (obj, "drag_request_event", GTK_SIGNAL_FUNC (panel_icon_list_drag_request), panel);
|
gtk_signal_connect (obj, "drag_request_event", GTK_SIGNAL_FUNC (panel_icon_list_drag_request), panel);
|
||||||
|
Loading…
Reference in New Issue
Block a user