Commit 16f34d21 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

app/actions/image-commands.c allocate structs using GSlice.

2007-05-23  Sven Neumann  <sven@gimp.org>

	* app/actions/image-commands.c
	* app/actions/templates-commands.c: allocate structs using GSlice.


svn path=/trunk/; revision=22592
parent 9ab35b10
2007-05-23 Sven Neumann <sven@gimp.org>
* app/actions/image-commands.c
* app/actions/templates-commands.c: allocate structs using GSlice.
2007-05-23 Tor Lillqvist <tml@novell.com>
 
* plug-ins/common/tiff-save.c (save_paths): Use memset() instead
......@@ -65,13 +65,11 @@
#include "gimp-intl.h"
typedef struct _ImageResizeOptions ImageResizeOptions;
struct _ImageResizeOptions
typedef struct
{
GimpContext *context;
GimpDisplay *display;
};
GimpContext *context;
GimpDisplay *display;
} ImageResizeOptions;
/* local function prototypes */
......@@ -85,12 +83,15 @@ static void image_resize_callback (GtkWidget *dialog,
gint offset_y,
GimpItemSet layer_set,
gpointer data);
static void image_resize_options_free (ImageResizeOptions *options);
static void image_print_size_callback (GtkWidget *dialog,
GimpImage *image,
gdouble xresolution,
gdouble yresolution,
GimpUnit resolution_unit,
gpointer data);
static void image_scale_callback (GtkWidget *dialog,
GimpViewable *viewable,
gint width,
......@@ -233,7 +234,7 @@ image_resize_cmd_callback (GtkAction *action,
return_if_no_widget (widget, data);
return_if_no_display (display, data);
options = g_new0 (ImageResizeOptions, 1);
options = g_slice_new (ImageResizeOptions);
options->display = display;
options->context = action_data_get_context (data);
......@@ -254,7 +255,8 @@ image_resize_cmd_callback (GtkAction *action,
G_CALLBACK (gtk_widget_destroy),
dialog, G_CONNECT_SWAPPED);
g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_free, options);
g_object_weak_ref (G_OBJECT (dialog),
(GWeakNotify) image_resize_options_free, options);
gtk_widget_show (dialog);
}
......@@ -565,6 +567,12 @@ image_resize_callback (GtkWidget *dialog,
}
}
static void
image_resize_options_free (ImageResizeOptions *options)
{
g_slice_free (ImageResizeOptions, options);
}
static void
image_print_size_callback (GtkWidget *dialog,
GimpImage *image,
......
......@@ -49,26 +49,25 @@
#include "gimp-intl.h"
typedef struct _TemplateDeleteData TemplateDeleteData;
struct _TemplateDeleteData
typedef struct
{
GimpContainer *container;
GimpTemplate *template;
};
} TemplateDeleteData;
/* local function prototypes */
static void templates_new_response (GtkWidget *dialog,
gint response_id,
TemplateOptionsDialog *options);
static void templates_edit_response (GtkWidget *widget,
gint response_id,
TemplateOptionsDialog *options);
static void templates_delete_response (GtkWidget *dialog,
gint response_id,
TemplateDeleteData *delete_data);
static void templates_new_response (GtkWidget *dialog,
gint response_id,
TemplateOptionsDialog *options);
static void templates_edit_response (GtkWidget *widget,
gint response_id,
TemplateOptionsDialog *options);
static void templates_delete_response (GtkWidget *dialog,
gint response_id,
TemplateDeleteData *delete_data);
static void templates_delete_data_free (TemplateDeleteData *delete_data);
/* public functions */
......@@ -89,11 +88,9 @@ templates_create_image_cmd_callback (GtkAction *action,
if (template && gimp_container_have (container, GIMP_OBJECT (template)))
{
GdkScreen *screen;
GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (editor));
GtkWidget *dialog;
screen = gtk_widget_get_screen (GTK_WIDGET (editor));
dialog = gimp_dialog_factory_dialog_new (global_dialog_factory, screen,
"gimp-image-new-dialog",
-1, FALSE);
......@@ -211,10 +208,8 @@ templates_delete_cmd_callback (GtkAction *action,
if (template && gimp_container_have (container, GIMP_OBJECT (template)))
{
TemplateDeleteData *delete_data;
GtkWidget *dialog;
delete_data = g_new0 (TemplateDeleteData, 1);
TemplateDeleteData *delete_data = g_slice_new (TemplateDeleteData);
GtkWidget *dialog;
delete_data->container = container;
delete_data->template = template;
......@@ -234,7 +229,9 @@ templates_delete_cmd_callback (GtkAction *action,
GTK_RESPONSE_CANCEL,
-1);
g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_free, delete_data);
g_object_weak_ref (G_OBJECT (dialog),
(GWeakNotify) templates_delete_data_free, delete_data);
g_signal_connect_object (template, "disconnect",
G_CALLBACK (gtk_widget_destroy),
dialog, G_CONNECT_SWAPPED);
......@@ -306,3 +303,9 @@ templates_delete_response (GtkWidget *dialog,
gtk_widget_destroy (dialog);
}
static void
templates_delete_data_free (TemplateDeleteData *delete_data)
{
g_slice_free (TemplateDeleteData, delete_data);
}
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