2006-12-10 05:33:38 +08:00
|
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2005-04-05 06:34:29 +08:00
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
|
|
|
|
* GimpImagePropView
|
|
|
|
|
* Copyright (C) 2005 Michael Natterer <mitch@gimp.org>
|
2006-10-25 15:31:04 +08:00
|
|
|
|
* Copyright (C) 2006 Sven Neumann <sven@gimp.org>
|
2005-04-05 06:34:29 +08:00
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2005-04-05 06:34:29 +08:00
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2005-04-05 06:34:29 +08:00
|
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2005-04-05 06:34:29 +08:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
|
#include <gegl.h>
|
2005-04-05 06:34:29 +08:00
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
|
|
#include "widgets-types.h"
|
|
|
|
|
|
2006-09-11 23:27:21 +08:00
|
|
|
|
#include "core/gimp.h"
|
2005-04-05 06:34:29 +08:00
|
|
|
|
#include "core/gimpcontainer.h"
|
|
|
|
|
#include "core/gimpimage.h"
|
2007-12-26 00:21:40 +08:00
|
|
|
|
#include "core/gimpimage-colormap.h"
|
2010-02-05 03:06:49 +08:00
|
|
|
|
#include "core/gimpimage-undo.h"
|
2005-07-29 06:40:32 +08:00
|
|
|
|
#include "core/gimpundostack.h"
|
2005-08-18 23:08:49 +08:00
|
|
|
|
#include "core/gimp-utils.h"
|
2005-04-05 06:34:29 +08:00
|
|
|
|
|
2016-01-04 03:05:27 +08:00
|
|
|
|
#include "plug-in/gimppluginmanager-file.h"
|
2007-02-18 22:25:34 +08:00
|
|
|
|
#include "plug-in/gimppluginprocedure.h"
|
2006-09-11 23:27:21 +08:00
|
|
|
|
|
2005-04-05 06:34:29 +08:00
|
|
|
|
#include "gimpimagepropview.h"
|
|
|
|
|
#include "gimppropwidgets.h"
|
|
|
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_IMAGE
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2011-01-14 16:38:11 +08:00
|
|
|
|
static void gimp_image_prop_view_constructed (GObject *object);
|
2006-10-25 15:31:04 +08:00
|
|
|
|
static void gimp_image_prop_view_set_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
static void gimp_image_prop_view_get_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
|
|
|
|
|
static GtkWidget * gimp_image_prop_view_add_label (GtkTable *table,
|
|
|
|
|
gint row,
|
|
|
|
|
const gchar *text);
|
|
|
|
|
static void gimp_image_prop_view_undo_event (GimpImage *image,
|
|
|
|
|
GimpUndoEvent event,
|
|
|
|
|
GimpUndo *undo,
|
|
|
|
|
GimpImagePropView *view);
|
|
|
|
|
static void gimp_image_prop_view_update (GimpImagePropView *view);
|
|
|
|
|
static void gimp_image_prop_view_file_update (GimpImagePropView *view);
|
2005-04-05 06:34:29 +08:00
|
|
|
|
|
|
|
|
|
|
2006-05-15 17:46:31 +08:00
|
|
|
|
G_DEFINE_TYPE (GimpImagePropView, gimp_image_prop_view, GTK_TYPE_TABLE)
|
2005-04-05 06:34:29 +08:00
|
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
|
#define parent_class gimp_image_prop_view_parent_class
|
2005-04-05 06:34:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_image_prop_view_class_init (GimpImagePropViewClass *klass)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
2011-01-14 16:38:11 +08:00
|
|
|
|
object_class->constructed = gimp_image_prop_view_constructed;
|
2005-04-05 06:34:29 +08:00
|
|
|
|
object_class->set_property = gimp_image_prop_view_set_property;
|
|
|
|
|
object_class->get_property = gimp_image_prop_view_get_property;
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_IMAGE,
|
|
|
|
|
g_param_spec_object ("image", NULL, NULL,
|
|
|
|
|
GIMP_TYPE_IMAGE,
|
2006-01-19 04:29:40 +08:00
|
|
|
|
GIMP_PARAM_READWRITE |
|
2005-04-05 06:34:29 +08:00
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_image_prop_view_init (GimpImagePropView *view)
|
|
|
|
|
{
|
2006-10-25 15:31:04 +08:00
|
|
|
|
GtkTable *table = GTK_TABLE (view);
|
|
|
|
|
gint row = 0;
|
|
|
|
|
|
2012-04-28 21:31:40 +08:00
|
|
|
|
gtk_table_resize (table, 15, 2);
|
2006-10-25 15:31:04 +08:00
|
|
|
|
|
|
|
|
|
gtk_table_set_col_spacings (table, 6);
|
|
|
|
|
gtk_table_set_row_spacings (table, 3);
|
|
|
|
|
|
|
|
|
|
view->pixel_size_label =
|
2010-02-05 04:24:53 +08:00
|
|
|
|
gimp_image_prop_view_add_label (table, row++, _("Size in pixels:"));
|
2006-10-25 15:31:04 +08:00
|
|
|
|
|
|
|
|
|
view->print_size_label =
|
|
|
|
|
gimp_image_prop_view_add_label (table, row++, _("Print size:"));
|
|
|
|
|
|
|
|
|
|
view->resolution_label =
|
|
|
|
|
gimp_image_prop_view_add_label (table, row++, _("Resolution:"));
|
|
|
|
|
|
|
|
|
|
view->colorspace_label =
|
2012-04-28 21:31:40 +08:00
|
|
|
|
gimp_image_prop_view_add_label (table, row++, _("Color space:"));
|
|
|
|
|
|
|
|
|
|
view->precision_label =
|
|
|
|
|
gimp_image_prop_view_add_label (table, row, _("Precision:"));
|
2006-10-25 15:31:04 +08:00
|
|
|
|
|
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (view), row++, 12);
|
|
|
|
|
|
|
|
|
|
view->filename_label =
|
2007-06-27 18:07:07 +08:00
|
|
|
|
gimp_image_prop_view_add_label (table, row++, _("File Name:"));
|
|
|
|
|
|
|
|
|
|
gtk_label_set_ellipsize (GTK_LABEL (view->filename_label),
|
|
|
|
|
PANGO_ELLIPSIZE_MIDDLE);
|
2006-10-25 15:31:04 +08:00
|
|
|
|
|
|
|
|
|
view->filesize_label =
|
|
|
|
|
gimp_image_prop_view_add_label (table, row++, _("File Size:"));
|
|
|
|
|
|
|
|
|
|
view->filetype_label =
|
|
|
|
|
gimp_image_prop_view_add_label (table, row, _("File Type:"));
|
|
|
|
|
|
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (view), row++, 12);
|
|
|
|
|
|
|
|
|
|
view->memsize_label =
|
|
|
|
|
gimp_image_prop_view_add_label (table, row++, _("Size in memory:"));
|
|
|
|
|
|
|
|
|
|
view->undo_label =
|
|
|
|
|
gimp_image_prop_view_add_label (table, row++, _("Undo steps:"));
|
|
|
|
|
|
|
|
|
|
view->redo_label =
|
|
|
|
|
gimp_image_prop_view_add_label (table, row, _("Redo steps:"));
|
|
|
|
|
|
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (view), row++, 12);
|
|
|
|
|
|
|
|
|
|
view->pixels_label =
|
|
|
|
|
gimp_image_prop_view_add_label (table, row++, _("Number of pixels:"));
|
|
|
|
|
|
|
|
|
|
view->layers_label =
|
|
|
|
|
gimp_image_prop_view_add_label (table, row++, _("Number of layers:"));
|
|
|
|
|
|
|
|
|
|
view->channels_label =
|
|
|
|
|
gimp_image_prop_view_add_label (table, row++, _("Number of channels:"));
|
|
|
|
|
|
|
|
|
|
view->vectors_label =
|
|
|
|
|
gimp_image_prop_view_add_label (table, row++, _("Number of paths:"));
|
2006-09-11 23:27:21 +08:00
|
|
|
|
|
2005-04-05 06:34:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2011-01-14 16:38:11 +08:00
|
|
|
|
gimp_image_prop_view_constructed (GObject *object)
|
2005-04-05 06:34:29 +08:00
|
|
|
|
{
|
|
|
|
|
GimpImagePropView *view = GIMP_IMAGE_PROP_VIEW (object);
|
|
|
|
|
|
2012-11-13 04:51:22 +08:00
|
|
|
|
G_OBJECT_CLASS (parent_class)->constructed (object);
|
2005-04-05 06:34:29 +08:00
|
|
|
|
|
|
|
|
|
g_assert (view->image != NULL);
|
|
|
|
|
|
2006-09-11 23:27:21 +08:00
|
|
|
|
g_signal_connect_object (view->image, "name-changed",
|
|
|
|
|
G_CALLBACK (gimp_image_prop_view_file_update),
|
|
|
|
|
G_OBJECT (view),
|
|
|
|
|
G_CONNECT_SWAPPED);
|
|
|
|
|
|
2005-04-05 06:34:29 +08:00
|
|
|
|
g_signal_connect_object (view->image, "size-changed",
|
|
|
|
|
G_CALLBACK (gimp_image_prop_view_update),
|
|
|
|
|
G_OBJECT (view),
|
|
|
|
|
G_CONNECT_SWAPPED);
|
|
|
|
|
g_signal_connect_object (view->image, "resolution-changed",
|
|
|
|
|
G_CALLBACK (gimp_image_prop_view_update),
|
|
|
|
|
G_OBJECT (view),
|
|
|
|
|
G_CONNECT_SWAPPED);
|
|
|
|
|
g_signal_connect_object (view->image, "unit-changed",
|
|
|
|
|
G_CALLBACK (gimp_image_prop_view_update),
|
|
|
|
|
G_OBJECT (view),
|
|
|
|
|
G_CONNECT_SWAPPED);
|
|
|
|
|
g_signal_connect_object (view->image, "mode-changed",
|
|
|
|
|
G_CALLBACK (gimp_image_prop_view_update),
|
|
|
|
|
G_OBJECT (view),
|
|
|
|
|
G_CONNECT_SWAPPED);
|
2005-07-29 06:40:32 +08:00
|
|
|
|
g_signal_connect_object (view->image, "undo-event",
|
|
|
|
|
G_CALLBACK (gimp_image_prop_view_undo_event),
|
|
|
|
|
G_OBJECT (view),
|
|
|
|
|
0);
|
2005-04-05 06:34:29 +08:00
|
|
|
|
|
|
|
|
|
gimp_image_prop_view_update (view);
|
2006-09-11 23:27:21 +08:00
|
|
|
|
gimp_image_prop_view_file_update (view);
|
2011-01-14 16:38:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_image_prop_view_set_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GimpImagePropView *view = GIMP_IMAGE_PROP_VIEW (object);
|
2005-04-05 06:34:29 +08:00
|
|
|
|
|
2011-01-14 16:38:11 +08:00
|
|
|
|
switch (property_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_IMAGE:
|
|
|
|
|
view->image = g_value_get_object (value);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_image_prop_view_get_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GimpImagePropView *view = GIMP_IMAGE_PROP_VIEW (object);
|
|
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_IMAGE:
|
|
|
|
|
g_value_set_object (value, view->image);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2005-04-05 06:34:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gimp_image_prop_view_new (GimpImage *image)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
|
|
|
|
|
|
|
|
|
return g_object_new (GIMP_TYPE_IMAGE_PROP_VIEW,
|
|
|
|
|
"image", image,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
2005-06-26 02:24:00 +08:00
|
|
|
|
static GtkWidget *
|
2007-06-27 18:07:07 +08:00
|
|
|
|
gimp_image_prop_view_add_label (GtkTable *table,
|
|
|
|
|
gint row,
|
|
|
|
|
const gchar *text)
|
2005-06-26 02:24:00 +08:00
|
|
|
|
{
|
|
|
|
|
GtkWidget *label;
|
|
|
|
|
GtkWidget *desc;
|
|
|
|
|
|
|
|
|
|
desc = g_object_new (GTK_TYPE_LABEL,
|
|
|
|
|
"label", text,
|
|
|
|
|
"xalign", 1.0,
|
|
|
|
|
"yalign", 0.5,
|
|
|
|
|
NULL);
|
|
|
|
|
gimp_label_set_attributes (GTK_LABEL (desc),
|
|
|
|
|
PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD,
|
|
|
|
|
-1);
|
|
|
|
|
gtk_table_attach (table, desc,
|
|
|
|
|
0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
|
|
|
|
|
gtk_widget_show (desc);
|
|
|
|
|
|
|
|
|
|
label = g_object_new (GTK_TYPE_LABEL,
|
2005-07-29 06:40:32 +08:00
|
|
|
|
"xalign", 0.0,
|
|
|
|
|
"yalign", 0.5,
|
|
|
|
|
"selectable", TRUE,
|
2005-06-26 02:24:00 +08:00
|
|
|
|
NULL);
|
2007-06-26 15:22:54 +08:00
|
|
|
|
|
2007-06-27 18:07:07 +08:00
|
|
|
|
gtk_table_attach (table, label,
|
|
|
|
|
1, 2, row, row + 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
|
2007-06-26 15:22:54 +08:00
|
|
|
|
|
2005-06-26 02:24:00 +08:00
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
|
|
return label;
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-29 06:40:32 +08:00
|
|
|
|
static void
|
|
|
|
|
gimp_image_prop_view_label_set_memsize (GtkWidget *label,
|
|
|
|
|
GimpObject *object)
|
|
|
|
|
{
|
2011-09-13 17:39:24 +08:00
|
|
|
|
gchar *str = g_format_size (gimp_object_get_memsize (object, NULL));
|
2005-07-29 06:40:32 +08:00
|
|
|
|
gtk_label_set_text (GTK_LABEL (label), str);
|
|
|
|
|
g_free (str);
|
|
|
|
|
}
|
|
|
|
|
|
2006-09-11 23:27:21 +08:00
|
|
|
|
static void
|
|
|
|
|
gimp_image_prop_view_label_set_filename (GtkWidget *label,
|
|
|
|
|
GimpImage *image)
|
|
|
|
|
{
|
2014-07-08 05:56:56 +08:00
|
|
|
|
GFile *file = gimp_image_get_any_file (image);
|
2006-09-11 23:27:21 +08:00
|
|
|
|
|
2014-07-08 05:56:56 +08:00
|
|
|
|
if (file)
|
2006-09-11 23:27:21 +08:00
|
|
|
|
{
|
2014-07-08 05:56:56 +08:00
|
|
|
|
gtk_label_set_text (GTK_LABEL (label),
|
|
|
|
|
gimp_file_get_utf8_name (file));
|
2006-09-11 23:27:21 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (label), NULL);
|
2007-06-26 15:22:54 +08:00
|
|
|
|
gimp_help_set_help_data (gtk_widget_get_parent (label), NULL, NULL);
|
2006-09-11 23:27:21 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_image_prop_view_label_set_filesize (GtkWidget *label,
|
|
|
|
|
GimpImage *image)
|
|
|
|
|
{
|
2014-07-08 05:56:56 +08:00
|
|
|
|
GFile *file = gimp_image_get_any_file (image);
|
2006-09-11 23:27:21 +08:00
|
|
|
|
|
2013-06-26 01:08:12 +08:00
|
|
|
|
if (file)
|
2006-09-11 23:27:21 +08:00
|
|
|
|
{
|
2013-06-26 01:08:12 +08:00
|
|
|
|
GFileInfo *info = g_file_query_info (file,
|
|
|
|
|
G_FILE_ATTRIBUTE_STANDARD_SIZE,
|
|
|
|
|
G_FILE_QUERY_INFO_NONE,
|
|
|
|
|
NULL, NULL);
|
2006-09-11 23:27:21 +08:00
|
|
|
|
|
2013-06-26 01:08:12 +08:00
|
|
|
|
if (info)
|
2006-09-11 23:27:21 +08:00
|
|
|
|
{
|
2013-06-26 01:08:12 +08:00
|
|
|
|
goffset size = g_file_info_get_size (info);
|
|
|
|
|
gchar *str = g_format_size (size);
|
2006-09-11 23:27:21 +08:00
|
|
|
|
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (label), str);
|
|
|
|
|
g_free (str);
|
2013-06-26 01:08:12 +08:00
|
|
|
|
|
|
|
|
|
g_object_unref (info);
|
2006-09-11 23:27:21 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (label), NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (label), NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_image_prop_view_label_set_filetype (GtkWidget *label,
|
|
|
|
|
GimpImage *image)
|
|
|
|
|
{
|
2016-01-04 03:05:27 +08:00
|
|
|
|
GimpPlugInProcedure *proc = gimp_image_get_save_proc (image);
|
2007-09-21 05:23:05 +08:00
|
|
|
|
|
|
|
|
|
if (! proc)
|
|
|
|
|
proc = gimp_image_get_load_proc (image);
|
|
|
|
|
|
2006-09-11 23:27:21 +08:00
|
|
|
|
if (! proc)
|
|
|
|
|
{
|
2016-01-04 03:05:27 +08:00
|
|
|
|
GimpPlugInManager *manager = image->gimp->plug_in_manager;
|
|
|
|
|
GFile *file = gimp_image_get_file (image);
|
2006-09-11 23:27:21 +08:00
|
|
|
|
|
2014-07-08 05:56:56 +08:00
|
|
|
|
if (file)
|
2016-01-04 03:05:27 +08:00
|
|
|
|
proc = gimp_plug_in_manager_file_procedure_find (manager,
|
|
|
|
|
GIMP_FILE_PROCEDURE_GROUP_OPEN,
|
|
|
|
|
file, NULL);
|
2006-09-11 23:27:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
2007-03-11 05:22:22 +08:00
|
|
|
|
gtk_label_set_text (GTK_LABEL (label),
|
2016-01-02 03:52:45 +08:00
|
|
|
|
proc ?
|
|
|
|
|
gimp_procedure_get_label (GIMP_PROCEDURE (proc)) : NULL);
|
2006-09-11 23:27:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-07-29 06:40:32 +08:00
|
|
|
|
static void
|
|
|
|
|
gimp_image_prop_view_label_set_undo (GtkWidget *label,
|
|
|
|
|
GimpUndoStack *stack)
|
|
|
|
|
{
|
|
|
|
|
gint steps = gimp_undo_stack_get_depth (stack);
|
|
|
|
|
|
|
|
|
|
if (steps > 0)
|
|
|
|
|
{
|
|
|
|
|
GimpObject *object = GIMP_OBJECT (stack);
|
|
|
|
|
gchar *str;
|
|
|
|
|
gchar buf[256];
|
|
|
|
|
|
2011-09-13 17:39:24 +08:00
|
|
|
|
str = g_format_size (gimp_object_get_memsize (object, NULL));
|
2005-07-29 06:40:32 +08:00
|
|
|
|
g_snprintf (buf, sizeof (buf), "%d (%s)", steps, str);
|
|
|
|
|
g_free (str);
|
|
|
|
|
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (label), buf);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* no undo (or redo) steps available */
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (label), _("None"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2006-03-29 01:08:36 +08:00
|
|
|
|
gimp_image_prop_view_undo_event (GimpImage *image,
|
2005-07-29 06:40:32 +08:00
|
|
|
|
GimpUndoEvent event,
|
|
|
|
|
GimpUndo *undo,
|
|
|
|
|
GimpImagePropView *view)
|
|
|
|
|
{
|
|
|
|
|
gimp_image_prop_view_update (view);
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-05 06:34:29 +08:00
|
|
|
|
static void
|
|
|
|
|
gimp_image_prop_view_update (GimpImagePropView *view)
|
|
|
|
|
{
|
|
|
|
|
GimpImage *image = view->image;
|
|
|
|
|
GimpImageBaseType type;
|
2012-04-28 21:31:40 +08:00
|
|
|
|
GimpPrecision precision;
|
2005-04-05 06:34:29 +08:00
|
|
|
|
GimpUnit unit;
|
|
|
|
|
gdouble unit_factor;
|
|
|
|
|
gint unit_digits;
|
2005-06-26 01:01:50 +08:00
|
|
|
|
const gchar *desc;
|
2005-04-05 06:34:29 +08:00
|
|
|
|
gchar format_buf[32];
|
|
|
|
|
gchar buf[256];
|
2007-12-27 01:33:41 +08:00
|
|
|
|
gdouble xres;
|
|
|
|
|
gdouble yres;
|
|
|
|
|
|
|
|
|
|
gimp_image_get_resolution (image, &xres, &yres);
|
2005-04-05 06:34:29 +08:00
|
|
|
|
|
|
|
|
|
/* pixel size */
|
2006-02-28 20:15:51 +08:00
|
|
|
|
g_snprintf (buf, sizeof (buf), ngettext ("%d × %d pixel",
|
2007-12-26 00:21:40 +08:00
|
|
|
|
"%d × %d pixels",
|
|
|
|
|
gimp_image_get_height (image)),
|
|
|
|
|
gimp_image_get_width (image),
|
|
|
|
|
gimp_image_get_height (image));
|
2005-04-05 06:34:29 +08:00
|
|
|
|
gtk_label_set_text (GTK_LABEL (view->pixel_size_label), buf);
|
|
|
|
|
|
|
|
|
|
/* print size */
|
2005-08-18 23:08:49 +08:00
|
|
|
|
unit = gimp_get_default_unit ();
|
2005-04-05 06:34:29 +08:00
|
|
|
|
|
2010-02-21 23:46:39 +08:00
|
|
|
|
unit_digits = gimp_unit_get_digits (unit);
|
2005-04-05 06:34:29 +08:00
|
|
|
|
|
2006-02-28 20:15:51 +08:00
|
|
|
|
g_snprintf (format_buf, sizeof (format_buf), "%%.%df × %%.%df %s",
|
2005-04-05 06:34:29 +08:00
|
|
|
|
unit_digits + 1, unit_digits + 1,
|
2010-02-21 23:46:39 +08:00
|
|
|
|
gimp_unit_get_plural (unit));
|
2005-04-05 06:34:29 +08:00
|
|
|
|
g_snprintf (buf, sizeof (buf), format_buf,
|
2010-02-21 23:46:39 +08:00
|
|
|
|
gimp_pixels_to_units (gimp_image_get_width (image), unit, xres),
|
|
|
|
|
gimp_pixels_to_units (gimp_image_get_height (image), unit, yres));
|
2005-04-05 06:34:29 +08:00
|
|
|
|
gtk_label_set_text (GTK_LABEL (view->print_size_label), buf);
|
|
|
|
|
|
|
|
|
|
/* resolution */
|
2010-02-21 23:46:39 +08:00
|
|
|
|
unit = gimp_image_get_unit (image);
|
|
|
|
|
unit_factor = gimp_unit_get_factor (unit);
|
2005-04-05 06:34:29 +08:00
|
|
|
|
|
|
|
|
|
g_snprintf (format_buf, sizeof (format_buf), _("pixels/%s"),
|
2010-02-21 23:46:39 +08:00
|
|
|
|
gimp_unit_get_abbreviation (unit));
|
2006-02-28 20:15:51 +08:00
|
|
|
|
g_snprintf (buf, sizeof (buf), _("%g × %g %s"),
|
2007-12-27 01:33:41 +08:00
|
|
|
|
xres / unit_factor,
|
|
|
|
|
yres / unit_factor,
|
2006-04-06 00:45:27 +08:00
|
|
|
|
unit == GIMP_UNIT_INCH ? _("ppi") : format_buf);
|
2005-04-05 06:34:29 +08:00
|
|
|
|
gtk_label_set_text (GTK_LABEL (view->resolution_label), buf);
|
|
|
|
|
|
|
|
|
|
/* color type */
|
2012-05-08 03:57:33 +08:00
|
|
|
|
type = gimp_image_get_base_type (image);
|
2005-04-05 06:34:29 +08:00
|
|
|
|
|
2005-06-26 01:01:50 +08:00
|
|
|
|
gimp_enum_get_value (GIMP_TYPE_IMAGE_BASE_TYPE, type,
|
|
|
|
|
NULL, NULL, &desc, NULL);
|
|
|
|
|
|
2005-04-05 06:34:29 +08:00
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case GIMP_RGB:
|
|
|
|
|
case GIMP_GRAY:
|
2005-06-26 01:01:50 +08:00
|
|
|
|
g_snprintf (buf, sizeof (buf), "%s", desc);
|
2005-04-05 06:34:29 +08:00
|
|
|
|
break;
|
|
|
|
|
case GIMP_INDEXED:
|
2005-06-26 01:01:50 +08:00
|
|
|
|
g_snprintf (buf, sizeof (buf),
|
2007-12-26 00:21:40 +08:00
|
|
|
|
"%s (%d %s)", desc, gimp_image_get_colormap_size (image),
|
|
|
|
|
_("colors"));
|
2005-04-05 06:34:29 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (view->colorspace_label), buf);
|
|
|
|
|
|
2012-04-28 21:31:40 +08:00
|
|
|
|
/* precision */
|
|
|
|
|
precision = gimp_image_get_precision (image);
|
|
|
|
|
|
|
|
|
|
gimp_enum_get_value (GIMP_TYPE_PRECISION, precision,
|
|
|
|
|
NULL, NULL, &desc, NULL);
|
|
|
|
|
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (view->precision_label), desc);
|
|
|
|
|
|
2006-09-11 23:51:39 +08:00
|
|
|
|
/* size in memory */
|
|
|
|
|
gimp_image_prop_view_label_set_memsize (view->memsize_label,
|
|
|
|
|
GIMP_OBJECT (image));
|
|
|
|
|
|
2005-07-29 06:40:32 +08:00
|
|
|
|
/* undo / redo */
|
2010-02-05 03:06:49 +08:00
|
|
|
|
gimp_image_prop_view_label_set_undo (view->undo_label,
|
|
|
|
|
gimp_image_get_undo_stack (image));
|
|
|
|
|
gimp_image_prop_view_label_set_undo (view->redo_label,
|
|
|
|
|
gimp_image_get_redo_stack (image));
|
2005-07-29 06:40:32 +08:00
|
|
|
|
|
2005-07-16 06:51:48 +08:00
|
|
|
|
/* number of layers */
|
2007-12-26 00:21:40 +08:00
|
|
|
|
g_snprintf (buf, sizeof (buf), "%d",
|
|
|
|
|
gimp_image_get_width (image) *
|
|
|
|
|
gimp_image_get_height (image));
|
2005-07-16 06:51:48 +08:00
|
|
|
|
gtk_label_set_text (GTK_LABEL (view->pixels_label), buf);
|
|
|
|
|
|
2005-04-05 06:34:29 +08:00
|
|
|
|
/* number of layers */
|
|
|
|
|
g_snprintf (buf, sizeof (buf), "%d",
|
2009-08-02 18:24:06 +08:00
|
|
|
|
gimp_image_get_n_layers (image));
|
2005-04-05 06:34:29 +08:00
|
|
|
|
gtk_label_set_text (GTK_LABEL (view->layers_label), buf);
|
|
|
|
|
|
|
|
|
|
/* number of channels */
|
|
|
|
|
g_snprintf (buf, sizeof (buf), "%d",
|
2009-08-02 18:24:06 +08:00
|
|
|
|
gimp_image_get_n_channels (image));
|
2005-04-05 06:34:29 +08:00
|
|
|
|
gtk_label_set_text (GTK_LABEL (view->channels_label), buf);
|
|
|
|
|
|
|
|
|
|
/* number of vectors */
|
|
|
|
|
g_snprintf (buf, sizeof (buf), "%d",
|
2009-08-02 18:24:06 +08:00
|
|
|
|
gimp_image_get_n_vectors (image));
|
2005-04-05 06:34:29 +08:00
|
|
|
|
gtk_label_set_text (GTK_LABEL (view->vectors_label), buf);
|
|
|
|
|
}
|
2006-09-11 23:27:21 +08:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_image_prop_view_file_update (GimpImagePropView *view)
|
|
|
|
|
{
|
|
|
|
|
GimpImage *image = view->image;
|
|
|
|
|
|
|
|
|
|
/* filename */
|
|
|
|
|
gimp_image_prop_view_label_set_filename (view->filename_label, image);
|
|
|
|
|
|
|
|
|
|
/* filesize */
|
|
|
|
|
gimp_image_prop_view_label_set_filesize (view->filesize_label, image);
|
|
|
|
|
|
|
|
|
|
/* filetype */
|
|
|
|
|
gimp_image_prop_view_label_set_filetype (view->filetype_label, image);
|
|
|
|
|
}
|