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

made the gimp_object_get_memsize() debugging output configurable by a

2002-02-06  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpobject.c: made the gimp_object_get_memsize()
	debugging output configurable by a global "gimp_debug_memsize"
	boolean.

	* app/display/gimpdisplay.c: removed duplicated prototype.

	* app/display/gimpdisplayshell.[ch]: renamed the various cursor
	functions to be more consistent and shorter. Compress window title
	updates by adding a "gboolean title_dirty" and updating the title
	in gimp_display_shell_flush().  Added "%m" (memory size) to the
	possible title string substitutions.

	* app/display/gimpdisplay-foreach.c
	* app/display/gimpdisplayshell-handlers.c
	* app/tools/gimpfuzzyselecttool.c
	* app/tools/gimptool.c: changed accordingly.

	* app/display/gimpdisplayshell-callbacks.c: forgot to grab the
	pointer when dragging guides from the rulers. Coincidentially,
	this also fixes the buggy offset between guide and mouse
	pointer...
	Cleaned up the main tool event callback a but more.

	* app/widgets/gimppreview.c
	* app/gui/commands.c: set the new global "gimp_debug_memsize"
	toggle to TRUE while calling gimp_object_get_memsize().

	* app/gui/preferences-dialog.c: added a image title example
	containing the new "%m" feature.

	* docs/gimprc-1.3.5.in: document "%m" in the manpage.

	* app/tools/gimpbezierselecttool.c: reordered some statements.

	* app/tools/gimpdrawtool.[ch]: store the GimpDisplay passed to
	gimp_draw_tool_start() in draw_tool->gdisp and use it for
	coordinate transfomration. This way we can paint on a display
	which is not tool->gdisp.

	* app/tools/gimppainttool.c: changed the gimp_draw_tool_foo()
	calls needed to make the straight_line preview work in a way
	that does not interfere with paint_tool subclasses which want
	to do their own drawing (like the clone tool).

	Also changed the paint_tools PRETRACE_PAINT and POSTTRACE_PAINT
	flags usage in a way that subclasses can use them without major
	hackery: don't simply wrap gimp_display_flush_now() with
	PRETRACE/POSTTRACE calls, but wrap the actual painting calls, so
	subclasses are able to do useful things with paint_tool->*_coords.

	* app/tools/gimpclonetool.c: removed poking around in draw_tool
	internals and simply suspend()/resume() it in
	PRETRACE_PAINT/POSTTRACE_PAINT to get the clone_src indicator
	drawn correctly.
parent acebb116
2002-02-06 Michael Natterer <mitch@gimp.org>
* app/core/gimpobject.c: made the gimp_object_get_memsize()
debugging output configurable by a global "gimp_debug_memsize"
boolean.
* app/display/gimpdisplay.c: removed duplicated prototype.
* app/display/gimpdisplayshell.[ch]: renamed the various cursor
functions to be more consistent and shorter. Compress window title
updates by adding a "gboolean title_dirty" and updating the title
in gimp_display_shell_flush(). Added "%m" (memory size) to the
possible title string substitutions.
* app/display/gimpdisplay-foreach.c
* app/display/gimpdisplayshell-handlers.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimptool.c: changed accordingly.
* app/display/gimpdisplayshell-callbacks.c: forgot to grab the
pointer when dragging guides from the rulers. Coincidentially,
this also fixes the buggy offset between guide and mouse
pointer...
Cleaned up the main tool event callback a but more.
* app/widgets/gimppreview.c
* app/gui/commands.c: set the new global "gimp_debug_memsize"
toggle to TRUE while calling gimp_object_get_memsize().
* app/gui/preferences-dialog.c: added a image title example
containing the new "%m" feature.
* docs/gimprc-1.3.5.in: document "%m" in the manpage.
* app/tools/gimpbezierselecttool.c: reordered some statements.
* app/tools/gimpdrawtool.[ch]: store the GimpDisplay passed to
gimp_draw_tool_start() in draw_tool->gdisp and use it for
coordinate transfomration. This way we can paint on a display
which is not tool->gdisp.
* app/tools/gimppainttool.c: changed the gimp_draw_tool_foo()
calls needed to make the straight_line preview work in a way
that does not interfere with paint_tool subclasses which want
to do their own drawing (like the clone tool).
Also changed the paint_tools PRETRACE_PAINT and POSTTRACE_PAINT
flags usage in a way that subclasses can use them without major
hackery: don't simply wrap gimp_display_flush_now() with
PRETRACE/POSTTRACE calls, but wrap the actual painting calls, so
subclasses are able to do useful things with paint_tool->*_coords.
* app/tools/gimpclonetool.c: removed poking around in draw_tool
internals and simply suspend()/resume() it in
PRETRACE_PAINT/POSTTRACE_PAINT to get the clone_src indicator
drawn correctly.
2002-02-05 Michael Natterer <mitch@gimp.org>
 
* plug-ins/FractalExplorer/Dialogs.c
......
......@@ -63,5 +63,11 @@ void
debug_mem_profile_cmd_callback (GtkWidget *widget,
gpointer data)
{
extern gboolean gimp_debug_memsize;
gimp_debug_memsize = TRUE;
gimp_object_get_memsize (GIMP_OBJECT (data));
gimp_debug_memsize = FALSE;
}
......@@ -251,56 +251,62 @@ gimp_object_name_changed (GimpObject *object)
g_signal_emit (G_OBJECT (object), object_signals[NAME_CHANGED], 0);
}
#define DEBUG_MEMSIZE 1
#ifdef DEBUG_MEMSIZE
gboolean gimp_debug_memsize = FALSE;
#endif
gsize
gimp_object_get_memsize (GimpObject *object)
{
g_return_val_if_fail (GIMP_IS_OBJECT (object), 0);
#define DEBUG_MEMSIZE 1
#ifdef DEBUG_MEMSIZE
{
static gint indent_level = 0;
static GList *aggregation_tree = NULL;
static gchar indent_buf[256];
if (gimp_debug_memsize)
{
static gint indent_level = 0;
static GList *aggregation_tree = NULL;
static gchar indent_buf[256];
gsize memsize;
gint i;
gint my_indent_level;
gchar *object_size;
gsize memsize;
gint i;
gint my_indent_level;
gchar *object_size;
indent_level++;
indent_level++;
my_indent_level = indent_level;
my_indent_level = indent_level;
memsize = GIMP_OBJECT_GET_CLASS (object)->get_memsize (object);
memsize = GIMP_OBJECT_GET_CLASS (object)->get_memsize (object);
indent_level--;
indent_level--;
for (i = 0; i < MIN (my_indent_level * 2, sizeof (indent_buf) - 1); i++)
indent_buf[i] = ' ';
for (i = 0; i < MIN (my_indent_level * 2, sizeof (indent_buf) - 1); i++)
indent_buf[i] = ' ';
indent_buf[i] = '\0';
indent_buf[i] = '\0';
object_size = g_strdup_printf ("%s%s \"%s\": %d\n",
indent_buf,
g_type_name (G_TYPE_FROM_INSTANCE (object)),
object->name,
memsize);
object_size = g_strdup_printf ("%s%s \"%s\": %d\n",
indent_buf,
g_type_name (G_TYPE_FROM_INSTANCE (object)),
object->name,
memsize);
aggregation_tree = g_list_prepend (aggregation_tree, object_size);
aggregation_tree = g_list_prepend (aggregation_tree, object_size);
if (indent_level == 0)
{
g_list_foreach (aggregation_tree, g_print, NULL);
g_list_foreach (aggregation_tree, g_free, NULL);
g_list_free (aggregation_tree);
if (indent_level == 0)
{
g_list_foreach (aggregation_tree, (GFunc) g_print, NULL);
g_list_foreach (aggregation_tree, (GFunc) g_free, NULL);
g_list_free (aggregation_tree);
aggregation_tree = NULL;
}
aggregation_tree = NULL;
}
return memsize;
}
return memsize;
}
#endif /* DEBUG_MEMSIZE */
return GIMP_OBJECT_GET_CLASS (object)->get_memsize (object);
......
......@@ -56,8 +56,6 @@ static void gimp_display_init (GimpDisplay *gdisp);
static void gimp_display_finalize (GObject *object);
static void gimp_display_flush_whenever (GimpDisplay *gdisp,
gboolean now);
static void gimp_display_flush_whenever (GimpDisplay *gdisp,
gboolean now);
static void gimp_display_idlerender_init (GimpDisplay *gdisp);
......
......@@ -2257,7 +2257,8 @@ preferences_dialog_create (Gimp *gimp)
"%f-%p.%i (%t)",
"%f-%p.%i (%t) %z%%",
"%f-%p.%i (%t) %d:%s",
"%f-%p.%i (%t) %s:%d"
"%f-%p.%i (%t) %s:%d",
"%f-%p.%i (%t) %m"
};
const gchar *combo_strings[] =
......@@ -2266,7 +2267,8 @@ preferences_dialog_create (Gimp *gimp)
N_("Standard"),
N_("Show zoom percentage"),
N_("Show zoom ratio"),
N_("Show reversed zoom ratio")
N_("Show reversed zoom ratio"),
N_("Show memory usage")
};
g_assert (G_N_ELEMENTS (format_strings) == G_N_ELEMENTS (combo_strings));
......
......@@ -202,7 +202,7 @@ gdisplays_set_busy (void)
{
shell = GIMP_DISPLAY_SHELL (GIMP_DISPLAY (list->data)->shell);
gimp_display_shell_install_override_cursor (shell, GDK_WATCH);
gimp_display_shell_set_override_cursor (shell, GDK_WATCH);
}
}
......@@ -216,6 +216,6 @@ gdisplays_unset_busy (void)
{
shell = GIMP_DISPLAY_SHELL (GIMP_DISPLAY (list->data)->shell);
gimp_display_shell_remove_override_cursor (shell);
gimp_display_shell_unset_override_cursor (shell);
}
}
......@@ -56,8 +56,6 @@ static void gimp_display_init (GimpDisplay *gdisp);
static void gimp_display_finalize (GObject *object);
static void gimp_display_flush_whenever (GimpDisplay *gdisp,
gboolean now);
static void gimp_display_flush_whenever (GimpDisplay *gdisp,
gboolean now);
static void gimp_display_idlerender_init (GimpDisplay *gdisp);
......
......@@ -191,10 +191,10 @@ gimp_display_shell_canvas_realize (GtkWidget *canvas,
gimp_display_shell_scale_setup (shell);
/* set the initial cursor */
gimp_display_shell_install_tool_cursor (shell,
GDK_TOP_LEFT_ARROW,
GIMP_TOOL_CURSOR_NONE,
GIMP_CURSOR_MODIFIER_NONE);
gimp_display_shell_set_cursor (shell,
GDK_TOP_LEFT_ARROW,
GIMP_TOOL_CURSOR_NONE,
GIMP_CURSOR_MODIFIER_NONE);
/* allow shrinking */
gtk_widget_set_size_request (GTK_WIDGET (shell), 0, 0);
......@@ -499,7 +499,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
gtk_grab_add (canvas);
gimp_display_shell_install_override_cursor (shell, GDK_FLEUR);
gimp_display_shell_set_override_cursor (shell, GDK_FLEUR);
break;
case 3:
......@@ -609,7 +609,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
gtk_grab_remove (canvas);
gimp_display_shell_remove_override_cursor (shell);
gimp_display_shell_unset_override_cursor (shell);
break;
case 3:
......@@ -695,11 +695,12 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
active_tool = tool_manager_get_active (gimage->gimp);
if ((state & GDK_BUTTON1_MASK) &&
active_tool && (! gimp_image_is_empty (gimage) ||
active_tool->handle_empty_image))
if (state & GDK_BUTTON1_MASK)
{
if (active_tool->state == ACTIVE)
if (active_tool &&
active_tool->state == ACTIVE &&
(! gimp_image_is_empty (gimage) ||
active_tool->handle_empty_image))
{
/* if the first mouse button is down, check for automatic
* scrolling...
......@@ -764,13 +765,16 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
gdisp);
}
}
else if ((state & GDK_BUTTON2_MASK) && scrolling)
else if (state & GDK_BUTTON2_MASK)
{
gimp_display_shell_scroll (shell,
(scroll_start_x - mevent->x -
shell->offset_x),
(scroll_start_y - mevent->y -
shell->offset_y));
if (scrolling)
{
gimp_display_shell_scroll (shell,
(scroll_start_x - mevent->x -
shell->offset_x),
(scroll_start_y - mevent->y -
shell->offset_y));
}
}
if (! (state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)))
......@@ -943,18 +947,18 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
}
else if (gimp_image_is_empty (gimage))
{
gimp_display_shell_install_tool_cursor (shell,
GIMP_BAD_CURSOR,
active_tool->tool_cursor,
GIMP_CURSOR_MODIFIER_NONE);
gimp_display_shell_set_cursor (shell,
GIMP_BAD_CURSOR,
active_tool->tool_cursor,
GIMP_CURSOR_MODIFIER_NONE);
}
}
else
{
gimp_display_shell_install_tool_cursor (shell,
GIMP_BAD_CURSOR,
GIMP_TOOL_CURSOR_NONE,
GIMP_CURSOR_MODIFIER_NONE);
gimp_display_shell_set_cursor (shell,
GIMP_BAD_CURSOR,
GIMP_TOOL_CURSOR_NONE,
GIMP_CURSOR_MODIFIER_NONE);
}
}
......@@ -998,8 +1002,13 @@ gimp_display_shell_hruler_button_press (GtkWidget *widget,
if (active_tool)
{
gdk_pointer_grab (shell->canvas->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK,
NULL, NULL, event->time);
gimp_move_tool_start_hguide (active_tool, gdisp);
gtk_grab_add (shell->canvas);
}
}
}
......@@ -1037,8 +1046,13 @@ gimp_display_shell_vruler_button_press (GtkWidget *widget,
if (active_tool)
{
gdk_pointer_grab (shell->canvas->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK,
NULL, NULL, event->time);
gimp_move_tool_start_vguide (active_tool, gdisp);
gtk_grab_add (shell->canvas);
}
}
}
......
......@@ -33,6 +33,7 @@
#include "core/gimpimage.h"
#include "core/gimpimage-guides.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-new.h"
#include "core/gimplayer.h"
#include "core/gimplayermask.h"
#include "core/gimppattern.h"
......@@ -93,6 +94,11 @@ static void gimp_display_shell_display_area (GimpDisplayShell *shell,
gint y,
gint w,
gint h);
static void gimp_display_shell_real_set_cursor (GimpDisplayShell *shell,
GdkCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier,
gboolean always_install);
static void gimp_display_shell_draw_cursor (GimpDisplayShell *shell);
static void gimp_display_shell_format_title (GimpDisplayShell *gdisp,
......@@ -208,6 +214,8 @@ gimp_display_shell_init (GimpDisplayShell *shell)
3);
shell->render_gc = NULL;
shell->title_dirty = FALSE;
shell->icon_size = 32;
shell->icon_idle_id = 0;
......@@ -1287,6 +1295,13 @@ gimp_display_shell_flush (GimpDisplayShell *shell)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (shell->title_dirty)
{
gimp_display_shell_update_title (shell);
shell->title_dirty = FALSE;
}
if (shell->display_areas)
{
GSList *list;
......@@ -1315,7 +1330,7 @@ gimp_display_shell_flush (GimpDisplayShell *shell)
/* draw the guides */
gimp_display_shell_draw_guides (shell);
/* and the cursor (if we have a software cursor */
/* and the cursor (if we have a software cursor) */
if (shell->have_cursor)
gimp_display_shell_draw_cursor (shell);
......@@ -1325,85 +1340,30 @@ gimp_display_shell_flush (GimpDisplayShell *shell)
/* start the currently active tool */
tool_manager_control_active (shell->gdisp->gimage->gimp, RESUME,
shell->gdisp);
}
}
void
gimp_display_shell_real_install_tool_cursor (GimpDisplayShell *shell,
GdkCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier,
gboolean always_install)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (cursor_type != GIMP_BAD_CURSOR)
{
switch (gimprc.cursor_mode)
{
case GIMP_CURSOR_MODE_TOOL_ICON:
break;
case GIMP_CURSOR_MODE_TOOL_CROSSHAIR:
cursor_type = GIMP_CROSSHAIR_SMALL_CURSOR;
break;
case GIMP_CURSOR_MODE_CROSSHAIR:
cursor_type = GIMP_CROSSHAIR_CURSOR;
tool_cursor = GIMP_TOOL_CURSOR_NONE;
modifier = GIMP_CURSOR_MODIFIER_NONE;
break;
}
}
if (shell->current_cursor != cursor_type ||
shell->tool_cursor != tool_cursor ||
shell->cursor_modifier != modifier ||
always_install)
{
GdkCursor *cursor;
shell->current_cursor = cursor_type;
shell->tool_cursor = tool_cursor;
shell->cursor_modifier = modifier;
cursor = gimp_cursor_new (cursor_type,
tool_cursor,
modifier);
gdk_window_set_cursor (shell->canvas->window, cursor);
gdk_cursor_unref (cursor);
}
}
void
gimp_display_shell_install_tool_cursor (GimpDisplayShell *shell,
GdkCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier)
gimp_display_shell_set_cursor (GimpDisplayShell *shell,
GdkCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (! shell->using_override_cursor)
{
gimp_display_shell_real_install_tool_cursor (shell,
cursor_type,
tool_cursor,
modifier,
FALSE);
gimp_display_shell_real_set_cursor (shell,
cursor_type,
tool_cursor,
modifier,
FALSE);
}
}
void
gimp_display_shell_remove_tool_cursor (GimpDisplayShell *shell)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
gdk_window_set_cursor (shell->canvas->window, NULL);
}
void
gimp_display_shell_install_override_cursor (GimpDisplayShell *shell,
GdkCursorType cursor_type)
gimp_display_shell_set_override_cursor (GimpDisplayShell *shell,
GdkCursorType cursor_type)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
......@@ -1425,7 +1385,7 @@ gimp_display_shell_install_override_cursor (GimpDisplayShell *shell,
}
void
gimp_display_shell_remove_override_cursor (GimpDisplayShell *shell)
gimp_display_shell_unset_override_cursor (GimpDisplayShell *shell)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
......@@ -1433,11 +1393,11 @@ gimp_display_shell_remove_override_cursor (GimpDisplayShell *shell)
{
shell->using_override_cursor = FALSE;
gimp_display_shell_real_install_tool_cursor (shell,
shell->current_cursor,
shell->tool_cursor,
shell->cursor_modifier,
TRUE);
gimp_display_shell_real_set_cursor (shell,
shell->current_cursor,
shell->tool_cursor,
shell->cursor_modifier,
TRUE);
}
}
......@@ -1953,6 +1913,53 @@ gimp_display_shell_display_area (GimpDisplayShell *shell,
}
}
static void
gimp_display_shell_real_set_cursor (GimpDisplayShell *shell,
GdkCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier,
gboolean always_install)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (cursor_type != GIMP_BAD_CURSOR)
{
switch (gimprc.cursor_mode)
{
case GIMP_CURSOR_MODE_TOOL_ICON:
break;
case GIMP_CURSOR_MODE_TOOL_CROSSHAIR:
cursor_type = GIMP_CROSSHAIR_SMALL_CURSOR;
break;
case GIMP_CURSOR_MODE_CROSSHAIR:
cursor_type = GIMP_CROSSHAIR_CURSOR;
tool_cursor = GIMP_TOOL_CURSOR_NONE;
modifier = GIMP_CURSOR_MODIFIER_NONE;
break;
}
}
if (shell->current_cursor != cursor_type ||
shell->tool_cursor != tool_cursor ||
shell->cursor_modifier != modifier ||
always_install)
{
GdkCursor *cursor;
shell->current_cursor = cursor_type;
shell->tool_cursor = tool_cursor;
shell->cursor_modifier = modifier;
cursor = gimp_cursor_new (cursor_type,
tool_cursor,
modifier);
gdk_window_set_cursor (shell->canvas->window, cursor);
gdk_cursor_unref (cursor);
}
}
static void
gimp_display_shell_draw_cursor (GimpDisplayShell *shell)
{
......@@ -2052,13 +2059,21 @@ gimp_display_shell_update_icon_scheduler (GimpImage *gimage,
NULL);
}
static int print (char *, int, int, const char *, ...) G_GNUC_PRINTF (4, 5);
static int
print (char *buf, int len, int start, const char *fmt, ...)
static gint print (gchar *buf,
gint len,
gint start,
const gchar *fmt,
...) G_GNUC_PRINTF (4, 5);
static gint
print (gchar *buf,
gint len,
gint start,
const gchar *fmt,
...)
{
va_list args;
int printed;
gint printed;
va_start (args, fmt);
......@@ -2077,7 +2092,7 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
gint title_len)
{
GimpImage *gimage;
gchar *image_type_str;
gchar *image_type_str = NULL;
gboolean empty;
gint i;
gchar *format;
......@@ -2100,7 +2115,7 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
image_type_str = empty ? _("indexed-empty") : _("indexed");
break;