More unfinished replacement for the info window:

2005-04-05  Michael Natterer  <mitch@gimp.org>

	More unfinished replacement for the info window:

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimpimagepropview.[ch]: new widget showing an image's
	size, resolution, mode, memsize etc.

	* app/dialogs/Makefile.am
	* app/dialogs/image-properties-dialog.[ch]: a dialog keeping the
	widget.

	* app/widgets/gimphelp-ids.h: a help ID for the dialog.

	* app/actions/image-actions.c
	* app/actions/image-commands.[ch]
	* menus/image-menu.xml.in: action and menu entry for the dialog.
This commit is contained in:
Michael Natterer 2005-04-04 22:34:29 +00:00 committed by Michael Natterer
parent 07412d61c9
commit dba31b149c
13 changed files with 594 additions and 1 deletions

View File

@ -1,3 +1,22 @@
2005-04-05 Michael Natterer <mitch@gimp.org>
More unfinished replacement for the info window:
* app/widgets/Makefile.am
* app/widgets/widgets-types.h
* app/widgets/gimpimagepropview.[ch]: new widget showing an image's
size, resolution, mode, memsize etc.
* app/dialogs/Makefile.am
* app/dialogs/image-properties-dialog.[ch]: a dialog keeping the
widget.
* app/widgets/gimphelp-ids.h: a help ID for the dialog.
* app/actions/image-actions.c
* app/actions/image-commands.[ch]
* menus/image-menu.xml.in: action and menu entry for the dialog.
2005-04-04 Sven Neumann <sven@gimp.org>
* app/tools/gimpclonetool.c (gimp_clone_tool_oper_update): check

View File

@ -114,7 +114,12 @@ static GimpActionEntry image_actions[] =
{ "image-configure-grid", GIMP_STOCK_GRID,
N_("Configure G_rid..."), NULL, NULL,
G_CALLBACK (image_configure_grid_cmd_callback),
GIMP_HELP_IMAGE_GRID }
GIMP_HELP_IMAGE_GRID },
{ "image-properties", GIMP_STOCK_INFO,
N_("Image Properties"), NULL, NULL,
G_CALLBACK (image_properties_cmd_callback),
GIMP_HELP_IMAGE_PROPERTIES }
};
static GimpEnumActionEntry image_convert_actions[] =
@ -248,6 +253,7 @@ image_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("image-merge-layers", gimage && !fs && !aux && lp);
SET_SENSITIVE ("image-flatten", gimage && !fs && !aux && lp);
SET_SENSITIVE ("image-configure-grid", gimage);
SET_SENSITIVE ("image-properties", gimage);
#undef SET_SENSITIVE
}

View File

@ -52,6 +52,7 @@
#include "dialogs/grid-dialog.h"
#include "dialogs/image-merge-layers-dialog.h"
#include "dialogs/image-new-dialog.h"
#include "dialogs/image-properties-dialog.h"
#include "dialogs/image-scale-dialog.h"
#include "dialogs/print-size-dialog.h"
#include "dialogs/resize-dialog.h"
@ -420,6 +421,29 @@ image_configure_grid_cmd_callback (GtkAction *action,
gtk_window_present (GTK_WINDOW (shell->grid_dialog));
}
void
image_properties_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDisplay *gdisp;
GimpDisplayShell *shell;
GimpImage *gimage;
GtkWidget *dialog;
return_if_no_display (gdisp, data);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimage = gdisp->gimage;
dialog = image_properties_dialog_new (gdisp->gimage, gdisp->shell);
gtk_window_set_transient_for (GTK_WINDOW (dialog),
GTK_WINDOW (gdisp->shell));
gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog),
TRUE);
gtk_window_present (GTK_WINDOW (dialog));
}
/* private functions */

View File

@ -56,6 +56,8 @@ void image_flatten_image_cmd_callback (GtkAction *action,
void image_configure_grid_cmd_callback (GtkAction *action,
gpointer data);
void image_properties_cmd_callback (GtkAction *action,
gpointer data);
#endif /* __IMAGE_COMMANDS_H__ */

View File

@ -40,6 +40,8 @@ libappdialogs_a_sources = \
image-merge-layers-dialog.h \
image-new-dialog.c \
image-new-dialog.h \
image-properties-dialog.c \
image-properties-dialog.h \
image-scale-dialog.c \
image-scale-dialog.h \
info-dialog.c \

View File

@ -0,0 +1,79 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* image-properties-dialog.c
* Copyright (C) 2005 Michael Natterer <mitch@gimp.org>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "dialogs-types.h"
#include "core/gimpimage.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpimagepropview.h"
#include "widgets/gimpviewabledialog.h"
#include "image-properties-dialog.h"
#include "gimp-intl.h"
/* public functions */
GtkWidget *
image_properties_dialog_new (GimpImage *image,
GtkWidget *parent)
{
GtkWidget *dialog;
GtkWidget *view;
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (parent == NULL || GTK_IS_WIDGET (parent), NULL);
dialog = gimp_viewable_dialog_new (GIMP_VIEWABLE (image),
_("Image Properties"),
"gimp-image-properties",
GIMP_STOCK_INFO,
_("View Image Properties"),
parent,
gimp_standard_help_func,
GIMP_HELP_IMAGE_PROPERTIES,
GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
NULL);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
g_signal_connect (dialog, "response",
G_CALLBACK (gtk_widget_destroy),
NULL);
view = gimp_image_prop_view_new (image);
gtk_container_set_border_width (GTK_CONTAINER (view), 12);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), view,
FALSE, FALSE, 0);
gtk_widget_show (view);
return dialog;
}

View File

@ -0,0 +1,30 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* image-properties-dialog.h
* Copyright (C) 2005 Michael Natterer <mitch@gimp.org>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __IMAGE_PROPERTIES_DIALOG_H__
#define __IMAGE_PROPERTIES_DIALOG_H__
GtkWidget * image_properties_dialog_new (GimpImage *image,
GtkWidget *parent);
#endif /* __IMAGE_PROPERTIES_DIALOG_H__ */

View File

@ -163,6 +163,8 @@ libappwidgets_a_sources = \
gimpimagedock.h \
gimpimageeditor.c \
gimpimageeditor.h \
gimpimagepropview.c \
gimpimagepropview.h \
gimpimageview.c \
gimpimageview.h \
gimpitemtreeview.c \

View File

@ -123,6 +123,7 @@
#define GIMP_HELP_IMAGE_MERGE_LAYERS "gimp-image-merge-layers"
#define GIMP_HELP_IMAGE_FLATTEN "gimp-image-flatten"
#define GIMP_HELP_IMAGE_GRID "gimp-image-grid"
#define GIMP_HELP_IMAGE_PROPERTIES "gimp-image-properties"
#define GIMP_HELP_LAYER_DIALOG "gimp-layer-dialog"
#define GIMP_HELP_LAYER_DIALOG_PAINT_MODE_MENU "gimp-layer-dialog-paint-mode-menu"

View File

@ -0,0 +1,360 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* GimpImagePropView
* Copyright (C) 2005 Michael Natterer <mitch@gimp.org>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "core/gimpcontainer.h"
#include "core/gimpimage.h"
#include "core/gimpunit.h"
#include "gimpimagepropview.h"
#include "gimppropwidgets.h"
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_IMAGE
};
static void gimp_image_prop_view_class_init (GimpImagePropViewClass *klass);
static void gimp_image_prop_view_init (GimpImagePropView *view);
static GObject * gimp_image_prop_view_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
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 void gimp_image_prop_view_update (GimpImagePropView *view);
static GtkTableClass *parent_class = NULL;
GType
gimp_image_prop_view_get_type (void)
{
static GType view_type = 0;
if (! view_type)
{
static const GTypeInfo view_info =
{
sizeof (GimpImagePropViewClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gimp_image_prop_view_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpImagePropView),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_image_prop_view_init
};
view_type = g_type_register_static (GTK_TYPE_TABLE,
"GimpImagePropView",
&view_info, 0);
}
return view_type;
}
static void
gimp_image_prop_view_class_init (GimpImagePropViewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gimp_image_prop_view_constructor;
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,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
}
static void
gimp_image_prop_view_init (GimpImagePropView *view)
{
gtk_table_set_col_spacing (GTK_TABLE (view), 0, 6);
gtk_table_set_row_spacings (GTK_TABLE (view), 4);
}
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);
switch (property_id)
{
case PROP_IMAGE:
view->image = GIMP_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;
}
}
static GObject *
gimp_image_prop_view_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GimpImagePropView *view;
GObject *object;
GtkWidget *label;
gint row = 0;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
view = GIMP_IMAGE_PROP_VIEW (object);
g_assert (view->image != NULL);
view->pixel_size_label = label = gtk_label_new (NULL);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gimp_table_attach_aligned (GTK_TABLE (view), 0, row++,
_("Pixel dimensions:"),
0.0, 0.5, label,
1, FALSE);
view->print_size_label = label = gtk_label_new (NULL);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gimp_table_attach_aligned (GTK_TABLE (view), 0, row++,
_("Print size:"),
0.0, 0.5, label,
1, FALSE);
view->resolution_label = label = gtk_label_new (NULL);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gimp_table_attach_aligned (GTK_TABLE (view), 0, row++,
_("Resolution:"),
0.0, 0.5, label,
1, FALSE);
view->colorspace_label = label = gtk_label_new (NULL);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gimp_table_attach_aligned (GTK_TABLE (view), 0, row++,
_("Color space:"),
0.0, 0.5, label,
1, FALSE);
view->memsize_label =label = gtk_label_new (NULL);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gimp_table_attach_aligned (GTK_TABLE (view), 0, row++,
_("Size in memory:"),
0.0, 0.5, label,
1, FALSE);
view->layers_label = label = gtk_label_new (NULL);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gimp_table_attach_aligned (GTK_TABLE (view), 0, row++,
_("Number of layers:"),
0.0, 0.5, label,
1, FALSE);
view->channels_label = label = gtk_label_new (NULL);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gimp_table_attach_aligned (GTK_TABLE (view), 0, row++,
_("Number of channels:"),
0.0, 0.5, label,
1, FALSE);
view->vectors_label = label = gtk_label_new (NULL);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gimp_table_attach_aligned (GTK_TABLE (view), 0, row++,
_("Number of paths:"),
0.0, 0.5, label,
1, FALSE);
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);
gimp_image_prop_view_update (view);
return object;
}
/* 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 */
static void
gimp_image_prop_view_update (GimpImagePropView *view)
{
GimpImage *image = view->image;
GimpImageBaseType type;
GimpUnit unit;
gdouble unit_factor;
gint unit_digits;
gchar format_buf[32];
gchar buf[256];
/* pixel size */
g_snprintf (buf, sizeof (buf), _("%d x %d pixels"),
image->width, image->height);
gtk_label_set_text (GTK_LABEL (view->pixel_size_label), buf);
/* print size */
#if 0
unit = GIMP_DISPLAY_SHELL (gdisp->shell)->unit;
if (unit == GIMP_UNIT_PIXEL)
#endif
unit = gimp_image_get_unit (image);
unit_factor = _gimp_unit_get_factor (image->gimp, unit);
unit_digits = _gimp_unit_get_digits (image->gimp, unit);
g_snprintf (format_buf, sizeof (format_buf), "%%.%df x %%.%df %s",
unit_digits + 1, unit_digits + 1,
_gimp_unit_get_plural (image->gimp, unit));
g_snprintf (buf, sizeof (buf), format_buf,
image->width * unit_factor / image->xresolution,
image->height * unit_factor / image->yresolution);
gtk_label_set_text (GTK_LABEL (view->print_size_label), buf);
/* resolution */
unit = gimp_image_get_unit (image);
unit_factor = _gimp_unit_get_factor (image->gimp, unit);
g_snprintf (format_buf, sizeof (format_buf), _("pixels/%s"),
_gimp_unit_get_abbreviation (image->gimp, unit));
g_snprintf (buf, sizeof (buf), _("%g x %g %s"),
image->xresolution / unit_factor,
image->yresolution / unit_factor,
unit == GIMP_UNIT_INCH ? _("dpi") : format_buf);
gtk_label_set_text (GTK_LABEL (view->resolution_label), buf);
/* color type */
type = gimp_image_base_type (image);
switch (type)
{
case GIMP_RGB:
g_snprintf (buf, sizeof (buf), "%s", _("RGB Color"));
break;
case GIMP_GRAY:
g_snprintf (buf, sizeof (buf), "%s", _("Grayscale"));
break;
case GIMP_INDEXED:
g_snprintf (buf, sizeof (buf), "%s (%d %s)",
_("Indexed Color"), image->num_cols, _("colors"));
break;
}
gtk_label_set_text (GTK_LABEL (view->colorspace_label), buf);
/* size in memory */
{
GimpObject *object = GIMP_OBJECT (image);
gchar *str;
str = gimp_memsize_to_string (gimp_object_get_memsize (object, NULL));
gtk_label_set_text (GTK_LABEL (view->memsize_label), str);
g_free (str);
}
/* number of layers */
g_snprintf (buf, sizeof (buf), "%d",
gimp_container_num_children (image->layers));
gtk_label_set_text (GTK_LABEL (view->layers_label), buf);
/* number of channels */
g_snprintf (buf, sizeof (buf), "%d",
gimp_container_num_children (image->channels));
gtk_label_set_text (GTK_LABEL (view->channels_label), buf);
/* number of vectors */
g_snprintf (buf, sizeof (buf), "%d",
gimp_container_num_children (image->vectors));
gtk_label_set_text (GTK_LABEL (view->vectors_label), buf);
}

View File

@ -0,0 +1,66 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* GimpImagePropView
* Copyright (C) 2005 Michael Natterer <mitch@gimp.org>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_IMAGE_PROP_VIEW_H__
#define __GIMP_IMAGE_PROP_VIEW_H__
#include <gtk/gtktable.h>
#define GIMP_TYPE_IMAGE_PROP_VIEW (gimp_image_prop_view_get_type ())
#define GIMP_IMAGE_PROP_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_IMAGE_PROP_VIEW, GimpImagePropView))
#define GIMP_IMAGE_PROP_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_IMAGE_PROP_VIEW, GimpImagePropViewClass))
#define GIMP_IS_IMAGE_PROP_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_IMAGE_PROP_VIEW))
#define GIMP_IS_IMAGE_PROP_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_IMAGE_PROP_VIEW))
#define GIMP_IMAGE_PROP_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_IMAGE_PROP_VIEW, GimpImagePropViewClass))
typedef struct _GimpImagePropViewClass GimpImagePropViewClass;
struct _GimpImagePropView
{
GtkTable parent_instance;
GimpImage *image;
GtkWidget *pixel_size_label;
GtkWidget *print_size_label;
GtkWidget *resolution_label;
GtkWidget *colorspace_label;
GtkWidget *memsize_label;
GtkWidget *layers_label;
GtkWidget *channels_label;
GtkWidget *vectors_label;
};
struct _GimpImagePropViewClass
{
GtkTableClass parent_class;
};
GType gimp_image_prop_view_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_image_prop_view_new (GimpImage *image);
#endif /* __GIMP_IMAGE_PROP_VIEW_H__ */

View File

@ -160,6 +160,7 @@ typedef struct _GimpFileProcView GimpFileProcView;
typedef struct _GimpGridEditor GimpGridEditor;
typedef struct _GimpHistogramBox GimpHistogramBox;
typedef struct _GimpHistogramView GimpHistogramView;
typedef struct _GimpImagePropView GimpImagePropView;
typedef struct _GimpMessageBox GimpMessageBox;
typedef struct _GimpProgressBox GimpProgressBox;
typedef struct _GimpSizeBox GimpSizeBox;

View File

@ -307,6 +307,7 @@
<menu action="image-guides-menu" name="Guides">
</menu>
<menuitem action="image-configure-grid" />
<menuitem action="image-properties" />
<separator />
</menu>