Commit 13ba2a52 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

added signals "parasite-attached" and "parasite-detached".

2006-10-25  Sven Neumann  <sven@gimp.org>

	* app/core/gimpimage.[ch]: added signals "parasite-attached" and
	"parasite-detached".

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimpimageprofileview.[ch]: draft of a new widget
that
	displays color profile information.

	* app/widgets/gimpimagepropview.c: minor cleanup and bug fix.

	* app/dialogs/image-properties-dialog.c: added Color Profile
	information.

	* plug-ins/common/lcms.c: bug fixes.
parent bc232ef8
2006-10-25 Sven Neumann <sven@gimp.org>
* app/core/gimpimage.[ch]: added signals "parasite-attached" and
"parasite-detached".
* app/widgets/Makefile.am
* app/widgets/widgets-types.h
* app/widgets/gimpimageprofileview.[ch]: draft of a new widget that
displays color profile information.
* app/widgets/gimpimagepropview.c: minor cleanup and bug fix.
* app/dialogs/image-properties-dialog.c: added Color Profile
information.
* plug-ins/common/lcms.c: bug fixes.
2006-10-24 Manish Singh <yosh@gimp.org>
* plug-ins/pygimp/pygimp-vectors.c: remove_stroke is now a Vectors
......
......@@ -100,6 +100,8 @@ enum
UPDATE_SAMPLE_POINT,
SAMPLE_POINT_ADDED,
SAMPLE_POINT_REMOVED,
PARASITE_ATTACHED,
PARASITE_DETACHED,
COLORMAP_CHANGED,
UNDO_EVENT,
FLUSH,
......@@ -406,6 +408,26 @@ gimp_image_class_init (GimpImageClass *klass)
G_TYPE_NONE, 1,
G_TYPE_POINTER);
gimp_image_signals[PARASITE_ATTACHED] =
g_signal_new ("parasite-attached",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpImageClass, parasite_attached),
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
gimp_image_signals[PARASITE_DETACHED] =
g_signal_new ("parasite-detached",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpImageClass, parasite_detached),
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
gimp_image_signals[COLORMAP_CHANGED] =
g_signal_new ("colormap-changed",
G_TYPE_FROM_CLASS (klass),
......@@ -472,6 +494,8 @@ gimp_image_class_init (GimpImageClass *klass)
klass->update_sample_point = NULL;
klass->sample_point_added = NULL;
klass->sample_point_removed = NULL;
klass->parasite_attached = NULL;
klass->parasite_detached = NULL;
klass->colormap_changed = gimp_image_real_colormap_changed;
klass->undo_event = NULL;
klass->flush = gimp_image_real_flush;
......@@ -2294,6 +2318,9 @@ gimp_image_parasite_attach (GimpImage *image,
}
g_free (copy);
g_signal_emit (image, gimp_image_signals[PARASITE_ATTACHED], 0,
parasite->name);
}
void
......@@ -2314,6 +2341,9 @@ gimp_image_parasite_detach (GimpImage *image,
name);
gimp_parasite_list_remove (image->parasites, name);
g_signal_emit (image, gimp_image_signals[PARASITE_DETACHED], 0,
name);
}
......
......@@ -214,6 +214,10 @@ struct _GimpImageClass
GimpSamplePoint *sample_point);
void (* sample_point_removed) (GimpImage *image,
GimpSamplePoint *sample_point);
void (* parasite_attached) (GimpImage *image,
const gchar *name);
void (* parasite_detached) (GimpImage *image,
const gchar *name);
void (* colormap_changed) (GimpImage *image,
gint color_index);
void (* undo_event) (GimpImage *image,
......
......@@ -32,6 +32,7 @@
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpimagepropview.h"
#include "widgets/gimpimageprofileview.h"
#include "widgets/gimpviewabledialog.h"
#include "image-properties-dialog.h"
......@@ -47,6 +48,7 @@ image_properties_dialog_new (GimpImage *image,
GtkWidget *parent)
{
GtkWidget *dialog;
GtkWidget *notebook;
GtkWidget *view;
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
......@@ -72,10 +74,21 @@ image_properties_dialog_new (GimpImage *image,
G_CALLBACK (gtk_widget_destroy),
NULL);
notebook = gtk_notebook_new ();
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook,
FALSE, FALSE, 0);
gtk_widget_show (notebook);
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_notebook_append_page (GTK_NOTEBOOK (notebook),
view, gtk_label_new (_("Properties")));
gtk_widget_show (view);
view = gimp_image_profile_view_new (image);
gtk_container_set_border_width (GTK_CONTAINER (view), 12);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
view, gtk_label_new (_("Color Profile")));
gtk_widget_show (view);
return dialog;
......
......@@ -169,6 +169,8 @@ libappwidgets_a_sources = \
gimpimagedock.h \
gimpimageeditor.c \
gimpimageeditor.h \
gimpimageprofileview.c \
gimpimageprofileview.h \
gimpimagepropview.c \
gimpimagepropview.h \
gimpimageview.c \
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* GimpImageProfileView
* Copyright (C) 2006 Sven Neumann <sven@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 <string.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "core/gimp.h"
#include "core/gimpimage.h"
#include "core/gimpparamspecs.h"
#include "pdb/gimppdb.h"
#include "gimpimageprofileview.h"
#include "gimp-intl.h"
#define ICC_PROFILE_INFO_PROC "plug-in-icc-profile-info"
enum
{
PROP_0,
PROP_IMAGE
};
static GObject * gimp_image_profile_view_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_image_profile_view_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_image_profile_view_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static GtkWidget * gimp_image_profile_view_add_label (GtkTable *table,
gint row,
const gchar *text);
static void gimp_image_profile_view_parasite_changed (GimpImageProfileView *view,
const gchar *name);
static void gimp_image_profile_view_update (GimpImageProfileView *view);
G_DEFINE_TYPE (GimpImageProfileView, gimp_image_profile_view, GTK_TYPE_VBOX)
#define parent_class gimp_image_profile_view_parent_class
static void
gimp_image_profile_view_class_init (GimpImageProfileViewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructor = gimp_image_profile_view_constructor;
object_class->set_property = gimp_image_profile_view_set_property;
object_class->get_property = gimp_image_profile_view_get_property;
g_object_class_install_property (object_class, PROP_IMAGE,
g_param_spec_object ("image", NULL, NULL,
GIMP_TYPE_IMAGE,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
}
static void
gimp_image_profile_view_init (GimpImageProfileView *view)
{
gint row = 0;
view->table = gtk_table_new (3, 2, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (view->table), 6);
gtk_table_set_row_spacings (GTK_TABLE (view->table), 6);
gtk_container_add (GTK_CONTAINER (view), view->table);
view->name_label =
gimp_image_profile_view_add_label (GTK_TABLE (view->table), row++,
_("Name:"));
view->desc_label =
gimp_image_profile_view_add_label (GTK_TABLE (view->table), row++,
_("Description:"));
view->info_label =
gimp_image_profile_view_add_label (GTK_TABLE (view->table), row++,
_("Info:"));
view->message = g_object_new (GTK_TYPE_LABEL,
"xalign", 0.5,
"yalign", 0.5,
NULL);
gtk_container_add (GTK_CONTAINER (view), view->message);
}
static void
gimp_image_profile_view_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpImageProfileView *view = GIMP_IMAGE_PROFILE_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_profile_view_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpImageProfileView *view = GIMP_IMAGE_PROFILE_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_profile_view_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GimpImageProfileView *view;
GObject *object;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
view = GIMP_IMAGE_PROFILE_VIEW (object);
g_assert (view->image != NULL);
g_signal_connect_object (view->image, "parasite-attached",
G_CALLBACK (gimp_image_profile_view_parasite_changed),
G_OBJECT (view),
G_CONNECT_SWAPPED);
g_signal_connect_object (view->image, "parasite-detached",
G_CALLBACK (gimp_image_profile_view_parasite_changed),
G_OBJECT (view),
G_CONNECT_SWAPPED);
gimp_image_profile_view_update (view);
return object;
}
/* public functions */
GtkWidget *
gimp_image_profile_view_new (GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
return g_object_new (GIMP_TYPE_IMAGE_PROFILE_VIEW,
"image", image,
NULL);
}
/* private functions */
static GtkWidget *
gimp_image_profile_view_add_label (GtkTable *table,
gint row,
const gchar *text)
{
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,
"xalign", 0.0,
"yalign", 0.5,
"selectable", TRUE,
NULL);
gtk_table_attach (table, label,
1, 2, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
return label;
}
static void
gimp_image_profile_view_parasite_changed (GimpImageProfileView *view,
const gchar *name)
{
if (name && strcmp (name, "icc-profile") == 0)
gimp_image_profile_view_update (view);
}
static void
gimp_image_profile_view_set_value (GtkLabel *label,
GValueArray *values,
gint index)
{
if (values->n_values > index)
{
GValue *value = g_value_array_get_nth (values, index);
if (G_VALUE_HOLDS_STRING (value))
{
gtk_label_set_text (label, g_value_get_string (value));
return;
}
}
gtk_label_set_text (label, NULL);
}
static void
gimp_image_profile_view_update (GimpImageProfileView *view)
{
Gimp *gimp = view->image->gimp;
GimpProcedure *procedure;
gtk_label_set_text (GTK_LABEL (view->name_label), NULL);
gtk_label_set_text (GTK_LABEL (view->desc_label), NULL);
gtk_label_set_text (GTK_LABEL (view->info_label), NULL);
gtk_widget_hide (view->table);
/* FIXME: do this from an idle handler, or even asynchronously */
procedure = gimp_pdb_lookup_procedure (gimp->pdb, ICC_PROFILE_INFO_PROC);
if (procedure)
{
GValueArray *return_vals;
GimpPDBStatusType status;
gtk_label_set_text (GTK_LABEL (view->message), "Querying...");
gtk_widget_show (view->message);
return_vals =
gimp_pdb_execute_procedure_by_name (gimp->pdb,
gimp_get_user_context (gimp),
NULL,
ICC_PROFILE_INFO_PROC,
GIMP_TYPE_INT32,
GIMP_RUN_NONINTERACTIVE,
GIMP_TYPE_IMAGE_ID,
gimp_image_get_ID (view->image),
G_TYPE_NONE);
status = g_value_get_enum (return_vals->values);
switch (status)
{
case GIMP_PDB_SUCCESS:
gtk_label_set_text (GTK_LABEL (view->message), NULL);
gtk_widget_hide (view->message);
gimp_image_profile_view_set_value (GTK_LABEL (view->name_label),
return_vals, 1);
gimp_image_profile_view_set_value (GTK_LABEL (view->desc_label),
return_vals, 2);
gimp_image_profile_view_set_value (GTK_LABEL (view->info_label),
return_vals, 3);
gtk_widget_show (view->table);
break;
default:
gtk_label_set_text (GTK_LABEL (view->message), "Query failed.");
break;
}
g_value_array_free (return_vals);
}
else
{
gtk_label_set_text (GTK_LABEL (view->message), "Plug-In is missing.");
gtk_widget_show (view->message);
}
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* GimpImageProfileView
* Copyright (C) 2006 Sven Neumann <sven@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_PROFILE_VIEW_H__
#define __GIMP_IMAGE_PROFILE_VIEW_H__
#include <gtk/gtkvbox.h>
#define GIMP_TYPE_IMAGE_PROFILE_VIEW (gimp_image_profile_view_get_type ())
#define GIMP_IMAGE_PROFILE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_IMAGE_PROFILE_VIEW, GimpImageProfileView))
#define GIMP_IMAGE_PROFILE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_IMAGE_PROFILE_VIEW, GimpImageProfileViewClass))
#define GIMP_IS_IMAGE_PROFILE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_IMAGE_PROFILE_VIEW))
#define GIMP_IS_IMAGE_PROFILE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_IMAGE_PROFILE_VIEW))
#define GIMP_IMAGE_PROFILE_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_IMAGE_PROFILE_VIEW, GimpImageProfileViewClass))
typedef struct _GimpImageProfileViewClass GimpImageProfileViewClass;
struct _GimpImageProfileView
{
GtkVBox parent_instance;
GimpImage *image;
GtkWidget *table;
GtkWidget *name_label;
GtkWidget *desc_label;
GtkWidget *info_label;
GtkWidget *message;
};
struct _GimpImageProfileViewClass
{
GtkVBoxClass parent_class;
};
GType gimp_image_profile_view_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_image_profile_view_new (GimpImage *image);
#endif /* __GIMP_IMAGE_PROFILE_VIEW_H__ */
......@@ -3,6 +3,7 @@
*
* GimpImagePropView
* Copyright (C) 2005 Michael Natterer <mitch@gimp.org>
* Copyright (C) 2006 Sven Neumann <sven@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
......@@ -59,27 +60,27 @@ enum
};
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 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);
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 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);
G_DEFINE_TYPE (GimpImagePropView, gimp_image_prop_view, GTK_TYPE_TABLE)
......@@ -106,10 +107,62 @@ gimp_image_prop_view_class_init (GimpImagePropViewClass *klass)
static void
gimp_image_prop_view_init (GimpImagePropView *view)
{
gtk_table_resize (GTK_TABLE (view), 14, 2);
GtkTable *table = GTK_TABLE (view);
gint row = 0;
gtk_table_resize (table, 14, 2);
gtk_table_set_col_spacings (table, 6);
gtk_table_set_row_spacings (table, 3);
view->pixel_size_label =
gimp_image_prop_view_add_label (table, row++, _("Pixel dimensions:"));
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 =
gimp_image_prop_view_add_label (table, row, _("Color space:"));
gtk_table_set_row_spacing (GTK_TABLE (view), row++, 12);
view->filename_label =
gimp_image_prop_view_add_label (table, row++, _("File Name:"));
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:"));
gtk_table_set_col_spacings (GTK_TABLE (view), 6);
gtk_table_set_row_spacings (GTK_TABLE (view), 3);
}
static void
......@@ -156,65 +209,14 @@ gimp_image_prop_view_constructor (GType type,
GObjectConstructParam *params)
{
GimpImagePropView *view;
GtkTable *table;
GObject *object;
gint row = 0;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
view = GIMP_IMAGE_PROP_VIEW (object);
table = GTK_TABLE (view);
g_assert (view->image != NULL);
view->pixel_size_label =
gimp_image_prop_view_add_label (table, row++, _("Pixel dimensions:"));
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 =
gimp_image_prop_view_add_label (table, row, _("Color space:"));
gtk_table_set_row_spacing (GTK_TABLE (view), row++, 12);
view->filename_label =
gimp_image_prop_view_add_label (table, row++, _("File Name:"));
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:"));
g_signal_connect_object (view->image, "name-changed",
G_CALLBACK (gimp_image_prop_view_file_update),
G_OBJECT (view),
......@@ -367,8 +369,11 @@ gimp_image_prop_view_label_set_filetype (GtkWidget *label,
{
gchar *filename = gimp_image_get_filename (image);
proc = file_utils_find_proc (manager->load_procs, filename, NULL);
g_free (filename);
if (filename)
{
proc = file_utils_find_proc (manager->load_procs, filename, NULL);