From 6b56a53703f9f970d34a35a78c37717c8806339b Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Thu, 1 Jul 1999 09:13:39 +0000 Subject: [PATCH] tools/pdbgen/pdb/guides.pdb fixed a bug in image_find_next_guide * tools/pdbgen/pdb/guides.pdb * app/guides_cmds.c: fixed a bug in image_find_next_guide * plug-ins/xjt: reflect the name change of gimp_image_find_next_guide * app/interface.c: applied the patch from Shuji Narazaki that allows to open images by dropping them onto the toolbar --Sven --- ChangeLog | 11 ++++ app/display/gimpdisplayshell-draw.c | 99 ++++++++++++++++++++++++++++- app/display/gimpdisplayshell.c | 99 ++++++++++++++++++++++++++++- app/guides_cmds.c | 6 +- app/interface.c | 99 ++++++++++++++++++++++++++++- plug-ins/xjt/xpdb_calls.c | 8 ++- tools/pdbgen/pdb/guides.pdb | 6 +- 7 files changed, 319 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index aedd24ea82..14db4fc28c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Thu Jul 1 10:29:44 MEST 1999 Sven Neumann + + * tools/pdbgen/pdb/guides.pdb + * app/guides_cmds.c: fixed a bug in image_find_next_guide + + * plug-ins/xjt: reflect the name change of gimp_image_find_next_guide + + * app/interface.c: applied the patch from + Shuji Narazaki that allows to open images by + dropping them onto the toolbar + 1999-06-30 Tuomas Kuosmanen * gimp1_1_splash.ppm: Dont even ask what this is :) diff --git a/app/display/gimpdisplayshell-draw.c b/app/display/gimpdisplayshell-draw.c index 48640db34e..64d06bb382 100644 --- a/app/display/gimpdisplayshell-draw.c +++ b/app/display/gimpdisplayshell-draw.c @@ -19,6 +19,7 @@ #include "config.h" #include +#include #include "appenv.h" #include "actionarea.h" #include "app_procs.h" @@ -30,6 +31,7 @@ #include "dialog_handler.h" #include "disp_callbacks.h" #include "errors.h" +#include "fileops.h" #include "gdisplay.h" #include "gdisplay_ops.h" #include "gimage.h" @@ -73,6 +75,15 @@ static GdkPixmap *create_pixmap (GdkWindow *parent, char **data, int width, int height); +static void gimp_set_drop_open (GtkWidget *); +static void gimp_dnd_data_received (GtkWidget *, + GdkDragContext *, + gint, + gint, + GtkSelectionData *, + guint, + guint); +static gint gimp_dnd_open_files (gchar *); static int pixmap_colors[8][3] = { @@ -101,6 +112,21 @@ GtkTooltips * tool_tips; static GdkColor colors[12]; static GtkWidget * toolbox_shell = NULL; +enum { + TARGET_URI_LIST, + TARGET_TEXT_PLAIN, +} TargetType; + +static +GtkTargetEntry dnd_target_table[] = +{ + { "text/uri-list", 0, TARGET_URI_LIST }, + { "text/plain", 0, TARGET_TEXT_PLAIN } +}; + +static guint +dnd_n_targets = sizeof(dnd_target_table) / sizeof(dnd_target_table[0]); + static void tools_select_update (GtkWidget *w, gpointer data) @@ -549,7 +575,7 @@ create_toolbox () if (show_indicators && (!no_data) ) create_indicator_area (vbox); gtk_widget_show (window); - + gimp_set_drop_open (window); toolbox_shell = window; } @@ -1332,3 +1358,74 @@ message_box_close_callback (GtkWidget *w, g_free (msg_box); } + +/* DnD functions */ +static void +gimp_set_drop_open (GtkWidget *object) +{ + gtk_drag_dest_set (object, + GTK_DEST_DEFAULT_ALL, + dnd_target_table, dnd_n_targets, + GDK_ACTION_COPY); + gtk_signal_connect (GTK_OBJECT (object), + "drag_data_received", + GTK_SIGNAL_FUNC (gimp_dnd_data_received), + object); +} + +static void +gimp_dnd_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 gint +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')) + { + *name++ = *buffer++; + len++; + } + if (len == 0) + break; + if (*(name - 1) == 0xd) + *(name - 1) = 0; + name = name_buffer; + if ((sig_len < len) && (! strncmp (name, data_type, sig_len))) + name += sig_len; + + file_open (name, name); + + if (*buffer) + buffer++; + } + return TRUE; +} diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c index 48640db34e..64d06bb382 100644 --- a/app/display/gimpdisplayshell.c +++ b/app/display/gimpdisplayshell.c @@ -19,6 +19,7 @@ #include "config.h" #include +#include #include "appenv.h" #include "actionarea.h" #include "app_procs.h" @@ -30,6 +31,7 @@ #include "dialog_handler.h" #include "disp_callbacks.h" #include "errors.h" +#include "fileops.h" #include "gdisplay.h" #include "gdisplay_ops.h" #include "gimage.h" @@ -73,6 +75,15 @@ static GdkPixmap *create_pixmap (GdkWindow *parent, char **data, int width, int height); +static void gimp_set_drop_open (GtkWidget *); +static void gimp_dnd_data_received (GtkWidget *, + GdkDragContext *, + gint, + gint, + GtkSelectionData *, + guint, + guint); +static gint gimp_dnd_open_files (gchar *); static int pixmap_colors[8][3] = { @@ -101,6 +112,21 @@ GtkTooltips * tool_tips; static GdkColor colors[12]; static GtkWidget * toolbox_shell = NULL; +enum { + TARGET_URI_LIST, + TARGET_TEXT_PLAIN, +} TargetType; + +static +GtkTargetEntry dnd_target_table[] = +{ + { "text/uri-list", 0, TARGET_URI_LIST }, + { "text/plain", 0, TARGET_TEXT_PLAIN } +}; + +static guint +dnd_n_targets = sizeof(dnd_target_table) / sizeof(dnd_target_table[0]); + static void tools_select_update (GtkWidget *w, gpointer data) @@ -549,7 +575,7 @@ create_toolbox () if (show_indicators && (!no_data) ) create_indicator_area (vbox); gtk_widget_show (window); - + gimp_set_drop_open (window); toolbox_shell = window; } @@ -1332,3 +1358,74 @@ message_box_close_callback (GtkWidget *w, g_free (msg_box); } + +/* DnD functions */ +static void +gimp_set_drop_open (GtkWidget *object) +{ + gtk_drag_dest_set (object, + GTK_DEST_DEFAULT_ALL, + dnd_target_table, dnd_n_targets, + GDK_ACTION_COPY); + gtk_signal_connect (GTK_OBJECT (object), + "drag_data_received", + GTK_SIGNAL_FUNC (gimp_dnd_data_received), + object); +} + +static void +gimp_dnd_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 gint +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')) + { + *name++ = *buffer++; + len++; + } + if (len == 0) + break; + if (*(name - 1) == 0xd) + *(name - 1) = 0; + name = name_buffer; + if ((sig_len < len) && (! strncmp (name, data_type, sig_len))) + name += sig_len; + + file_open (name, name); + + if (*buffer) + buffer++; + } + return TRUE; +} diff --git a/app/guides_cmds.c b/app/guides_cmds.c index 2ef352afac..40e7134dab 100644 --- a/app/guides_cmds.c +++ b/app/guides_cmds.c @@ -319,8 +319,10 @@ image_find_next_guide_invoker (Argument *args) while (tmplist && (((Guide *) tmplist->data)->position < 0)) tmplist = tmplist->next; - if (tmplist); - next_guide = ((Guide *) tmplist->data)->guide_ID; + if (tmplist) + next_guide = ((Guide *) tmplist->data)->guide_ID; + else + next_guide = 0; break; } diff --git a/app/interface.c b/app/interface.c index 48640db34e..64d06bb382 100644 --- a/app/interface.c +++ b/app/interface.c @@ -19,6 +19,7 @@ #include "config.h" #include +#include #include "appenv.h" #include "actionarea.h" #include "app_procs.h" @@ -30,6 +31,7 @@ #include "dialog_handler.h" #include "disp_callbacks.h" #include "errors.h" +#include "fileops.h" #include "gdisplay.h" #include "gdisplay_ops.h" #include "gimage.h" @@ -73,6 +75,15 @@ static GdkPixmap *create_pixmap (GdkWindow *parent, char **data, int width, int height); +static void gimp_set_drop_open (GtkWidget *); +static void gimp_dnd_data_received (GtkWidget *, + GdkDragContext *, + gint, + gint, + GtkSelectionData *, + guint, + guint); +static gint gimp_dnd_open_files (gchar *); static int pixmap_colors[8][3] = { @@ -101,6 +112,21 @@ GtkTooltips * tool_tips; static GdkColor colors[12]; static GtkWidget * toolbox_shell = NULL; +enum { + TARGET_URI_LIST, + TARGET_TEXT_PLAIN, +} TargetType; + +static +GtkTargetEntry dnd_target_table[] = +{ + { "text/uri-list", 0, TARGET_URI_LIST }, + { "text/plain", 0, TARGET_TEXT_PLAIN } +}; + +static guint +dnd_n_targets = sizeof(dnd_target_table) / sizeof(dnd_target_table[0]); + static void tools_select_update (GtkWidget *w, gpointer data) @@ -549,7 +575,7 @@ create_toolbox () if (show_indicators && (!no_data) ) create_indicator_area (vbox); gtk_widget_show (window); - + gimp_set_drop_open (window); toolbox_shell = window; } @@ -1332,3 +1358,74 @@ message_box_close_callback (GtkWidget *w, g_free (msg_box); } + +/* DnD functions */ +static void +gimp_set_drop_open (GtkWidget *object) +{ + gtk_drag_dest_set (object, + GTK_DEST_DEFAULT_ALL, + dnd_target_table, dnd_n_targets, + GDK_ACTION_COPY); + gtk_signal_connect (GTK_OBJECT (object), + "drag_data_received", + GTK_SIGNAL_FUNC (gimp_dnd_data_received), + object); +} + +static void +gimp_dnd_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 gint +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')) + { + *name++ = *buffer++; + len++; + } + if (len == 0) + break; + if (*(name - 1) == 0xd) + *(name - 1) = 0; + name = name_buffer; + if ((sig_len < len) && (! strncmp (name, data_type, sig_len))) + name += sig_len; + + file_open (name, name); + + if (*buffer) + buffer++; + } + return TRUE; +} diff --git a/plug-ins/xjt/xpdb_calls.c b/plug-ins/xjt/xpdb_calls.c index d89e75334a..33b9a68b94 100644 --- a/plug-ins/xjt/xpdb_calls.c +++ b/plug-ins/xjt/xpdb_calls.c @@ -495,7 +495,7 @@ gint32 p_gimp_image_add_guide(gint32 image_id, gint32 position, gint32 orienta GParam *return_vals; int nreturn_vals; - if(orientation == 0 ) /* in GIMP 1.1 we could use (orientation == ORIENTATION_VERTICAL) */ + if(orientation != 1 ) /* in GIMP 1.1 we could use (orientation != ORIENTATION_HORIZONTAL) */ { l_add_guide_proc = "gimp_image_add_vguide"; } @@ -543,7 +543,7 @@ gint32 p_gimp_image_add_guide(gint32 image_id, gint32 position, gint32 orienta gint32 p_gimp_image_findnext_guide(gint32 image_id, gint32 guide_id) { - static char *l_findnext_guide_proc = "gimp_image_findnext_guide"; + static char *l_findnext_guide_proc = "gimp_image_find_next_guide"; GParam *return_vals; int nreturn_vals; @@ -630,6 +630,10 @@ gint p_gimp_image_get_guide_orientation(gint32 image_id, gint32 guide_id) if (return_vals[0].data.d_status == STATUS_SUCCESS) { + if(return_vals[1].data.d_int32 != 1) /* in GIMP 1.1 we could use (orientation != ORIENTATION_HORIZONTAL) */ + { + return(0); + } return(return_vals[1].data.d_int32); /* return the guide orientation */ } printf("XJT: Error: PDB call of %s failed\n", l_get_guide_pos_orient); diff --git a/tools/pdbgen/pdb/guides.pdb b/tools/pdbgen/pdb/guides.pdb index 4bc6b12aab..25dcc15508 100644 --- a/tools/pdbgen/pdb/guides.pdb +++ b/tools/pdbgen/pdb/guides.pdb @@ -182,8 +182,10 @@ HELP while (tmplist && (((Guide *) tmplist->data)->position < 0)) tmplist = tmplist->next; - if (tmplist); - next_guide = ((Guide *) tmplist->data)->guide_ID; + if (tmplist) + next_guide = ((Guide *) tmplist->data)->guide_ID; + else + next_guide = 0; break; }