Commit f0e8517e authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

removed "grid_changed" signal. The user of GimpGridEditor can connect to

2003-10-14  Sven Neumann  <sven@gimp.org>

	* app/widgets/gimpgrideditor.[ch]: removed "grid_changed" signal.
	The user of GimpGridEditor can connect to notifications of the
	grid that is being edited. There is no need for a proxy signal.

	* app/core/gimpimage-grid.c (gimp_image_set_grid): don't exchange
	the image's grid object, it is part of the image. Copy all grid
	properties instead.

	* app/core/gimpimage-undo-push.c
	* app/gui/grid-dialog.c: changed accordingly.
parent 93f2394f
2003-10-14 Sven Neumann <sven@gimp.org>
* app/widgets/gimpgrideditor.[ch]: removed "grid_changed" signal.
The user of GimpGridEditor can connect to notifications of the
grid that is being edited. There is no need for a proxy signal.
* app/core/gimpimage-grid.c (gimp_image_set_grid): don't exchange
the image's grid object, it is part of the image. Copy all grid
properties instead.
* app/core/gimpimage-undo-push.c
* app/gui/grid-dialog.c: changed accordingly.
2003-10-14 Michael Natterer <mitch@gimp.org>
Refactored modifier handling of displays and tools. Hopefully
......@@ -25,6 +25,9 @@
#include "core-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-utils.h"
#include "gimpgrid.h"
#include "gimpimage.h"
#include "gimpimage-grid.h"
......@@ -48,21 +51,15 @@ gimp_image_set_grid (GimpImage *gimage,
gboolean push_undo)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (grid == NULL || GIMP_IS_GRID (grid));
if (grid != gimage->grid)
{
if (push_undo)
gimp_image_undo_push_image_grid (gimage, _("Grid"), gimage->grid);
g_return_if_fail (GIMP_IS_GRID (grid));
if (gimage->grid)
g_object_unref (gimage->grid);
if (gimp_config_is_equal_to (GIMP_CONFIG (gimage->grid), GIMP_CONFIG (grid)))
return;
gimage->grid = grid;
if (push_undo)
gimp_image_undo_push_image_grid (gimage, _("Grid"), gimage->grid);
if (gimage->grid)
g_object_ref (gimage->grid);
}
gimp_config_copy_properties (GIMP_CONFIG (grid), GIMP_CONFIG (gimage->grid));
gimp_image_grid_changed (gimage);
}
......@@ -27,6 +27,8 @@
#include "core-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-utils.h"
#include "config/gimpcoreconfig.h"
#include "base/pixel-region.h"
......@@ -609,11 +611,9 @@ undo_pop_image_qmask (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum)
{
QmaskUndo *qu;
QmaskUndo *qu = undo->data;
gboolean tmp;
qu = (QmaskUndo *) undo->data;
tmp = undo->gimage->qmask_state;
undo->gimage->qmask_state = qu->qmask_state;
qu->qmask_state = tmp;
......@@ -656,7 +656,7 @@ gimp_image_undo_push_image_grid (GimpImage *gimage,
GimpUndo *new;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (grid == NULL || GIMP_IS_GRID (grid), FALSE);
g_return_val_if_fail (GIMP_IS_GRID (grid), FALSE);
if ((new = gimp_image_undo_push (gimage,
sizeof (GridUndo),
......@@ -666,12 +666,9 @@ gimp_image_undo_push_image_grid (GimpImage *gimage,
undo_pop_image_grid,
undo_free_image_grid)))
{
GridUndo *gu;
gu = new->data;
GridUndo *gu = new->data;
if (grid)
gu->grid = g_object_ref (grid);
gu->grid = GIMP_GRID (gimp_config_duplicate (GIMP_CONFIG (grid)));
return TRUE;
}
......@@ -684,22 +681,15 @@ undo_pop_image_grid (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum)
{
GridUndo *gu;
GimpGrid *tmp;
gu = (GridUndo *) undo->data;
tmp = gimp_image_get_grid (undo->gimage);
GridUndo *gu = undo->data;
GimpGrid *grid;
if (tmp)
g_object_ref (tmp);
grid = GIMP_GRID (gimp_config_duplicate (GIMP_CONFIG (undo->gimage->grid)));
gimp_image_set_grid (undo->gimage, gu->grid, FALSE);
if (gu->grid)
g_object_unref (gu->grid);
gu->grid = tmp;
g_object_unref (gu->grid);
gu->grid = grid;
return TRUE;
}
......@@ -708,9 +698,7 @@ static void
undo_free_image_grid (GimpUndo *undo,
GimpUndoMode undo_mode)
{
GridUndo *gu;
gu = (GridUndo *) undo->data;
GridUndo *gu = undo->data;
if (gu->grid)
g_object_unref (gu->grid);
......@@ -775,12 +763,10 @@ undo_pop_image_guide (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum)
{
GuideUndo *gu;
GuideUndo *gu = undo->data;
gint old_position;
GimpOrientationType old_orientation;
gu = (GuideUndo *) undo->data;
old_position = gu->guide->position;
old_orientation = gu->guide->orientation;
......@@ -814,9 +800,7 @@ static void
undo_free_image_guide (GimpUndo *undo,
GimpUndoMode undo_mode)
{
GuideUndo *gu;
gu = (GuideUndo *) undo->data;
GuideUndo *gu = undo->data;
gimp_image_guide_unref (gu->guide);
g_free (gu);
......
......@@ -31,6 +31,7 @@
#include "config/gimpconfig.h"
#include "config/gimpconfig-types.h"
#include "config/gimpconfig-utils.h"
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "core/gimpimage.h"
......@@ -54,14 +55,15 @@
/* local functions */
static void grid_changed_cb (GtkWidget *widget,
gpointer data);
static void reset_callback (GtkWidget *widget,
GtkWidget *dialog);
static void cancel_callback (GtkWidget *widget,
GtkWidget *dialog);
static void ok_callback (GtkWidget *widget,
GtkWidget *dialog);
static void grid_notify_callback (GtkWidget *widget,
GParamSpec *pspec,
gpointer data);
static void reset_callback (GtkWidget *widget,
GtkWidget *dialog);
static void cancel_callback (GtkWidget *widget,
GtkWidget *dialog);
static void ok_callback (GtkWidget *widget,
GtkWidget *dialog);
/* public function */
......@@ -78,10 +80,7 @@ grid_dialog_new (GimpImage *gimage)
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
grid = gimp_image_get_grid (GIMP_IMAGE (gimage));
grid_backup = g_object_new (GIMP_TYPE_GRID, NULL);
gimp_config_copy_properties (GIMP_CONFIG (grid),
GIMP_CONFIG (grid_backup));
grid_backup = gimp_config_duplicate (GIMP_CONFIG (grid));
/* dialog */
dialog = gimp_viewable_dialog_new (GIMP_VIEWABLE (gimage),
......@@ -108,8 +107,8 @@ grid_dialog_new (GimpImage *gimage)
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
editor);
g_signal_connect (editor, "grid_changed",
G_CALLBACK (grid_changed_cb),
g_signal_connect (grid, "notify",
G_CALLBACK (grid_notify_callback),
gimage);
gtk_widget_show (editor);
......@@ -128,11 +127,10 @@ grid_dialog_new (GimpImage *gimage)
static void
grid_changed_cb (GtkWidget *widget,
gpointer data)
grid_notify_callback (GtkWidget *widget,
GParamSpec *pspec,
gpointer data)
{
g_return_if_fail (GIMP_IS_IMAGE (data));
gimp_image_grid_changed (GIMP_IMAGE (data));
}
......@@ -142,13 +140,11 @@ reset_callback (GtkWidget *widget,
{
GimpImage *gimage;
GimpImage *grid;
GimpGrid *grid_backup;
gimage = g_object_get_data (G_OBJECT (dialog), "gimage");
grid = g_object_get_data (G_OBJECT (dialog), "grid");
grid_backup = g_object_get_data (G_OBJECT (dialog), "grid-backup");
gimage = g_object_get_data (G_OBJECT (dialog), "gimage");
grid = g_object_get_data (G_OBJECT (dialog), "grid");
gimp_config_copy_properties (GIMP_CONFIG (grid_backup),
gimp_config_copy_properties (GIMP_CONFIG (gimage->gimp->config->default_grid),
GIMP_CONFIG (grid));
gimp_image_grid_changed (GIMP_IMAGE (gimage));
}
......@@ -182,7 +178,9 @@ ok_callback (GtkWidget *widget,
if (! gimp_config_is_equal_to (GIMP_CONFIG (grid_backup),
GIMP_CONFIG (grid)))
gimp_image_undo_push_image_grid (gimage, _("Grid"), grid_backup);
{
gimp_image_undo_push_image_grid (gimage, _("Grid"), grid_backup);
}
gtk_widget_destroy (dialog);
}
......@@ -31,6 +31,7 @@
#include "config/gimpconfig.h"
#include "config/gimpconfig-types.h"
#include "config/gimpconfig-utils.h"
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "core/gimpimage.h"
......@@ -54,14 +55,15 @@
/* local functions */
static void grid_changed_cb (GtkWidget *widget,
gpointer data);
static void reset_callback (GtkWidget *widget,
GtkWidget *dialog);
static void cancel_callback (GtkWidget *widget,
GtkWidget *dialog);
static void ok_callback (GtkWidget *widget,
GtkWidget *dialog);
static void grid_notify_callback (GtkWidget *widget,
GParamSpec *pspec,
gpointer data);
static void reset_callback (GtkWidget *widget,
GtkWidget *dialog);
static void cancel_callback (GtkWidget *widget,
GtkWidget *dialog);
static void ok_callback (GtkWidget *widget,
GtkWidget *dialog);
/* public function */
......@@ -78,10 +80,7 @@ grid_dialog_new (GimpImage *gimage)
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
grid = gimp_image_get_grid (GIMP_IMAGE (gimage));
grid_backup = g_object_new (GIMP_TYPE_GRID, NULL);
gimp_config_copy_properties (GIMP_CONFIG (grid),
GIMP_CONFIG (grid_backup));
grid_backup = gimp_config_duplicate (GIMP_CONFIG (grid));
/* dialog */
dialog = gimp_viewable_dialog_new (GIMP_VIEWABLE (gimage),
......@@ -108,8 +107,8 @@ grid_dialog_new (GimpImage *gimage)
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
editor);
g_signal_connect (editor, "grid_changed",
G_CALLBACK (grid_changed_cb),
g_signal_connect (grid, "notify",
G_CALLBACK (grid_notify_callback),
gimage);
gtk_widget_show (editor);
......@@ -128,11 +127,10 @@ grid_dialog_new (GimpImage *gimage)
static void
grid_changed_cb (GtkWidget *widget,
gpointer data)
grid_notify_callback (GtkWidget *widget,
GParamSpec *pspec,
gpointer data)
{
g_return_if_fail (GIMP_IS_IMAGE (data));
gimp_image_grid_changed (GIMP_IMAGE (data));
}
......@@ -142,13 +140,11 @@ reset_callback (GtkWidget *widget,
{
GimpImage *gimage;
GimpImage *grid;
GimpGrid *grid_backup;
gimage = g_object_get_data (G_OBJECT (dialog), "gimage");
grid = g_object_get_data (G_OBJECT (dialog), "grid");
grid_backup = g_object_get_data (G_OBJECT (dialog), "grid-backup");
gimage = g_object_get_data (G_OBJECT (dialog), "gimage");
grid = g_object_get_data (G_OBJECT (dialog), "grid");
gimp_config_copy_properties (GIMP_CONFIG (grid_backup),
gimp_config_copy_properties (GIMP_CONFIG (gimage->gimp->config->default_grid),
GIMP_CONFIG (grid));
gimp_image_grid_changed (GIMP_IMAGE (gimage));
}
......@@ -182,7 +178,9 @@ ok_callback (GtkWidget *widget,
if (! gimp_config_is_equal_to (GIMP_CONFIG (grid_backup),
GIMP_CONFIG (grid)))
gimp_image_undo_push_image_grid (gimage, _("Grid"), grid_backup);
{
gimp_image_undo_push_image_grid (gimage, _("Grid"), grid_backup);
}
gtk_widget_destroy (dialog);
}
......@@ -48,12 +48,6 @@ enum
PROP_YRESOLUTION
};
enum
{
GRID_CHANGED,
LAST_SIGNAL
};
static void gimp_grid_editor_class_init (GimpGridEditorClass *klass);
static GObject * gimp_grid_editor_constructor (GType type,
......@@ -68,12 +62,9 @@ static void gimp_grid_editor_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static void gimp_grid_editor_finalize (GObject *object);
static void gimp_grid_editor_grid_changed (GtkWidget *widget,
gpointer data);
static GtkVBoxClass *parent_class = NULL;
static guint grid_editor_signals[LAST_SIGNAL] = { 0 };
GType
......@@ -135,17 +126,6 @@ gimp_grid_editor_class_init (GimpGridEditorClass *klass)
GRID_EDITOR_DEFAULT_RESOLUTION,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
grid_editor_signals[GRID_CHANGED] =
g_signal_new ("grid_changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpGridEditorClass, grid_changed),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
klass->grid_changed = NULL;
}
static void
......@@ -231,9 +211,6 @@ gimp_grid_editor_constructor (GType type,
style = gimp_prop_enum_option_menu_new (G_OBJECT (editor->grid), "style",
GIMP_GRID_DOTS,
GIMP_GRID_SOLID);
g_signal_connect (style, "changed",
G_CALLBACK (gimp_grid_editor_grid_changed),
editor);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("Line _Style:"), 1.0, 0.5,
style, 1, TRUE);
......@@ -243,9 +220,6 @@ gimp_grid_editor_constructor (GType type,
GRID_EDITOR_COLOR_BUTTON_SIZE,
GRID_EDITOR_COLOR_BUTTON_SIZE,
GIMP_COLOR_AREA_FLAT);
g_signal_connect (color_button, "color-changed",
G_CALLBACK (gimp_grid_editor_grid_changed),
editor);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("_Foreground Color:"), 1.0, 0.5,
color_button, 1, TRUE);
......@@ -255,9 +229,6 @@ gimp_grid_editor_constructor (GType type,
GRID_EDITOR_COLOR_BUTTON_SIZE,
GRID_EDITOR_COLOR_BUTTON_SIZE,
GIMP_COLOR_AREA_FLAT);
g_signal_connect (color_button, "color-changed",
G_CALLBACK (gimp_grid_editor_grid_changed),
editor);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
_("_Background Color:"), 1.0, 0.5,
color_button, 1, TRUE);
......@@ -297,16 +268,6 @@ gimp_grid_editor_constructor (GType type,
gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry),
_("Pixels"), 1, 4, 0.0);
g_signal_connect (sizeentry, "refval-changed",
G_CALLBACK (gimp_grid_editor_grid_changed),
editor);
g_signal_connect (sizeentry, "unit-changed",
G_CALLBACK (gimp_grid_editor_grid_changed),
editor);
g_signal_connect (sizeentry, "value-changed",
G_CALLBACK (gimp_grid_editor_grid_changed),
editor);
gtk_box_pack_start (GTK_BOX (hbox), sizeentry, FALSE, FALSE, 0);
gtk_widget_show (sizeentry);
......@@ -353,16 +314,6 @@ gimp_grid_editor_constructor (GType type,
gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry),
_("Pixels"), 1, 4, 0.0);
g_signal_connect (sizeentry, "refval-changed",
G_CALLBACK (gimp_grid_editor_grid_changed),
editor);
g_signal_connect (sizeentry, "unit-changed",
G_CALLBACK (gimp_grid_editor_grid_changed),
editor);
g_signal_connect (sizeentry, "value-changed",
G_CALLBACK (gimp_grid_editor_grid_changed),
editor);
gtk_box_pack_start (GTK_BOX (hbox), sizeentry, FALSE, FALSE, 0);
gtk_widget_show (sizeentry);
......@@ -393,21 +344,8 @@ gimp_grid_editor_new (GimpGrid *grid,
g_return_val_if_fail (GIMP_IS_GRID (grid), NULL);
return GTK_WIDGET (g_object_new (GIMP_TYPE_GRID_EDITOR,
"grid", grid,
"grid", grid,
"xresolution", xresolution,
"yresolution", yresolution,
NULL));
}
static void
gimp_grid_editor_grid_changed (GtkWidget *widget,
gpointer data)
{
GimpGridEditor *editor;
g_return_if_fail (GIMP_IS_GRID_EDITOR (data));
editor = GIMP_GRID_EDITOR (data);
g_signal_emit (editor, grid_editor_signals[GRID_CHANGED], 0);
}
......@@ -48,8 +48,6 @@ struct _GimpGridEditor
struct _GimpGridEditorClass
{
GtkVBoxClass parent_class;
void (* grid_changed) (GimpGridEditor *editor);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment