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
This commit is contained in:
Sven Neumann 1998-07-23 18:33:01 +00:00
parent 1e365c6a0d
commit 1f73342df7
7 changed files with 110 additions and 51 deletions

View File

@ -1,3 +1,8 @@
Thu Jul 23 20:29:40 MEST 1998 Sven Neumann <sven@gimp.org>
* 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 <yosh@gimp.org>
* app/fileops.c: tell the PDB that gimp_register_magic_load_handler

View File

@ -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? */

View File

@ -16,7 +16,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <stdio.h>
#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);
}

View File

@ -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? */

View File

@ -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? */

View File

@ -16,7 +16,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <stdio.h>
#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);
}

View File

@ -16,7 +16,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <stdio.h>
#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);
}