mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 10:04:32 +03:00
More drag and drop work; the desktop is usable in some areas now
This commit is contained in:
parent
8222d0bd69
commit
644baf741f
@ -39,6 +39,7 @@ typedef struct {
|
||||
icon_t type;
|
||||
int x, y;
|
||||
char *title;
|
||||
char *pathname;
|
||||
} desktop_icon_t;
|
||||
|
||||
/* The list of icons on the desktop */
|
||||
@ -131,7 +132,9 @@ drop_cb (GtkWidget *widget, GdkEventDropDataAvailable *event, desktop_icon_t *di
|
||||
char *p;
|
||||
int count;
|
||||
int len;
|
||||
|
||||
int is_directory = strcasecmp (di->dentry->type, "directory") == 0;
|
||||
|
||||
|
||||
if (strcmp (event->data_type, "url:ALL") == 0){
|
||||
count = event->data_numbytes;
|
||||
p = event->data;
|
||||
@ -145,8 +148,6 @@ drop_cb (GtkWidget *widget, GdkEventDropDataAvailable *event, desktop_icon_t *di
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp (event->data_type, "urls:ALL") == 0){
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -190,6 +191,13 @@ dentry_button_click (GtkWidget *widget, GdkEventButton *event, desktop_icon_t *d
|
||||
dentry_properties (di);
|
||||
}
|
||||
|
||||
char *drop_types [] = {
|
||||
"text/plain",
|
||||
"url:ALL",
|
||||
};
|
||||
|
||||
#define ELEMENTS(x) (sizeof (x) / sizeof (x[0]))
|
||||
|
||||
static void
|
||||
desktop_load_dentry (char *filename)
|
||||
{
|
||||
@ -197,11 +205,6 @@ desktop_load_dentry (char *filename)
|
||||
desktop_icon_t *di;
|
||||
GtkWidget *window;
|
||||
|
||||
char *drop_types [] = {
|
||||
"text/plain",
|
||||
"url:ALL",
|
||||
};
|
||||
|
||||
dentry = gnome_desktop_entry_load (filename);
|
||||
|
||||
if (!dentry)
|
||||
@ -241,7 +244,7 @@ desktop_load_dentry (char *filename)
|
||||
|
||||
/* 1. Drag and drop functionality */
|
||||
connect_drop_signals (window, di);
|
||||
gtk_widget_dnd_drop_set (window, TRUE, drop_types, 1, FALSE);
|
||||
gtk_widget_dnd_drop_set (window, TRUE, drop_types, ELEMENTS (drop_types), FALSE);
|
||||
|
||||
/* 2. Double clicking executes the command */
|
||||
gtk_signal_connect (GTK_OBJECT (window), "button_press_event", GTK_SIGNAL_FUNC (dentry_button_click), di);
|
||||
@ -291,8 +294,21 @@ get_desktop_icon (char *pathname)
|
||||
static void
|
||||
desktop_file_exec (GtkWidget *widget, GdkEventButton *event, desktop_icon_t *di)
|
||||
{
|
||||
if (event->type == GDK_2BUTTON_PRESS && event->button == 1)
|
||||
printf ("YOu just discovered that regex_command ('open') is not being invoked yet\n");
|
||||
if (!(event->type == GDK_2BUTTON_PRESS && event->button == 1))
|
||||
return;
|
||||
|
||||
if (di->dentry){
|
||||
printf ("FIXME: No support for dentry loaded stuff yet\n");
|
||||
} else
|
||||
regex_command (di->pathname, "Open", 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
drop_on_launch_entry (GtkWidget *widget, GdkEventDropDataAvailable *event, desktop_icon_t *di)
|
||||
{
|
||||
if (strcmp (event->data_type, "url:ALL") == 0){
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
@ -308,12 +324,20 @@ desktop_create_launch_entry (char *pathname, char *short_name)
|
||||
di = xmalloc (sizeof (desktop_icon_t), "dcle");
|
||||
di->dentry = NULL;
|
||||
di->widget = window;
|
||||
di->pathname = strdup (pathname);
|
||||
desktop_icon_set_position (di, window);
|
||||
|
||||
desktop_icons = g_list_prepend (desktop_icons, (gpointer) di);
|
||||
|
||||
/* Double clicking executes the command */
|
||||
gtk_signal_connect (GTK_OBJECT (window), "button_press_event", GTK_SIGNAL_FUNC (desktop_file_exec), di);
|
||||
gtk_widget_realize (window);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "drop_data_available_event",
|
||||
GTK_SIGNAL_FUNC (drop_on_launch_entry), di);
|
||||
|
||||
gtk_widget_dnd_drop_set (window, TRUE, drop_types, ELEMENTS (drop_types), FALSE);
|
||||
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
||||
@ -360,8 +384,14 @@ desktop_load (char *desktop_dir)
|
||||
} else {
|
||||
if (strstr (dent->d_name, ".desktop"))
|
||||
desktop_load_dentry (full);
|
||||
else
|
||||
desktop_create_launch_entry (full, dent->d_name);
|
||||
else {
|
||||
char *desktop_version;
|
||||
|
||||
desktop_version = copy_strings (full, ".desktop", NULL);
|
||||
if (!exist_file (desktop_version))
|
||||
desktop_create_launch_entry (full, dent->d_name);
|
||||
free (desktop_version);
|
||||
}
|
||||
}
|
||||
|
||||
free (full);
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <stdlib.h> /* atoi */
|
||||
#include "fs.h"
|
||||
#include "x.h"
|
||||
#include <gdk/gdkprivate.h>
|
||||
#include "dir.h"
|
||||
#include "panel.h"
|
||||
#include "command.h"
|
||||
@ -37,6 +38,7 @@ GdkBitmap *directory_mask;
|
||||
static int mc_bindings;
|
||||
|
||||
static char *drag_types [] = { "text/plain", "url:ALL" };
|
||||
static char *drop_types [] = { "url:ALL" };
|
||||
|
||||
#define ELEMENTS(x) (sizeof (x) / sizeof (x[0]))
|
||||
|
||||
@ -621,23 +623,28 @@ panel_build_selected_file_list (WPanel *panel, int *file_list_len)
|
||||
if (panel->marked){
|
||||
char *data, *copy;
|
||||
int i, total_len = 0;
|
||||
|
||||
int cwdlen = strlen (panel->cwd) + 1;
|
||||
|
||||
/* first pass, compute the length */
|
||||
for (i = 0; i < panel->count; i++)
|
||||
if (panel->dir.list [i].f.marked)
|
||||
total_len += panel->dir.list [i].fnamelen + 1;
|
||||
total_len += (cwdlen + panel->dir.list [i].fnamelen + 1);
|
||||
|
||||
data = copy = xmalloc (total_len, "build_selected_file_list");
|
||||
for (i = 0; i < panel->count; i++)
|
||||
if (panel->dir.list [i].f.marked){
|
||||
strcpy (copy, panel->dir.list [i].fname);
|
||||
copy += panel->dir.list [i].fnamelen + 1;
|
||||
strcpy (copy, panel->cwd);
|
||||
copy [cwdlen] = '/';
|
||||
strcpy (© [cwdlen+1], panel->dir.list [i].fname);
|
||||
copy += panel->dir.list [i].fnamelen + 1 + cwdlen;
|
||||
}
|
||||
*file_list_len = total_len;
|
||||
return data;
|
||||
} else {
|
||||
*file_list_len = strlen (panel->dir.list [panel->selected].fname) + 1;
|
||||
return strdup (panel->dir.list [panel->selected].fname);
|
||||
char *fullname = concat_dir_and_file (panel->cwd, panel->dir.list [panel->selected].fname);
|
||||
|
||||
*file_list_len = strlen (fullname) + 1;
|
||||
return fullname;
|
||||
}
|
||||
}
|
||||
|
||||
@ -646,12 +653,21 @@ panel_drag_request (GtkWidget *widget, GdkEventDragRequest *event, WPanel *panel
|
||||
{
|
||||
void *data;
|
||||
int len;
|
||||
|
||||
GdkWindowPrivate *clist_window = (GdkWindowPrivate *) (GTK_WIDGET (widget)->window);
|
||||
GdkWindowPrivate *clist_areaw = (GdkWindowPrivate *) (GTK_CLIST (widget)->clist_window);
|
||||
|
||||
printf ("Drag request!\n");
|
||||
printf ("Drag [%s] request!\n", event->data_type);
|
||||
|
||||
if ((strcmp (event->data_type, "text/plain") == 0) ||
|
||||
(strcmp (event->data_type, "url:ALL") == 0)){
|
||||
data = panel_build_selected_file_list (panel, &len);
|
||||
gtk_widget_dnd_data_set (widget, (GdkEvent *) event, data, len);
|
||||
printf ("Data: %s\n", data);
|
||||
|
||||
if (clist_window->dnd_drag_accepted)
|
||||
gdk_window_dnd_data_set ((GdkWindow *)clist_window, (GdkEvent *) event, data, len);
|
||||
else
|
||||
gdk_window_dnd_data_set ((GdkWindow *)clist_areaw, (GdkEvent *) event, data, len);
|
||||
free (data);
|
||||
}
|
||||
}
|
||||
@ -671,17 +687,17 @@ panel_drop_data_available (GtkWidget *widget, GdkEventDropDataAvailable *data, W
|
||||
|
||||
/* Workaround for the CList that is not adding its clist-window to the DND windows */
|
||||
static void
|
||||
fixed_gtk_widget_dnd_drop_set (GtkCList *clist, int drop_enable, char **drag_types, int count, int is_destructive)
|
||||
fixed_gtk_widget_dnd_drop_set (GtkCList *clist, int drop_enable, char **drop_types, int count, int is_destructive)
|
||||
{
|
||||
gtk_widget_dnd_drop_set (GTK_WIDGET (clist), drop_enable, drag_types, count, is_destructive);
|
||||
gdk_window_dnd_drop_set (clist->clist_window, drop_enable, drag_types, count, is_destructive);
|
||||
gtk_widget_dnd_drop_set (GTK_WIDGET (clist), drop_enable, drop_types, count, is_destructive);
|
||||
gdk_window_dnd_drop_set (clist->clist_window, drop_enable, drop_types, count, is_destructive);
|
||||
}
|
||||
|
||||
static void
|
||||
fixed_gtk_widget_dnd_drag_set (GtkCList *clist, int drag_enable, gchar **type_accept_list, int numtypes)
|
||||
{
|
||||
gtk_widget_dnd_drag_set (GTK_WIDGET (clist), drag_enable, type_accept_list, numtypes);
|
||||
/* gdk_window_dnd_drag_set (clist->clist_window, drag_enable, type_accept_list, numtypes); */
|
||||
gdk_window_dnd_drag_set (clist->clist_window, drag_enable, type_accept_list, numtypes);
|
||||
}
|
||||
|
||||
void
|
||||
@ -693,7 +709,7 @@ panel_realized (GtkWidget *file_list, WPanel *panel)
|
||||
gtk_signal_connect (obj, "drag_request_event",
|
||||
GTK_SIGNAL_FUNC (panel_drag_request), panel);
|
||||
fixed_gtk_widget_dnd_drag_set (GTK_CLIST (file_list), TRUE, drag_types, ELEMENTS (drag_types));
|
||||
|
||||
|
||||
/* DND: Drop setup */
|
||||
gtk_signal_connect (obj, "drop_enter_event",
|
||||
GTK_SIGNAL_FUNC (panel_drop_enter), panel);
|
||||
@ -704,7 +720,7 @@ panel_realized (GtkWidget *file_list, WPanel *panel)
|
||||
gtk_signal_connect (obj, "drop_data_available_event",
|
||||
GTK_SIGNAL_FUNC (panel_drop_data_available), panel);
|
||||
|
||||
fixed_gtk_widget_dnd_drop_set (GTK_CLIST (file_list), TRUE, drag_types, ELEMENTS (drag_types), FALSE);
|
||||
fixed_gtk_widget_dnd_drop_set (GTK_CLIST (file_list), TRUE, drop_types, ELEMENTS (drop_types), FALSE);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
@ -738,7 +754,6 @@ panel_create_file_list (WPanel *panel)
|
||||
gtk_signal_connect (GTK_OBJECT (file_list),
|
||||
"realize",
|
||||
GTK_SIGNAL_FUNC (panel_realized), panel);
|
||||
|
||||
return file_list;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
Mon Mar 2 15:54:55 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
|
||||
* dlg.c (create_dlg): Set running to 0 on creation;
|
||||
(add_widgetl): do widget initialization if the dialog is already
|
||||
running when this dialog box is created.
|
||||
|
||||
Mon Mar 2 12:11:37 1998 Norbert Warmuth <k3190@fh-sw.de>
|
||||
|
||||
* vfs/ftpfs.c (changetype): Removed the hack which always forced
|
||||
|
@ -178,7 +178,8 @@ exec_extension (char *filename, char *data, char *drops, int *move_dir, int star
|
||||
text = (*quote_func) (filename, 0);
|
||||
}
|
||||
} else if (*data == 'q') {
|
||||
text = (*quote_func) (drops, 0);
|
||||
/* FIXME: currently broken */
|
||||
/* text = (*quote_func) (drops, 0); */
|
||||
} else
|
||||
text = expand_format (*data, !is_cd);
|
||||
if (!is_cd)
|
||||
@ -298,7 +299,7 @@ exec_extension (char *filename, char *data, char *drops, int *move_dir, int star
|
||||
* if the value for %d exists, then the viewer is started up at that line number.
|
||||
*/
|
||||
char *regex_command_title = NULL;
|
||||
char *regex_command (char *filename, char *action, char *drops, int *move_dir)
|
||||
char *regex_command (char *filename, char *action, char **drops, int *move_dir)
|
||||
{
|
||||
char *extension_file;
|
||||
char *p, *q, *r, c;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef __EXT_H
|
||||
#define __EXT_H
|
||||
|
||||
char *regex_command (char *filename, char *action, char *drops, int *move_dir);
|
||||
char *regex_command (char *filename, char *action, char **drops, int *move_dir);
|
||||
|
||||
/* Call it after the user has edited the mc.ext file,
|
||||
* to flush the cached mc.ext file
|
||||
|
@ -2000,6 +2000,7 @@ int midnight_callback (struct Dlg_head *h, int id, int msg)
|
||||
/* This should be rewritten in order to support as many panel containers as
|
||||
the user wants */
|
||||
|
||||
#ifndef HAVE_GNOME
|
||||
widget_data containers [2];
|
||||
int containers_no = 2;
|
||||
|
||||
@ -2028,6 +2029,10 @@ xtoolkit_panel_setup ()
|
||||
# define xtoolkit_panel_setup()
|
||||
#endif
|
||||
|
||||
#else
|
||||
# define xtoolkit_panel_setup()
|
||||
#endif
|
||||
|
||||
#ifndef PORT_HAS_LOAD_HINT
|
||||
void load_hint ()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user