From 1f73342df7c6d973044bf8000cf32f19ed19f7e2 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Thu, 23 Jul 1998 18:33:01 +0000 Subject: [PATCH] Display the move offset in the statusbar and some code cleanup in rect_select.c. Sorry for committing so much half-done stuff in the last time. I'll do more testing in the future... --Sven --- ChangeLog | 5 +++++ app/edit_selection.c | 21 ++++++++++++++++++++- app/rect_select.c | 31 +++++++++++++++---------------- app/tools/edit_selection.c | 21 ++++++++++++++++++++- app/tools/gimpeditselectiontool.c | 21 ++++++++++++++++++++- app/tools/gimprectselecttool.c | 31 +++++++++++++++---------------- app/tools/rect_select.c | 31 +++++++++++++++---------------- 7 files changed, 110 insertions(+), 51 deletions(-) diff --git a/ChangeLog b/ChangeLog index c3ede9bb61..ce319226f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jul 23 20:29:40 MEST 1998 Sven Neumann + + * app/edit_selection.c: Display the move offset in the statusbar. + * app/rect_select.c: Some code cleanup. + Thu Jul 23 10:30:12 PDT 1998 Manish Singh * app/fileops.c: tell the PDB that gimp_register_magic_load_handler diff --git a/app/edit_selection.c b/app/edit_selection.c index 76814d54e5..6d14fa1bf7 100644 --- a/app/edit_selection.c +++ b/app/edit_selection.c @@ -52,6 +52,7 @@ struct _edit_selection int old_scroll_lock; /* old value of scroll lock */ int old_auto_snap_to; /* old value of auto snap to */ + guint context_id; /* for the statusbar */ }; @@ -96,6 +97,7 @@ init_edit_selection (Tool *tool, { GDisplay *gdisp; Layer *layer; + gchar *offset; int x, y; gdisp = (GDisplay *) gdisp_ptr; @@ -145,6 +147,13 @@ init_edit_selection (Tool *tool, /* pause the current selection */ selection_pause (gdisp->select); + /* initialize the statusbar display */ + edit_select.context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), + "edit_select"); + offset = g_new (gchar, 11); /* strlen("Move: 0, 0") */ + gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), edit_select.context_id, "Move: 0, 0"); + g_free (offset); + /* Create and start the selection core */ edit_select.core = draw_core_new (edit_selection_draw); draw_core_start (edit_select.core, @@ -172,6 +181,8 @@ edit_selection_button_release (Tool *tool, gdk_pointer_ungrab (bevent->time); gdk_flush (); + gtk_statusbar_pop (GTK_STATUSBAR(gdisp->statusbar), edit_select.context_id); + /* Stop and free the selection core */ draw_core_stop (edit_select.core, tool); draw_core_free (edit_select.core); @@ -274,6 +285,7 @@ edit_selection_motion (Tool *tool, gpointer gdisp_ptr) { GDisplay * gdisp; + gchar *offset; if (tool->state != ACTIVE) return; @@ -284,6 +296,13 @@ edit_selection_motion (Tool *tool, edit_selection_snap (gdisp, mevent->x, mevent->y); + gtk_statusbar_pop (GTK_STATUSBAR(gdisp->statusbar), edit_select.context_id); + offset = g_new (gchar, 22); /* strlen("Move: x ") + 2*6 */ + g_snprintf (offset, 22, "Move: %d, %d", + (edit_select.x - edit_select.origx), (edit_select.y - edit_select.origy)); + gtk_statusbar_push (GTK_STATUSBAR(gdisp->statusbar), edit_select.context_id, offset); + g_free (offset); + draw_core_resume (edit_select.core, tool); } @@ -477,7 +496,7 @@ edit_selection_cursor_update (Tool *tool, } static int -process_event_queue_keys(GdkEventKey *kevent, ...) +process_event_queue_keys (GdkEventKey *kevent, ...) /* GdkKeyType, GdkModifierType, value ... 0 * could move this function to a more central location so it can be used * by other tools? */ diff --git a/app/rect_select.c b/app/rect_select.c index 863631c014..69864f074d 100644 --- a/app/rect_select.c +++ b/app/rect_select.c @@ -16,7 +16,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include -#include #include "appenv.h" #include "gdisplay.h" #include "gimage_mask.h" @@ -378,29 +377,29 @@ rect_select_button_press (Tool *tool, } rect_sel->op = REPLACE; } - rect_sel->context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR(gdisp->statusbar), - "selection"); + + rect_sel->context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), "selection"); select_mode = g_new (gchar, 21); /* strlen("Selection: INTERSECT") */ switch (rect_sel->op) { case ADD: - sprintf (select_mode, "Selection: ADD"); + g_snprintf (select_mode, 21, "Selection: ADD"); break; case SUB: - sprintf (select_mode, "Selection: SUBTRACT"); + g_snprintf (select_mode, 21, "Selection: SUBTRACT"); break; case INTERSECT: - sprintf (select_mode, "Selection: INTERSECT"); + g_snprintf (select_mode, 21, "Selection: INTERSECT"); break; case REPLACE: - sprintf (select_mode, "Selection: REPLACE"); + g_snprintf (select_mode, 21, "Selection: REPLACE"); break; default: break; } - gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), - rect_sel->context_id, select_mode); + gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), rect_sel->context_id, select_mode); g_free (select_mode); + draw_core_start (rect_sel->core, gdisp->canvas->window, tool); } @@ -419,8 +418,8 @@ rect_select_button_release (Tool *tool, gdk_pointer_ungrab (bevent->time); gdk_flush (); - gtk_statusbar_pop (GTK_STATUSBAR(gdisp->statusbar), - rect_sel->context_id); + gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), rect_sel->context_id); + draw_core_stop (rect_sel->core, tool); tool->state = INACTIVE; @@ -590,13 +589,13 @@ rect_select_motion (Tool *tool, rect_sel->center = FALSE; } - gtk_statusbar_pop (GTK_STATUSBAR(gdisp->statusbar), - rect_sel->context_id); + + gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), rect_sel->context_id); size = g_new (gchar, 25); /* strlen("Selection: x ") + 2*5 */ - sprintf (size, "Selection: %d x %d", abs(rect_sel->w), abs(rect_sel->h)); - gtk_statusbar_push (GTK_STATUSBAR(gdisp->statusbar), - rect_sel->context_id, size); + g_snprintf (size, 25, "Selection: %d x %d", abs(rect_sel->w), abs(rect_sel->h)); + gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), rect_sel->context_id, size); g_free (size); + draw_core_resume (rect_sel->core, tool); } diff --git a/app/tools/edit_selection.c b/app/tools/edit_selection.c index 76814d54e5..6d14fa1bf7 100644 --- a/app/tools/edit_selection.c +++ b/app/tools/edit_selection.c @@ -52,6 +52,7 @@ struct _edit_selection int old_scroll_lock; /* old value of scroll lock */ int old_auto_snap_to; /* old value of auto snap to */ + guint context_id; /* for the statusbar */ }; @@ -96,6 +97,7 @@ init_edit_selection (Tool *tool, { GDisplay *gdisp; Layer *layer; + gchar *offset; int x, y; gdisp = (GDisplay *) gdisp_ptr; @@ -145,6 +147,13 @@ init_edit_selection (Tool *tool, /* pause the current selection */ selection_pause (gdisp->select); + /* initialize the statusbar display */ + edit_select.context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), + "edit_select"); + offset = g_new (gchar, 11); /* strlen("Move: 0, 0") */ + gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), edit_select.context_id, "Move: 0, 0"); + g_free (offset); + /* Create and start the selection core */ edit_select.core = draw_core_new (edit_selection_draw); draw_core_start (edit_select.core, @@ -172,6 +181,8 @@ edit_selection_button_release (Tool *tool, gdk_pointer_ungrab (bevent->time); gdk_flush (); + gtk_statusbar_pop (GTK_STATUSBAR(gdisp->statusbar), edit_select.context_id); + /* Stop and free the selection core */ draw_core_stop (edit_select.core, tool); draw_core_free (edit_select.core); @@ -274,6 +285,7 @@ edit_selection_motion (Tool *tool, gpointer gdisp_ptr) { GDisplay * gdisp; + gchar *offset; if (tool->state != ACTIVE) return; @@ -284,6 +296,13 @@ edit_selection_motion (Tool *tool, edit_selection_snap (gdisp, mevent->x, mevent->y); + gtk_statusbar_pop (GTK_STATUSBAR(gdisp->statusbar), edit_select.context_id); + offset = g_new (gchar, 22); /* strlen("Move: x ") + 2*6 */ + g_snprintf (offset, 22, "Move: %d, %d", + (edit_select.x - edit_select.origx), (edit_select.y - edit_select.origy)); + gtk_statusbar_push (GTK_STATUSBAR(gdisp->statusbar), edit_select.context_id, offset); + g_free (offset); + draw_core_resume (edit_select.core, tool); } @@ -477,7 +496,7 @@ edit_selection_cursor_update (Tool *tool, } static int -process_event_queue_keys(GdkEventKey *kevent, ...) +process_event_queue_keys (GdkEventKey *kevent, ...) /* GdkKeyType, GdkModifierType, value ... 0 * could move this function to a more central location so it can be used * by other tools? */ diff --git a/app/tools/gimpeditselectiontool.c b/app/tools/gimpeditselectiontool.c index 76814d54e5..6d14fa1bf7 100644 --- a/app/tools/gimpeditselectiontool.c +++ b/app/tools/gimpeditselectiontool.c @@ -52,6 +52,7 @@ struct _edit_selection int old_scroll_lock; /* old value of scroll lock */ int old_auto_snap_to; /* old value of auto snap to */ + guint context_id; /* for the statusbar */ }; @@ -96,6 +97,7 @@ init_edit_selection (Tool *tool, { GDisplay *gdisp; Layer *layer; + gchar *offset; int x, y; gdisp = (GDisplay *) gdisp_ptr; @@ -145,6 +147,13 @@ init_edit_selection (Tool *tool, /* pause the current selection */ selection_pause (gdisp->select); + /* initialize the statusbar display */ + edit_select.context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), + "edit_select"); + offset = g_new (gchar, 11); /* strlen("Move: 0, 0") */ + gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), edit_select.context_id, "Move: 0, 0"); + g_free (offset); + /* Create and start the selection core */ edit_select.core = draw_core_new (edit_selection_draw); draw_core_start (edit_select.core, @@ -172,6 +181,8 @@ edit_selection_button_release (Tool *tool, gdk_pointer_ungrab (bevent->time); gdk_flush (); + gtk_statusbar_pop (GTK_STATUSBAR(gdisp->statusbar), edit_select.context_id); + /* Stop and free the selection core */ draw_core_stop (edit_select.core, tool); draw_core_free (edit_select.core); @@ -274,6 +285,7 @@ edit_selection_motion (Tool *tool, gpointer gdisp_ptr) { GDisplay * gdisp; + gchar *offset; if (tool->state != ACTIVE) return; @@ -284,6 +296,13 @@ edit_selection_motion (Tool *tool, edit_selection_snap (gdisp, mevent->x, mevent->y); + gtk_statusbar_pop (GTK_STATUSBAR(gdisp->statusbar), edit_select.context_id); + offset = g_new (gchar, 22); /* strlen("Move: x ") + 2*6 */ + g_snprintf (offset, 22, "Move: %d, %d", + (edit_select.x - edit_select.origx), (edit_select.y - edit_select.origy)); + gtk_statusbar_push (GTK_STATUSBAR(gdisp->statusbar), edit_select.context_id, offset); + g_free (offset); + draw_core_resume (edit_select.core, tool); } @@ -477,7 +496,7 @@ edit_selection_cursor_update (Tool *tool, } static int -process_event_queue_keys(GdkEventKey *kevent, ...) +process_event_queue_keys (GdkEventKey *kevent, ...) /* GdkKeyType, GdkModifierType, value ... 0 * could move this function to a more central location so it can be used * by other tools? */ diff --git a/app/tools/gimprectselecttool.c b/app/tools/gimprectselecttool.c index 863631c014..69864f074d 100644 --- a/app/tools/gimprectselecttool.c +++ b/app/tools/gimprectselecttool.c @@ -16,7 +16,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include -#include #include "appenv.h" #include "gdisplay.h" #include "gimage_mask.h" @@ -378,29 +377,29 @@ rect_select_button_press (Tool *tool, } rect_sel->op = REPLACE; } - rect_sel->context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR(gdisp->statusbar), - "selection"); + + rect_sel->context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), "selection"); select_mode = g_new (gchar, 21); /* strlen("Selection: INTERSECT") */ switch (rect_sel->op) { case ADD: - sprintf (select_mode, "Selection: ADD"); + g_snprintf (select_mode, 21, "Selection: ADD"); break; case SUB: - sprintf (select_mode, "Selection: SUBTRACT"); + g_snprintf (select_mode, 21, "Selection: SUBTRACT"); break; case INTERSECT: - sprintf (select_mode, "Selection: INTERSECT"); + g_snprintf (select_mode, 21, "Selection: INTERSECT"); break; case REPLACE: - sprintf (select_mode, "Selection: REPLACE"); + g_snprintf (select_mode, 21, "Selection: REPLACE"); break; default: break; } - gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), - rect_sel->context_id, select_mode); + gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), rect_sel->context_id, select_mode); g_free (select_mode); + draw_core_start (rect_sel->core, gdisp->canvas->window, tool); } @@ -419,8 +418,8 @@ rect_select_button_release (Tool *tool, gdk_pointer_ungrab (bevent->time); gdk_flush (); - gtk_statusbar_pop (GTK_STATUSBAR(gdisp->statusbar), - rect_sel->context_id); + gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), rect_sel->context_id); + draw_core_stop (rect_sel->core, tool); tool->state = INACTIVE; @@ -590,13 +589,13 @@ rect_select_motion (Tool *tool, rect_sel->center = FALSE; } - gtk_statusbar_pop (GTK_STATUSBAR(gdisp->statusbar), - rect_sel->context_id); + + gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), rect_sel->context_id); size = g_new (gchar, 25); /* strlen("Selection: x ") + 2*5 */ - sprintf (size, "Selection: %d x %d", abs(rect_sel->w), abs(rect_sel->h)); - gtk_statusbar_push (GTK_STATUSBAR(gdisp->statusbar), - rect_sel->context_id, size); + g_snprintf (size, 25, "Selection: %d x %d", abs(rect_sel->w), abs(rect_sel->h)); + gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), rect_sel->context_id, size); g_free (size); + draw_core_resume (rect_sel->core, tool); } diff --git a/app/tools/rect_select.c b/app/tools/rect_select.c index 863631c014..69864f074d 100644 --- a/app/tools/rect_select.c +++ b/app/tools/rect_select.c @@ -16,7 +16,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include -#include #include "appenv.h" #include "gdisplay.h" #include "gimage_mask.h" @@ -378,29 +377,29 @@ rect_select_button_press (Tool *tool, } rect_sel->op = REPLACE; } - rect_sel->context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR(gdisp->statusbar), - "selection"); + + rect_sel->context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), "selection"); select_mode = g_new (gchar, 21); /* strlen("Selection: INTERSECT") */ switch (rect_sel->op) { case ADD: - sprintf (select_mode, "Selection: ADD"); + g_snprintf (select_mode, 21, "Selection: ADD"); break; case SUB: - sprintf (select_mode, "Selection: SUBTRACT"); + g_snprintf (select_mode, 21, "Selection: SUBTRACT"); break; case INTERSECT: - sprintf (select_mode, "Selection: INTERSECT"); + g_snprintf (select_mode, 21, "Selection: INTERSECT"); break; case REPLACE: - sprintf (select_mode, "Selection: REPLACE"); + g_snprintf (select_mode, 21, "Selection: REPLACE"); break; default: break; } - gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), - rect_sel->context_id, select_mode); + gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), rect_sel->context_id, select_mode); g_free (select_mode); + draw_core_start (rect_sel->core, gdisp->canvas->window, tool); } @@ -419,8 +418,8 @@ rect_select_button_release (Tool *tool, gdk_pointer_ungrab (bevent->time); gdk_flush (); - gtk_statusbar_pop (GTK_STATUSBAR(gdisp->statusbar), - rect_sel->context_id); + gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), rect_sel->context_id); + draw_core_stop (rect_sel->core, tool); tool->state = INACTIVE; @@ -590,13 +589,13 @@ rect_select_motion (Tool *tool, rect_sel->center = FALSE; } - gtk_statusbar_pop (GTK_STATUSBAR(gdisp->statusbar), - rect_sel->context_id); + + gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), rect_sel->context_id); size = g_new (gchar, 25); /* strlen("Selection: x ") + 2*5 */ - sprintf (size, "Selection: %d x %d", abs(rect_sel->w), abs(rect_sel->h)); - gtk_statusbar_push (GTK_STATUSBAR(gdisp->statusbar), - rect_sel->context_id, size); + g_snprintf (size, 25, "Selection: %d x %d", abs(rect_sel->w), abs(rect_sel->h)); + gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), rect_sel->context_id, size); g_free (size); + draw_core_resume (rect_sel->core, tool); }