[gimp] app: one more round of general dialog cleanup
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: one more round of general dialog cleanup
- Date: Thu, 27 Oct 2016 19:27:15 +0000 (UTC)
commit 440a1bae82bfc59790b12faf590f065469abef0f
Author: Michael Natterer <mitch gimp org>
Date: Thu Oct 27 21:26:07 2016 +0200
app: one more round of general dialog cleanup
- consistent coding style
- hide public structs
- add callbacks to move logic out of app/dialogs/
app/actions/image-commands.c | 2 +
app/actions/vectors-commands.c | 322 +++++++++++++++----------------
app/dialogs/color-profile-dialog.c | 14 +-
app/dialogs/convert-indexed-dialog.c | 32 ++--
app/dialogs/convert-precision-dialog.c | 22 ++-
app/dialogs/data-delete-dialog.c | 32 ++--
app/dialogs/fade-dialog.c | 25 ++--
app/dialogs/fill-dialog.c | 24 ++-
app/dialogs/grid-dialog.c | 84 +++++----
app/dialogs/image-merge-layers-dialog.c | 27 ++--
app/dialogs/image-new-dialog.c | 204 ++++++++++----------
app/dialogs/image-new-dialog.h | 2 +-
app/dialogs/image-scale-dialog.c | 182 +++++++++---------
app/dialogs/layer-add-mask-dialog.c | 33 ++--
app/dialogs/module-dialog.c | 220 +++++++++++-----------
app/dialogs/offset-dialog.c | 20 +-
app/dialogs/palette-import-dialog.c | 6 +-
app/dialogs/print-size-dialog.c | 63 ++++---
app/dialogs/resize-dialog.c | 31 ++-
app/dialogs/scale-dialog.c | 52 +++--
app/dialogs/stroke-dialog.c | 26 ++--
app/dialogs/template-options-dialog.c | 7 +
app/dialogs/vectors-export-dialog.c | 139 ++++++++++---
app/dialogs/vectors-export-dialog.h | 28 ++--
app/dialogs/vectors-import-dialog.c | 150 +++++++++++----
app/dialogs/vectors-import-dialog.h | 32 ++--
app/dialogs/vectors-options-dialog.c | 3 +
27 files changed, 990 insertions(+), 792 deletions(-)
---
diff --git a/app/actions/image-commands.c b/app/actions/image-commands.c
index dff1c11..4cc9b4c 100644
--- a/app/actions/image-commands.c
+++ b/app/actions/image-commands.c
@@ -1393,6 +1393,8 @@ image_scale_callback (GtkWidget *dialog,
if (width > 0 && height > 0)
{
+ gtk_widget_destroy (dialog);
+
if (width == gimp_image_get_width (image) &&
height == gimp_image_get_height (image) &&
xresolution == xres &&
diff --git a/app/actions/vectors-commands.c b/app/actions/vectors-commands.c
index 7158387..0739ac2 100644
--- a/app/actions/vectors-commands.c
+++ b/app/actions/vectors-commands.c
@@ -74,44 +74,51 @@
/* local function prototypes */
-static void vectors_new_callback (GtkWidget *dialog,
- GimpImage *image,
- GimpVectors *vectors,
- GimpContext *context,
- const gchar *vectors_name,
- gboolean vectors_visible,
- gboolean vectors_linked,
- gboolean vectors_lock_content,
- gboolean vectors_lock_position,
- gpointer user_data);
-static void vectors_edit_attributes_callback (GtkWidget *dialog,
- GimpImage *image,
- GimpVectors *vectors,
- GimpContext *context,
- const gchar *vectors_name,
- gboolean vectors_visible,
- gboolean vectors_linked,
- gboolean vectors_lock_content,
- gboolean vectors_lock_position,
- gpointer user_data);
-static void vectors_fill_callback (GtkWidget *dialog,
- GimpItem *item,
- GimpDrawable *drawable,
- GimpContext *context,
- GimpFillOptions *options,
- gpointer user_data);
-static void vectors_stroke_callback (GtkWidget *dialog,
- GimpItem *item,
- GimpDrawable *drawable,
- GimpContext *context,
- GimpStrokeOptions *options,
- gpointer user_data);
-static void vectors_import_response (GtkWidget *widget,
- gint response_id,
- VectorsImportDialog *dialog);
-static void vectors_export_response (GtkWidget *widget,
- gint response_id,
- VectorsExportDialog *dialog);
+static void vectors_new_callback (GtkWidget *dialog,
+ GimpImage *image,
+ GimpVectors *vectors,
+ GimpContext *context,
+ const gchar *vectors_name,
+ gboolean vectors_visible,
+ gboolean vectors_linked,
+ gboolean vectors_lock_content,
+ gboolean vectors_lock_position,
+ gpointer user_data);
+static void vectors_edit_attributes_callback (GtkWidget *dialog,
+ GimpImage *image,
+ GimpVectors *vectors,
+ GimpContext *context,
+ const gchar *vectors_name,
+ gboolean vectors_visible,
+ gboolean vectors_linked,
+ gboolean vectors_lock_content,
+ gboolean vectors_lock_position,
+ gpointer user_data);
+static void vectors_fill_callback (GtkWidget *dialog,
+ GimpItem *item,
+ GimpDrawable *drawable,
+ GimpContext *context,
+ GimpFillOptions *options,
+ gpointer user_data);
+static void vectors_stroke_callback (GtkWidget *dialog,
+ GimpItem *item,
+ GimpDrawable *drawable,
+ GimpContext *context,
+ GimpStrokeOptions *options,
+ gpointer user_data);
+static void vectors_import_callback (GtkWidget *dialog,
+ GimpImage *image,
+ GFile *file,
+ GFile *import_folder,
+ gboolean merge_vectors,
+ gboolean scale_vectors,
+ gpointer user_data);
+static void vectors_export_callback (GtkWidget *dialog,
+ GimpImage *image,
+ GFile *file,
+ GFile *export_folder,
+ gboolean active_only,
+ gpointer user_data);
/* public functions */
@@ -437,7 +444,6 @@ vectors_fill_cmd_callback (GtkAction *action,
return;
}
-
#define FILL_DIALOG_KEY "gimp-vectors-fill-dialog"
dialog = dialogs_get_dialog (G_OBJECT (drawable), FILL_DIALOG_KEY);
@@ -646,74 +652,75 @@ void
vectors_export_cmd_callback (GtkAction *action,
gpointer data)
{
- GimpImage *image;
- GimpVectors *vectors;
- GtkWidget *widget;
- GimpDialogConfig *config;
- VectorsExportDialog *dialog;
+ GimpImage *image;
+ GimpVectors *vectors;
+ GtkWidget *widget;
+ GtkWidget *dialog;
return_if_no_vectors (image, vectors, data);
return_if_no_widget (widget, data);
- config = GIMP_DIALOG_CONFIG (image->gimp->config);
+#define EXPORT_DIALOG_KEY "gimp-vectors-export-dialog"
- dialog = vectors_export_dialog_new (image, widget,
- config->vectors_export_active_only);
+ dialog = dialogs_get_dialog (G_OBJECT (image), EXPORT_DIALOG_KEY);
- if (config->vectors_export_path)
+ if (! dialog)
{
- GFile *folder = gimp_file_new_for_config_path (config->vectors_export_path,
- NULL);
+ GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
+ GFile *folder = NULL;
+
+ if (config->vectors_export_path)
+ folder = gimp_file_new_for_config_path (config->vectors_export_path,
+ NULL);
+
+ dialog = vectors_export_dialog_new (image, widget,
+ folder,
+ config->vectors_export_active_only,
+ vectors_export_callback,
+ NULL);
if (folder)
- {
- gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog->dialog),
- folder, NULL);
- g_object_unref (folder);
- }
- }
+ g_object_unref (folder);
- g_signal_connect (dialog->dialog, "response",
- G_CALLBACK (vectors_export_response),
- dialog);
+ dialogs_attach_dialog (G_OBJECT (image), EXPORT_DIALOG_KEY, dialog);
+ }
- gtk_widget_show (dialog->dialog);
+ gtk_window_present (GTK_WINDOW (dialog));
}
void
vectors_import_cmd_callback (GtkAction *action,
gpointer data)
{
- GimpImage *image;
- GtkWidget *widget;
- GimpDialogConfig *config;
- VectorsImportDialog *dialog;
+ GimpImage *image;
+ GtkWidget *widget;
+ GtkWidget *dialog;
return_if_no_image (image, data);
return_if_no_widget (widget, data);
- config = GIMP_DIALOG_CONFIG (image->gimp->config);
+#define IMPORT_DIALOG_KEY "gimp-vectors-import-dialog"
- dialog = vectors_import_dialog_new (image, widget,
- config->vectors_import_merge,
- config->vectors_import_scale);
+ dialog = dialogs_get_dialog (G_OBJECT (image), IMPORT_DIALOG_KEY);
- if (config->vectors_import_path)
+ if (! dialog)
{
- GFile *folder = gimp_file_new_for_config_path (config->vectors_import_path,
- NULL);
+ GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
+ GFile *folder = NULL;
- if (folder)
- {
- gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog->dialog),
- folder, NULL);
- g_object_unref (folder);
- }
- }
+ if (config->vectors_import_path)
+ folder = gimp_file_new_for_config_path (config->vectors_import_path,
+ NULL);
- g_signal_connect (dialog->dialog, "response",
- G_CALLBACK (vectors_import_response),
- dialog);
+ dialog = vectors_import_dialog_new (image, widget,
+ folder,
+ config->vectors_import_merge,
+ config->vectors_import_scale,
+ vectors_import_callback,
+ NULL);
+
+ dialogs_attach_dialog (G_OBJECT (image), IMPORT_DIALOG_KEY, dialog);
+ }
- gtk_widget_show (dialog->dialog);
+ gtk_window_present (GTK_WINDOW (dialog));
}
void
@@ -975,110 +982,85 @@ vectors_stroke_callback (GtkWidget *dialog,
}
static void
-vectors_import_response (GtkWidget *widget,
- gint response_id,
- VectorsImportDialog *dialog)
+vectors_import_callback (GtkWidget *dialog,
+ GimpImage *image,
+ GFile *file,
+ GFile *import_folder,
+ gboolean merge_vectors,
+ gboolean scale_vectors,
+ gpointer user_data)
{
- if (response_id == GTK_RESPONSE_OK)
- {
- GimpDialogConfig *config;
- GtkFileChooser *chooser = GTK_FILE_CHOOSER (widget);
- GFile *file;
- gchar *folder = NULL;
- GError *error = NULL;
-
- config = GIMP_DIALOG_CONFIG (dialog->image->gimp->config);
-
- file = gtk_file_chooser_get_current_folder_file (chooser);
-
- if (file)
- {
- folder = gimp_file_get_config_path (file, NULL);
- g_object_unref (file);
- }
-
- g_object_set (config,
- "path-import-path", folder,
- "path-import-merge", dialog->merge_vectors,
- "path-import-scale", dialog->scale_vectors,
- NULL);
+ GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
+ gchar *path = NULL;
+ GError *error = NULL;
- if (folder)
- g_free (folder);
+ if (import_folder)
+ path = gimp_file_get_config_path (import_folder, NULL);
- file = gtk_file_chooser_get_file (chooser);
+ g_object_set (config,
+ "path-import-path", path,
+ "path-import-merge", merge_vectors,
+ "path-import-scale", scale_vectors,
+ NULL);
- if (gimp_vectors_import_file (dialog->image, file,
- config->vectors_import_merge,
- config->vectors_import_scale,
- GIMP_IMAGE_ACTIVE_PARENT, -1,
- NULL, &error))
- {
- gimp_image_flush (dialog->image);
- }
- else
- {
- gimp_message (dialog->image->gimp, G_OBJECT (widget),
- GIMP_MESSAGE_ERROR,
- "%s", error->message);
- g_error_free (error);
- return;
- }
+ if (path)
+ g_free (path);
- g_object_unref (file);
+ if (gimp_vectors_import_file (image, file,
+ config->vectors_import_merge,
+ config->vectors_import_scale,
+ GIMP_IMAGE_ACTIVE_PARENT, -1,
+ NULL, &error))
+ {
+ gimp_image_flush (image);
+ }
+ else
+ {
+ gimp_message (image->gimp, G_OBJECT (dialog),
+ GIMP_MESSAGE_ERROR,
+ "%s", error->message);
+ g_error_free (error);
+ return;
}
- gtk_widget_destroy (widget);
+ gtk_widget_destroy (dialog);
}
static void
-vectors_export_response (GtkWidget *widget,
- gint response_id,
- VectorsExportDialog *dialog)
+vectors_export_callback (GtkWidget *dialog,
+ GimpImage *image,
+ GFile *file,
+ GFile *export_folder,
+ gboolean active_only,
+ gpointer user_data)
{
- if (response_id == GTK_RESPONSE_OK)
- {
- GimpDialogConfig *config;
- GtkFileChooser *chooser = GTK_FILE_CHOOSER (widget);
- GimpVectors *vectors = NULL;
- GFile *file;
- gchar *folder = NULL;
- GError *error = NULL;
-
- config = GIMP_DIALOG_CONFIG (dialog->image->gimp->config);
-
- file = gtk_file_chooser_get_current_folder_file (chooser);
+ GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
+ GimpVectors *vectors = NULL;
+ gchar *path = NULL;
+ GError *error = NULL;
- if (file)
- {
- folder = gimp_file_get_config_path (file, NULL);
- g_object_unref (file);
- }
+ if (export_folder)
+ path = gimp_file_get_config_path (export_folder, NULL);
- g_object_set (config,
- "path-export-path", folder,
- "path-export-active-only", dialog->active_only,
- NULL);
-
- if (folder)
- g_free (folder);
-
- file = gtk_file_chooser_get_file (chooser);
+ g_object_set (config,
+ "path-export-path", path,
+ "path-export-active-only", active_only,
+ NULL);
- if (config->vectors_export_active_only)
- vectors = gimp_image_get_active_vectors (dialog->image);
+ if (path)
+ g_free (path);
- if (! gimp_vectors_export_file (dialog->image, vectors, file, &error))
- {
- gimp_message (dialog->image->gimp, G_OBJECT (widget),
- GIMP_MESSAGE_ERROR,
- "%s", error->message);
- g_error_free (error);
- return;
- }
+ if (config->vectors_export_active_only)
+ vectors = gimp_image_get_active_vectors (image);
- g_object_unref (file);
+ if (! gimp_vectors_export_file (image, vectors, file, &error))
+ {
+ gimp_message (image->gimp, G_OBJECT (dialog),
+ GIMP_MESSAGE_ERROR,
+ "%s", error->message);
+ g_clear_error (&error);
+ return;
}
- gtk_widget_destroy (widget);
+ gtk_widget_destroy (dialog);
}
diff --git a/app/dialogs/color-profile-dialog.c b/app/dialogs/color-profile-dialog.c
index e16510a..d8c7bf6 100644
--- a/app/dialogs/color-profile-dialog.c
+++ b/app/dialogs/color-profile-dialog.c
@@ -68,13 +68,13 @@ typedef struct
} ProfileDialog;
+static void color_profile_dialog_free (ProfileDialog *private);
static GtkWidget * color_profile_combo_box_new (ProfileDialog *private);
static void color_profile_dialog_response (GtkWidget *dialog,
gint response_id,
ProfileDialog *private);
static void color_profile_dest_changed (GtkWidget *combo,
ProfileDialog *private);
-static void color_profile_dialog_free (ProfileDialog *private);
/* public functions */
@@ -319,6 +319,12 @@ color_profile_dialog_new (ColorProfileDialogType dialog_type,
/* private functions */
+static void
+color_profile_dialog_free (ProfileDialog *private)
+{
+ g_slice_free (ProfileDialog, private);
+}
+
static GtkWidget *
color_profile_combo_box_new (ProfileDialog *private)
{
@@ -482,9 +488,3 @@ color_profile_dest_changed (GtkWidget *combo,
g_object_unref (dest_profile);
}
}
-
-static void
-color_profile_dialog_free (ProfileDialog *private)
-{
- g_slice_free (ProfileDialog, private);
-}
diff --git a/app/dialogs/convert-indexed-dialog.c b/app/dialogs/convert-indexed-dialog.c
index 661b5dc..66efe12 100644
--- a/app/dialogs/convert-indexed-dialog.c
+++ b/app/dialogs/convert-indexed-dialog.c
@@ -42,7 +42,9 @@
#include "gimp-intl.h"
-typedef struct
+typedef struct _IndexedDialog IndexedDialog;
+
+struct _IndexedDialog
{
GimpImage *image;
GimpConvertPaletteType palette_type;
@@ -58,9 +60,10 @@ typedef struct
GtkWidget *dialog;
GimpContext *context;
GimpContainer *container;
-} IndexedDialog;
+};
+static void convert_dialog_free (IndexedDialog *private);
static void convert_dialog_response (GtkWidget *widget,
gint response_id,
IndexedDialog *private);
@@ -70,7 +73,6 @@ static gboolean convert_dialog_palette_filter (GimpObject *object,
static void convert_dialog_palette_changed (GimpContext *context,
GimpPalette *palette,
IndexedDialog *private);
-static void convert_dialog_free (IndexedDialog *private);
/* public functions */
@@ -296,6 +298,18 @@ convert_indexed_dialog_new (GimpImage *image,
/* private functions */
static void
+convert_dialog_free (IndexedDialog *private)
+{
+ if (private->container)
+ g_object_unref (private->container);
+
+ if (private->context)
+ g_object_unref (private->context);
+
+ g_slice_free (IndexedDialog, private);
+}
+
+static void
convert_dialog_response (GtkWidget *dialog,
gint response_id,
IndexedDialog *private)
@@ -406,15 +420,3 @@ convert_dialog_palette_changed (GimpContext *context,
private->custom_palette = palette;
}
}
-
-static void
-convert_dialog_free (IndexedDialog *private)
-{
- if (private->container)
- g_object_unref (private->container);
-
- if (private->context)
- g_object_unref (private->context);
-
- g_slice_free (IndexedDialog, private);
-}
diff --git a/app/dialogs/convert-precision-dialog.c b/app/dialogs/convert-precision-dialog.c
index 78e8454..0ecbc1d 100644
--- a/app/dialogs/convert-precision-dialog.c
+++ b/app/dialogs/convert-precision-dialog.c
@@ -39,7 +39,9 @@
#include "gimp-intl.h"
-typedef struct
+typedef struct _ConvertDialog ConvertDialog;
+
+struct _ConvertDialog
{
GimpImage *image;
GimpComponentType component_type;
@@ -50,13 +52,15 @@ typedef struct
GeglDitherMethod channel_dither_method;
GimpConvertPrecisionCallback callback;
gpointer user_data;
-} ConvertDialog;
+};
+
+/* local function prototypes */
+static void convert_precision_dialog_free (ConvertDialog *private);
static void convert_precision_dialog_response (GtkWidget *widget,
gint response_id,
ConvertDialog *private);
-static void convert_precision_dialog_free (ConvertDialog *private);
/* public functions */
@@ -279,6 +283,12 @@ convert_precision_dialog_new (GimpImage *image,
/* private functions */
static void
+convert_precision_dialog_free (ConvertDialog *private)
+{
+ g_slice_free (ConvertDialog, private);
+}
+
+static void
convert_precision_dialog_response (GtkWidget *dialog,
gint response_id,
ConvertDialog *private)
@@ -301,9 +311,3 @@ convert_precision_dialog_response (GtkWidget *dialog,
gtk_widget_destroy (dialog);
}
}
-
-static void
-convert_precision_dialog_free (ConvertDialog *private)
-{
- g_slice_free (ConvertDialog, private);
-}
diff --git a/app/dialogs/data-delete-dialog.c b/app/dialogs/data-delete-dialog.c
index 555f035..faef53e 100644
--- a/app/dialogs/data-delete-dialog.c
+++ b/app/dialogs/data-delete-dialog.c
@@ -53,7 +53,7 @@ struct _DataDeleteDialog
static void data_delete_dialog_response (GtkWidget *dialog,
gint response_id,
- DataDeleteDialog *delete_data);
+ DataDeleteDialog *private);
/* public functions */
@@ -64,7 +64,7 @@ data_delete_dialog_new (GimpDataFactory *factory,
GimpContext *context,
GtkWidget *parent)
{
- DataDeleteDialog *delete_data;
+ DataDeleteDialog *private;
GtkWidget *dialog;
g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL);
@@ -72,12 +72,12 @@ data_delete_dialog_new (GimpDataFactory *factory,
g_return_val_if_fail (context == NULL || GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (GTK_IS_WIDGET (parent), NULL);
- delete_data = g_slice_new0 (DataDeleteDialog);
+ private = g_slice_new0 (DataDeleteDialog);
- delete_data->factory = factory;
- delete_data->data = data;
- delete_data->context = context;
- delete_data->parent = parent;
+ private->factory = factory;
+ private->data = data;
+ private->context = context;
+ private->parent = parent;
dialog = gimp_message_dialog_new (_("Delete Object"), "edit-delete",
gtk_widget_get_toplevel (parent), 0,
@@ -99,7 +99,7 @@ data_delete_dialog_new (GimpDataFactory *factory,
g_signal_connect (dialog, "response",
G_CALLBACK (data_delete_dialog_response),
- delete_data);
+ private);
gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
_("Delete '%s'?"),
@@ -118,23 +118,23 @@ data_delete_dialog_new (GimpDataFactory *factory,
static void
data_delete_dialog_response (GtkWidget *dialog,
gint response_id,
- DataDeleteDialog *delete_data)
+ DataDeleteDialog *private)
{
gtk_widget_destroy (dialog);
if (response_id == GTK_RESPONSE_OK)
{
- GimpDataFactory *factory = delete_data->factory;
- GimpData *data = delete_data->data;
+ GimpDataFactory *factory = private->factory;
+ GimpData *data = private->data;
GimpContainer *container;
GimpObject *new_active = NULL;
GError *error = NULL;
container = gimp_data_factory_get_container (factory);
- if (delete_data->context &&
+ if (private->context &&
GIMP_OBJECT (data) ==
- gimp_context_get_by_type (delete_data->context,
+ gimp_context_get_by_type (private->context,
gimp_container_get_children_type (container)))
{
new_active = gimp_container_get_neighbor_of (container,
@@ -144,16 +144,16 @@ data_delete_dialog_response (GtkWidget *dialog,
if (! gimp_data_factory_data_delete (factory, data, TRUE, &error))
{
gimp_message (gimp_data_factory_get_gimp (factory),
- G_OBJECT (delete_data->parent), GIMP_MESSAGE_ERROR,
+ G_OBJECT (private->parent), GIMP_MESSAGE_ERROR,
"%s", error->message);
g_clear_error (&error);
}
if (new_active)
- gimp_context_set_by_type (delete_data->context,
+ gimp_context_set_by_type (private->context,
gimp_container_get_children_type (container),
new_active);
}
- g_slice_free (DataDeleteDialog, delete_data);
+ g_slice_free (DataDeleteDialog, private);
}
diff --git a/app/dialogs/fade-dialog.c b/app/dialogs/fade-dialog.c
index 455fac4..8851753 100644
--- a/app/dialogs/fade-dialog.c
+++ b/app/dialogs/fade-dialog.c
@@ -54,12 +54,13 @@ typedef struct
} FadeDialog;
+/* local function prototypes */
+
+static void fade_dialog_free (FadeDialog *private);
static void fade_dialog_response (GtkWidget *dialog,
gint response_id,
FadeDialog *private);
-
static void fade_dialog_context_changed (FadeDialog *private);
-static void fade_dialog_free (FadeDialog *private);
/* public functions */
@@ -88,8 +89,8 @@ fade_dialog_new (GimpImage *image,
if (! (undo && undo->applied_buffer))
return NULL;
- item = GIMP_ITEM_UNDO (undo)->item;
- drawable = GIMP_DRAWABLE (item);
+ item = GIMP_ITEM_UNDO (undo)->item;
+ drawable = GIMP_DRAWABLE (item);
private = g_slice_new0 (FadeDialog);
@@ -108,7 +109,6 @@ fade_dialog_new (GimpImage *image,
title = g_strdup_printf (_("Fade %s"), gimp_object_get_name (undo));
-
dialog = gimp_viewable_dialog_new (GIMP_VIEWABLE (drawable),
private->context,
title, "gimp-edit-fade",
@@ -124,12 +124,13 @@ fade_dialog_new (GimpImage *image,
g_free (title);
- gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
+ gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+
g_object_weak_ref (G_OBJECT (dialog),
(GWeakNotify) fade_dialog_free, private);
@@ -175,6 +176,12 @@ fade_dialog_new (GimpImage *image,
/* private functions */
static void
+fade_dialog_free (FadeDialog *private)
+{
+ g_slice_free (FadeDialog, private);
+}
+
+static void
fade_dialog_response (GtkWidget *dialog,
gint response_id,
FadeDialog *private)
@@ -206,9 +213,3 @@ fade_dialog_context_changed (FadeDialog *private)
gimp_image_flush (private->image);
}
}
-
-static void
-fade_dialog_free (FadeDialog *private)
-{
- g_slice_free (FadeDialog, private);
-}
diff --git a/app/dialogs/fill-dialog.c b/app/dialogs/fill-dialog.c
index b75aa93..24ec9ad 100644
--- a/app/dialogs/fill-dialog.c
+++ b/app/dialogs/fill-dialog.c
@@ -42,7 +42,9 @@
#define RESPONSE_RESET 1
-typedef struct
+typedef struct _FillDialog FillDialog;
+
+struct _FillDialog
{
GimpItem *item;
GimpDrawable *drawable;
@@ -50,15 +52,15 @@ typedef struct
GimpFillOptions *options;
GimpFillCallback callback;
gpointer user_data;
-} FillDialog;
+};
/* local function prototypes */
+static void fill_dialog_free (FillDialog *private);
static void fill_dialog_response (GtkWidget *dialog,
gint response_id,
FillDialog *private);
-static void fill_dialog_free (FillDialog *private);
/* public function */
@@ -147,6 +149,14 @@ fill_dialog_new (GimpItem *item,
/* private functions */
static void
+fill_dialog_free (FillDialog *private)
+{
+ g_object_unref (private->options);
+
+ g_slice_free (FillDialog, private);
+}
+
+static void
fill_dialog_response (GtkWidget *dialog,
gint response_id,
FillDialog *private)
@@ -171,11 +181,3 @@ fill_dialog_response (GtkWidget *dialog,
break;
}
}
-
-static void
-fill_dialog_free (FillDialog *private)
-{
- g_object_unref (private->options);
-
- g_slice_free (FillDialog, private);
-}
diff --git a/app/dialogs/grid-dialog.c b/app/dialogs/grid-dialog.c
index e8ccfa9..bbd07e0 100644
--- a/app/dialogs/grid-dialog.c
+++ b/app/dialogs/grid-dialog.c
@@ -50,36 +50,46 @@
#define GRID_RESPONSE_RESET 1
+typedef struct _GridDialog GridDialog;
+
+struct _GridDialog
+{
+ GimpImage *image;
+ GimpGrid *grid;
+ GimpGrid *grid_backup;
+};
+
+
/* local functions */
-static void grid_dialog_response (GtkWidget *widget,
- gint response_id,
- GtkWidget *dialog);
+static void grid_dialog_free (GridDialog *private);
+static void grid_dialog_response (GtkWidget *dialog,
+ gint response_id,
+ GridDialog *private);
/* public function */
-
GtkWidget *
grid_dialog_new (GimpImage *image,
GimpContext *context,
GtkWidget *parent)
{
- GimpGrid *grid;
- GimpGrid *grid_backup;
- GtkWidget *dialog;
- GtkWidget *editor;
- gdouble xres;
- gdouble yres;
+ GridDialog *private;
+ GtkWidget *dialog;
+ GtkWidget *editor;
+ gdouble xres;
+ gdouble yres;
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (parent == NULL || GTK_IS_WIDGET (parent), NULL);
- gimp_image_get_resolution (image, &xres, &yres);
+ private = g_slice_new0 (GridDialog);
- grid = gimp_image_get_grid (GIMP_IMAGE (image));
- grid_backup = gimp_config_duplicate (GIMP_CONFIG (grid));
+ private->image = image;
+ private->grid = gimp_image_get_grid (image);
+ private->grid_backup = gimp_config_duplicate (GIMP_CONFIG (private->grid));
dialog = gimp_viewable_dialog_new (GIMP_VIEWABLE (image), context,
_("Configure Grid"), "gimp-grid-configure",
@@ -94,31 +104,30 @@ grid_dialog_new (GimpImage *image,
NULL);
- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
-
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GRID_RESPONSE_RESET,
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
+ gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+
+ g_object_weak_ref (G_OBJECT (dialog),
+ (GWeakNotify) grid_dialog_free, private);
+
g_signal_connect (dialog, "response",
G_CALLBACK (grid_dialog_response),
dialog);
- editor = gimp_grid_editor_new (grid, context, xres, yres);
+ gimp_image_get_resolution (image, &xres, &yres);
+
+ editor = gimp_grid_editor_new (private->grid, context, xres, yres);
gtk_container_set_border_width (GTK_CONTAINER (editor), 12);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
editor, TRUE, TRUE, 0);
gtk_widget_show (editor);
- g_object_set_data (G_OBJECT (dialog), "image", image);
- g_object_set_data (G_OBJECT (dialog), "grid", grid);
-
- g_object_set_data_full (G_OBJECT (dialog), "grid-backup", grid_backup,
- (GDestroyNotify) g_object_unref);
-
return dialog;
}
@@ -126,37 +135,38 @@ grid_dialog_new (GimpImage *image,
/* local functions */
static void
-grid_dialog_response (GtkWidget *widget,
- gint response_id,
- GtkWidget *dialog)
+grid_dialog_free (GridDialog *private)
{
- GimpImage *image;
- GimpImage *grid;
- GimpGrid *grid_backup;
+ g_object_unref (private->grid_backup);
- image = g_object_get_data (G_OBJECT (dialog), "image");
- grid = g_object_get_data (G_OBJECT (dialog), "grid");
- grid_backup = g_object_get_data (G_OBJECT (dialog), "grid-backup");
+ g_slice_free (GridDialog, private);
+}
+static void
+grid_dialog_response (GtkWidget *dialog,
+ gint response_id,
+ GridDialog *private)
+{
switch (response_id)
{
case GRID_RESPONSE_RESET:
- gimp_config_sync (G_OBJECT (image->gimp->config->default_grid),
- G_OBJECT (grid), 0);
+ gimp_config_sync (G_OBJECT (private->image->gimp->config->default_grid),
+ G_OBJECT (private->grid), 0);
break;
case GTK_RESPONSE_OK:
- if (! gimp_config_is_equal_to (GIMP_CONFIG (grid_backup),
- GIMP_CONFIG (grid)))
+ if (! gimp_config_is_equal_to (GIMP_CONFIG (private->grid_backup),
+ GIMP_CONFIG (private->grid)))
{
- gimp_image_undo_push_image_grid (image, _("Grid"), grid_backup);
+ gimp_image_undo_push_image_grid (private->image, _("Grid"),
+ private->grid_backup);
}
gtk_widget_destroy (dialog);
break;
default:
- gimp_image_set_grid (GIMP_IMAGE (image), grid_backup, FALSE);
+ gimp_image_set_grid (private->image, private->grid_backup, FALSE);
gtk_widget_destroy (dialog);
}
}
diff --git a/app/dialogs/image-merge-layers-dialog.c b/app/dialogs/image-merge-layers-dialog.c
index 21dbd65..639cc1f 100644
--- a/app/dialogs/image-merge-layers-dialog.c
+++ b/app/dialogs/image-merge-layers-dialog.c
@@ -52,10 +52,10 @@ struct _ImageMergeLayersDialog
/* local function prototypes */
+static void image_merge_layers_dialog_free (ImageMergeLayersDialog *private);
static void image_merge_layers_dialog_response (GtkWidget *dialog,
gint response_id,
ImageMergeLayersDialog *private);
-static void image_merge_layers_dialog_free (ImageMergeLayersDialog *private);
/* public functions */
@@ -102,16 +102,16 @@ image_merge_layers_dialog_new (GimpImage *image,
NULL);
- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
-
- g_object_weak_ref (G_OBJECT (dialog),
- (GWeakNotify) image_merge_layers_dialog_free, private);
-
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
+ gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+
+ g_object_weak_ref (G_OBJECT (dialog),
+ (GWeakNotify) image_merge_layers_dialog_free, private);
+
g_signal_connect (dialog, "response",
G_CALLBACK (image_merge_layers_dialog_response),
private);
@@ -161,6 +161,15 @@ image_merge_layers_dialog_new (GimpImage *image,
return dialog;
}
+
+/* private functions */
+
+static void
+image_merge_layers_dialog_free (ImageMergeLayersDialog *private)
+{
+ g_slice_free (ImageMergeLayersDialog, private);
+}
+
static void
image_merge_layers_dialog_response (GtkWidget *dialog,
gint response_id,
@@ -180,9 +189,3 @@ image_merge_layers_dialog_response (GtkWidget *dialog,
gtk_widget_destroy (dialog);
}
}
-
-static void
-image_merge_layers_dialog_free (ImageMergeLayersDialog *private)
-{
- g_slice_free (ImageMergeLayersDialog, private);
-}
diff --git a/app/dialogs/image-new-dialog.c b/app/dialogs/image-new-dialog.c
index 0ea833d..3bd4482 100644
--- a/app/dialogs/image-new-dialog.c
+++ b/app/dialogs/image-new-dialog.c
@@ -65,15 +65,15 @@ typedef struct
/* local function prototypes */
-static void image_new_dialog_free (ImageNewDialog *dialog);
+static void image_new_dialog_free (ImageNewDialog *private);
static void image_new_dialog_response (GtkWidget *widget,
gint response_id,
- ImageNewDialog *dialog);
+ ImageNewDialog *private);
static void image_new_template_changed (GimpContext *context,
GimpTemplate *template,
- ImageNewDialog *dialog);
-static void image_new_confirm_dialog (ImageNewDialog *dialog);
-static void image_new_create_image (ImageNewDialog *dialog);
+ ImageNewDialog *private);
+static void image_new_confirm_dialog (ImageNewDialog *private);
+static void image_new_create_image (ImageNewDialog *private);
/* public functions */
@@ -81,7 +81,8 @@ static void image_new_create_image (ImageNewDialog *dialog);
GtkWidget *
image_new_dialog_new (GimpContext *context)
{
- ImageNewDialog *dialog;
+ ImageNewDialog *private;
+ GtkWidget *dialog;
GtkWidget *main_vbox;
GtkWidget *hbox;
GtkWidget *label;
@@ -89,42 +90,43 @@ image_new_dialog_new (GimpContext *context)
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
- dialog = g_slice_new0 (ImageNewDialog);
+ private = g_slice_new0 (ImageNewDialog);
- dialog->context = gimp_context_new (context->gimp, "image-new-dialog",
- context);
- dialog->template = g_object_new (GIMP_TYPE_TEMPLATE, NULL);
+ private->context = gimp_context_new (context->gimp, "image-new-dialog",
+ context);
+ private->template = g_object_new (GIMP_TYPE_TEMPLATE, NULL);
- dialog->dialog = gimp_dialog_new (_("Create a New Image"),
- "gimp-image-new",
- NULL, 0,
- gimp_standard_help_func, GIMP_HELP_FILE_NEW,
+ private->dialog = dialog =
+ gimp_dialog_new (_("Create a New Image"),
+ "gimp-image-new",
+ NULL, 0,
+ gimp_standard_help_func, GIMP_HELP_FILE_NEW,
- GIMP_STOCK_RESET, RESPONSE_RESET,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
+ GIMP_STOCK_RESET, RESPONSE_RESET,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK,
- NULL);
+ NULL);
- gtk_window_set_resizable (GTK_WINDOW (dialog->dialog), FALSE);
-
- g_object_set_data_full (G_OBJECT (dialog->dialog),
- "gimp-image-new-dialog", dialog,
- (GDestroyNotify) image_new_dialog_free);
-
- g_signal_connect (dialog->dialog, "response",
- G_CALLBACK (image_new_dialog_response),
- dialog);
-
- gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog->dialog),
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
RESPONSE_RESET,
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
+ gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+
+ g_object_set_data_full (G_OBJECT (dialog),
+ "gimp-image-new-dialog", private,
+ (GDestroyNotify) image_new_dialog_free);
+
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (image_new_dialog_response),
+ private);
+
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog->dialog))),
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
main_vbox, TRUE, TRUE, 0);
gtk_widget_show (main_vbox);
@@ -137,63 +139,63 @@ image_new_dialog_new (GimpContext *context)
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
- dialog->combo = g_object_new (GIMP_TYPE_CONTAINER_COMBO_BOX,
- "container", context->gimp->templates,
- "context", dialog->context,
- "view-size", 16,
- "view-border-width", 0,
- "ellipsize", PANGO_ELLIPSIZE_NONE,
- "focus-on-click", FALSE,
- NULL);
- gtk_box_pack_start (GTK_BOX (hbox), dialog->combo, TRUE, TRUE, 0);
- gtk_widget_show (dialog->combo);
+ private->combo = g_object_new (GIMP_TYPE_CONTAINER_COMBO_BOX,
+ "container", context->gimp->templates,
+ "context", private->context,
+ "view-size", 16,
+ "view-border-width", 0,
+ "ellipsize", PANGO_ELLIPSIZE_NONE,
+ "focus-on-click", FALSE,
+ NULL);
+ gtk_box_pack_start (GTK_BOX (hbox), private->combo, TRUE, TRUE, 0);
+ gtk_widget_show (private->combo);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->combo);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), private->combo);
- g_signal_connect (dialog->context, "template-changed",
+ g_signal_connect (private->context, "template-changed",
G_CALLBACK (image_new_template_changed),
- dialog);
+ private);
/* Template editor */
- dialog->editor = gimp_template_editor_new (dialog->template, context->gimp,
- FALSE);
- gtk_box_pack_start (GTK_BOX (main_vbox), dialog->editor, FALSE, FALSE, 0);
- gtk_widget_show (dialog->editor);
+ private->editor = gimp_template_editor_new (private->template, context->gimp,
+ FALSE);
+ gtk_box_pack_start (GTK_BOX (main_vbox), private->editor, FALSE, FALSE, 0);
+ gtk_widget_show (private->editor);
- entry = GIMP_SIZE_ENTRY (gimp_template_editor_get_size_se (GIMP_TEMPLATE_EDITOR (dialog->editor)));
+ entry = GIMP_SIZE_ENTRY (gimp_template_editor_get_size_se (GIMP_TEMPLATE_EDITOR (private->editor)));
gimp_size_entry_set_activates_default (entry, TRUE);
gimp_size_entry_grab_focus (entry);
- image_new_template_changed (dialog->context,
- gimp_context_get_template (dialog->context),
- dialog);
+ image_new_template_changed (private->context,
+ gimp_context_get_template (private->context),
+ private);
- return dialog->dialog;
+ return dialog;
}
void
-image_new_dialog_set (GtkWidget *widget,
+image_new_dialog_set (GtkWidget *dialog,
GimpImage *image,
GimpTemplate *template)
{
- ImageNewDialog *dialog;
+ ImageNewDialog *private;
- g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (GIMP_IS_DIALOG (dialog));
g_return_if_fail (image == NULL || GIMP_IS_IMAGE (image));
g_return_if_fail (template == NULL || GIMP_IS_TEMPLATE (template));
- dialog = g_object_get_data (G_OBJECT (widget), "gimp-image-new-dialog");
+ private = g_object_get_data (G_OBJECT (dialog), "gimp-image-new-dialog");
- g_return_if_fail (dialog != NULL);
+ g_return_if_fail (private != NULL);
- gimp_context_set_template (dialog->context, template);
+ gimp_context_set_template (private->context, template);
if (! template)
{
- template = gimp_image_new_get_last_template (dialog->context->gimp,
+ template = gimp_image_new_get_last_template (private->context->gimp,
image);
- image_new_template_changed (dialog->context, template, dialog);
+ image_new_template_changed (private->context, template, private);
g_object_unref (template);
}
@@ -203,37 +205,37 @@ image_new_dialog_set (GtkWidget *widget,
/* private functions */
static void
-image_new_dialog_free (ImageNewDialog *dialog)
+image_new_dialog_free (ImageNewDialog *private)
{
- g_object_unref (dialog->context);
- g_object_unref (dialog->template);
+ g_object_unref (private->context);
+ g_object_unref (private->template);
- g_slice_free (ImageNewDialog, dialog);
+ g_slice_free (ImageNewDialog, private);
}
static void
-image_new_dialog_response (GtkWidget *widget,
+image_new_dialog_response (GtkWidget *dialog,
gint response_id,
- ImageNewDialog *dialog)
+ ImageNewDialog *private)
{
switch (response_id)
{
case RESPONSE_RESET:
- gimp_config_sync (G_OBJECT (dialog->context->gimp->config->default_image),
- G_OBJECT (dialog->template), 0);
- gimp_context_set_template (dialog->context, NULL);
+ gimp_config_sync (G_OBJECT (private->context->gimp->config->default_image),
+ G_OBJECT (private->template), 0);
+ gimp_context_set_template (private->context, NULL);
break;
case GTK_RESPONSE_OK:
- if (gimp_template_get_initial_size (dialog->template) >
- GIMP_GUI_CONFIG (dialog->context->gimp->config)->max_new_image_size)
- image_new_confirm_dialog (dialog);
+ if (gimp_template_get_initial_size (private->template) >
+ GIMP_GUI_CONFIG (private->context->gimp->config)->max_new_image_size)
+ image_new_confirm_dialog (private);
else
- image_new_create_image (dialog);
+ image_new_create_image (private);
break;
default:
- gtk_widget_destroy (dialog->dialog);
+ gtk_widget_destroy (dialog);
break;
}
}
@@ -241,7 +243,7 @@ image_new_dialog_response (GtkWidget *widget,
static void
image_new_template_changed (GimpContext *context,
GimpTemplate *template,
- ImageNewDialog *dialog)
+ ImageNewDialog *private)
{
GimpTemplateEditor *editor;
GtkWidget *chain;
@@ -251,7 +253,7 @@ image_new_template_changed (GimpContext *context,
if (! template)
return;
- editor = GIMP_TEMPLATE_EDITOR (dialog->editor);
+ editor = GIMP_TEMPLATE_EDITOR (private->editor);
chain = gimp_template_editor_get_resolution_chain (editor);
xres = gimp_template_get_resolution_x (template);
@@ -263,18 +265,18 @@ image_new_template_changed (GimpContext *context,
comment = (gchar *) gimp_template_get_comment (template);
if (! comment || ! strlen (comment))
- comment = g_strdup (gimp_template_get_comment (dialog->template));
+ comment = g_strdup (gimp_template_get_comment (private->template));
else
comment = NULL;
/* make sure the resolution values are copied first (see bug #546924) */
- gimp_config_sync (G_OBJECT (template), G_OBJECT (dialog->template),
+ gimp_config_sync (G_OBJECT (template), G_OBJECT (private->template),
GIMP_TEMPLATE_PARAM_COPY_FIRST);
- gimp_config_sync (G_OBJECT (template), G_OBJECT (dialog->template), 0);
+ gimp_config_sync (G_OBJECT (template), G_OBJECT (private->template), 0);
if (comment)
{
- g_object_set (dialog->template,
+ g_object_set (private->template,
"comment", comment,
NULL);
@@ -288,35 +290,35 @@ image_new_template_changed (GimpContext *context,
static void
image_new_confirm_response (GtkWidget *dialog,
gint response_id,
- ImageNewDialog *data)
+ ImageNewDialog *private)
{
gtk_widget_destroy (dialog);
- data->confirm_dialog = NULL;
+ private->confirm_dialog = NULL;
if (response_id == GTK_RESPONSE_OK)
- image_new_create_image (data);
+ image_new_create_image (private);
else
- gtk_widget_set_sensitive (data->dialog, TRUE);
+ gtk_widget_set_sensitive (private->dialog, TRUE);
}
static void
-image_new_confirm_dialog (ImageNewDialog *data)
+image_new_confirm_dialog (ImageNewDialog *private)
{
GimpGuiConfig *config;
GtkWidget *dialog;
gchar *size;
- if (data->confirm_dialog)
+ if (private->confirm_dialog)
{
- gtk_window_present (GTK_WINDOW (data->confirm_dialog));
+ gtk_window_present (GTK_WINDOW (private->confirm_dialog));
return;
}
- data->confirm_dialog =
+ private->confirm_dialog =
dialog = gimp_message_dialog_new (_("Confirm Image Size"),
GIMP_STOCK_WARNING,
- data->dialog,
+ private->dialog,
GTK_DIALOG_DESTROY_WITH_PARENT,
gimp_standard_help_func, NULL,
@@ -325,22 +327,22 @@ image_new_confirm_dialog (ImageNewDialog *data)
NULL);
- gtk_dialog_set_alternative_button_order (GTK_DIALOG (data->confirm_dialog),
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (private->confirm_dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
g_signal_connect (dialog, "response",
G_CALLBACK (image_new_confirm_response),
- data);
+ private);
- size = g_format_size (gimp_template_get_initial_size (data->template));
+ size = g_format_size (gimp_template_get_initial_size (private->template));
gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
_("You are trying to create an image "
"with a size of %s."), size);
g_free (size);
- config = GIMP_GUI_CONFIG (data->context->gimp->config);
+ config = GIMP_GUI_CONFIG (private->context->gimp->config);
size = g_format_size (config->max_new_image_size);
gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box,
_("An image of the chosen size will use more "
@@ -349,28 +351,28 @@ image_new_confirm_dialog (ImageNewDialog *data)
"dialog (currently %s)."), size);
g_free (size);
- gtk_widget_set_sensitive (data->dialog, FALSE);
+ gtk_widget_set_sensitive (private->dialog, FALSE);
gtk_widget_show (dialog);
}
static void
-image_new_create_image (ImageNewDialog *dialog)
+image_new_create_image (ImageNewDialog *private)
{
- GimpTemplate *template = g_object_ref (dialog->template);
- Gimp *gimp = dialog->context->gimp;
+ GimpTemplate *template = g_object_ref (private->template);
+ Gimp *gimp = private->context->gimp;
GimpImage *image;
- gtk_widget_hide (dialog->dialog);
+ gtk_widget_hide (private->dialog);
image = gimp_image_new_from_template (gimp, template,
gimp_get_user_context (gimp));
gimp_create_display (gimp, image, gimp_template_get_unit (template), 1.0,
- G_OBJECT (gtk_widget_get_screen (dialog->dialog)),
- gimp_widget_get_monitor (dialog->dialog));
+ G_OBJECT (gtk_widget_get_screen (private->dialog)),
+ gimp_widget_get_monitor (private->dialog));
g_object_unref (image);
- gtk_widget_destroy (dialog->dialog);
+ gtk_widget_destroy (private->dialog);
gimp_image_new_set_last_template (gimp, template);
diff --git a/app/dialogs/image-new-dialog.h b/app/dialogs/image-new-dialog.h
index 6e4bfc0..f895650 100644
--- a/app/dialogs/image-new-dialog.h
+++ b/app/dialogs/image-new-dialog.h
@@ -21,7 +21,7 @@
GtkWidget * image_new_dialog_new (GimpContext *context);
-void image_new_dialog_set (GtkWidget *widget,
+void image_new_dialog_set (GtkWidget *dialog,
GimpImage *image,
GimpTemplate *template);
diff --git a/app/dialogs/image-scale-dialog.c b/app/dialogs/image-scale-dialog.c
index ba86d25..44c8dc4 100644
--- a/app/dialogs/image-scale-dialog.c
+++ b/app/dialogs/image-scale-dialog.c
@@ -64,27 +64,28 @@ typedef struct
} ImageScaleDialog;
-static void image_scale_callback (GtkWidget *widget,
- GimpViewable *viewable,
- gint width,
- gint height,
- GimpUnit unit,
- GimpInterpolationType interpolation,
- gdouble xresolution,
- gdouble yresolution,
- GimpUnit resolution_unit,
- gpointer data);
-
-static void image_scale_dialog_free (ImageScaleDialog *dialog);
-
-static GtkWidget * image_scale_confirm_dialog (ImageScaleDialog *dialog);
-static void image_scale_confirm_large (ImageScaleDialog *dialog,
- gint64 new_memsize,
- gint64 max_memsize);
-static void image_scale_confirm_small (ImageScaleDialog *dialog);
-static void image_scale_confirm_response (GtkWidget *widget,
- gint response_id,
- ImageScaleDialog *dialog);
+/* local function prototypes */
+
+static void image_scale_dialog_free (ImageScaleDialog *private);
+static void image_scale_callback (GtkWidget *widget,
+ GimpViewable *viewable,
+ gint width,
+ gint height,
+ GimpUnit unit,
+ GimpInterpolationType interpolation,
+ gdouble xresolution,
+ gdouble yresolution,
+ GimpUnit resolution_unit,
+ gpointer data);
+
+static GtkWidget * image_scale_confirm_dialog (ImageScaleDialog *private);
+static void image_scale_confirm_large (ImageScaleDialog *private,
+ gint64 new_memsize,
+ gint64 max_memsize);
+static void image_scale_confirm_small (ImageScaleDialog *private);
+static void image_scale_confirm_response (GtkWidget *widget,
+ gint response_id,
+ ImageScaleDialog *private);
/* public functions */
@@ -98,33 +99,42 @@ image_scale_dialog_new (GimpImage *image,
GimpScaleCallback callback,
gpointer user_data)
{
- ImageScaleDialog *dialog;
+ ImageScaleDialog *private;
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (callback != NULL, NULL);
- dialog = g_slice_new0 (ImageScaleDialog);
+ private = g_slice_new0 (ImageScaleDialog);
- dialog->image = image;
- dialog->dialog = scale_dialog_new (GIMP_VIEWABLE (image), context,
- C_("dialog-title", "Scale Image"),
- "gimp-image-scale",
- parent,
- gimp_standard_help_func,
- GIMP_HELP_IMAGE_SCALE,
- unit,
- interpolation,
- image_scale_callback,
- dialog);
+ private->image = image;
+ private->callback = callback;
+ private->user_data = user_data;
- g_object_weak_ref (G_OBJECT (dialog->dialog),
- (GWeakNotify) image_scale_dialog_free, dialog);
+ private->dialog = scale_dialog_new (GIMP_VIEWABLE (image), context,
+ C_("dialog-title", "Scale Image"),
+ "gimp-image-scale",
+ parent,
+ gimp_standard_help_func,
+ GIMP_HELP_IMAGE_SCALE,
+ unit,
+ interpolation,
+ image_scale_callback,
+ private);
- dialog->callback = callback;
- dialog->user_data = user_data;
+ g_object_weak_ref (G_OBJECT (private->dialog),
+ (GWeakNotify) image_scale_dialog_free, private);
- return dialog->dialog;
+ return private->dialog;
+}
+
+
+/* private functions */
+
+static void
+image_scale_dialog_free (ImageScaleDialog *private)
+{
+ g_slice_free (ImageScaleDialog, private);
}
static void
@@ -139,19 +149,19 @@ image_scale_callback (GtkWidget *widget,
GimpUnit resolution_unit,
gpointer data)
{
- ImageScaleDialog *dialog = data;
- GimpImage *image = GIMP_IMAGE (viewable);
+ ImageScaleDialog *private = data;
+ GimpImage *image = GIMP_IMAGE (viewable);
GimpImageScaleCheckType scale_check;
gint64 max_memsize;
gint64 new_memsize;
- dialog->width = width;
- dialog->height = height;
- dialog->unit = unit;
- dialog->interpolation = interpolation;
- dialog->xresolution = xresolution;
- dialog->yresolution = yresolution;
- dialog->resolution_unit = resolution_unit;
+ private->width = width;
+ private->height = height;
+ private->unit = unit;
+ private->interpolation = interpolation;
+ private->xresolution = xresolution;
+ private->yresolution = yresolution;
+ private->resolution_unit = resolution_unit;
gtk_widget_set_sensitive (widget, FALSE);
@@ -163,48 +173,36 @@ image_scale_callback (GtkWidget *widget,
switch (scale_check)
{
case GIMP_IMAGE_SCALE_TOO_BIG:
- image_scale_confirm_large (dialog, new_memsize, max_memsize);
+ image_scale_confirm_large (private, new_memsize, max_memsize);
break;
case GIMP_IMAGE_SCALE_TOO_SMALL:
- image_scale_confirm_small (dialog);
+ image_scale_confirm_small (private);
break;
case GIMP_IMAGE_SCALE_OK:
- gtk_widget_hide (widget);
- dialog->callback (dialog->dialog,
- GIMP_VIEWABLE (dialog->image),
- dialog->width,
- dialog->height,
- dialog->unit,
- dialog->interpolation,
- dialog->xresolution,
- dialog->yresolution,
- dialog->resolution_unit,
- dialog->user_data);
- gtk_widget_destroy (widget);
-
- /* remember the last used unit */
- g_object_set_data (G_OBJECT (image),
- "scale-dialog-unit", GINT_TO_POINTER (unit));
+ private->callback (private->dialog,
+ GIMP_VIEWABLE (private->image),
+ private->width,
+ private->height,
+ private->unit,
+ private->interpolation,
+ private->xresolution,
+ private->yresolution,
+ private->resolution_unit,
+ private->user_data);
break;
}
}
-static void
-image_scale_dialog_free (ImageScaleDialog *dialog)
-{
- g_slice_free (ImageScaleDialog, dialog);
-}
-
static GtkWidget *
-image_scale_confirm_dialog (ImageScaleDialog *dialog)
+image_scale_confirm_dialog (ImageScaleDialog *private)
{
GtkWidget *widget;
widget = gimp_message_dialog_new (_("Confirm Scaling"),
GIMP_STOCK_WARNING,
- dialog->dialog,
+ private->dialog,
GTK_DIALOG_DESTROY_WITH_PARENT,
gimp_standard_help_func,
GIMP_HELP_IMAGE_SCALE_WARNING,
@@ -221,17 +219,17 @@ image_scale_confirm_dialog (ImageScaleDialog *dialog)
g_signal_connect (widget, "response",
G_CALLBACK (image_scale_confirm_response),
- dialog);
+ private);
return widget;
}
static void
-image_scale_confirm_large (ImageScaleDialog *dialog,
+image_scale_confirm_large (ImageScaleDialog *private,
gint64 new_memsize,
gint64 max_memsize)
{
- GtkWidget *widget = image_scale_confirm_dialog (dialog);
+ GtkWidget *widget = image_scale_confirm_dialog (private);
gchar *size;
size = g_format_size (new_memsize);
@@ -252,9 +250,9 @@ image_scale_confirm_large (ImageScaleDialog *dialog,
}
static void
-image_scale_confirm_small (ImageScaleDialog *dialog)
+image_scale_confirm_small (ImageScaleDialog *private)
{
- GtkWidget *widget = image_scale_confirm_dialog (dialog);
+ GtkWidget *widget = image_scale_confirm_dialog (private);
gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (widget)->box,
_("Scaling the image to the chosen size "
@@ -269,27 +267,25 @@ image_scale_confirm_small (ImageScaleDialog *dialog)
static void
image_scale_confirm_response (GtkWidget *widget,
gint response_id,
- ImageScaleDialog *dialog)
+ ImageScaleDialog *private)
{
gtk_widget_destroy (widget);
if (response_id == GTK_RESPONSE_OK)
{
- gtk_widget_hide (dialog->dialog);
- dialog->callback (dialog->dialog,
- GIMP_VIEWABLE (dialog->image),
- dialog->width,
- dialog->height,
- dialog->unit,
- dialog->interpolation,
- dialog->xresolution,
- dialog->yresolution,
- dialog->resolution_unit,
- dialog->user_data);
- gtk_widget_destroy (dialog->dialog);
+ private->callback (private->dialog,
+ GIMP_VIEWABLE (private->image),
+ private->width,
+ private->height,
+ private->unit,
+ private->interpolation,
+ private->xresolution,
+ private->yresolution,
+ private->resolution_unit,
+ private->user_data);
}
else
{
- gtk_widget_set_sensitive (dialog->dialog, TRUE);
+ gtk_widget_set_sensitive (private->dialog, TRUE);
}
}
diff --git a/app/dialogs/layer-add-mask-dialog.c b/app/dialogs/layer-add-mask-dialog.c
index 8bea16d..8dd09ff 100644
--- a/app/dialogs/layer-add-mask-dialog.c
+++ b/app/dialogs/layer-add-mask-dialog.c
@@ -57,14 +57,14 @@ struct _LayerAddMaskDialog
/* local function prototypes */
+static void layer_add_mask_dialog_free (LayerAddMaskDialog *private);
+static void layer_add_mask_dialog_response (GtkWidget *dialog,
+ gint response_id,
+ LayerAddMaskDialog *private);
static gboolean layer_add_mask_dialog_channel_selected (GimpContainerView *view,
GimpViewable *viewable,
gpointer insert_data,
LayerAddMaskDialog *dialog);
-static void layer_add_mask_dialog_response (GtkWidget *dialog,
- gint response_id,
- LayerAddMaskDialog *private);
-static void layer_add_mask_dialog_free (LayerAddMaskDialog *private);
/* public functions */
@@ -112,12 +112,13 @@ layer_add_mask_dialog_new (GimpLayer *layer,
NULL);
- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
+ gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+
g_object_weak_ref (G_OBJECT (dialog),
(GWeakNotify) layer_add_mask_dialog_free, private);
@@ -179,15 +180,10 @@ layer_add_mask_dialog_new (GimpLayer *layer,
/* private functions */
-static gboolean
-layer_add_mask_dialog_channel_selected (GimpContainerView *view,
- GimpViewable *viewable,
- gpointer insert_data,
- LayerAddMaskDialog *private)
+static void
+layer_add_mask_dialog_free (LayerAddMaskDialog *private)
{
- private->channel = GIMP_CHANNEL (viewable);
-
- return TRUE;
+ g_slice_free (LayerAddMaskDialog, private);
}
static void
@@ -221,8 +217,13 @@ layer_add_mask_dialog_response (GtkWidget *dialog,
}
}
-static void
-layer_add_mask_dialog_free (LayerAddMaskDialog *private)
+static gboolean
+layer_add_mask_dialog_channel_selected (GimpContainerView *view,
+ GimpViewable *viewable,
+ gpointer insert_data,
+ LayerAddMaskDialog *private)
{
- g_slice_free (LayerAddMaskDialog, private);
+ private->channel = GIMP_CHANNEL (viewable);
+
+ return TRUE;
}
diff --git a/app/dialogs/module-dialog.c b/app/dialogs/module-dialog.c
index 2f826ab..a52aded 100644
--- a/app/dialogs/module-dialog.c
+++ b/app/dialogs/module-dialog.c
@@ -60,7 +60,9 @@ enum
N_INFOS
};
-typedef struct
+typedef struct _ModuleDialog ModuleDialog;
+
+struct _ModuleDialog
{
Gimp *gimp;
@@ -72,33 +74,33 @@ typedef struct
GtkWidget *label[N_INFOS];
GtkWidget *error_box;
GtkWidget *error_label;
-} ModuleDialog;
+};
/* local function prototypes */
static void dialog_response (GtkWidget *widget,
gint response_id,
- ModuleDialog *dialog);
+ ModuleDialog *private);
static void dialog_destroy_callback (GtkWidget *widget,
- ModuleDialog *dialog);
+ ModuleDialog *private);
static void dialog_select_callback (GtkTreeSelection *sel,
- ModuleDialog *dialog);
+ ModuleDialog *private);
static void dialog_enabled_toggled (GtkCellRendererToggle *celltoggle,
const gchar *path_string,
- ModuleDialog *dialog);
+ ModuleDialog *private);
static void make_list_item (gpointer data,
gpointer user_data);
static void dialog_info_add (GimpModuleDB *db,
GimpModule *module,
- ModuleDialog *dialog);
+ ModuleDialog *private);
static void dialog_info_remove (GimpModuleDB *db,
GimpModule *module,
- ModuleDialog *dialog);
+ ModuleDialog *private);
static void dialog_info_update (GimpModuleDB *db,
GimpModule *module,
- ModuleDialog *dialog);
-static void dialog_info_init (ModuleDialog *dialog,
+ ModuleDialog *private);
+static void dialog_info_init (ModuleDialog *private,
GtkWidget *table);
@@ -107,12 +109,12 @@ static void dialog_info_init (ModuleDialog *dialog,
GtkWidget *
module_dialog_new (Gimp *gimp)
{
- GtkWidget *shell;
+ ModuleDialog *private;
+ GtkWidget *dialog;
GtkWidget *vbox;
GtkWidget *sw;
GtkWidget *view;
GtkWidget *image;
- ModuleDialog *dialog;
GtkTreeSelection *sel;
GtkTreeIter iter;
GtkTreeViewColumn *col;
@@ -120,40 +122,40 @@ module_dialog_new (Gimp *gimp)
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
- dialog = g_slice_new0 (ModuleDialog);
+ private = g_slice_new0 (ModuleDialog);
- dialog->gimp = gimp;
+ private->gimp = gimp;
- shell = gimp_dialog_new (_("Module Manager"),
- "gimp-modules", NULL, 0,
- gimp_standard_help_func, GIMP_HELP_MODULE_DIALOG,
+ dialog = gimp_dialog_new (_("Module Manager"),
+ "gimp-modules", NULL, 0,
+ gimp_standard_help_func, GIMP_HELP_MODULE_DIALOG,
- GTK_STOCK_REFRESH, RESPONSE_REFRESH,
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+ GTK_STOCK_REFRESH, RESPONSE_REFRESH,
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
- NULL);
+ NULL);
- gtk_dialog_set_alternative_button_order (GTK_DIALOG (shell),
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_CLOSE,
RESPONSE_REFRESH,
-1);
- g_signal_connect (shell, "response",
+ g_signal_connect (dialog, "response",
G_CALLBACK (dialog_response),
- dialog);
+ private);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (shell))),
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
vbox, TRUE, TRUE, 0);
gtk_widget_show (vbox);
- dialog->hint = gimp_hint_box_new (_("You will have to restart GIMP "
- "for the changes to take effect."));
- gtk_box_pack_start (GTK_BOX (vbox), dialog->hint, FALSE, FALSE, 0);
+ private->hint = gimp_hint_box_new (_("You will have to restart GIMP "
+ "for the changes to take effect."));
+ gtk_box_pack_start (GTK_BOX (vbox), private->hint, FALSE, FALSE, 0);
if (gimp->write_modulerc)
- gtk_widget_show (dialog->hint);
+ gtk_widget_show (private->hint);
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
@@ -165,22 +167,22 @@ module_dialog_new (Gimp *gimp)
gtk_widget_set_size_request (sw, 124, 100);
gtk_widget_show (sw);
- dialog->list = gtk_list_store_new (N_COLUMNS,
- G_TYPE_STRING,
- G_TYPE_BOOLEAN,
- GIMP_TYPE_MODULE);
- view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (dialog->list));
- g_object_unref (dialog->list);
+ private->list = gtk_list_store_new (N_COLUMNS,
+ G_TYPE_STRING,
+ G_TYPE_BOOLEAN,
+ GIMP_TYPE_MODULE);
+ view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (private->list));
+ g_object_unref (private->list);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), FALSE);
- g_list_foreach (gimp->module_db->modules, make_list_item, dialog);
+ g_list_foreach (gimp->module_db->modules, make_list_item, private);
rend = gtk_cell_renderer_toggle_new ();
g_signal_connect (rend, "toggled",
G_CALLBACK (dialog_enabled_toggled),
- dialog);
+ private);
col = gtk_tree_view_column_new ();
gtk_tree_view_column_pack_start (col, rend, FALSE);
@@ -197,35 +199,35 @@ module_dialog_new (Gimp *gimp)
gtk_container_add (GTK_CONTAINER (sw), view);
gtk_widget_show (view);
- dialog->table = gtk_table_new (2, N_INFOS, FALSE);
- gtk_table_set_col_spacings (GTK_TABLE (dialog->table), 6);
- gtk_box_pack_start (GTK_BOX (vbox), dialog->table, FALSE, FALSE, 0);
- gtk_widget_show (dialog->table);
+ private->table = gtk_table_new (2, N_INFOS, FALSE);
+ gtk_table_set_col_spacings (GTK_TABLE (private->table), 6);
+ gtk_box_pack_start (GTK_BOX (vbox), private->table, FALSE, FALSE, 0);
+ gtk_widget_show (private->table);
- dialog->error_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_box_pack_start (GTK_BOX (vbox), dialog->error_box, FALSE, FALSE, 0);
+ private->error_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ gtk_box_pack_start (GTK_BOX (vbox), private->error_box, FALSE, FALSE, 0);
image = gtk_image_new_from_icon_name (GIMP_STOCK_WARNING, GTK_ICON_SIZE_BUTTON);
- gtk_box_pack_start (GTK_BOX (dialog->error_box), image, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (private->error_box), image, FALSE, FALSE, 0);
gtk_widget_show (image);
- dialog->error_label = gtk_label_new (NULL);
- gtk_label_set_xalign (GTK_LABEL (dialog->error_label), 0.0);
- gtk_box_pack_start (GTK_BOX (dialog->error_box),
- dialog->error_label, TRUE, TRUE, 0);
- gtk_widget_show (dialog->error_label);
+ private->error_label = gtk_label_new (NULL);
+ gtk_label_set_xalign (GTK_LABEL (private->error_label), 0.0);
+ gtk_box_pack_start (GTK_BOX (private->error_box),
+ private->error_label, TRUE, TRUE, 0);
+ gtk_widget_show (private->error_label);
- dialog_info_init (dialog, dialog->table);
+ dialog_info_init (private, private->table);
- dialog_info_update (gimp->module_db, dialog->selected, dialog);
+ dialog_info_update (gimp->module_db, private->selected, private);
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
g_signal_connect (sel, "changed",
G_CALLBACK (dialog_select_callback),
- dialog);
+ private);
- if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (dialog->list), &iter))
+ if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (private->list), &iter))
gtk_tree_selection_select_iter (sel, &iter);
/* hook the GimpModuleDB signals so we can refresh the display
@@ -233,19 +235,19 @@ module_dialog_new (Gimp *gimp)
*/
g_signal_connect (gimp->module_db, "add",
G_CALLBACK (dialog_info_add),
- dialog);
+ private);
g_signal_connect (gimp->module_db, "remove",
G_CALLBACK (dialog_info_remove),
- dialog);
+ private);
g_signal_connect (gimp->module_db, "module-modified",
G_CALLBACK (dialog_info_update),
- dialog);
+ private);
- g_signal_connect (shell, "destroy",
+ g_signal_connect (dialog, "destroy",
G_CALLBACK (dialog_destroy_callback),
- dialog);
+ private);
- return shell;
+ return dialog;
}
@@ -254,34 +256,34 @@ module_dialog_new (Gimp *gimp)
static void
dialog_response (GtkWidget *widget,
gint response_id,
- ModuleDialog *dialog)
+ ModuleDialog *private)
{
if (response_id == RESPONSE_REFRESH)
- gimp_modules_refresh (dialog->gimp);
+ gimp_modules_refresh (private->gimp);
else
gtk_widget_destroy (widget);
}
static void
dialog_destroy_callback (GtkWidget *widget,
- ModuleDialog *dialog)
+ ModuleDialog *private)
{
- g_signal_handlers_disconnect_by_func (dialog->gimp->module_db,
+ g_signal_handlers_disconnect_by_func (private->gimp->module_db,
dialog_info_add,
- dialog);
- g_signal_handlers_disconnect_by_func (dialog->gimp->module_db,
+ private);
+ g_signal_handlers_disconnect_by_func (private->gimp->module_db,
dialog_info_remove,
- dialog);
- g_signal_handlers_disconnect_by_func (dialog->gimp->module_db,
+ private);
+ g_signal_handlers_disconnect_by_func (private->gimp->module_db,
dialog_info_update,
- dialog);
+ private);
- g_slice_free (ModuleDialog, dialog);
+ g_slice_free (ModuleDialog, private);
}
static void
dialog_select_callback (GtkTreeSelection *sel,
- ModuleDialog *dialog)
+ ModuleDialog *private)
{
GtkTreeIter iter;
@@ -289,25 +291,25 @@ dialog_select_callback (GtkTreeSelection *sel,
{
GimpModule *module;
- gtk_tree_model_get (GTK_TREE_MODEL (dialog->list), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (private->list), &iter,
COLUMN_MODULE, &module, -1);
if (module)
g_object_unref (module);
- if (dialog->selected == module)
+ if (private->selected == module)
return;
- dialog->selected = module;
+ private->selected = module;
- dialog_info_update (dialog->gimp->module_db, dialog->selected, dialog);
+ dialog_info_update (private->gimp->module_db, private->selected, private);
}
}
static void
dialog_enabled_toggled (GtkCellRendererToggle *celltoggle,
const gchar *path_string,
- ModuleDialog *dialog)
+ ModuleDialog *private)
{
GtkTreePath *path;
GtkTreeIter iter;
@@ -315,7 +317,7 @@ dialog_enabled_toggled (GtkCellRendererToggle *celltoggle,
path = gtk_tree_path_new_from_string (path_string);
- if (! gtk_tree_model_get_iter (GTK_TREE_MODEL (dialog->list), &iter, path))
+ if (! gtk_tree_model_get_iter (GTK_TREE_MODEL (private->list), &iter, path))
{
g_warning ("%s: bad tree path?", G_STRFUNC);
return;
@@ -323,7 +325,7 @@ dialog_enabled_toggled (GtkCellRendererToggle *celltoggle,
gtk_tree_path_free (path);
- gtk_tree_model_get (GTK_TREE_MODEL (dialog->list), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (private->list), &iter,
COLUMN_MODULE, &module,
-1);
@@ -332,17 +334,17 @@ dialog_enabled_toggled (GtkCellRendererToggle *celltoggle,
gimp_module_set_load_inhibit (module, ! module->load_inhibit);
g_object_unref (module);
- dialog->gimp->write_modulerc = TRUE;
- gtk_widget_show (dialog->hint);
+ private->gimp->write_modulerc = TRUE;
+ gtk_widget_show (private->hint);
}
}
static void
-dialog_list_item_update (ModuleDialog *dialog,
+dialog_list_item_update (ModuleDialog *private,
GtkTreeIter *iter,
GimpModule *module)
{
- gtk_list_store_set (dialog->list, iter,
+ gtk_list_store_set (private->list, iter,
COLUMN_NAME, (module->info ?
gettext (module->info->purpose) :
gimp_filename_to_utf8 (module->filename)),
@@ -356,42 +358,42 @@ make_list_item (gpointer data,
gpointer user_data)
{
GimpModule *module = data;
- ModuleDialog *dialog = user_data;
+ ModuleDialog *private = user_data;
GtkTreeIter iter;
- if (! dialog->selected)
- dialog->selected = module;
+ if (! private->selected)
+ private->selected = module;
- gtk_list_store_append (dialog->list, &iter);
+ gtk_list_store_append (private->list, &iter);
- dialog_list_item_update (dialog, &iter, module);
+ dialog_list_item_update (private, &iter, module);
}
static void
dialog_info_add (GimpModuleDB *db,
GimpModule *module,
- ModuleDialog *dialog)
+ ModuleDialog *private)
{
- make_list_item (module, dialog);
+ make_list_item (module, private);
}
static void
dialog_info_remove (GimpModuleDB *db,
GimpModule *module,
- ModuleDialog *dialog)
+ ModuleDialog *private)
{
GtkTreeIter iter;
/* FIXME: Use gtk_list_store_foreach_remove when it becomes available */
- if (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (dialog->list), &iter))
+ if (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (private->list), &iter))
return;
do
{
GimpModule *this;
- gtk_tree_model_get (GTK_TREE_MODEL (dialog->list), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (private->list), &iter,
COLUMN_MODULE, &this,
-1);
@@ -400,11 +402,11 @@ dialog_info_remove (GimpModuleDB *db,
if (this == module)
{
- gtk_list_store_remove (dialog->list, &iter);
+ gtk_list_store_remove (private->list, &iter);
return;
}
}
- while (gtk_tree_model_iter_next (GTK_TREE_MODEL (dialog->list), &iter));
+ while (gtk_tree_model_iter_next (GTK_TREE_MODEL (private->list), &iter));
g_warning ("%s: Tried to remove a module not in the dialog's list.",
G_STRFUNC);
@@ -413,12 +415,12 @@ dialog_info_remove (GimpModuleDB *db,
static void
dialog_info_update (GimpModuleDB *db,
GimpModule *module,
- ModuleDialog *dialog)
+ ModuleDialog *private)
{
- GtkTreeModel *model = GTK_TREE_MODEL (dialog->list);
+ GtkTreeModel *model = GTK_TREE_MODEL (private->list);
GtkTreeIter iter;
const gchar *text[N_INFOS] = { NULL, };
- gchar *location = NULL;
+ gchar *location = NULL;
gboolean iter_valid;
gint i;
gboolean show_error;
@@ -440,19 +442,19 @@ dialog_info_update (GimpModuleDB *db,
}
if (iter_valid)
- dialog_list_item_update (dialog, &iter, module);
+ dialog_list_item_update (private, &iter, module);
/* only update the info if we're actually showing it */
- if (module != dialog->selected)
+ if (module != private->selected)
return;
if (! module)
{
for (i = 0; i < N_INFOS; i++)
- gtk_label_set_text (GTK_LABEL (dialog->label[i]), NULL);
+ gtk_label_set_text (GTK_LABEL (private->label[i]), NULL);
- gtk_label_set_text (GTK_LABEL (dialog->error_label), NULL);
- gtk_widget_hide (dialog->error_box);
+ gtk_label_set_text (GTK_LABEL (private->error_label), NULL);
+ gtk_widget_hide (private->error_box);
return;
}
@@ -475,20 +477,20 @@ dialog_info_update (GimpModuleDB *db,
}
for (i = 0; i < N_INFOS; i++)
- gtk_label_set_text (GTK_LABEL (dialog->label[i]),
+ gtk_label_set_text (GTK_LABEL (private->label[i]),
text[i] ? text[i] : "--");
g_free (location);
/* Show errors */
show_error = (module->state == GIMP_MODULE_STATE_ERROR &&
module->last_module_error);
- gtk_label_set_text (GTK_LABEL (dialog->error_label),
+ gtk_label_set_text (GTK_LABEL (private->error_label),
show_error ? module->last_module_error : NULL);
- gtk_widget_set_visible (dialog->error_box, show_error);
+ gtk_widget_set_visible (private->error_box, show_error);
}
static void
-dialog_info_init (ModuleDialog *dialog,
+dialog_info_init (ModuleDialog *private,
GtkWidget *table)
{
GtkWidget *label;
@@ -511,13 +513,13 @@ dialog_info_init (ModuleDialog *dialog,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 2);
gtk_widget_show (label);
- dialog->label[i] = gtk_label_new ("");
- gtk_label_set_xalign (GTK_LABEL (dialog->label[i]), 0.0);
- gtk_label_set_ellipsize (GTK_LABEL (dialog->label[i]),
+ private->label[i] = gtk_label_new ("");
+ gtk_label_set_xalign (GTK_LABEL (private->label[i]), 0.0);
+ gtk_label_set_ellipsize (GTK_LABEL (private->label[i]),
PANGO_ELLIPSIZE_END);
- gtk_table_attach (GTK_TABLE (dialog->table), dialog->label[i],
+ gtk_table_attach (GTK_TABLE (private->table), private->label[i],
1, 2, i, i + 1,
GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 2);
- gtk_widget_show (dialog->label[i]);
+ gtk_widget_show (private->label[i]);
}
}
diff --git a/app/dialogs/offset-dialog.c b/app/dialogs/offset-dialog.c
index 52bf96b..450b94e 100644
--- a/app/dialogs/offset-dialog.c
+++ b/app/dialogs/offset-dialog.c
@@ -45,7 +45,9 @@
#define FILL_MASK (GIMP_OFFSET_BACKGROUND | GIMP_OFFSET_TRANSPARENT)
-typedef struct
+typedef struct _OffsetDialog OffsetDialog;
+
+struct _OffsetDialog
{
GimpDrawable *drawable;
GimpContext *context;
@@ -54,11 +56,12 @@ typedef struct
gpointer user_data;
GtkWidget *off_se;
-} OffsetDialog;
+};
/* local function prototypes */
+static void offset_dialog_free (OffsetDialog *private);
static void offset_dialog_response (GtkWidget *dialog,
gint response_id,
OffsetDialog *private);
@@ -68,7 +71,6 @@ static void offset_dialog_half_x_callback (GtkWidget *widget,
OffsetDialog *private);
static void offset_dialog_half_y_callback (GtkWidget *widget,
OffsetDialog *private);
-static void offset_dialog_free (OffsetDialog *private);
/* public functions */
@@ -272,6 +274,12 @@ offset_dialog_new (GimpDrawable *drawable,
/* private functions */
static void
+offset_dialog_free (OffsetDialog *private)
+{
+ g_slice_free (OffsetDialog, private);
+}
+
+static void
offset_dialog_response (GtkWidget *dialog,
gint response_id,
OffsetDialog *private)
@@ -333,9 +341,3 @@ offset_dialog_half_y_callback (GtkWidget *widget,
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->off_se),
1, gimp_item_get_height (item) / 2);
}
-
-static void
-offset_dialog_free (OffsetDialog *private)
-{
- g_slice_free (OffsetDialog, private);
-}
diff --git a/app/dialogs/palette-import-dialog.c b/app/dialogs/palette-import-dialog.c
index 7aa032d..425dd78 100644
--- a/app/dialogs/palette-import-dialog.c
+++ b/app/dialogs/palette-import-dialog.c
@@ -56,7 +56,9 @@ typedef enum
} ImportType;
-typedef struct
+typedef struct _ImportDialog ImportDialog;
+
+struct _ImportDialog
{
GtkWidget *dialog;
@@ -84,7 +86,7 @@ typedef struct
GtkWidget *preview;
GtkWidget *no_colors_label;
-} ImportDialog;
+};
static void palette_import_free (ImportDialog *private);
diff --git a/app/dialogs/print-size-dialog.c b/app/dialogs/print-size-dialog.c
index 086d703..7597b7a 100644
--- a/app/dialogs/print-size-dialog.c
+++ b/app/dialogs/print-size-dialog.c
@@ -41,7 +41,9 @@
#define SB_WIDTH 8
-typedef struct
+typedef struct _PrintSizeDialog PrintSizeDialog;
+
+struct _PrintSizeDialog
{
GimpImage *image;
GimpSizeEntry *size_entry;
@@ -51,13 +53,16 @@ typedef struct
gdouble yres;
GimpResolutionCallback callback;
gpointer user_data;
-} PrintSizeDialog;
+};
+
+/* local function prototypes */
-static void print_size_dialog_response (GtkWidget *dialog,
- gint response_id,
- PrintSizeDialog *private);
-static void print_size_dialog_reset (PrintSizeDialog *private);
+static void print_size_dialog_free (PrintSizeDialog *private);
+static void print_size_dialog_response (GtkWidget *dialog,
+ gint response_id,
+ PrintSizeDialog *private);
+static void print_size_dialog_reset (PrintSizeDialog *private);
static void print_size_dialog_size_changed (GtkWidget *widget,
PrintSizeDialog *private);
@@ -69,9 +74,10 @@ static void print_size_dialog_set_size (PrintSizeDialog *private,
static void print_size_dialog_set_resolution (PrintSizeDialog *private,
gdouble xres,
gdouble yres);
-static void print_size_dialog_free (PrintSizeDialog *private);
+/* public functions */
+
GtkWidget *
print_size_dialog_new (GimpImage *image,
GimpContext *context,
@@ -100,6 +106,14 @@ print_size_dialog_new (GimpImage *image,
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (callback != NULL, NULL);
+ private = g_slice_new0 (PrintSizeDialog);
+
+ private->image = image;
+ private->callback = callback;
+ private->user_data = user_data;
+
+ gimp_image_get_resolution (image, &private->xres, &private->yres);
+
dialog = gimp_viewable_dialog_new (GIMP_VIEWABLE (image), context,
title, role,
GIMP_STOCK_PRINT_RESOLUTION, title,
@@ -112,9 +126,13 @@ print_size_dialog_new (GimpImage *image,
NULL);
- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
+ RESPONSE_RESET,
+ GTK_RESPONSE_OK,
+ GTK_RESPONSE_CANCEL,
+ -1);
- private = g_slice_new0 (PrintSizeDialog);
+ gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
g_object_weak_ref (G_OBJECT (dialog),
(GWeakNotify) print_size_dialog_free, private);
@@ -123,18 +141,6 @@ print_size_dialog_new (GimpImage *image,
G_CALLBACK (print_size_dialog_response),
private);
- gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
- RESPONSE_RESET,
- GTK_RESPONSE_OK,
- GTK_RESPONSE_CANCEL,
- -1);
-
- private->image = image;
- private->callback = callback;
- private->user_data = user_data;
-
- gimp_image_get_resolution (image, &private->xres, &private->yres);
-
frame = gimp_frame_new (_("Print Size"));
gtk_container_set_border_width (GTK_CONTAINER (frame), 12);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
@@ -303,6 +309,15 @@ print_size_dialog_new (GimpImage *image,
return dialog;
}
+
+/* private functions */
+
+static void
+print_size_dialog_free (PrintSizeDialog *private)
+{
+ g_slice_free (PrintSizeDialog, private);
+}
+
static void
print_size_dialog_response (GtkWidget *dialog,
gint response_id,
@@ -437,9 +452,3 @@ print_size_dialog_set_resolution (PrintSizeDialog *private,
print_size_dialog_size_changed,
private);
}
-
-static void
-print_size_dialog_free (PrintSizeDialog *private)
-{
- g_slice_free (PrintSizeDialog, private);
-}
diff --git a/app/dialogs/resize-dialog.c b/app/dialogs/resize-dialog.c
index 6c5b6bc..0d46668 100644
--- a/app/dialogs/resize-dialog.c
+++ b/app/dialogs/resize-dialog.c
@@ -43,7 +43,9 @@
#define SB_WIDTH 8
-typedef struct
+typedef struct _ResizeDialog ResizeDialog;
+
+struct _ResizeDialog
{
GimpViewable *viewable;
GimpContext *context;
@@ -66,14 +68,16 @@ typedef struct
GtkWidget *layer_set_combo;
GtkWidget *fill_type_combo;
GtkWidget *text_layers_button;
-} ResizeDialog;
+};
+
+/* local function prototypes */
+static void resize_dialog_free (ResizeDialog *private);
static void resize_dialog_response (GtkWidget *dialog,
gint response_id,
ResizeDialog *private);
static void resize_dialog_reset (ResizeDialog *private);
-static void resize_dialog_free (ResizeDialog *private);
static void size_notify (GimpSizeBox *box,
GParamSpec *pspec,
@@ -88,6 +92,8 @@ static void offset_center_clicked (GtkWidget *widget,
ResizeDialog *private);
+/* public function */
+
GtkWidget *
resize_dialog_new (GimpViewable *viewable,
GimpContext *context,
@@ -182,14 +188,14 @@ resize_dialog_new (GimpViewable *viewable,
NULL);
- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
-
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
RESPONSE_RESET,
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
+ gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+
g_object_weak_ref (G_OBJECT (dialog),
(GWeakNotify) resize_dialog_free, private);
@@ -390,6 +396,15 @@ resize_dialog_new (GimpViewable *viewable,
return dialog;
}
+
+/* private functions */
+
+static void
+resize_dialog_free (ResizeDialog *private)
+{
+ g_slice_free (ResizeDialog, private);
+}
+
static void
resize_dialog_response (GtkWidget *dialog,
gint response_id,
@@ -459,12 +474,6 @@ resize_dialog_reset (ResizeDialog *private)
}
static void
-resize_dialog_free (ResizeDialog *private)
-{
- g_slice_free (ResizeDialog, private);
-}
-
-static void
size_notify (GimpSizeBox *box,
GParamSpec *pspec,
ResizeDialog *private)
diff --git a/app/dialogs/scale-dialog.c b/app/dialogs/scale-dialog.c
index d937ccd..9cbd897 100644
--- a/app/dialogs/scale-dialog.c
+++ b/app/dialogs/scale-dialog.c
@@ -40,8 +40,9 @@
#define RESPONSE_RESET 1
+typedef struct _ScaleDialog ScaleDialog;
-typedef struct
+struct _ScaleDialog
{
GimpViewable *viewable;
GimpUnit unit;
@@ -50,16 +51,20 @@ typedef struct
GtkWidget *combo;
GimpScaleCallback callback;
gpointer user_data;
-} ScaleDialog;
+};
+/* local function prototypes */
+
+static void scale_dialog_free (ScaleDialog *private);
static void scale_dialog_response (GtkWidget *dialog,
gint response_id,
ScaleDialog *private);
static void scale_dialog_reset (ScaleDialog *private);
-static void scale_dialog_free (ScaleDialog *private);
+/* public function */
+
GtkWidget *
scale_dialog_new (GimpViewable *viewable,
GimpContext *context,
@@ -113,6 +118,16 @@ scale_dialog_new (GimpViewable *viewable,
g_return_val_if_reached (NULL);
}
+ private = g_slice_new0 (ScaleDialog);
+
+ private->viewable = viewable;
+ private->interpolation = interpolation;
+ private->unit = unit;
+ private->callback = callback;
+ private->user_data = user_data;
+
+ gimp_image_get_resolution (image, &xres, &yres);
+
dialog = gimp_viewable_dialog_new (viewable, context,
title, role, GIMP_STOCK_SCALE, title,
parent,
@@ -132,18 +147,12 @@ scale_dialog_new (GimpViewable *viewable,
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
- private = g_slice_new0 (ScaleDialog);
-
g_object_weak_ref (G_OBJECT (dialog),
(GWeakNotify) scale_dialog_free, private);
- private->viewable = viewable;
- private->interpolation = interpolation;
- private->unit = unit;
- private->callback = callback;
- private->user_data = user_data;
-
- gimp_image_get_resolution (image, &xres, &yres);
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (scale_dialog_response),
+ private);
private->box = g_object_new (GIMP_TYPE_SIZE_BOX,
"width", width,
@@ -156,10 +165,6 @@ scale_dialog_new (GimpViewable *viewable,
"edit-resolution", GIMP_IS_IMAGE (viewable),
NULL);
- g_signal_connect (dialog, "response",
- G_CALLBACK (scale_dialog_response),
- private);
-
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
@@ -217,6 +222,15 @@ scale_dialog_new (GimpViewable *viewable,
return dialog;
}
+
+/* private functions */
+
+static void
+scale_dialog_free (ScaleDialog *private)
+{
+ g_slice_free (ScaleDialog, private);
+}
+
static void
scale_dialog_response (GtkWidget *dialog,
gint response_id,
@@ -310,9 +324,3 @@ scale_dialog_reset (ScaleDialog *private)
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (private->combo),
private->interpolation);
}
-
-static void
-scale_dialog_free (ScaleDialog *private)
-{
- g_slice_free (ScaleDialog, private);
-}
diff --git a/app/dialogs/stroke-dialog.c b/app/dialogs/stroke-dialog.c
index bb87fd2..510f0d7 100644
--- a/app/dialogs/stroke-dialog.c
+++ b/app/dialogs/stroke-dialog.c
@@ -47,7 +47,9 @@
#define RESPONSE_RESET 1
-typedef struct
+typedef struct _StrokeDialog StrokeDialog;
+
+struct _StrokeDialog
{
GimpItem *item;
GimpDrawable *drawable;
@@ -57,15 +59,15 @@ typedef struct
gpointer user_data;
GtkWidget *tool_combo;
-} StrokeDialog;
+};
-/* local functions */
+/* local function prototypes */
+static void stroke_dialog_free (StrokeDialog *private);
static void stroke_dialog_response (GtkWidget *dialog,
gint response_id,
StrokeDialog *private);
-static void stroke_dialog_free (StrokeDialog *private);
/* public function */
@@ -259,6 +261,14 @@ stroke_dialog_new (GimpItem *item,
/* private functions */
static void
+stroke_dialog_free (StrokeDialog *private)
+{
+ g_object_unref (private->options);
+
+ g_slice_free (StrokeDialog, private);
+}
+
+static void
stroke_dialog_response (GtkWidget *dialog,
gint response_id,
StrokeDialog *private)
@@ -291,11 +301,3 @@ stroke_dialog_response (GtkWidget *dialog,
break;
}
}
-
-static void
-stroke_dialog_free (StrokeDialog *private)
-{
- g_object_unref (private->options);
-
- g_slice_free (StrokeDialog, private);
-}
diff --git a/app/dialogs/template-options-dialog.c b/app/dialogs/template-options-dialog.c
index 80c96e3..393514d 100644
--- a/app/dialogs/template-options-dialog.c
+++ b/app/dialogs/template-options-dialog.c
@@ -39,9 +39,13 @@
#include "gimp-intl.h"
+/* local function prototypes */
+
static void template_options_dialog_free (TemplateOptionsDialog *dialog);
+/* public function */
+
TemplateOptionsDialog *
template_options_dialog_new (GimpTemplate *template,
GimpContext *context,
@@ -119,6 +123,9 @@ template_options_dialog_new (GimpTemplate *template,
return options;
}
+
+/* private functions */
+
static void
template_options_dialog_free (TemplateOptionsDialog *dialog)
{
diff --git a/app/dialogs/vectors-export-dialog.c b/app/dialogs/vectors-export-dialog.c
index 3b88c65..db9608d 100644
--- a/app/dialogs/vectors-export-dialog.c
+++ b/app/dialogs/vectors-export-dialog.c
@@ -31,78 +31,151 @@
#include "gimp-intl.h"
-static void vectors_export_dialog_free (VectorsExportDialog *dialog);
+typedef struct _VectorsExportDialog VectorsExportDialog;
+struct _VectorsExportDialog
+{
+ GimpImage *image;
+ gboolean active_only;
+ GimpVectorsExportCallback callback;
+ gpointer user_data;
+};
+
+
+/* local function prototypes */
+
+static void vectors_export_dialog_free (VectorsExportDialog *private);
+static void vectors_export_dialog_response (GtkWidget *widget,
+ gint response_id,
+ VectorsExportDialog *private);
-VectorsExportDialog *
-vectors_export_dialog_new (GimpImage *image,
- GtkWidget *parent,
- gboolean active_only)
+
+/* public function */
+
+GtkWidget *
+vectors_export_dialog_new (GimpImage *image,
+ GtkWidget *parent,
+ GFile *export_folder,
+ gboolean active_only,
+ GimpVectorsExportCallback callback,
+ gpointer user_data)
{
- VectorsExportDialog *dialog;
+ VectorsExportDialog *private;
+ GtkWidget *dialog;
GtkWidget *combo;
- GtkFileChooser *chooser;
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (GTK_IS_WIDGET (parent), NULL);
+ g_return_val_if_fail (export_folder == NULL || G_IS_FILE (export_folder),
+ NULL);
+ g_return_val_if_fail (callback != NULL, NULL);
- dialog = g_slice_new0 (VectorsExportDialog);
+ private = g_slice_new0 (VectorsExportDialog);
- dialog->image = image;
- dialog->active_only = active_only;
+ private->image = image;
+ private->active_only = active_only;
+ private->callback = callback;
+ private->user_data = user_data;
- dialog->dialog =
- gtk_file_chooser_dialog_new (_("Export Path to SVG"), NULL,
- GTK_FILE_CHOOSER_ACTION_SAVE,
+ dialog = gtk_file_chooser_dialog_new (_("Export Path to SVG"), NULL,
+ GTK_FILE_CHOOSER_ACTION_SAVE,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_SAVE, GTK_RESPONSE_OK,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_OK,
- NULL);
+ NULL);
- chooser = GTK_FILE_CHOOSER (dialog->dialog);
-
- gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog->dialog),
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
- gtk_window_set_screen (GTK_WINDOW (dialog->dialog),
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+
+ gtk_window_set_screen (GTK_WINDOW (dialog),
gtk_widget_get_screen (parent));
- gtk_window_set_role (GTK_WINDOW (dialog->dialog), "gimp-vectors-export");
- gtk_window_set_position (GTK_WINDOW (dialog->dialog), GTK_WIN_POS_MOUSE);
+ gtk_window_set_role (GTK_WINDOW (dialog), "gimp-vectors-export");
+ gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
- gtk_dialog_set_default_response (GTK_DIALOG (chooser), GTK_RESPONSE_OK);
- gtk_file_chooser_set_do_overwrite_confirmation (chooser, TRUE);
+ gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog),
+ TRUE);
- g_object_weak_ref (G_OBJECT (dialog->dialog),
- (GWeakNotify) vectors_export_dialog_free, dialog);
+ if (export_folder)
+ gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog),
+ export_folder, NULL);
+
+ g_object_weak_ref (G_OBJECT (dialog),
+ (GWeakNotify) vectors_export_dialog_free, private);
g_signal_connect_object (image, "disconnect",
G_CALLBACK (gtk_widget_destroy),
- dialog->dialog, 0);
+ dialog, 0);
- g_signal_connect (dialog->dialog, "delete-event",
+ g_signal_connect (dialog, "delete-event",
G_CALLBACK (gtk_true),
NULL);
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (vectors_export_dialog_response),
+ private);
+
combo = gimp_int_combo_box_new (_("Export the active path"), TRUE,
_("Export all paths from this image"), FALSE,
NULL);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo),
- dialog->active_only);
- gtk_file_chooser_set_extra_widget (chooser, combo);
+ private->active_only);
+ gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), combo);
g_signal_connect (combo, "changed",
G_CALLBACK (gimp_int_combo_box_get_active),
- &dialog->active_only);
+ &private->active_only);
return dialog;
}
+
+/* private functions */
+
+static void
+vectors_export_dialog_free (VectorsExportDialog *private)
+{
+ g_slice_free (VectorsExportDialog, private);
+}
+
static void
-vectors_export_dialog_free (VectorsExportDialog *dialog)
+vectors_export_dialog_response (GtkWidget *dialog,
+ gint response_id,
+ VectorsExportDialog *private)
{
- g_slice_free (VectorsExportDialog, dialog);
+ if (response_id == GTK_RESPONSE_OK)
+ {
+ GtkFileChooser *chooser = GTK_FILE_CHOOSER (dialog);
+ GFile *file;
+
+ file = gtk_file_chooser_get_file (chooser);
+
+ if (file)
+ {
+ GFile *folder;
+
+ folder = gtk_file_chooser_get_current_folder_file (chooser);
+
+ private->callback (dialog,
+ private->image,
+ file,
+ folder,
+ private->active_only,
+ private->user_data);
+
+ if (folder)
+ g_object_unref (folder);
+
+ g_object_unref (file);
+ }
+ }
+ else
+ {
+ gtk_widget_destroy (dialog);
+ }
}
diff --git a/app/dialogs/vectors-export-dialog.h b/app/dialogs/vectors-export-dialog.h
index b016c9b..5b20e86 100644
--- a/app/dialogs/vectors-export-dialog.h
+++ b/app/dialogs/vectors-export-dialog.h
@@ -19,20 +19,20 @@
#define __VECTORS_EXPORT_DIALOG_H__
-typedef struct _VectorsExportDialog VectorsExportDialog;
-
-struct _VectorsExportDialog
-{
- GtkWidget *dialog;
-
- GimpImage *image;
- gboolean active_only;
-};
-
-
-VectorsExportDialog * vectors_export_dialog_new (GimpImage *image,
- GtkWidget *parent,
- gboolean active_only);
+typedef void (* GimpVectorsExportCallback) (GtkWidget *dialog,
+ GimpImage *image,
+ GFile *file,
+ GFile *export_folder,
+ gboolean active_only,
+ gpointer user_data);
+
+
+GtkWidget * vectors_export_dialog_new (GimpImage *image,
+ GtkWidget *parent,
+ GFile *export_folder,
+ gboolean active_only,
+ GimpVectorsExportCallback callback,
+ gpointer user_data);
#endif /* __VECTORS_EXPORT_DIALOG_H__ */
diff --git a/app/dialogs/vectors-import-dialog.c b/app/dialogs/vectors-import-dialog.c
index e094081..ce0fd8b 100644
--- a/app/dialogs/vectors-import-dialog.c
+++ b/app/dialogs/vectors-import-dialog.c
@@ -31,106 +31,182 @@
#include "gimp-intl.h"
-static void vectors_import_dialog_free (VectorsImportDialog *dialog);
+typedef struct _VectorsImportDialog VectorsImportDialog;
+struct _VectorsImportDialog
+{
+ GimpImage *image;
+ gboolean merge_vectors;
+ gboolean scale_vectors;
+ GimpVectorsImportCallback callback;
+ gpointer user_data;
+};
+
+
+/* local function prototypes */
+
+static void vectors_import_dialog_free (VectorsImportDialog *private);
+static void vectors_import_dialog_response (GtkWidget *dialog,
+ gint response_id,
+ VectorsImportDialog *private);
-VectorsImportDialog *
-vectors_import_dialog_new (GimpImage *image,
- GtkWidget *parent,
- gboolean merge_vectors,
- gboolean scale_vectors)
+
+/* public function */
+
+GtkWidget *
+vectors_import_dialog_new (GimpImage *image,
+ GtkWidget *parent,
+ GFile *import_folder,
+ gboolean merge_vectors,
+ gboolean scale_vectors,
+ GimpVectorsImportCallback callback,
+ gpointer user_data)
{
- VectorsImportDialog *dialog;
+ VectorsImportDialog *private;
+ GtkWidget *dialog;
GtkWidget *vbox;
GtkWidget *button;
GtkFileFilter *filter;
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (GTK_IS_WIDGET (parent), NULL);
+ g_return_val_if_fail (import_folder == NULL || G_IS_FILE (import_folder),
+ NULL);
+ g_return_val_if_fail (callback != NULL, NULL);
- dialog = g_slice_new0 (VectorsImportDialog);
+ private = g_slice_new0 (VectorsImportDialog);
- dialog->image = image;
- dialog->merge_vectors = merge_vectors;
- dialog->scale_vectors = scale_vectors;
+ private->image = image;
+ private->merge_vectors = merge_vectors;
+ private->scale_vectors = scale_vectors;
+ private->callback = callback;
+ private->user_data = user_data;
- dialog->dialog =
- gtk_file_chooser_dialog_new (_("Import Paths from SVG"), NULL,
- GTK_FILE_CHOOSER_ACTION_OPEN,
+ dialog = gtk_file_chooser_dialog_new (_("Import Paths from SVG"), NULL,
+ GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_OK,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_OK,
- NULL);
+ NULL);
- gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog->dialog),
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
- gtk_window_set_screen (GTK_WINDOW (dialog->dialog),
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog),
+ GTK_RESPONSE_OK);
+
+ gtk_window_set_screen (GTK_WINDOW (dialog),
gtk_widget_get_screen (parent));
- gtk_window_set_role (GTK_WINDOW (dialog->dialog), "gimp-vectors-import");
- gtk_window_set_position (GTK_WINDOW (dialog->dialog), GTK_WIN_POS_MOUSE);
+ gtk_window_set_role (GTK_WINDOW (dialog), "gimp-vectors-import");
+ gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog->dialog),
- GTK_RESPONSE_OK);
+ if (import_folder)
+ gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog),
+ import_folder, NULL);
- g_object_weak_ref (G_OBJECT (dialog->dialog),
- (GWeakNotify) vectors_import_dialog_free, dialog);
+ g_object_weak_ref (G_OBJECT (dialog),
+ (GWeakNotify) vectors_import_dialog_free, private);
g_signal_connect_object (image, "disconnect",
G_CALLBACK (gtk_widget_destroy),
- dialog->dialog, 0);
+ dialog, 0);
- g_signal_connect (dialog->dialog, "delete-event",
+ g_signal_connect (dialog, "delete-event",
G_CALLBACK (gtk_true),
NULL);
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (vectors_import_dialog_response),
+ private);
+
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, _("All files (*.*)"));
gtk_file_filter_add_pattern (filter, "*");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog->dialog), filter);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, _("Scalable SVG image (*.svg)"));
gtk_file_filter_add_pattern (filter, "*.[Ss][Vv][Gg]");
gtk_file_filter_add_mime_type (filter, "image/svg+xml");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog->dialog), filter);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog->dialog), filter);
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog->dialog), vbox);
+ gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), vbox);
gtk_widget_show (vbox);
button = gtk_check_button_new_with_mnemonic (_("_Merge imported paths"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
- dialog->merge_vectors);
+ private->merge_vectors);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
g_signal_connect (button, "toggled",
G_CALLBACK (gimp_toggle_button_update),
- &dialog->merge_vectors);
+ &private->merge_vectors);
button = gtk_check_button_new_with_mnemonic (_("_Scale imported paths "
"to fit image"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
- dialog->scale_vectors);
+ private->scale_vectors);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
g_signal_connect (button, "toggled",
G_CALLBACK (gimp_toggle_button_update),
- &dialog->scale_vectors);
+ &private->scale_vectors);
return dialog;
}
+
+/* private functions */
+
+static void
+vectors_import_dialog_free (VectorsImportDialog *private)
+{
+ g_slice_free (VectorsImportDialog, private);
+}
+
static void
-vectors_import_dialog_free (VectorsImportDialog *dialog)
+vectors_import_dialog_response (GtkWidget *dialog,
+ gint response_id,
+ VectorsImportDialog *private)
{
- g_slice_free (VectorsImportDialog, dialog);
+ if (response_id == GTK_RESPONSE_OK)
+ {
+ GtkFileChooser *chooser = GTK_FILE_CHOOSER (dialog);
+ GFile *file;
+
+ file = gtk_file_chooser_get_file (chooser);
+
+ if (file)
+ {
+ GFile *folder;
+
+ folder = gtk_file_chooser_get_current_folder_file (chooser);
+
+ private->callback (dialog,
+ private->image,
+ file,
+ folder,
+ private->merge_vectors,
+ private->scale_vectors,
+ private->user_data);
+
+ if (folder)
+ g_object_unref (folder);
+
+ g_object_unref (file);
+ }
+ }
+ else
+ {
+ gtk_widget_destroy (dialog);
+ }
}
diff --git a/app/dialogs/vectors-import-dialog.h b/app/dialogs/vectors-import-dialog.h
index b4d2c40..558adcc 100644
--- a/app/dialogs/vectors-import-dialog.h
+++ b/app/dialogs/vectors-import-dialog.h
@@ -19,22 +19,22 @@
#define __VECTORS_IMPORT_DIALOG_H__
-typedef struct _VectorsImportDialog VectorsImportDialog;
-
-struct _VectorsImportDialog
-{
- GtkWidget *dialog;
-
- GimpImage *image;
- gboolean merge_vectors;
- gboolean scale_vectors;
-};
-
-
-VectorsImportDialog * vectors_import_dialog_new (GimpImage *image,
- GtkWidget *parent,
- gboolean merge_vectors,
- gboolean scale_vectors);
+typedef void (* GimpVectorsImportCallback) (GtkWidget *dialog,
+ GimpImage *image,
+ GFile *file,
+ GFile *import_folder,
+ gboolean merge_vectors,
+ gboolean scale_vectors,
+ gpointer user_data);
+
+
+GtkWidget * vectors_import_dialog_new (GimpImage *image,
+ GtkWidget *parent,
+ GFile *import_folder,
+ gboolean merge_vectors,
+ gboolean scale_vectors,
+ GimpVectorsImportCallback callback,
+ gpointer user_data);
#endif /* __VECTORS_IMPORT_DIALOG_H__ */
diff --git a/app/dialogs/vectors-options-dialog.c b/app/dialogs/vectors-options-dialog.c
index 4af580d..8021c79 100644
--- a/app/dialogs/vectors-options-dialog.c
+++ b/app/dialogs/vectors-options-dialog.c
@@ -119,6 +119,9 @@ vectors_options_dialog_new (GimpImage *image,
return dialog;
}
+
+/* private functions */
+
static void
vectors_options_dialog_free (VectorsOptionsDialog *private)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]