mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 09:23:24 +00:00
libgimp: further cleanup in GimpGradientChooser code.
- No need of local_grad_data_new(). Just set default variables in init() as it should be. - Also move gimp_gradient_chooser_draw_interior() to the init() function, so that the new() function is only a wrapper of g_object_new() which is the proper way to implement new classes. - Get rid of wrong comment.
This commit is contained in:
parent
2d7a1a5d6d
commit
15d2e25404
1 changed files with 7 additions and 19 deletions
|
@ -76,7 +76,6 @@ static gboolean gimp_gradient_select_model_change_handler (GimpGradientChooser
|
|||
GimpResource *resource,
|
||||
gboolean is_closing);
|
||||
|
||||
static void local_grad_data_new (GimpGradientChooser *self);
|
||||
static void local_grad_data_free (GimpGradientChooser *self);
|
||||
static gboolean local_grad_data_exists (GimpGradientChooser *self);
|
||||
static gboolean local_grad_data_refresh (GimpGradientChooser *self,
|
||||
|
@ -115,6 +114,10 @@ gimp_gradient_chooser_init (GimpGradientChooser *self)
|
|||
button = gtk_button_new ();
|
||||
gtk_container_add (GTK_CONTAINER (self), button);
|
||||
|
||||
self->local_grad_data.data = NULL;
|
||||
self->local_grad_data.n_samples = 0;
|
||||
self->local_grad_data.allocation_width = 0;
|
||||
|
||||
self->preview = gtk_drawing_area_new ();
|
||||
gtk_widget_set_size_request (self->preview, CELL_WIDTH, CELL_HEIGHT);
|
||||
gtk_container_add (GTK_CONTAINER (button), self->preview);
|
||||
|
@ -133,6 +136,8 @@ gimp_gradient_chooser_init (GimpGradientChooser *self)
|
|||
self->preview, &drag_target);
|
||||
|
||||
_gimp_resource_chooser_set_clickable (GIMP_RESOURCE_CHOOSER (self), button);
|
||||
|
||||
gimp_gradient_chooser_draw_interior (GIMP_RESOURCE_CHOOSER (self));
|
||||
}
|
||||
|
||||
/* Called when dialog is closed and owning ResourceSelect button is disposed. */
|
||||
|
@ -193,10 +198,6 @@ gimp_gradient_chooser_new (const gchar *title,
|
|||
"resource", gradient,
|
||||
NULL);
|
||||
|
||||
local_grad_data_new (GIMP_GRADIENT_CHOOSER (self));
|
||||
|
||||
gimp_gradient_chooser_draw_interior (GIMP_RESOURCE_CHOOSER (self));
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -390,23 +391,10 @@ local_grad_data_exists (GimpGradientChooser *self)
|
|||
return self->local_grad_data.data != NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
local_grad_data_new (GimpGradientChooser *self)
|
||||
{
|
||||
self->local_grad_data.data = NULL;
|
||||
self->local_grad_data.n_samples = 0;
|
||||
self->local_grad_data.allocation_width = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
local_grad_data_free (GimpGradientChooser *self)
|
||||
{
|
||||
/* More robust when set to NULL.
|
||||
* g_free(NULL) is safe but g_free twice is not.
|
||||
*/
|
||||
g_free (self->local_grad_data.data);
|
||||
self->local_grad_data.data = NULL;
|
||||
|
||||
g_clear_pointer (&self->local_grad_data.data, g_free);
|
||||
self->local_grad_data.n_samples = 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue