gless DnD support patch
- From: David Knight <david ritter demon co uk>
- To: "gnome-list gnome org" <gnome-list gnome org>
- Subject: gless DnD support patch
- Date: Tue, 25 May 1999 17:52:43 +0100
I've been annoyed for a while now each time I've wanted to drop a file onto
gless that it didn't support it.
So here's a patch I've just done that adds support.
David
--
The superior man understands what is right;
the inferior man understands what will sell.
-- Confucius
--- gless.c Tue May 25 17:32:45 1999
+++ gless.c Tue May 25 17:44:30 1999
@@ -49,6 +49,10 @@
the window closes. */
};
+enum {
+ TARGET_URI_LIST
+};
+
/****************************
Function prototypes
******************************/
@@ -73,6 +77,10 @@
static void new_app_cb(GtkWidget * w, gpointer data);
static void fixed_cb(GtkWidget * w, gpointer data);
+static void drop_file(GtkWidget *widget, GdkDragContext *context,
+ gint x, gint y, GtkSelectionData *selectionData,
+ guint info, guint time, GnomeLessApp *app );
+
/***********************************
Globals
***********************************/
@@ -308,12 +316,20 @@
GNOMEUIINFO_END
};
+static const GtkTargetEntry drop_types[] = {
+ { "text/uri-list", 0, TARGET_URI_LIST },
+};
+
static void gless_new_app(const gchar * filename, const gchar * geometry,
gint fd)
{
GnomeLessApp * app;
GtkWidget * app_box;
+ const gint num_drop_types = sizeof( drop_types ) /
+ sizeof( drop_types [0] );
+
+
gint width = 480, height = 500;
gboolean geometry_error = FALSE;
@@ -366,6 +382,16 @@
gtk_widget_show_all(app->app);
+ /* setup drop support */
+ gtk_drag_dest_set( app->less,
+ GTK_DEST_DEFAULT_MOTION |
+ GTK_DEST_DEFAULT_HIGHLIGHT |
+ GTK_DEST_DEFAULT_DROP,
+ drop_types, num_drop_types,
+ GDK_ACTION_COPY );
+ gtk_signal_connect( GTK_OBJECT( app->less ), "drag_data_received",
+ drop_file, app );
+
app->file = NULL;
if (filename) {
@@ -702,5 +728,20 @@
}
-
+static void drop_file(GtkWidget *widget, GdkDragContext *context,
+ gint x, gint y, GtkSelectionData *selectionData,
+ guint info, guint time, GnomeLessApp *app )
+{
+ gchar *text = NULL;
+
+ switch( info ) {
+ case TARGET_URI_LIST:
+ text = selectionData->data + strlen( "file:" );
+ /* get rid of the \r\n from the end */
+ *(text + strlen( text ) - 2) = 0;
+ gless_app_show_file(app, text);
+ break;
+ }
+
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]