gimp/app/display/gimpdisplayshell-title.c

439 lines
13 KiB
C
Raw Normal View History

/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <string.h>
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "libgimpbase/gimpbase.h"
#include "display-types.h"
#include "config/gimpdisplayconfig.h"
#include "gegl/gimp-babl.h"
#include "core/gimpcontainer.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimpitem.h"
#include "gimpdisplay.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-title.h"
#include "gimpstatusbar.h"
#include "about.h"
#include "gimp-intl.h"
#define MAX_TITLE_BUF 512
static gboolean gimp_display_shell_update_title_idle (gpointer data);
static gint gimp_display_shell_format_title (GimpDisplayShell *display,
gchar *title,
gint title_len,
const gchar *format);
/* public functions */
void
gimp_display_shell_title_update (GimpDisplayShell *shell)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (shell->title_idle_id)
g_source_remove (shell->title_idle_id);
shell->title_idle_id = g_idle_add (gimp_display_shell_update_title_idle,
shell);
}
/* private functions */
static gboolean
gimp_display_shell_update_title_idle (gpointer data)
{
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data);
shell->title_idle_id = 0;
if (gimp_display_get_image (shell->display))
{
GimpDisplayConfig *config = shell->display->config;
gchar title[MAX_TITLE_BUF];
gchar status[MAX_TITLE_BUF];
gint len;
/* format the title */
len = gimp_display_shell_format_title (shell, title, sizeof (title),
config->image_title_format);
if (len) /* U+2013 EN DASH */
len += g_strlcpy (title + len, " \342\200\223 ", sizeof (title) - len);
g_strlcpy (title + len, GIMP_ACRONYM, sizeof (title) - len);
/* format the statusbar */
gimp_display_shell_format_title (shell, status, sizeof (status),
config->image_status_format);
g_object_set (shell,
"title", title,
"status", status,
NULL);
}
else
{
g_object_set (shell,
"title", GIMP_NAME,
"status", " ",
NULL);
}
return FALSE;
}
static const gchar *
gimp_display_shell_title_image_type (GimpImage *image)
{
const gchar *name = "";
gimp_enum_get_value (GIMP_TYPE_IMAGE_BASE_TYPE,
gimp_image_get_base_type (image), NULL, NULL, &name, NULL);
return name;
}
static const gchar *
gimp_display_shell_title_image_precision (GimpImage *image)
{
const gchar *name = "";
gimp_enum_get_value (GIMP_TYPE_PRECISION,
gimp_image_get_precision (image), NULL, NULL, &name, NULL);
return name;
}
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;
gint printed;
va_start (args, fmt);
printed = g_vsnprintf (buf + start, len - start, fmt, args);
if (printed < 0)
printed = len - start;
va_end (args);
return printed;
}
static gint
gimp_display_shell_format_title (GimpDisplayShell *shell,
gchar *title,
gint title_len,
const gchar *format)
{
tools/pdbgen/pdb/image.pdb app/pdb/image_cmds.c reverted changes I did to 2004-06-01 Sven Neumann <sven@gimp.org> * tools/pdbgen/pdb/image.pdb * app/pdb/image_cmds.c * app/core/gimpimage.[ch]: reverted changes I did to the image unit earlier. As in 2.0, it will continue to not accept pixels. This makes the PDB API and the XCF format compatible again and fixes bug #142961 (and to some extent bug #137704). * app/core/Makefile.am * app/core/gimpimage-unit.[ch]: removed these files. The convenience accessors defined here aren't commonly used any longer. * app/display/gimpdisplay.[ch] * app/display/gimpdisplayshell.[ch]: added a unit parameter to gimp_display_new(). Made "unit" and "scale" properties of GimpDisplayShell. * app/actions/image-commands.c * app/actions/images-commands.c * app/actions/layers-commands.c * app/actions/select-commands.c * app/actions/view-commands.c * app/core/gimp-edit.c * app/core/gimp.[ch] * app/core/gimptemplate.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-title.c * app/display/gimpstatusbar.c * app/file/file-open.c * app/gui/gui-vtable.c * app/gui/info-window.c * app/gui/offset-dialog.c * app/gui/resize-dialog.[ch] * app/pdb/display_cmds.c * app/tools/gimpcroptool.c * app/tools/gimpmeasuretool.c * app/tools/gimppainttool.c * app/tools/gimprectselecttool.c * app/tools/gimprotatetool.c * app/tools/gimpscaletool.c * app/vectors/gimpvectors-export.c * app/widgets/gimptoolbox-dnd.c * tools/pdbgen/pdb/display.pdb: changed accordingly. Use the display unit where the image unit was used before.
2004-06-02 06:04:20 +08:00
GimpImage *image;
gint num, denom;
gint i = 0;
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), 0);
image = gimp_display_get_image (shell->display);
First draft of the "no image open" window, which is implemented as a 2008-03-18 Michael Natterer <mitch@gimp.org> First draft of the "no image open" window, which is implemented as a display without image (a view with NULL model). Didn't change the display's appearance yet so I can first make sure the display without image works properly in all details before hiding these details. * app/core/gimp-gui.[ch]: add "gimp" parameter to display_create() and allow "image" to be NULL. * app/core/gimpcontext.c (gimp_context_real_set_display): a display's image can be NULL now. * app/display/gimpdisplay.[ch]: add Gimp and GimpDisplayConfig members. Add Gimp parameter to gimp_display_shell_new(). Changed gimp_display_reconnect() to gimp_display_set_image() and allow to set a NULL image. * app/gui/gui-vtable.c (gui_display_create): if there is a single display without an image, call gimp_display_set_image() on that display instead of creating a new one. * app/display/gimpdisplayshell-close.c: if the last display is closed, don't close it but make it empty. Factored out that code to gimp_display_shell_really_close(). * app/display/gimpdisplayshell-dnd.c: when dropping uris on an empty display, open the first one into that display and the other ones as layers of the newly opened image. This is consistent with dropping on an existing image but maybe needs some discussion. * app/display/gimpdisplayshell-callbacks.c: bail out early in the tool event callback so tools never have to deal with empty displays. In expose(), draw the drop zone on the empty display. * app/display/gimpdisplayshell-title.c: set the empty display's title to "Gimp - Drop Files". * app/display/gimpdisplay-foreach.c * app/display/gimpdisplay-handlers.c * app/display/gimpdisplayshell-appearance.c * app/display/gimpdisplayshell-autoscroll.c * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-cursor.c * app/display/gimpdisplayshell-dnd.c * app/display/gimpdisplayshell-draw.c * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-layer-select.c * app/display/gimpdisplayshell-preview.c * app/display/gimpdisplayshell-render.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-scroll.c * app/display/gimpdisplayshell-selection.c * app/display/gimpdisplayshell-title.c * app/display/gimpdisplayshell.c * app/display/gimpnavigationeditor.c * app/display/gimpstatusbar.c: use display->gimp and display->config instead of going via the image. Guard against empty displays in some few places (most places can't be called). Where needed, use the canvas' dimensions instead of the image's dimensions so scroll offsets and scrollbars still have sane values instead of the last image's ones. * app/actions/actions.c (action_data_get_gimp) (action_data_get_context): use display->gimp instead of display->image->gimp. * app/actions/edit-commands.c (edit_paste_cmd_callback): redirect to "paste as new" if there is an empty display. * app/actions/tools-commands.c (tools_select_cmd_callback): don't initialize the new tool on an empty display. * app/actions/view-actions.c (view_actions_update): changed lots of sensitivity settings to be insensitive when there is no image (instead of no display). * app/actions/view-commands.c: use the display's config object instead of gimp's. svn path=/trunk/; revision=25113
2008-03-19 05:22:21 +08:00
if (! image)
{
title[0] = '\n';
return 0;
First draft of the "no image open" window, which is implemented as a 2008-03-18 Michael Natterer <mitch@gimp.org> First draft of the "no image open" window, which is implemented as a display without image (a view with NULL model). Didn't change the display's appearance yet so I can first make sure the display without image works properly in all details before hiding these details. * app/core/gimp-gui.[ch]: add "gimp" parameter to display_create() and allow "image" to be NULL. * app/core/gimpcontext.c (gimp_context_real_set_display): a display's image can be NULL now. * app/display/gimpdisplay.[ch]: add Gimp and GimpDisplayConfig members. Add Gimp parameter to gimp_display_shell_new(). Changed gimp_display_reconnect() to gimp_display_set_image() and allow to set a NULL image. * app/gui/gui-vtable.c (gui_display_create): if there is a single display without an image, call gimp_display_set_image() on that display instead of creating a new one. * app/display/gimpdisplayshell-close.c: if the last display is closed, don't close it but make it empty. Factored out that code to gimp_display_shell_really_close(). * app/display/gimpdisplayshell-dnd.c: when dropping uris on an empty display, open the first one into that display and the other ones as layers of the newly opened image. This is consistent with dropping on an existing image but maybe needs some discussion. * app/display/gimpdisplayshell-callbacks.c: bail out early in the tool event callback so tools never have to deal with empty displays. In expose(), draw the drop zone on the empty display. * app/display/gimpdisplayshell-title.c: set the empty display's title to "Gimp - Drop Files". * app/display/gimpdisplay-foreach.c * app/display/gimpdisplay-handlers.c * app/display/gimpdisplayshell-appearance.c * app/display/gimpdisplayshell-autoscroll.c * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-cursor.c * app/display/gimpdisplayshell-dnd.c * app/display/gimpdisplayshell-draw.c * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-layer-select.c * app/display/gimpdisplayshell-preview.c * app/display/gimpdisplayshell-render.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-scroll.c * app/display/gimpdisplayshell-selection.c * app/display/gimpdisplayshell-title.c * app/display/gimpdisplayshell.c * app/display/gimpnavigationeditor.c * app/display/gimpstatusbar.c: use display->gimp and display->config instead of going via the image. Guard against empty displays in some few places (most places can't be called). Where needed, use the canvas' dimensions instead of the image's dimensions so scroll offsets and scrollbars still have sane values instead of the last image's ones. * app/actions/actions.c (action_data_get_gimp) (action_data_get_context): use display->gimp instead of display->image->gimp. * app/actions/edit-commands.c (edit_paste_cmd_callback): redirect to "paste as new" if there is an empty display. * app/actions/tools-commands.c (tools_select_cmd_callback): don't initialize the new tool on an empty display. * app/actions/view-actions.c (view_actions_update): changed lots of sensitivity settings to be insensitive when there is no image (instead of no display). * app/actions/view-commands.c: use the display's config object instead of gimp's. svn path=/trunk/; revision=25113
2008-03-19 05:22:21 +08:00
}
gimp_zoom_model_get_fraction (shell->zoom, &num, &denom);
while (i < title_len && *format)
{
switch (*format)
{
case '%':
format++;
switch (*format)
{
case 0:
/* format string ends within %-sequence, print literal '%' */
case '%':
title[i++] = '%';
break;
case 'f': /* base filename */
i += print (title, title_len, i, "%s",
gimp_image_get_display_name (image));
break;
case 'F': /* full filename */
i += print (title, title_len, i, "%s",
gimp_image_get_display_path (image));
break;
case 'p': /* PDB id */
i += print (title, title_len, i, "%d", gimp_image_get_ID (image));
break;
case 'i': /* instance */
i += print (title, title_len, i, "%d",
gimp_display_get_instance (shell->display));
break;
case 't': /* image type */
i += print (title, title_len, i, "%s %s",
gimp_display_shell_title_image_type (image),
gimp_display_shell_title_image_precision (image));
break;
case 'T': /* drawable type */
{
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
const Babl *format = gimp_drawable_get_format (drawable);
if (drawable)
i += print (title, title_len, i, "%s",
gimp_babl_get_description (format));
}
break;
case 's': /* user source zoom factor */
i += print (title, title_len, i, "%d", denom);
break;
case 'd': /* user destination zoom factor */
i += print (title, title_len, i, "%d", num);
break;
case 'z': /* user zoom factor (percentage) */
{
gdouble scale = gimp_zoom_model_get_factor (shell->zoom);
i += print (title, title_len, i,
scale >= 0.15 ? "%.0f" : "%.2f", 100.0 * scale);
}
break;
case 'D': /* dirty flag */
if (format[1] == 0)
{
/* format string ends within %D-sequence, print literal '%D' */
i += print (title, title_len, i, "%%D");
break;
}
2009-07-04 03:11:21 +08:00
if (gimp_image_is_dirty (image))
title[i++] = format[1];
format++;
break;
case 'C': /* clean flag */
if (format[1] == 0)
{
/* format string ends within %C-sequence, print literal '%C' */
i += print (title, title_len, i, "%%C");
break;
}
2009-07-04 03:11:21 +08:00
if (! gimp_image_is_dirty (image))
title[i++] = format[1];
format++;
break;
case 'B': /* dirty flag (long) */
2009-07-04 03:11:21 +08:00
if (gimp_image_is_dirty (image))
i += print (title, title_len, i, "%s", _("(modified)"));
break;
case 'A': /* clean flag (long) */
2009-07-04 03:11:21 +08:00
if (! gimp_image_is_dirty (image))
i += print (title, title_len, i, "%s", _("(clean)"));
break;
case 'm': /* memory used by image */
{
tools/pdbgen/pdb/image.pdb app/pdb/image_cmds.c reverted changes I did to 2004-06-01 Sven Neumann <sven@gimp.org> * tools/pdbgen/pdb/image.pdb * app/pdb/image_cmds.c * app/core/gimpimage.[ch]: reverted changes I did to the image unit earlier. As in 2.0, it will continue to not accept pixels. This makes the PDB API and the XCF format compatible again and fixes bug #142961 (and to some extent bug #137704). * app/core/Makefile.am * app/core/gimpimage-unit.[ch]: removed these files. The convenience accessors defined here aren't commonly used any longer. * app/display/gimpdisplay.[ch] * app/display/gimpdisplayshell.[ch]: added a unit parameter to gimp_display_new(). Made "unit" and "scale" properties of GimpDisplayShell. * app/actions/image-commands.c * app/actions/images-commands.c * app/actions/layers-commands.c * app/actions/select-commands.c * app/actions/view-commands.c * app/core/gimp-edit.c * app/core/gimp.[ch] * app/core/gimptemplate.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-title.c * app/display/gimpstatusbar.c * app/file/file-open.c * app/gui/gui-vtable.c * app/gui/info-window.c * app/gui/offset-dialog.c * app/gui/resize-dialog.[ch] * app/pdb/display_cmds.c * app/tools/gimpcroptool.c * app/tools/gimpmeasuretool.c * app/tools/gimppainttool.c * app/tools/gimprectselecttool.c * app/tools/gimprotatetool.c * app/tools/gimpscaletool.c * app/vectors/gimpvectors-export.c * app/widgets/gimptoolbox-dnd.c * tools/pdbgen/pdb/display.pdb: changed accordingly. Use the display unit where the image unit was used before.
2004-06-02 06:04:20 +08:00
GimpObject *object = GIMP_OBJECT (image);
gchar *str;
str = g_format_size (gimp_object_get_memsize (object, NULL));
i += print (title, title_len, i, "%s", str);
g_free (str);
}
break;
case 'M': /* image size in megapixels */
2010-09-30 15:24:26 +08:00
i += print (title, title_len, i, "%.1f",
(gdouble) gimp_image_get_width (image) *
(gdouble) gimp_image_get_height (image) / 1000000.0);
break;
case 'l': /* number of layers */
i += print (title, title_len, i, "%d",
gimp_image_get_n_layers (image));
break;
case 'L': /* number of layers (long) */
{
gint num = gimp_image_get_n_layers (image);
i += print (title, title_len, i,
ngettext ("%d layer", "%d layers", num), num);
}
break;
case 'n': /* active drawable name */
{
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
if (drawable)
{
gchar *desc;
desc = gimp_viewable_get_description (GIMP_VIEWABLE (drawable),
NULL);
i += print (title, title_len, i, "%s", desc);
g_free (desc);
}
else
{
i += print (title, title_len, i, "%s", _("(none)"));
}
}
break;
case 'P': /* active drawable PDB id */
{
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
if (drawable)
i += print (title, title_len, i, "%d",
gimp_item_get_ID (GIMP_ITEM (drawable)));
else
i += print (title, title_len, i, "%s", _("(none)"));
}
break;
case 'W': /* width in real-world units */
tools/pdbgen/pdb/image.pdb app/pdb/image_cmds.c reverted changes I did to 2004-06-01 Sven Neumann <sven@gimp.org> * tools/pdbgen/pdb/image.pdb * app/pdb/image_cmds.c * app/core/gimpimage.[ch]: reverted changes I did to the image unit earlier. As in 2.0, it will continue to not accept pixels. This makes the PDB API and the XCF format compatible again and fixes bug #142961 (and to some extent bug #137704). * app/core/Makefile.am * app/core/gimpimage-unit.[ch]: removed these files. The convenience accessors defined here aren't commonly used any longer. * app/display/gimpdisplay.[ch] * app/display/gimpdisplayshell.[ch]: added a unit parameter to gimp_display_new(). Made "unit" and "scale" properties of GimpDisplayShell. * app/actions/image-commands.c * app/actions/images-commands.c * app/actions/layers-commands.c * app/actions/select-commands.c * app/actions/view-commands.c * app/core/gimp-edit.c * app/core/gimp.[ch] * app/core/gimptemplate.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-title.c * app/display/gimpstatusbar.c * app/file/file-open.c * app/gui/gui-vtable.c * app/gui/info-window.c * app/gui/offset-dialog.c * app/gui/resize-dialog.[ch] * app/pdb/display_cmds.c * app/tools/gimpcroptool.c * app/tools/gimpmeasuretool.c * app/tools/gimppainttool.c * app/tools/gimprectselecttool.c * app/tools/gimprotatetool.c * app/tools/gimpscaletool.c * app/vectors/gimpvectors-export.c * app/widgets/gimptoolbox-dnd.c * tools/pdbgen/pdb/display.pdb: changed accordingly. Use the display unit where the image unit was used before.
2004-06-02 06:04:20 +08:00
if (shell->unit != GIMP_UNIT_PIXEL)
{
gdouble xres;
gdouble yres;
gchar unit_format[8];
gimp_image_get_resolution (image, &xres, &yres);
g_snprintf (unit_format, sizeof (unit_format), "%%.%df",
gimp_unit_get_digits (shell->unit) + 1);
i += print (title, title_len, i, unit_format,
gimp_pixels_to_units (gimp_image_get_width (image),
shell->unit, xres));
break;
}
/* else fallthru */
case 'w': /* width in pixels */
app/actions/channels-commands.c app/actions/colormap-actions.c 2007-12-25 Michael Natterer <mitch@gimp.org> * app/actions/channels-commands.c * app/actions/colormap-actions.c * app/actions/colormap-commands.c * app/actions/image-commands.c * app/core/gimp-edit.c * app/core/gimpdrawable-preview.c * app/core/gimpimage-colorhash.c * app/core/gimpimage-colormap.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-flip.c * app/core/gimpimage-guides.c * app/core/gimpimage-merge.c * app/core/gimpimage-preview.c * app/core/gimpimage-quick-mask.c * app/core/gimpimage-resize.c * app/core/gimpimage-rotate.c * app/core/gimpimage-sample-points.c * app/core/gimpimage-scale.c * app/core/gimpimage-snap.c * app/core/gimpimage.c * app/core/gimpimagefile.c * app/core/gimpimageundo.c * app/core/gimpitem-preview.c * app/core/gimpitem.c * app/core/gimplayer.c * app/core/gimppalette-import.c * app/core/gimpprojection-construct.c * app/core/gimpprojection.c * app/core/gimpselection.c * app/core/gimpundo.c * app/dialogs/layer-options-dialog.c * app/dialogs/print-size-dialog.c * app/display/gimpdisplay.c * app/display/gimpdisplayshell-draw.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-scroll.c * app/display/gimpdisplayshell-title.c * app/display/gimpdisplayshell-transform.c * app/display/gimpdisplayshell.c * app/display/gimpstatusbar.c * app/file/file-open.c * app/paint/gimppaintoptions.c * app/tools/gimpaligntool.c * app/tools/gimpcolortool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimpperspectiveclonetool.c * app/tools/gimprectangleselecttool.c * app/tools/gimprectangletool.c * app/tools/gimprotatetool.c * app/vectors/gimpvectors-export.c * app/vectors/gimpvectors-import.c * app/vectors/gimpvectors.c * app/widgets/gimpimagepropview.c * app/widgets/gimpnavigationview.c * app/widgets/gimpselectioneditor.c * app/widgets/gimpviewrendererdrawable.c * app/widgets/gimpviewrendererimage.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/image.pdb: use accessors for many image properties. * app/pdb/guides_cmds.c * app/pdb/image_cmds.c: regenerated. svn path=/trunk/; revision=24432
2007-12-26 00:21:40 +08:00
i += print (title, title_len, i, "%d",
gimp_image_get_width (image));
break;
case 'H': /* height in real-world units */
tools/pdbgen/pdb/image.pdb app/pdb/image_cmds.c reverted changes I did to 2004-06-01 Sven Neumann <sven@gimp.org> * tools/pdbgen/pdb/image.pdb * app/pdb/image_cmds.c * app/core/gimpimage.[ch]: reverted changes I did to the image unit earlier. As in 2.0, it will continue to not accept pixels. This makes the PDB API and the XCF format compatible again and fixes bug #142961 (and to some extent bug #137704). * app/core/Makefile.am * app/core/gimpimage-unit.[ch]: removed these files. The convenience accessors defined here aren't commonly used any longer. * app/display/gimpdisplay.[ch] * app/display/gimpdisplayshell.[ch]: added a unit parameter to gimp_display_new(). Made "unit" and "scale" properties of GimpDisplayShell. * app/actions/image-commands.c * app/actions/images-commands.c * app/actions/layers-commands.c * app/actions/select-commands.c * app/actions/view-commands.c * app/core/gimp-edit.c * app/core/gimp.[ch] * app/core/gimptemplate.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-title.c * app/display/gimpstatusbar.c * app/file/file-open.c * app/gui/gui-vtable.c * app/gui/info-window.c * app/gui/offset-dialog.c * app/gui/resize-dialog.[ch] * app/pdb/display_cmds.c * app/tools/gimpcroptool.c * app/tools/gimpmeasuretool.c * app/tools/gimppainttool.c * app/tools/gimprectselecttool.c * app/tools/gimprotatetool.c * app/tools/gimpscaletool.c * app/vectors/gimpvectors-export.c * app/widgets/gimptoolbox-dnd.c * tools/pdbgen/pdb/display.pdb: changed accordingly. Use the display unit where the image unit was used before.
2004-06-02 06:04:20 +08:00
if (shell->unit != GIMP_UNIT_PIXEL)
{
gdouble xres;
gdouble yres;
gchar unit_format[8];
gimp_image_get_resolution (image, &xres, &yres);
g_snprintf (unit_format, sizeof (unit_format), "%%.%df",
gimp_unit_get_digits (shell->unit) + 1);
i += print (title, title_len, i, unit_format,
gimp_pixels_to_units (gimp_image_get_height (image),
shell->unit, yres));
break;
}
/* else fallthru */
case 'h': /* height in pixels */
app/actions/channels-commands.c app/actions/colormap-actions.c 2007-12-25 Michael Natterer <mitch@gimp.org> * app/actions/channels-commands.c * app/actions/colormap-actions.c * app/actions/colormap-commands.c * app/actions/image-commands.c * app/core/gimp-edit.c * app/core/gimpdrawable-preview.c * app/core/gimpimage-colorhash.c * app/core/gimpimage-colormap.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-flip.c * app/core/gimpimage-guides.c * app/core/gimpimage-merge.c * app/core/gimpimage-preview.c * app/core/gimpimage-quick-mask.c * app/core/gimpimage-resize.c * app/core/gimpimage-rotate.c * app/core/gimpimage-sample-points.c * app/core/gimpimage-scale.c * app/core/gimpimage-snap.c * app/core/gimpimage.c * app/core/gimpimagefile.c * app/core/gimpimageundo.c * app/core/gimpitem-preview.c * app/core/gimpitem.c * app/core/gimplayer.c * app/core/gimppalette-import.c * app/core/gimpprojection-construct.c * app/core/gimpprojection.c * app/core/gimpselection.c * app/core/gimpundo.c * app/dialogs/layer-options-dialog.c * app/dialogs/print-size-dialog.c * app/display/gimpdisplay.c * app/display/gimpdisplayshell-draw.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-scroll.c * app/display/gimpdisplayshell-title.c * app/display/gimpdisplayshell-transform.c * app/display/gimpdisplayshell.c * app/display/gimpstatusbar.c * app/file/file-open.c * app/paint/gimppaintoptions.c * app/tools/gimpaligntool.c * app/tools/gimpcolortool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimpperspectiveclonetool.c * app/tools/gimprectangleselecttool.c * app/tools/gimprectangletool.c * app/tools/gimprotatetool.c * app/vectors/gimpvectors-export.c * app/vectors/gimpvectors-import.c * app/vectors/gimpvectors.c * app/widgets/gimpimagepropview.c * app/widgets/gimpnavigationview.c * app/widgets/gimpselectioneditor.c * app/widgets/gimpviewrendererdrawable.c * app/widgets/gimpviewrendererimage.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/image.pdb: use accessors for many image properties. * app/pdb/guides_cmds.c * app/pdb/image_cmds.c: regenerated. svn path=/trunk/; revision=24432
2007-12-26 00:21:40 +08:00
i += print (title, title_len, i, "%d",
gimp_image_get_height (image));
break;
case 'u': /* unit symbol */
i += print (title, title_len, i, "%s",
gimp_unit_get_symbol (shell->unit));
break;
case 'U': /* unit abbreviation */
i += print (title, title_len, i, "%s",
gimp_unit_get_abbreviation (shell->unit));
break;
/* Other cool things to be added:
* %r = xresolution
* %R = yresolution
* %<EFBFBD> = image's fractal dimension
* %<EFBFBD> = the answer to everything
*/
default:
/* format string contains unknown %-sequence, print it literally */
i += print (title, title_len, i, "%%%c", *format);
break;
}
break;
default:
title[i++] = *format;
break;
}
format++;
}
title[MIN (i, title_len - 1)] = '\0';
return i;
}