Commit 0231374c authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

added new signals "sample-point-added" and "sample-point-removed" and

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

	* app/core/gimpimage.[ch]: added new signals "sample-point-added"
	and "sample-point-removed" and public functions to emit them.

	* app/core/gimpimage-sample-points.c (gimp_image_add_sample_point)
	(gimp_image_remove_sample_point): emit them accordingly.

	* app/core/gimpimage-undo-push.c (undo_pop_image_sample_point):
	ditto.

	(undo_pop_image_guide)
	(undo_pop_image_sample_point): added comments why we add/remove
	stuff manually instead of using the GimpImage APIs.

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimpcursorview.[ch]
	* app/widgets/gimpsamplepointeditor.[ch]: new widgets.
	GimpCursorView is a replacement for the info window's "Cursor"
	page, GimpSamplePointEditor is a view on an image's sample points.
	The sample point editor does nothing yet except keeping a 2x2 grid
	of GimpColorFrames. Addresses bug #137776.

	* app/dialogs/dialogs.c
	* app/dialogs/dialogs-constructors.[ch]: register the new widgets
	as dockable dialogs.

	* app/actions/dialogs-actions.c (dialogs_dockable_actions)
	* menus/dialogs-menuitems.xml: added actions and menu items for
	the new dialogs.

	* app/display/gimpdisplayshell-cursor.c
	(gimp_display_shell_update_cursor)
	(gimp_display_shell_clear_cursor): update the new cursor view.

	* app/widgets/gimphelp-ids.h: help IDs for the new dialogs.

	* app/widgets/widgets-enums.[ch] (enum GimpColorFrameMode):
	changed description "Pixel values" to "Pixel" because the former
	was too long.
parent 268f1b62
2005-04-03 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage.[ch]: added new signals "sample-point-added"
and "sample-point-removed" and public functions to emit them.
* app/core/gimpimage-sample-points.c (gimp_image_add_sample_point)
(gimp_image_remove_sample_point): emit them accordingly.
* app/core/gimpimage-undo-push.c (undo_pop_image_sample_point):
ditto.
(undo_pop_image_guide)
(undo_pop_image_sample_point): added comments why we add/remove
stuff manually instead of using the GimpImage APIs.
* app/widgets/Makefile.am
* app/widgets/widgets-types.h
* app/widgets/gimpcursorview.[ch]
* app/widgets/gimpsamplepointeditor.[ch]: new widgets.
GimpCursorView is a replacement for the info window's "Cursor"
page, GimpSamplePointEditor is a view on an image's sample points.
The sample point editor does nothing yet except keeping a 2x2 grid
of GimpColorFrames. Addresses bug #137776.
* app/dialogs/dialogs.c
* app/dialogs/dialogs-constructors.[ch]: register the new widgets
as dockable dialogs.
* app/actions/dialogs-actions.c (dialogs_dockable_actions)
* menus/dialogs-menuitems.xml: added actions and menu items for
the new dialogs.
* app/display/gimpdisplayshell-cursor.c
(gimp_display_shell_update_cursor)
(gimp_display_shell_clear_cursor): update the new cursor view.
* app/widgets/gimphelp-ids.h: help IDs for the new dialogs.
* app/widgets/widgets-enums.[ch] (enum GimpColorFrameMode):
changed description "Pixel values" to "Pixel" because the former
was too long.
2005-04-02 Michael Natterer <mitch@gimp.org>
* themes/Default/images/Makefile.am
......
......@@ -111,6 +111,16 @@ GimpStringActionEntry dialogs_dockable_actions[] =
"gimp-undo-history",
GIMP_HELP_UNDO_DIALOG },
{ "dialogs-cursor", GIMP_STOCK_CURSOR,
N_("_Cursor"), NULL, NULL,
"gimp-cursor-view",
GIMP_HELP_CURSOR_DIALOG },
{ "dialogs-sample-points", GIMP_STOCK_SAMPLE_POINT,
N_("_Sample Points"), NULL, NULL,
"gimp-sample-point-editor",
GIMP_HELP_SAMPLE_POINT_DIALOG },
{ "dialogs-colors", GIMP_STOCK_DEFAULT_COLORS,
N_("Colo_rs"), NULL, NULL,
"gimp-color-editor",
......
......@@ -101,6 +101,7 @@ gimp_image_add_sample_point (GimpImage *gimage,
sample_point->y = y;
gimp_image_sample_point_ref (sample_point);
gimp_image_sample_point_added (gimage, sample_point);
gimp_image_update_sample_point (gimage, sample_point);
}
......@@ -126,6 +127,8 @@ gimp_image_remove_sample_point (GimpImage *gimage,
gimage->sample_points = g_list_remove (gimage->sample_points, sample_point);
gimp_image_sample_point_removed (gimage, sample_point);
sample_point->x = -1;
sample_point->y = -1;
gimp_image_sample_point_unref (sample_point);
......
......@@ -369,6 +369,12 @@ undo_pop_image_guide (GimpUndo *undo,
old_position = gu->guide->position;
old_orientation = gu->guide->orientation;
/* add and move guides manually (nor using the gimp_image_guide
* API), because we might be in the middle of an image resizing
* undo group and the guide's position might be temporarily out of
* image.
*/
if (gu->guide->position == -1)
{
undo->gimage->guides = g_list_prepend (undo->gimage->guides, gu->guide);
......@@ -521,11 +527,11 @@ gimp_image_undo_push_image_sample_point (GimpImage *gimage,
undo_free_image_sample_point,
NULL)))
{
SamplePointUndo *gu = new->data;
SamplePointUndo *spu = new->data;
gu->sample_point = gimp_image_sample_point_ref (sample_point);
gu->x = sample_point->x;
gu->y = sample_point->y;
spu->sample_point = gimp_image_sample_point_ref (sample_point);
spu->x = sample_point->x;
spu->y = sample_point->y;
return TRUE;
}
......@@ -538,36 +544,45 @@ undo_pop_image_sample_point (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum)
{
SamplePointUndo *gu = undo->data;
SamplePointUndo *spu = undo->data;
gint old_x;
gint old_y;
old_x = gu->sample_point->x;
old_y = gu->sample_point->y;
old_x = spu->sample_point->x;
old_y = spu->sample_point->y;
if (gu->sample_point->x == -1)
/* add and move sample points manually (nor using the
* gimp_image_sample_point API), because we might be in the middle
* of an image resizing undo group and the sample point's position
* might be temporarily out of image.
*/
if (spu->sample_point->x == -1)
{
undo->gimage->sample_points = g_list_append (undo->gimage->sample_points,
gu->sample_point);
gu->sample_point->x = gu->x;
gu->sample_point->y = gu->y;
gimp_image_sample_point_ref (gu->sample_point);
gimp_image_update_sample_point (undo->gimage, gu->sample_point);
spu->sample_point);
spu->sample_point->x = spu->x;
spu->sample_point->y = spu->y;
gimp_image_sample_point_ref (spu->sample_point);
gimp_image_sample_point_added (undo->gimage, spu->sample_point);
gimp_image_update_sample_point (undo->gimage, spu->sample_point);
}
else if (gu->x == -1)
else if (spu->x == -1)
{
gimp_image_remove_sample_point (undo->gimage, gu->sample_point, FALSE);
gimp_image_remove_sample_point (undo->gimage, spu->sample_point, FALSE);
}
else
{
gimp_image_update_sample_point (undo->gimage, gu->sample_point);
gu->sample_point->x = gu->x;
gu->sample_point->y = gu->y;
gimp_image_update_sample_point (undo->gimage, gu->sample_point);
gimp_image_update_sample_point (undo->gimage, spu->sample_point);
spu->sample_point->x = spu->x;
spu->sample_point->y = spu->y;
gimp_image_update_sample_point (undo->gimage, spu->sample_point);
}
gu->x = old_x;
gu->y = old_y;
spu->x = old_x;
spu->y = old_y;
return TRUE;
}
......
......@@ -94,6 +94,8 @@ enum
UPDATE,
UPDATE_GUIDE,
UPDATE_SAMPLE_POINT,
SAMPLE_POINT_ADDED,
SAMPLE_POINT_REMOVED,
COLORMAP_CHANGED,
UNDO_EVENT,
FLUSH,
......@@ -410,6 +412,26 @@ gimp_image_class_init (GimpImageClass *klass)
G_TYPE_NONE, 1,
G_TYPE_POINTER);
gimp_image_signals[SAMPLE_POINT_ADDED] =
g_signal_new ("sample_point_added",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpImageClass, sample_point_added),
NULL, NULL,
gimp_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
gimp_image_signals[SAMPLE_POINT_REMOVED] =
g_signal_new ("sample_point_removed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpImageClass, sample_point_removed),
NULL, NULL,
gimp_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
gimp_image_signals[COLORMAP_CHANGED] =
g_signal_new ("colormap_changed",
G_TYPE_FROM_CLASS (klass),
......@@ -473,6 +495,8 @@ gimp_image_class_init (GimpImageClass *klass)
klass->update = NULL;
klass->update_guide = NULL;
klass->update_sample_point = NULL;
klass->sample_point_added = NULL;
klass->sample_point_removed = NULL;
klass->colormap_changed = gimp_image_real_colormap_changed;
klass->undo_event = NULL;
klass->flush = gimp_image_real_flush;
......@@ -1665,6 +1689,28 @@ gimp_image_update_sample_point (GimpImage *gimage,
sample_point);
}
void
gimp_image_sample_point_added (GimpImage *gimage,
GimpSamplePoint *sample_point)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (sample_point != NULL);
g_signal_emit (gimage, gimp_image_signals[SAMPLE_POINT_ADDED], 0,
sample_point);
}
void
gimp_image_sample_point_removed (GimpImage *gimage,
GimpSamplePoint *sample_point)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (sample_point != NULL);
g_signal_emit (gimage, gimp_image_signals[SAMPLE_POINT_REMOVED], 0,
sample_point);
}
void
gimp_image_colormap_changed (GimpImage *gimage,
gint color_index)
......
......@@ -210,6 +210,10 @@ struct _GimpImageClass
GimpGuide *guide);
void (* update_sample_point) (GimpImage *gimage,
GimpSamplePoint *sample_point);
void (* sample_point_added) (GimpImage *gimage,
GimpSamplePoint *sample_point);
void (* sample_point_removed) (GimpImage *gimage,
GimpSamplePoint *sample_point);
void (* colormap_changed) (GimpImage *gimage,
gint color_index);
void (* undo_event) (GimpImage *gimage,
......@@ -299,6 +303,10 @@ void gimp_image_update_guide (GimpImage *gimage,
GimpGuide *guide);
void gimp_image_update_sample_point (GimpImage *gimage,
GimpSamplePoint *sample_point);
void gimp_image_sample_point_added (GimpImage *gimage,
GimpSamplePoint *sample_point);
void gimp_image_sample_point_removed (GimpImage *gimage,
GimpSamplePoint *sample_point);
void gimp_image_colormap_changed (GimpImage *gimage,
gint col);
void gimp_image_selection_control (GimpImage *gimage,
......@@ -386,7 +394,7 @@ gboolean gimp_image_set_tattoo_state (GimpImage *gimage,
GimpTattoo gimp_image_get_tattoo_state (GimpImage *gimage);
/* layers / channels / vectors / old paths */
/* layers / channels / vectors */
GimpContainer * gimp_image_get_layers (const GimpImage *gimage);
GimpContainer * gimp_image_get_channels (const GimpImage *gimage);
......
......@@ -40,6 +40,7 @@
#include "widgets/gimpcontainergridview.h"
#include "widgets/gimpcontainertreeview.h"
#include "widgets/gimpcontainerview-utils.h"
#include "widgets/gimpcursorview.h"
#include "widgets/gimpdataeditor.h"
#include "widgets/gimpdevicestatus.h"
#include "widgets/gimpdialogfactory.h"
......@@ -56,6 +57,7 @@
#include "widgets/gimplayertreeview.h"
#include "widgets/gimppaletteeditor.h"
#include "widgets/gimppatternfactoryview.h"
#include "widgets/gimpsamplepointeditor.h"
#include "widgets/gimpselectioneditor.h"
#include "widgets/gimptemplateview.h"
#include "widgets/gimptoolbox.h"
......@@ -232,7 +234,7 @@ dialogs_dockable_constructor (GimpDialogFactory *factory,
/***** singleton dialogs *****/
GtkWidget *
dialogs_tool_options_get (GimpDialogFactory *factory,
dialogs_tool_options_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
......@@ -241,7 +243,7 @@ dialogs_tool_options_get (GimpDialogFactory *factory,
}
GtkWidget *
dialogs_device_status_get (GimpDialogFactory *factory,
dialogs_device_status_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
......@@ -249,7 +251,7 @@ dialogs_device_status_get (GimpDialogFactory *factory,
}
GtkWidget *
dialogs_error_console_get (GimpDialogFactory *factory,
dialogs_error_console_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
......@@ -257,6 +259,14 @@ dialogs_error_console_get (GimpDialogFactory *factory,
factory->menu_factory);
}
GtkWidget *
dialogs_cursor_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
return gimp_cursor_view_new (context);
}
/***** list views *****/
......@@ -602,6 +612,14 @@ dialogs_undo_editor_new (GimpDialogFactory *factory,
factory->menu_factory);
}
GtkWidget *
dialogs_sample_point_editor_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
return gimp_sample_point_editor_new (factory->menu_factory);
}
/***** display related dialogs *****/
......
......@@ -71,13 +71,16 @@ GtkWidget * dialogs_dockable_constructor (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_tool_options_get (GimpDialogFactory *factory,
GtkWidget * dialogs_tool_options_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_device_status_get (GimpDialogFactory *factory,
GtkWidget * dialogs_device_status_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_error_console_get (GimpDialogFactory *factory,
GtkWidget * dialogs_error_console_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_cursor_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
......@@ -167,6 +170,9 @@ GtkWidget * dialogs_selection_editor_new (GimpDialogFactory *factory,
GtkWidget * dialogs_undo_editor_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_sample_point_editor_new(GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_navigation_editor_new (GimpDialogFactory *factory,
GimpContext *context,
......
......@@ -122,15 +122,19 @@ static const GimpDialogFactoryEntry dock_entries[] =
DOCKABLE ("gimp-tool-options",
N_("Tool Options"), NULL, GIMP_STOCK_TOOL_OPTIONS,
GIMP_HELP_TOOL_OPTIONS_DIALOG,
dialogs_tool_options_get, 0, TRUE),
dialogs_tool_options_new, 0, TRUE),
DOCKABLE ("gimp-device-status",
N_("Devices"), N_("Device Status"), GIMP_STOCK_DEVICE_STATUS,
GIMP_HELP_DEVICE_STATUS_DIALOG,
dialogs_device_status_get, 0, TRUE),
dialogs_device_status_new, 0, TRUE),
DOCKABLE ("gimp-error-console",
N_("Errors"), N_("Error Console"), GIMP_STOCK_WARNING,
GIMP_HELP_ERRORS_DIALOG,
dialogs_error_console_get, 0, TRUE),
dialogs_error_console_new, 0, TRUE),
DOCKABLE ("gimp-cursor-view",
N_("Cursor"), N_("Cursor Info"), GIMP_STOCK_CURSOR,
GIMP_HELP_CURSOR_DIALOG,
dialogs_cursor_view_new, 0, TRUE),
/* list & grid views */
LISTGRID (image, N_("Images"), NULL, GIMP_STOCK_IMAGES,
......@@ -183,6 +187,10 @@ static const GimpDialogFactoryEntry dock_entries[] =
N_("Undo"), N_("Undo History"), GIMP_STOCK_UNDO_HISTORY,
GIMP_HELP_UNDO_DIALOG,
dialogs_undo_editor_new, 0, FALSE),
DOCKABLE ("gimp-sample-point-editor",
N_("Sample Points"), N_("Sample Points"), GIMP_STOCK_SAMPLE_POINT,
GIMP_HELP_SAMPLE_POINT_DIALOG,
dialogs_sample_point_editor_new, 0, FALSE),
/* display related */
DOCKABLE ("gimp-navigation-view",
......
......@@ -34,6 +34,9 @@
#include "dialogs/info-window.h"
#include "widgets/gimpcursor.h"
#include "widgets/gimpcursorview.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpsessioninfo.h"
#include "gimpdisplay.h"
#include "gimpdisplayshell.h"
......@@ -117,6 +120,10 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
gint t_x = -1;
gint t_y = -1;
GimpDialogFactory *factory;
GimpSessionInfo *session_info;
GtkWidget *cursor_view = NULL;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
gimage = shell->gdisp->gimage;
......@@ -155,6 +162,12 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
gimp_display_shell_untransform_xy (shell, display_x, display_y,
&t_x, &t_y, FALSE, FALSE);
factory = gimp_dialog_factory_from_name ("dock");
session_info = gimp_dialog_factory_find_session_info (factory,
"gimp-cursor-view");
if (session_info && session_info->widget)
cursor_view = gtk_bin_get_child (GTK_BIN (session_info->widget));
if (t_x < 0 ||
t_y < 0 ||
t_x >= gimage->width ||
......@@ -166,16 +179,35 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
{
info_window_update_cursor (shell->gdisp, t_x, t_y);
}
if (cursor_view)
gimp_cursor_view_update_cursor (GIMP_CURSOR_VIEW (cursor_view),
shell->gdisp->gimage, shell->unit,
t_x, t_y);
}
void
gimp_display_shell_clear_cursor (GimpDisplayShell *shell)
{
GimpDialogFactory *factory;
GimpSessionInfo *session_info;
GtkWidget *cursor_view = NULL;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
gimp_statusbar_clear_cursor (GIMP_STATUSBAR (shell->statusbar));
info_window_update_cursor (shell->gdisp, -1, -1);
factory = gimp_dialog_factory_from_name ("dock");
session_info = gimp_dialog_factory_find_session_info (factory,
"gimp-cursor-view");
if (session_info && session_info->widget)
cursor_view = gtk_bin_get_child (GTK_BIN (session_info->widget));
if (cursor_view)
gimp_cursor_view_update_cursor (GIMP_CURSOR_VIEW (cursor_view),
NULL, GIMP_UNIT_PIXEL, 0, 0);
}
static void
......
......@@ -92,6 +92,8 @@ libappwidgets_a_sources = \
gimpcontrollerwheel.h \
gimpcursor.c \
gimpcursor.h \
gimpcursorview.c \
gimpcursorview.h \
gimpdasheditor.c \
gimpdasheditor.h \
gimpdataeditor.c \
......@@ -193,6 +195,8 @@ libappwidgets_a_sources = \
gimpprogressdialog.h \
gimppropwidgets.c \
gimppropwidgets.h \
gimpsamplepointeditor.c \
gimpsamplepointeditor.h \
gimpselectiondata.c \
gimpselectiondata.h \
gimpselectioneditor.c \
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcursorview.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 <string.h>
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimppickable.h"
#include "core/gimpunit.h"
#include "gimpcolorframe.h"
#include "gimpcursorview.h"
#include "gimpdocked.h"
#include "gimpsessioninfo.h"
#include "gimp-intl.h"
static void gimp_cursor_view_class_init (GimpCursorViewClass *klass);
static void gimp_cursor_view_init (GimpCursorView *view);
static void gimp_cursor_view_docked_iface_init (GimpDockedInterface *docked_iface);
static void gimp_cursor_view_destroy (GtkObject *object);
static void gimp_cursor_view_style_set (GtkWidget *widget,
GtkStyle *prev_style);
static void gimp_cursor_view_set_aux_info (GimpDocked *docked,
GList *aux_info);
static GList *gimp_cursor_view_get_aux_info (GimpDocked *docked);
static void gimp_cursor_view_set_context (GimpDocked *docked,
GimpContext *context);
static void gimp_cursor_view_destroy (GtkObject *object);
#if 0
static void gimp_cursor_view_fg_changed (GimpContext *context,
const GimpRGB *rgb,
GimpCursorView *view);
static void gimp_cursor_view_bg_changed (GimpContext *context,
const GimpRGB *rgb,
GimpCursorView *view);
#endif
static GimpEditorClass *parent_class = NULL;
GType
gimp_cursor_view_get_type (void)
{
static GType type = 0;
if (! type)
{
static const GTypeInfo view_info =
{
sizeof (GimpCursorViewClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_cursor_view_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpCursorView),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_cursor_view_init,
};
static const GInterfaceInfo docked_iface_info =
{
(GInterfaceInitFunc) gimp_cursor_view_docked_iface_init,
NULL, /* iface_finalize */
NULL /* iface_data */
};
type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpCursorView",
&view_info, 0);
g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
&docked_iface_info);
}
return type;
}
static void
gimp_cursor_view_class_init (GimpCursorViewClass* klass)
{
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->destroy = gimp_cursor_view_destroy;
widget_class->style_set = gimp_cursor_view_style_set;
}
static void
gimp_cursor_view_init (GimpCursorView *view)
{
GtkWidget *hbox;
GtkWidget *frame;
GtkWidget *table;
gint content_spacing;
gint button_spacing;
GtkIconSize button_icon_size;
gtk_widget_style_get (GTK_WIDGET (view),
"content_spacing", &content_spacing,
"button_spacing", &button_spacing,
"button_icon_size", &button_icon_size,
NULL);
/* cursor information */
hbox = gtk_hbox_new (TRUE, content_spacing);
gtk_box_pack_start (GTK_BOX (view), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
frame = gimp_frame_new (_("Pixels"));
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
gtk_widget_show (frame);
table = gtk_table_new (2, 2, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
view->pixel_x_label = gtk_label_new (_("n/a"));
gtk_misc_set_alignment (GTK_MISC (view->pixel_x_label), 1.0, 0.5);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("X"), 0.5, 0.5,
view->pixel_x_label, 1, FALSE);
view->pixel_y_label = gtk_label_new (_("n/a"));
gtk_misc_set_alignment (GTK_MISC (view->pixel_y_label), 1.0, 0.5);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("Y"), 0.5, 0.5,
view->pixel_y_label, 1, FALSE);
frame = gimp_frame_new (_("Units"));
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
gtk_widget_show (frame);
table = gtk_table_new (2, 2, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
view->unit_x_label = gtk_label_new (_("n/a"));
gtk_misc_set_alignment (GTK_MISC (view->unit_x_label), 1.0, 0.5);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("X"), 0.5, 0.5,
view->unit_x_label, 1, FALSE);
view->unit_y_label = gtk_label_new (_("n/a"));
gtk_misc_set_alignment (GTK_MISC (view->unit_y_label), 1.0, 0.5);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("Y"), 0.5, 0.5,
view->unit_y_label, 1, FALSE);
/* color information */
hbox = gtk_hbox_new (TRUE, 6);
gtk_box_pack_start (GTK_BOX (view), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
view->color_frame_1 = gimp_color_frame_new ();
gimp_color_frame_set_mode (GIMP_COLOR_FRAME (view->color_frame_1),
GIMP_COLOR_FRAME_MODE_PIXEL);
gtk_box_pack_start (GTK_BOX (hbox), view->color_frame_1, TRUE, TRUE, 0);
gtk_widget_show (view->color_frame_1);
view->color_frame_2 = gimp_color_frame_new ();
gimp_color_frame_set_mode (GIMP_COLOR_FRAME (view->color_frame_2),
GIMP_COLOR_FRAME_MODE_RGB);
gtk_box_pack_start (GTK_BOX (hbox), view->color_frame_2, TRUE, TRUE, 0);
gtk_widget_show (view->color_frame_2);
}
static void
gimp_cursor_view_docked_iface_init (GimpDockedInterface *docked_iface)
{
docked_iface->set_aux_info = gimp_cursor_view_set_aux_info;
docked_iface->get_aux_info = gimp_cursor_view_get_aux_info;
docked_iface->set_context = gimp_cursor_view_set_context;
}
#define AUX_INFO_CURRENT_PAGE "current-page"
static void
gimp_cursor_view_set_aux_info (GimpDocked *docked,
GList *aux_info)
{
GimpCursorView *view = GIMP_CURSOR_VIEW (docked);
GList *list;
for (list = aux_info; list; list = g_list_next (list))
{
GimpSessionInfoAux *aux = list->data;
if (! strcmp (