mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-05 11:04:42 +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;
|
icon_t type;
|
||||||
int x, y;
|
int x, y;
|
||||||
char *title;
|
char *title;
|
||||||
|
char *pathname;
|
||||||
} desktop_icon_t;
|
} desktop_icon_t;
|
||||||
|
|
||||||
/* The list of icons on the desktop */
|
/* The list of icons on the desktop */
|
||||||
@ -131,6 +132,8 @@ drop_cb (GtkWidget *widget, GdkEventDropDataAvailable *event, desktop_icon_t *di
|
|||||||
char *p;
|
char *p;
|
||||||
int count;
|
int count;
|
||||||
int len;
|
int len;
|
||||||
|
int is_directory = strcasecmp (di->dentry->type, "directory") == 0;
|
||||||
|
|
||||||
|
|
||||||
if (strcmp (event->data_type, "url:ALL") == 0){
|
if (strcmp (event->data_type, "url:ALL") == 0){
|
||||||
count = event->data_numbytes;
|
count = event->data_numbytes;
|
||||||
@ -145,8 +148,6 @@ drop_cb (GtkWidget *widget, GdkEventDropDataAvailable *event, desktop_icon_t *di
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp (event->data_type, "urls:ALL") == 0){
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -190,6 +191,13 @@ dentry_button_click (GtkWidget *widget, GdkEventButton *event, desktop_icon_t *d
|
|||||||
dentry_properties (di);
|
dentry_properties (di);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *drop_types [] = {
|
||||||
|
"text/plain",
|
||||||
|
"url:ALL",
|
||||||
|
};
|
||||||
|
|
||||||
|
#define ELEMENTS(x) (sizeof (x) / sizeof (x[0]))
|
||||||
|
|
||||||
static void
|
static void
|
||||||
desktop_load_dentry (char *filename)
|
desktop_load_dentry (char *filename)
|
||||||
{
|
{
|
||||||
@ -197,11 +205,6 @@ desktop_load_dentry (char *filename)
|
|||||||
desktop_icon_t *di;
|
desktop_icon_t *di;
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
|
|
||||||
char *drop_types [] = {
|
|
||||||
"text/plain",
|
|
||||||
"url:ALL",
|
|
||||||
};
|
|
||||||
|
|
||||||
dentry = gnome_desktop_entry_load (filename);
|
dentry = gnome_desktop_entry_load (filename);
|
||||||
|
|
||||||
if (!dentry)
|
if (!dentry)
|
||||||
@ -241,7 +244,7 @@ desktop_load_dentry (char *filename)
|
|||||||
|
|
||||||
/* 1. Drag and drop functionality */
|
/* 1. Drag and drop functionality */
|
||||||
connect_drop_signals (window, di);
|
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 */
|
/* 2. Double clicking executes the command */
|
||||||
gtk_signal_connect (GTK_OBJECT (window), "button_press_event", GTK_SIGNAL_FUNC (dentry_button_click), di);
|
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
|
static void
|
||||||
desktop_file_exec (GtkWidget *widget, GdkEventButton *event, desktop_icon_t *di)
|
desktop_file_exec (GtkWidget *widget, GdkEventButton *event, desktop_icon_t *di)
|
||||||
{
|
{
|
||||||
if (event->type == GDK_2BUTTON_PRESS && event->button == 1)
|
if (!(event->type == GDK_2BUTTON_PRESS && event->button == 1))
|
||||||
printf ("YOu just discovered that regex_command ('open') is not being invoked yet\n");
|
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
|
static void
|
||||||
@ -308,12 +324,20 @@ desktop_create_launch_entry (char *pathname, char *short_name)
|
|||||||
di = xmalloc (sizeof (desktop_icon_t), "dcle");
|
di = xmalloc (sizeof (desktop_icon_t), "dcle");
|
||||||
di->dentry = NULL;
|
di->dentry = NULL;
|
||||||
di->widget = window;
|
di->widget = window;
|
||||||
|
di->pathname = strdup (pathname);
|
||||||
desktop_icon_set_position (di, window);
|
desktop_icon_set_position (di, window);
|
||||||
|
|
||||||
desktop_icons = g_list_prepend (desktop_icons, (gpointer) di);
|
desktop_icons = g_list_prepend (desktop_icons, (gpointer) di);
|
||||||
|
|
||||||
/* Double clicking executes the command */
|
/* Double clicking executes the command */
|
||||||
gtk_signal_connect (GTK_OBJECT (window), "button_press_event", GTK_SIGNAL_FUNC (desktop_file_exec), di);
|
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);
|
gtk_widget_show (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,8 +384,14 @@ desktop_load (char *desktop_dir)
|
|||||||
} else {
|
} else {
|
||||||
if (strstr (dent->d_name, ".desktop"))
|
if (strstr (dent->d_name, ".desktop"))
|
||||||
desktop_load_dentry (full);
|
desktop_load_dentry (full);
|
||||||
else
|
else {
|
||||||
|
char *desktop_version;
|
||||||
|
|
||||||
|
desktop_version = copy_strings (full, ".desktop", NULL);
|
||||||
|
if (!exist_file (desktop_version))
|
||||||
desktop_create_launch_entry (full, dent->d_name);
|
desktop_create_launch_entry (full, dent->d_name);
|
||||||
|
free (desktop_version);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free (full);
|
free (full);
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <stdlib.h> /* atoi */
|
#include <stdlib.h> /* atoi */
|
||||||
#include "fs.h"
|
#include "fs.h"
|
||||||
#include "x.h"
|
#include "x.h"
|
||||||
|
#include <gdk/gdkprivate.h>
|
||||||
#include "dir.h"
|
#include "dir.h"
|
||||||
#include "panel.h"
|
#include "panel.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
@ -37,6 +38,7 @@ GdkBitmap *directory_mask;
|
|||||||
static int mc_bindings;
|
static int mc_bindings;
|
||||||
|
|
||||||
static char *drag_types [] = { "text/plain", "url:ALL" };
|
static char *drag_types [] = { "text/plain", "url:ALL" };
|
||||||
|
static char *drop_types [] = { "url:ALL" };
|
||||||
|
|
||||||
#define ELEMENTS(x) (sizeof (x) / sizeof (x[0]))
|
#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){
|
if (panel->marked){
|
||||||
char *data, *copy;
|
char *data, *copy;
|
||||||
int i, total_len = 0;
|
int i, total_len = 0;
|
||||||
|
int cwdlen = strlen (panel->cwd) + 1;
|
||||||
|
|
||||||
/* first pass, compute the length */
|
/* first pass, compute the length */
|
||||||
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 += panel->dir.list [i].fnamelen + 1;
|
total_len += (cwdlen + panel->dir.list [i].fnamelen + 1);
|
||||||
|
|
||||||
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->dir.list [i].fname);
|
strcpy (copy, panel->cwd);
|
||||||
copy += panel->dir.list [i].fnamelen + 1;
|
copy [cwdlen] = '/';
|
||||||
|
strcpy (© [cwdlen+1], panel->dir.list [i].fname);
|
||||||
|
copy += panel->dir.list [i].fnamelen + 1 + cwdlen;
|
||||||
}
|
}
|
||||||
*file_list_len = total_len;
|
*file_list_len = total_len;
|
||||||
return data;
|
return data;
|
||||||
} else {
|
} else {
|
||||||
*file_list_len = strlen (panel->dir.list [panel->selected].fname) + 1;
|
char *fullname = concat_dir_and_file (panel->cwd, panel->dir.list [panel->selected].fname);
|
||||||
return strdup (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;
|
void *data;
|
||||||
int len;
|
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 request!\n");
|
||||||
|
printf ("Drag [%s] request!\n", event->data_type);
|
||||||
|
|
||||||
if ((strcmp (event->data_type, "text/plain") == 0) ||
|
if ((strcmp (event->data_type, "text/plain") == 0) ||
|
||||||
(strcmp (event->data_type, "url:ALL") == 0)){
|
(strcmp (event->data_type, "url:ALL") == 0)){
|
||||||
data = panel_build_selected_file_list (panel, &len);
|
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);
|
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 */
|
/* Workaround for the CList that is not adding its clist-window to the DND windows */
|
||||||
static void
|
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);
|
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, drag_types, count, is_destructive);
|
gdk_window_dnd_drop_set (clist->clist_window, drop_enable, drop_types, count, is_destructive);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fixed_gtk_widget_dnd_drag_set (GtkCList *clist, int drag_enable, gchar **type_accept_list, int numtypes)
|
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);
|
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
|
void
|
||||||
@ -704,7 +720,7 @@ panel_realized (GtkWidget *file_list, WPanel *panel)
|
|||||||
gtk_signal_connect (obj, "drop_data_available_event",
|
gtk_signal_connect (obj, "drop_data_available_event",
|
||||||
GTK_SIGNAL_FUNC (panel_drop_data_available), panel);
|
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 *
|
GtkWidget *
|
||||||
@ -738,7 +754,6 @@ panel_create_file_list (WPanel *panel)
|
|||||||
gtk_signal_connect (GTK_OBJECT (file_list),
|
gtk_signal_connect (GTK_OBJECT (file_list),
|
||||||
"realize",
|
"realize",
|
||||||
GTK_SIGNAL_FUNC (panel_realized), panel);
|
GTK_SIGNAL_FUNC (panel_realized), panel);
|
||||||
|
|
||||||
return file_list;
|
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>
|
Mon Mar 2 12:11:37 1998 Norbert Warmuth <k3190@fh-sw.de>
|
||||||
|
|
||||||
* vfs/ftpfs.c (changetype): Removed the hack which always forced
|
* 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);
|
text = (*quote_func) (filename, 0);
|
||||||
}
|
}
|
||||||
} else if (*data == 'q') {
|
} else if (*data == 'q') {
|
||||||
text = (*quote_func) (drops, 0);
|
/* FIXME: currently broken */
|
||||||
|
/* text = (*quote_func) (drops, 0); */
|
||||||
} else
|
} else
|
||||||
text = expand_format (*data, !is_cd);
|
text = expand_format (*data, !is_cd);
|
||||||
if (!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.
|
* if the value for %d exists, then the viewer is started up at that line number.
|
||||||
*/
|
*/
|
||||||
char *regex_command_title = NULL;
|
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 *extension_file;
|
||||||
char *p, *q, *r, c;
|
char *p, *q, *r, c;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef __EXT_H
|
#ifndef __EXT_H
|
||||||
#define __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,
|
/* Call it after the user has edited the mc.ext file,
|
||||||
* to flush the cached 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
|
/* This should be rewritten in order to support as many panel containers as
|
||||||
the user wants */
|
the user wants */
|
||||||
|
|
||||||
|
#ifndef HAVE_GNOME
|
||||||
widget_data containers [2];
|
widget_data containers [2];
|
||||||
int containers_no = 2;
|
int containers_no = 2;
|
||||||
|
|
||||||
@ -2028,6 +2029,10 @@ xtoolkit_panel_setup ()
|
|||||||
# define xtoolkit_panel_setup()
|
# define xtoolkit_panel_setup()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
# define xtoolkit_panel_setup()
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef PORT_HAS_LOAD_HINT
|
#ifndef PORT_HAS_LOAD_HINT
|
||||||
void load_hint ()
|
void load_hint ()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user