Commit dfbbe8a9 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

new public function gimp_dnd_file_dest_set(). Moved the file/url dnd stuff

2000-05-06  Michael Natterer  <mitch@gimp.org>

	* app/gimpdnd.[ch]: new public function gimp_dnd_file_dest_set().
	Moved the file/url dnd stuff from interface.c to gimpdnd.c.

	* app/docindex.c
	* app/interface.c: use the function from gimpdnd.
parent f3ab0d50
2000-05-06 Michael Natterer <mitch@gimp.org>
* app/gimpdnd.[ch]: new public function gimp_dnd_file_dest_set().
Moved the file/url dnd stuff from interface.c to gimpdnd.c.
* app/docindex.c
* app/interface.c: use the function from gimpdnd.
2000-05-06 Michael Natterer <mitch@gimp.org>
 
* po/POTFILES.in
......
......@@ -79,13 +79,6 @@ static GdkPixmap *create_pixmap (GdkWindow *parent,
gint height);
static void toolbox_set_drag_dest (GtkWidget *widget);
static void toolbox_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time);
static gboolean toolbox_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
......@@ -96,7 +89,6 @@ static ToolType toolbox_drag_tool (GtkWidget *widget,
static void toolbox_drop_tool (GtkWidget *widget,
ToolType tool,
gpointer data);
static void gimp_dnd_open_files (gchar *buffer);
static gint pixmap_colors[8][3] =
{
......@@ -1114,40 +1106,14 @@ toolbox_set_drag_dest (GtkWidget *object)
toolbox_target_table, toolbox_n_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (object), "drag_data_received",
GTK_SIGNAL_FUNC (toolbox_drag_data_received),
object);
gtk_signal_connect (GTK_OBJECT (object), "drag_drop",
GTK_SIGNAL_FUNC (toolbox_drag_drop),
NULL);
gimp_dnd_file_dest_set (object);
gimp_dnd_tool_dest_set (object, toolbox_drop_tool, NULL);
}
static void
toolbox_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time)
{
switch (context->action)
{
case GDK_ACTION_DEFAULT:
case GDK_ACTION_COPY:
case GDK_ACTION_MOVE:
case GDK_ACTION_LINK:
case GDK_ACTION_ASK:
default:
gimp_dnd_open_files ((gchar *) data->data);
gtk_drag_finish (context, TRUE, FALSE, time);
break;
}
return;
}
static gboolean
toolbox_drag_drop (GtkWidget *widget,
GdkDragContext *context,
......@@ -1317,38 +1283,3 @@ toolbox_drop_tool (GtkWidget *widget,
{
gimp_context_set_tool (gimp_context_get_user (), tool);
}
static void
gimp_dnd_open_files (gchar *buffer)
{
gchar name_buffer[1024];
const gchar *data_type = "file:";
const gint sig_len = strlen (data_type);
while (*buffer)
{
gchar *name = name_buffer;
gint len = 0;
while ((*buffer != 0) && (*buffer != '\n') && len < 1024)
{
*name++ = *buffer++;
len++;
}
if (len == 0)
break;
if (*(name - 1) == 0xd) /* gmc uses RETURN+NEWLINE as delimiter */
*(name - 1) = '\0';
else
*name = '\0';
name = name_buffer;
if ((sig_len < len) && (! strncmp (name, data_type, sig_len)))
name += sig_len;
file_open (name, name);
if (*buffer)
buffer++;
}
}
......@@ -79,13 +79,6 @@ static GdkPixmap *create_pixmap (GdkWindow *parent,
gint height);
static void toolbox_set_drag_dest (GtkWidget *widget);
static void toolbox_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time);
static gboolean toolbox_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
......@@ -96,7 +89,6 @@ static ToolType toolbox_drag_tool (GtkWidget *widget,
static void toolbox_drop_tool (GtkWidget *widget,
ToolType tool,
gpointer data);
static void gimp_dnd_open_files (gchar *buffer);
static gint pixmap_colors[8][3] =
{
......@@ -1114,40 +1106,14 @@ toolbox_set_drag_dest (GtkWidget *object)
toolbox_target_table, toolbox_n_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (object), "drag_data_received",
GTK_SIGNAL_FUNC (toolbox_drag_data_received),
object);
gtk_signal_connect (GTK_OBJECT (object), "drag_drop",
GTK_SIGNAL_FUNC (toolbox_drag_drop),
NULL);
gimp_dnd_file_dest_set (object);
gimp_dnd_tool_dest_set (object, toolbox_drop_tool, NULL);
}
static void
toolbox_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time)
{
switch (context->action)
{
case GDK_ACTION_DEFAULT:
case GDK_ACTION_COPY:
case GDK_ACTION_MOVE:
case GDK_ACTION_LINK:
case GDK_ACTION_ASK:
default:
gimp_dnd_open_files ((gchar *) data->data);
gtk_drag_finish (context, TRUE, FALSE, time);
break;
}
return;
}
static gboolean
toolbox_drag_drop (GtkWidget *widget,
GdkDragContext *context,
......@@ -1317,38 +1283,3 @@ toolbox_drop_tool (GtkWidget *widget,
{
gimp_context_set_tool (gimp_context_get_user (), tool);
}
static void
gimp_dnd_open_files (gchar *buffer)
{
gchar name_buffer[1024];
const gchar *data_type = "file:";
const gint sig_len = strlen (data_type);
while (*buffer)
{
gchar *name = name_buffer;
gint len = 0;
while ((*buffer != 0) && (*buffer != '\n') && len < 1024)
{
*name++ = *buffer++;
len++;
}
if (len == 0)
break;
if (*(name - 1) == 0xd) /* gmc uses RETURN+NEWLINE as delimiter */
*(name - 1) = '\0';
else
*name = '\0';
name = name_buffer;
if ((sig_len < len) && (! strncmp (name, data_type, sig_len)))
name += sig_len;
file_open (name, name);
if (*buffer)
buffer++;
}
}
......@@ -53,7 +53,9 @@ static GList *idea_list = NULL;
static GtkTargetEntry drag_types[] =
{
GIMP_TARGET_URI_LIST
GIMP_TARGET_URI_LIST,
GIMP_TARGET_TEXT_PLAIN,
GIMP_TARGET_NETSCAPE_URL
};
static gint n_drag_types = sizeof (drag_types) / sizeof (drag_types[0]);
......@@ -145,52 +147,6 @@ idea_manager_parse_line (FILE * fp)
/* local functions */
static void
docindex_dnd_filenames_dropped (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time)
{
gint len;
gchar *data;
gchar *end;
switch (info)
{
case GIMP_DND_TYPE_URI_LIST:
data = (gchar *) selection_data->data;
len = selection_data->length;
while (len > 0)
{
end = strstr (data, "\x0D\x0A");
if (end != NULL)
*end = 0;
if (*data != '#')
{
gchar *filename = strchr (data, ':');
if (filename != NULL)
filename ++;
else
filename = data;
file_open (filename, filename);
}
if (end)
{
len -= end - data + 2;
data = end + 2;
}
else
len = 0;
}
break;
}
return;
}
static void
load_from_list (gpointer data,
gpointer data_null)
......@@ -739,15 +695,11 @@ open_idea_window (void)
gtk_widget_show (ideas->list);
gtk_drag_dest_set (ideas->window,
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_DROP,
GTK_DEST_DEFAULT_ALL,
drag_types, n_drag_types,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (ideas->window), "drag_data_received",
GTK_SIGNAL_FUNC (docindex_dnd_filenames_dropped),
NULL);
gimp_dnd_file_dest_set (ideas->window);
dialog_register (ideas->window);
session_set_window_geometry (ideas->window, &document_index_session_info,
......
......@@ -15,6 +15,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include "fileops.h"
#include "gimage.h"
#include "gimpcontextpreview.h"
#include "gimpdnd.h"
......@@ -1203,3 +1206,75 @@ gimp_dnd_set_drawable_preview_icon (GtkWidget *widget,
gtk_drag_set_icon_widget (context, window,
DRAG_ICON_OFFSET, DRAG_ICON_OFFSET);
}
/******************************/
/* file / url dnd functions */
/******************************/
static void
gimp_dnd_file_open_files (gchar *buffer)
{
gchar name_buffer[1024];
const gchar *data_type = "file:";
const gint sig_len = strlen (data_type);
while (*buffer)
{
gchar *name = name_buffer;
gint len = 0;
while ((*buffer != 0) && (*buffer != '\n') && len < 1024)
{
*name++ = *buffer++;
len++;
}
if (len == 0)
break;
if (*(name - 1) == 0xd) /* gmc uses RETURN+NEWLINE as delimiter */
*(name - 1) = '\0';
else
*name = '\0';
name = name_buffer;
if ((sig_len < len) && (! strncmp (name, data_type, sig_len)))
name += sig_len;
file_open (name, name);
if (*buffer)
buffer++;
}
}
static void
gimp_dnd_file_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time)
{
switch (context->action)
{
case GDK_ACTION_DEFAULT:
case GDK_ACTION_COPY:
case GDK_ACTION_MOVE:
case GDK_ACTION_LINK:
case GDK_ACTION_ASK:
default:
gimp_dnd_file_open_files ((gchar *) data->data);
gtk_drag_finish (context, TRUE, FALSE, time);
break;
}
return;
}
void
gimp_dnd_file_dest_set (GtkWidget *widget)
{
gtk_signal_connect (GTK_OBJECT (widget), "drag_data_received",
GTK_SIGNAL_FUNC (gimp_dnd_file_drag_data_received),
NULL);
}
......@@ -199,4 +199,8 @@ void gimp_dnd_set_drawable_preview_icon (GtkWidget *widget,
GdkDragContext *context,
GimpDrawable *drawable);
/* file / url dnd functions */
void gimp_dnd_file_dest_set (GtkWidget *widget);
#endif /* __GIMP_DND_H__ */
......@@ -79,13 +79,6 @@ static GdkPixmap *create_pixmap (GdkWindow *parent,
gint height);
static void toolbox_set_drag_dest (GtkWidget *widget);
static void toolbox_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time);
static gboolean toolbox_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
......@@ -96,7 +89,6 @@ static ToolType toolbox_drag_tool (GtkWidget *widget,
static void toolbox_drop_tool (GtkWidget *widget,
ToolType tool,
gpointer data);
static void gimp_dnd_open_files (gchar *buffer);
static gint pixmap_colors[8][3] =
{
......@@ -1114,40 +1106,14 @@ toolbox_set_drag_dest (GtkWidget *object)
toolbox_target_table, toolbox_n_targets,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (object), "drag_data_received",
GTK_SIGNAL_FUNC (toolbox_drag_data_received),
object);
gtk_signal_connect (GTK_OBJECT (object), "drag_drop",
GTK_SIGNAL_FUNC (toolbox_drag_drop),
NULL);
gimp_dnd_file_dest_set (object);
gimp_dnd_tool_dest_set (object, toolbox_drop_tool, NULL);
}
static void
toolbox_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time)
{
switch (context->action)
{
case GDK_ACTION_DEFAULT:
case GDK_ACTION_COPY:
case GDK_ACTION_MOVE:
case GDK_ACTION_LINK:
case GDK_ACTION_ASK:
default:
gimp_dnd_open_files ((gchar *) data->data);
gtk_drag_finish (context, TRUE, FALSE, time);
break;
}
return;
}
static gboolean
toolbox_drag_drop (GtkWidget *widget,
GdkDragContext *context,
......@@ -1317,38 +1283,3 @@ toolbox_drop_tool (GtkWidget *widget,
{
gimp_context_set_tool (gimp_context_get_user (), tool);
}
static void
gimp_dnd_open_files (gchar *buffer)
{
gchar name_buffer[1024];
const gchar *data_type = "file:";
const gint sig_len = strlen (data_type);
while (*buffer)
{
gchar *name = name_buffer;
gint len = 0;
while ((*buffer != 0) && (*buffer != '\n') && len < 1024)
{
*name++ = *buffer++;
len++;
}
if (len == 0)
break;
if (*(name - 1) == 0xd) /* gmc uses RETURN+NEWLINE as delimiter */
*(name - 1) = '\0';
else
*name = '\0';
name = name_buffer;
if ((sig_len < len) && (! strncmp (name, data_type, sig_len)))
name += sig_len;
file_open (name, name);
if (*buffer)
buffer++;
}
}
......@@ -15,6 +15,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include "fileops.h"
#include "gimage.h"
#include "gimpcontextpreview.h"
#include "gimpdnd.h"
......@@ -1203,3 +1206,75 @@ gimp_dnd_set_drawable_preview_icon (GtkWidget *widget,
gtk_drag_set_icon_widget (context, window,
DRAG_ICON_OFFSET, DRAG_ICON_OFFSET);
}
/******************************/
/* file / url dnd functions */
/******************************/
static void
gimp_dnd_file_open_files (gchar *buffer)
{
gchar name_buffer[1024];
const gchar *data_type = "file:";
const gint sig_len = strlen (data_type);
while (*buffer)
{
gchar *name = name_buffer;
gint len = 0;
while ((*buffer != 0) && (*buffer != '\n') && len < 1024)
{
*name++ = *buffer++;
len++;
}
if (len == 0)
break;
if (*(name - 1) == 0xd) /* gmc uses RETURN+NEWLINE as delimiter */
*(name - 1) = '\0';
else
*name = '\0';
name = name_buffer;
if ((sig_len < len) && (! strncmp (name, data_type, sig_len)))
name += sig_len;
file_open (name, name);
if (*buffer)
buffer++;
}
}
static void
gimp_dnd_file_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time)
{
switch (context->action)
{
case GDK_ACTION_DEFAULT:
case GDK_ACTION_COPY:
case GDK_ACTION_MOVE:
case GDK_ACTION_LINK:
case GDK_ACTION_ASK:
default:
gimp_dnd_file_open_files ((gchar *) data->data);
gtk_drag_finish (context, TRUE, FALSE, time);
break;
}
return;
}
void
gimp_dnd_file_dest_set (GtkWidget *widget)
{
gtk_signal_connect (GTK_OBJECT (widget), "drag_data_received",
GTK_SIGNAL_FUNC (gimp_dnd_file_drag_data_received),
NULL);
}
......@@ -199,4 +199,8 @@ void gimp_dnd_set_drawable_preview_icon (GtkWidget *widget,
GdkDragContext *context,
GimpDrawable *drawable);
/* file / url dnd functions */
void gimp_dnd_file_dest_set (GtkWidget *widget);
#endif /* __GIMP_DND_H__ */
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