mirror of https://github.com/GNOME/gimp.git
app/core/gimpimage-undo-push.c (undo_pop_image_grid) ref/unref the grid.
2003-06-24 Michael Natterer <mitch@gimp.org> * app/core/gimpimage-undo-push.c (undo_pop_image_grid) * app/core/gimpimage.c (gimp_image_set_grid): ref/unref the grid. * app/gui/view-commands.c (view_configure_grid_cmd_callback): set the dialog transient for the shell, make shell->grid_dialog a weak pointer of the grid dialog. * app/gui/grid-dialog.c: don't set shell->grid_dialog to NULL here, attach the grid using g_object_set_data_full() and don't unref it explicitely. Use gimp_config_is_equal_to() instead of gimp_config_diff().
This commit is contained in:
parent
bd9231c940
commit
a1c1fe4c70
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
2003-06-24 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
|
* app/core/gimpimage-undo-push.c (undo_pop_image_grid)
|
||||||
|
* app/core/gimpimage.c (gimp_image_set_grid): ref/unref the grid.
|
||||||
|
|
||||||
|
* app/gui/view-commands.c (view_configure_grid_cmd_callback): set
|
||||||
|
the dialog transient for the shell, make shell->grid_dialog a
|
||||||
|
weak pointer of the grid dialog.
|
||||||
|
|
||||||
|
* app/gui/grid-dialog.c: don't set shell->grid_dialog to NULL
|
||||||
|
here, attach the grid using g_object_set_data_full() and don't
|
||||||
|
unref it explicitely. Use gimp_config_is_equal_to() instead of
|
||||||
|
gimp_config_diff().
|
||||||
|
|
||||||
2003-06-24 Sven Neumann <sven@gimp.org>
|
2003-06-24 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* plug-ins/common/grid.c (dialog): update the preview when the
|
* plug-ins/common/grid.c (dialog): update the preview when the
|
||||||
|
|
|
@ -364,11 +364,14 @@ view_configure_grid_cmd_callback (GtkWidget *widget,
|
||||||
if (! shell->grid_dialog)
|
if (! shell->grid_dialog)
|
||||||
{
|
{
|
||||||
shell->grid_dialog = grid_dialog_new (GIMP_DISPLAY (gdisp));
|
shell->grid_dialog = grid_dialog_new (GIMP_DISPLAY (gdisp));
|
||||||
|
|
||||||
g_signal_connect_object (gdisp, "disconnect",
|
gtk_window_set_transient_for (GTK_WINDOW (shell->grid_dialog),
|
||||||
G_CALLBACK (gtk_widget_destroy),
|
GTK_WINDOW (shell));
|
||||||
shell->grid_dialog,
|
gtk_window_set_destroy_with_parent (GTK_WINDOW (shell->grid_dialog),
|
||||||
G_CONNECT_SWAPPED);
|
TRUE);
|
||||||
|
|
||||||
|
g_object_add_weak_pointer (G_OBJECT (shell->grid_dialog),
|
||||||
|
(gpointer *) &shell->grid_dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_window_present (GTK_WINDOW (shell->grid_dialog));
|
gtk_window_present (GTK_WINDOW (shell->grid_dialog));
|
||||||
|
|
|
@ -669,8 +669,6 @@ gimp_image_undo_push_image_grid (GimpImage *gimage,
|
||||||
|
|
||||||
if (grid)
|
if (grid)
|
||||||
gu->grid = g_object_ref (grid);
|
gu->grid = g_object_ref (grid);
|
||||||
else
|
|
||||||
gu->grid = NULL;
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -689,7 +687,15 @@ undo_pop_image_grid (GimpUndo *undo,
|
||||||
gu = (GridUndo *) undo->data;
|
gu = (GridUndo *) undo->data;
|
||||||
|
|
||||||
tmp = gimp_image_get_grid (undo->gimage);
|
tmp = gimp_image_get_grid (undo->gimage);
|
||||||
|
|
||||||
|
if (tmp)
|
||||||
|
g_object_ref (tmp);
|
||||||
|
|
||||||
gimp_image_set_grid (undo->gimage, gu->grid, FALSE);
|
gimp_image_set_grid (undo->gimage, gu->grid, FALSE);
|
||||||
|
|
||||||
|
if (gu->grid)
|
||||||
|
g_object_unref (gu->grid);
|
||||||
|
|
||||||
gu->grid = tmp;
|
gu->grid = tmp;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -3271,9 +3271,19 @@ gimp_image_set_grid (GimpImage *gimage,
|
||||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||||
g_return_if_fail (grid == NULL || GIMP_IS_GRID (grid));
|
g_return_if_fail (grid == NULL || GIMP_IS_GRID (grid));
|
||||||
|
|
||||||
if (push_undo)
|
if (grid != gimage->grid)
|
||||||
gimp_image_undo_push_image_grid (gimage, _("Grid"), gimage->grid);
|
{
|
||||||
|
if (push_undo)
|
||||||
|
gimp_image_undo_push_image_grid (gimage, _("Grid"), gimage->grid);
|
||||||
|
|
||||||
|
if (gimage->grid)
|
||||||
|
g_object_unref (gimage->grid);
|
||||||
|
|
||||||
|
gimage->grid = grid;
|
||||||
|
|
||||||
|
if (gimage->grid)
|
||||||
|
g_object_ref (gimage->grid);
|
||||||
|
}
|
||||||
|
|
||||||
gimage->grid = grid;
|
|
||||||
gimp_image_grid_changed (gimage);
|
gimp_image_grid_changed (gimage);
|
||||||
}
|
}
|
||||||
|
|
|
@ -283,7 +283,8 @@ grid_dialog_new (GimpDisplay *gdisp)
|
||||||
g_object_set_data (G_OBJECT (dialog), "gimage", gimage);
|
g_object_set_data (G_OBJECT (dialog), "gimage", gimage);
|
||||||
g_object_set_data (G_OBJECT (dialog), "shell", shell);
|
g_object_set_data (G_OBJECT (dialog), "shell", shell);
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (dialog), "grid", grid);
|
g_object_set_data_full (G_OBJECT (dialog), "grid", grid,
|
||||||
|
(GDestroyNotify) g_object_unref);
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (dialog), "show-button", show_button);
|
g_object_set_data (G_OBJECT (dialog), "show-button", show_button);
|
||||||
g_object_set_data (G_OBJECT (dialog), "snap-button", snap_button);
|
g_object_set_data (G_OBJECT (dialog), "snap-button", snap_button);
|
||||||
|
@ -353,16 +354,13 @@ remove_callback (GtkWidget *widget,
|
||||||
{
|
{
|
||||||
GimpImage *gimage;
|
GimpImage *gimage;
|
||||||
GimpDisplayShell *shell;
|
GimpDisplayShell *shell;
|
||||||
GimpGrid *grid;
|
|
||||||
|
|
||||||
gimage = g_object_get_data (G_OBJECT (dialog), "gimage");
|
gimage = g_object_get_data (G_OBJECT (dialog), "gimage");
|
||||||
shell = g_object_get_data (G_OBJECT (dialog), "shell");
|
shell = g_object_get_data (G_OBJECT (dialog), "shell");
|
||||||
grid = g_object_get_data (G_OBJECT (dialog), "grid");
|
|
||||||
|
|
||||||
gimp_image_set_grid (gimage, NULL, TRUE);
|
gimp_image_set_grid (gimage, NULL, TRUE);
|
||||||
g_object_unref (G_OBJECT (grid));
|
|
||||||
gtk_widget_destroy (dialog);
|
gtk_widget_destroy (dialog);
|
||||||
shell->grid_dialog = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -371,14 +369,10 @@ cancel_callback (GtkWidget *widget,
|
||||||
GtkWidget *dialog)
|
GtkWidget *dialog)
|
||||||
{
|
{
|
||||||
GimpDisplayShell *shell;
|
GimpDisplayShell *shell;
|
||||||
GimpGrid *grid;
|
|
||||||
|
|
||||||
shell = g_object_get_data (G_OBJECT (dialog), "shell");
|
shell = g_object_get_data (G_OBJECT (dialog), "shell");
|
||||||
grid = g_object_get_data (G_OBJECT (dialog), "grid");
|
|
||||||
|
|
||||||
g_object_unref (G_OBJECT (grid));
|
|
||||||
gtk_widget_destroy (dialog);
|
gtk_widget_destroy (dialog);
|
||||||
shell->grid_dialog = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -402,10 +396,9 @@ ok_callback (GtkWidget *widget,
|
||||||
|
|
||||||
grid_orig = gimp_image_get_grid (GIMP_IMAGE (gimage));
|
grid_orig = gimp_image_get_grid (GIMP_IMAGE (gimage));
|
||||||
|
|
||||||
if (grid_orig == NULL || gimp_config_diff (G_OBJECT (grid_orig), G_OBJECT (grid), 0))
|
if (grid_orig == NULL || ! gimp_config_is_equal_to (G_OBJECT (grid_orig),
|
||||||
|
G_OBJECT (grid)))
|
||||||
gimp_image_set_grid (GIMP_IMAGE (gimage), grid, TRUE);
|
gimp_image_set_grid (GIMP_IMAGE (gimage), grid, TRUE);
|
||||||
else
|
|
||||||
g_object_unref (G_OBJECT (grid));
|
|
||||||
|
|
||||||
show_grid = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (show_button));
|
show_grid = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (show_button));
|
||||||
gimp_display_shell_set_show_grid (GIMP_DISPLAY_SHELL (shell), show_grid);
|
gimp_display_shell_set_show_grid (GIMP_DISPLAY_SHELL (shell), show_grid);
|
||||||
|
@ -414,5 +407,4 @@ ok_callback (GtkWidget *widget,
|
||||||
gimp_display_shell_set_snap_to_grid (GIMP_DISPLAY_SHELL (shell), snap_to_grid);
|
gimp_display_shell_set_snap_to_grid (GIMP_DISPLAY_SHELL (shell), snap_to_grid);
|
||||||
|
|
||||||
gtk_widget_destroy (dialog);
|
gtk_widget_destroy (dialog);
|
||||||
shell->grid_dialog = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -283,7 +283,8 @@ grid_dialog_new (GimpDisplay *gdisp)
|
||||||
g_object_set_data (G_OBJECT (dialog), "gimage", gimage);
|
g_object_set_data (G_OBJECT (dialog), "gimage", gimage);
|
||||||
g_object_set_data (G_OBJECT (dialog), "shell", shell);
|
g_object_set_data (G_OBJECT (dialog), "shell", shell);
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (dialog), "grid", grid);
|
g_object_set_data_full (G_OBJECT (dialog), "grid", grid,
|
||||||
|
(GDestroyNotify) g_object_unref);
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (dialog), "show-button", show_button);
|
g_object_set_data (G_OBJECT (dialog), "show-button", show_button);
|
||||||
g_object_set_data (G_OBJECT (dialog), "snap-button", snap_button);
|
g_object_set_data (G_OBJECT (dialog), "snap-button", snap_button);
|
||||||
|
@ -353,16 +354,13 @@ remove_callback (GtkWidget *widget,
|
||||||
{
|
{
|
||||||
GimpImage *gimage;
|
GimpImage *gimage;
|
||||||
GimpDisplayShell *shell;
|
GimpDisplayShell *shell;
|
||||||
GimpGrid *grid;
|
|
||||||
|
|
||||||
gimage = g_object_get_data (G_OBJECT (dialog), "gimage");
|
gimage = g_object_get_data (G_OBJECT (dialog), "gimage");
|
||||||
shell = g_object_get_data (G_OBJECT (dialog), "shell");
|
shell = g_object_get_data (G_OBJECT (dialog), "shell");
|
||||||
grid = g_object_get_data (G_OBJECT (dialog), "grid");
|
|
||||||
|
|
||||||
gimp_image_set_grid (gimage, NULL, TRUE);
|
gimp_image_set_grid (gimage, NULL, TRUE);
|
||||||
g_object_unref (G_OBJECT (grid));
|
|
||||||
gtk_widget_destroy (dialog);
|
gtk_widget_destroy (dialog);
|
||||||
shell->grid_dialog = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -371,14 +369,10 @@ cancel_callback (GtkWidget *widget,
|
||||||
GtkWidget *dialog)
|
GtkWidget *dialog)
|
||||||
{
|
{
|
||||||
GimpDisplayShell *shell;
|
GimpDisplayShell *shell;
|
||||||
GimpGrid *grid;
|
|
||||||
|
|
||||||
shell = g_object_get_data (G_OBJECT (dialog), "shell");
|
shell = g_object_get_data (G_OBJECT (dialog), "shell");
|
||||||
grid = g_object_get_data (G_OBJECT (dialog), "grid");
|
|
||||||
|
|
||||||
g_object_unref (G_OBJECT (grid));
|
|
||||||
gtk_widget_destroy (dialog);
|
gtk_widget_destroy (dialog);
|
||||||
shell->grid_dialog = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -402,10 +396,9 @@ ok_callback (GtkWidget *widget,
|
||||||
|
|
||||||
grid_orig = gimp_image_get_grid (GIMP_IMAGE (gimage));
|
grid_orig = gimp_image_get_grid (GIMP_IMAGE (gimage));
|
||||||
|
|
||||||
if (grid_orig == NULL || gimp_config_diff (G_OBJECT (grid_orig), G_OBJECT (grid), 0))
|
if (grid_orig == NULL || ! gimp_config_is_equal_to (G_OBJECT (grid_orig),
|
||||||
|
G_OBJECT (grid)))
|
||||||
gimp_image_set_grid (GIMP_IMAGE (gimage), grid, TRUE);
|
gimp_image_set_grid (GIMP_IMAGE (gimage), grid, TRUE);
|
||||||
else
|
|
||||||
g_object_unref (G_OBJECT (grid));
|
|
||||||
|
|
||||||
show_grid = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (show_button));
|
show_grid = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (show_button));
|
||||||
gimp_display_shell_set_show_grid (GIMP_DISPLAY_SHELL (shell), show_grid);
|
gimp_display_shell_set_show_grid (GIMP_DISPLAY_SHELL (shell), show_grid);
|
||||||
|
@ -414,5 +407,4 @@ ok_callback (GtkWidget *widget,
|
||||||
gimp_display_shell_set_snap_to_grid (GIMP_DISPLAY_SHELL (shell), snap_to_grid);
|
gimp_display_shell_set_snap_to_grid (GIMP_DISPLAY_SHELL (shell), snap_to_grid);
|
||||||
|
|
||||||
gtk_widget_destroy (dialog);
|
gtk_widget_destroy (dialog);
|
||||||
shell->grid_dialog = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -364,11 +364,14 @@ view_configure_grid_cmd_callback (GtkWidget *widget,
|
||||||
if (! shell->grid_dialog)
|
if (! shell->grid_dialog)
|
||||||
{
|
{
|
||||||
shell->grid_dialog = grid_dialog_new (GIMP_DISPLAY (gdisp));
|
shell->grid_dialog = grid_dialog_new (GIMP_DISPLAY (gdisp));
|
||||||
|
|
||||||
g_signal_connect_object (gdisp, "disconnect",
|
gtk_window_set_transient_for (GTK_WINDOW (shell->grid_dialog),
|
||||||
G_CALLBACK (gtk_widget_destroy),
|
GTK_WINDOW (shell));
|
||||||
shell->grid_dialog,
|
gtk_window_set_destroy_with_parent (GTK_WINDOW (shell->grid_dialog),
|
||||||
G_CONNECT_SWAPPED);
|
TRUE);
|
||||||
|
|
||||||
|
g_object_add_weak_pointer (G_OBJECT (shell->grid_dialog),
|
||||||
|
(gpointer *) &shell->grid_dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_window_present (GTK_WINDOW (shell->grid_dialog));
|
gtk_window_present (GTK_WINDOW (shell->grid_dialog));
|
||||||
|
|
Loading…
Reference in New Issue