Commit 72ca4d3e authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

renamed the image size utility functions from foo_size_bar() to

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

	* app/core/gimpimage-new.[ch]: renamed the image size utility
	functions from foo_size_bar() to foo_memsize_bar(), use "gsize"
	instead of "gdouble". Also take the selection mask into account
	for the initial image size.

	* app/display/gimpdisplayshell.c
	* app/gui/file-new-dialog.c: changed accordingly.

	* app/display/gimpdisplayshell-handlers.c: connect to "undo_event",
	not "dirty" and "clean" to dirty the image title.

	* app/tools/gimpmovetool.c: factored common code out to
	gimp_move_tool_start_guide(), also set a useful cursor there.
parent 619a0724
2002-02-07 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-new.[ch]: renamed the image size utility
functions from foo_size_bar() to foo_memsize_bar(), use "gsize"
instead of "gdouble". Also take the selection mask into account
for the initial image size.
* app/display/gimpdisplayshell.c
* app/gui/file-new-dialog.c: changed accordingly.
* app/display/gimpdisplayshell-handlers.c: connect to "undo_event",
not "dirty" and "clean" to dirty the image title.
* app/tools/gimpmovetool.c: factored common code out to
gimp_move_tool_start_guide(), also set a useful cursor there.
2002-02-07 Sven Neumann <sven@gimp.org>
 
* app/widgets/gimpwidgets-utils.c (gimp_message_box): changed the
......@@ -69,7 +85,7 @@
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.
Cleaned up the main tool event callback a bit more.
 
* app/widgets/gimppreview.c
* app/gui/commands.c: set the new global "gimp_debug_memsize"
......@@ -84,7 +100,7 @@
 
* 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
coordinate transfomration. This way we can draw on a display
which is not tool->gdisp.
 
* app/tools/gimppainttool.c: changed the gimp_draw_tool_foo()
......
......@@ -182,38 +182,45 @@ gimp_image_new_values_free (GimpImageNewValues *values)
g_free (values);
}
gdouble
gimp_image_new_calculate_size (GimpImageNewValues *values)
gsize
gimp_image_new_calculate_memsize (GimpImageNewValues *values)
{
gdouble width, height;
gdouble size;
gint channels;
width = (gdouble) values->width;
height = (gdouble) values->height;
channels = ((values->type == GIMP_RGB ? 3 : 1) /* color */ +
(values->fill_type == TRANSPARENT_FILL) /* alpha */ +
1 /* selection */);
size =
width * height *
((values->type == GIMP_RGB ? 3 : 1) + /* bytes per pixel */
(values->fill_type == TRANSPARENT_FILL ? 1 : 0)); /* alpha channel */
return size;
return channels * values->width * values->height;
}
gchar *
gimp_image_new_get_size_string (gdouble size)
gimp_image_new_get_memsize_string (gsize memsize)
{
if (size < 4096)
return g_strdup_printf (_("%d Bytes"), (gint) size);
else if (size < 1024 * 10)
return g_strdup_printf (_("%.2f KB"), size / 1024);
else if (size < 1024 * 100)
return g_strdup_printf (_("%.1f KB"), size / 1024);
else if (size < 1024 * 1024)
return g_strdup_printf (_("%d KB"), (gint) size / 1024);
else if (size < 1024 * 1024 * 10)
return g_strdup_printf (_("%.2f MB"), size / 1024 / 1024);
if (memsize < 4096)
{
return g_strdup_printf (_("%d Bytes"), memsize);
}
else if (memsize < 1024 * 10)
{
return g_strdup_printf (_("%.2f KB"), (gdouble) memsize / 1024.0);
}
else if (memsize < 1024 * 100)
{
return g_strdup_printf (_("%.1f KB"), (gdouble) memsize / 1024.0);
}
else if (memsize < 1024 * 1024)
{
return g_strdup_printf (_("%d KB"), memsize / 1024);
}
else if (memsize < 1024 * 1024 * 10)
{
return g_strdup_printf (_("%.2f MB"), (gdouble) memsize / 1024.0 / 1024.0);
}
else
return g_strdup_printf (_("%.1f MB"), size / 1024 / 1024);
{
return g_strdup_printf (_("%.1f MB"), (gdouble) memsize / 1024.0 / 1024.0);
}
}
void
......
......@@ -61,8 +61,8 @@ void gimp_image_new_set_default_values (Gimp *gimp,
GimpImageNewValues *values);
void gimp_image_new_values_free (GimpImageNewValues *values);
gdouble gimp_image_new_calculate_size (GimpImageNewValues *values);
gchar * gimp_image_new_get_size_string (gdouble size);
gsize gimp_image_new_calculate_memsize (GimpImageNewValues *values);
gchar * gimp_image_new_get_memsize_string (gsize memsize);
void gimp_image_new_set_have_current_cut_buffer (Gimp *gimp);
......
......@@ -582,8 +582,8 @@ file_new_confirm_dialog (NewImageInfo *info)
gtk_widget_set_sensitive (info->dialog, FALSE);
size = gimp_image_new_get_size_string (info->size);
max_size = gimp_image_new_get_size_string (gimprc.max_new_image_size);
size = gimp_image_new_get_memsize_string (info->size);
max_size = gimp_image_new_get_memsize_string (gimprc.max_new_image_size);
/* xgettext:no-c-format */
......@@ -685,9 +685,9 @@ file_new_image_size_callback (GtkWidget *widget,
info->values->height =
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1));
info->size = gimp_image_new_calculate_size (info->values);
info->size = gimp_image_new_calculate_memsize (info->values);
text = gimp_image_new_get_size_string (info->size);
text = gimp_image_new_get_memsize_string (info->size);
gtk_label_set_text (GTK_LABEL (info->memsize_label), text);
g_free (text);
}
......@@ -2199,7 +2199,7 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
memsize = gimp_object_get_memsize (GIMP_OBJECT (gimage));
size_str = gimp_image_new_get_size_string (memsize);
size_str = gimp_image_new_get_memsize_string (memsize);
i += print (title, title_len, i, "%s", size_str);
......
......@@ -38,7 +38,10 @@
/* local function prototypes */
static void gimp_display_shell_update_title_handler (GimpImage *gimage,
static void gimp_display_shell_undo_event_handler (GimpImage *gimage,
gint event,
GimpDisplayShell *shell);
static void gimp_display_shell_name_changed_handler (GimpImage *gimage,
GimpDisplayShell *shell);
static void gimp_display_shell_selection_control_handler (GimpImage *gimage,
GimpSelectionControl control,
......@@ -69,16 +72,12 @@ gimp_display_shell_connect (GimpDisplayShell *shell)
gimage = shell->gdisp->gimage;
g_signal_connect (G_OBJECT (gimage), "dirty",
G_CALLBACK (gimp_display_shell_update_title_handler),
shell);
g_signal_connect (G_OBJECT (gimage), "clean",
G_CALLBACK (gimp_display_shell_update_title_handler),
g_signal_connect (G_OBJECT (gimage), "undo_event",
G_CALLBACK (gimp_display_shell_undo_event_handler),
shell);
g_signal_connect (G_OBJECT (gimage), "name_changed",
G_CALLBACK (gimp_display_shell_update_title_handler),
G_CALLBACK (gimp_display_shell_name_changed_handler),
shell);
g_signal_connect (G_OBJECT (gimage), "selection_control",
G_CALLBACK (gimp_display_shell_selection_control_handler),
shell);
......@@ -128,9 +127,11 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell)
g_signal_handlers_disconnect_by_func (G_OBJECT (gimage),
gimp_display_shell_selection_control_handler,
shell);
g_signal_handlers_disconnect_by_func (G_OBJECT (gimage),
gimp_display_shell_update_title_handler,
gimp_display_shell_name_changed_handler,
shell);
g_signal_handlers_disconnect_by_func (G_OBJECT (gimage),
gimp_display_shell_undo_event_handler,
shell);
}
......@@ -138,7 +139,15 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell)
/* private functions */
static void
gimp_display_shell_update_title_handler (GimpImage *gimage,
gimp_display_shell_undo_event_handler (GimpImage *gimage,
gint event,
GimpDisplayShell *shell)
{
shell->title_dirty = TRUE;
}
static void
gimp_display_shell_name_changed_handler (GimpImage *gimage,
GimpDisplayShell *shell)
{
shell->title_dirty = TRUE;
......
......@@ -2199,7 +2199,7 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
memsize = gimp_object_get_memsize (GIMP_OBJECT (gimage));
size_str = gimp_image_new_get_size_string (memsize);
size_str = gimp_image_new_get_memsize_string (memsize);
i += print (title, title_len, i, "%s", size_str);
......
......@@ -582,8 +582,8 @@ file_new_confirm_dialog (NewImageInfo *info)
gtk_widget_set_sensitive (info->dialog, FALSE);
size = gimp_image_new_get_size_string (info->size);
max_size = gimp_image_new_get_size_string (gimprc.max_new_image_size);
size = gimp_image_new_get_memsize_string (info->size);
max_size = gimp_image_new_get_memsize_string (gimprc.max_new_image_size);
/* xgettext:no-c-format */
......@@ -685,9 +685,9 @@ file_new_image_size_callback (GtkWidget *widget,
info->values->height =
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1));
info->size = gimp_image_new_calculate_size (info->values);
info->size = gimp_image_new_calculate_memsize (info->values);
text = gimp_image_new_get_size_string (info->size);
text = gimp_image_new_get_memsize_string (info->size);
gtk_label_set_text (GTK_LABEL (info->memsize_label), text);
g_free (text);
}
......@@ -97,6 +97,10 @@ static void gimp_move_tool_cursor_update (GimpTool *tool,
static void gimp_move_tool_draw (GimpDrawTool *draw_tool);
static void gimp_move_tool_start_guide (GimpTool *tool,
GimpDisplay *gdisp,
OrientationType orientation);
static GimpToolOptions * move_options_new (GimpToolInfo *tool_info);
static void move_options_reset (GimpToolOptions *tool_options);
......@@ -594,55 +598,62 @@ void
gimp_move_tool_start_hguide (GimpTool *tool,
GimpDisplay *gdisp)
{
GimpMoveTool *move;
move = GIMP_MOVE_TOOL (tool);
gimp_display_shell_selection_visibility (GIMP_DISPLAY_SHELL (gdisp->shell),
GIMP_SELECTION_PAUSE);
tool->gdisp = gdisp;
tool->scroll_lock = TRUE;
if (move->guide && move->disp && move->disp->gimage)
gimp_display_shell_draw_guide (GIMP_DISPLAY_SHELL (move->disp->shell),
move->guide, FALSE);
move->guide = gimp_image_add_hguide (gdisp->gimage);
move->disp = gdisp;
tool->state = ACTIVE;
undo_push_guide (gdisp->gimage, move->guide);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
gimp_move_tool_start_guide (tool, gdisp, HORIZONTAL);
}
void
gimp_move_tool_start_vguide (GimpTool *tool,
GimpDisplay *gdisp)
{
gimp_move_tool_start_guide (tool, gdisp, VERTICAL);
}
static void
gimp_move_tool_start_guide (GimpTool *tool,
GimpDisplay *gdisp,
OrientationType orientation)
{
GimpMoveTool *move;
g_return_if_fail (GIMP_IS_MOVE_TOOL (tool));
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
move = GIMP_MOVE_TOOL (tool);
gimp_display_shell_selection_visibility (GIMP_DISPLAY_SHELL (gdisp->shell),
GIMP_SELECTION_PAUSE);
tool->gdisp = gdisp;
tool->state = ACTIVE;
tool->scroll_lock = TRUE;
if (move->guide && move->disp && move->disp->gimage)
gimp_display_shell_draw_guide (GIMP_DISPLAY_SHELL (move->disp->shell),
move->guide, FALSE);
move->guide = gimp_image_add_vguide (gdisp->gimage);
move->disp = gdisp;
switch (orientation)
{
case HORIZONTAL:
move->guide = gimp_image_add_hguide (gdisp->gimage);
break;
case VERTICAL:
move->guide = gimp_image_add_vguide (gdisp->gimage);
break;
tool->state = ACTIVE;
default:
g_assert_not_reached ();
}
move->disp = gdisp;
undo_push_guide (gdisp->gimage, move->guide);
gimp_tool_set_cursor (tool, gdisp,
GDK_HAND2,
GIMP_TOOL_CURSOR_NONE,
GIMP_CURSOR_MODIFIER_HAND);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment