[gimp] libgimp: Add export dialog API



commit 8cd7f148d6bb63dfa6164984b328c628f7d9b274
Author: Martin Nordholts <martinn src gnome org>
Date:   Wed Jul 15 12:12:13 2009 +0200

    libgimp: Add export dialog API
    
    Add gimp_export_dialog_new() for creating a export dialog and
    gimp_export_dialog_get_content_area() for accessing the vbox where
    clients can put widgets.

 libgimp/gimpexport.c |   71 ++++++++++++++++++++++++++++++++++++++++++++++++++
 libgimp/gimpexport.h |   12 +++++---
 libgimp/gimpui.def   |    2 +
 3 files changed, 81 insertions(+), 4 deletions(-)
---
diff --git a/libgimp/gimpexport.c b/libgimp/gimpexport.c
index a63f387..45e125e 100644
--- a/libgimp/gimpexport.c
+++ b/libgimp/gimpexport.c
@@ -928,3 +928,74 @@ gimp_export_image (gint32                 *image_ID,
 
   return retval;
 }
+
+/**
+ * gimp_export_dialog_new:
+ * @format_name: The short name of the image_format (e.g. JPEG or PNG).
+ * @role:        The dialog's @role which will be set with
+ *               gtk_window_set_role().
+ * @help_id:     The GIMP help id.
+ *
+ * Creates a new export dialog. All file plug-ins should use this
+ * dialog to get a consistent look on the export dialogs. Use
+ * gimp_export_dialog_get_content_area() to get a #GtkVBox to be
+ * filled with export options. The export dialog is a wrapped
+ * #GimpDialog.
+ *
+ * The dialog response when the user clicks on the Export button is
+ * %GTK_RESPONSE_OK, and when the Cancel button is clicked it is
+ * %GTK_RESPONSE_CANCEL.
+ *
+ * Returns: The new export dialog.
+ *
+ * Since: GIMP 2.8
+ **/
+GtkWidget *
+gimp_export_dialog_new (const gchar *format_name,
+                        const gchar *role,
+                        const gchar *help_id)
+{
+  GtkWidget *dialog = NULL;
+  GtkWidget *button = NULL;
+  gchar     *title  = g_strconcat (_("Export Image as "), format_name, NULL);
+
+  dialog = gimp_dialog_new (title, role,
+                            NULL, 0,
+                            gimp_standard_help_func, help_id,
+                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                            NULL);
+
+  button = gimp_dialog_add_button (GIMP_DIALOG (dialog),
+                                   _("_Export"), GTK_RESPONSE_OK);
+  gtk_button_set_image (GTK_BUTTON (button),
+                        gtk_image_new_from_stock (GTK_STOCK_SAVE,
+                                                  GTK_ICON_SIZE_BUTTON));
+
+  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
+                                           GTK_RESPONSE_OK,
+                                           GTK_RESPONSE_CANCEL,
+                                           -1);
+
+  gimp_window_set_transient (GTK_WINDOW (dialog));
+
+  g_free (title);
+
+  return dialog;
+}
+
+/**
+ * gimp_export_dialog_get_content_area:
+ * @dialog: A dialog created with gimp_export_dialog_new()
+ *
+ * Returns the #GtkVBox of the passed export dialog to be filled with
+ * export options.
+ *
+ * Returns: The #GtkVBox to fill with export options.
+ *
+ * Since: GIMP 2.8
+ **/
+GtkWidget *
+gimp_export_dialog_get_content_area (GtkWidget *dialog)
+{
+  return gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+}
diff --git a/libgimp/gimpexport.h b/libgimp/gimpexport.h
index be3575c..0dfcfc4 100644
--- a/libgimp/gimpexport.h
+++ b/libgimp/gimpexport.h
@@ -47,10 +47,14 @@ typedef enum
   GIMP_EXPORT_EXPORT
 } GimpExportReturn;
 
-GimpExportReturn   gimp_export_image (gint32                 *image_ID,
-                                      gint32                 *drawable_ID,
-                                      const gchar            *format_name,
-                                      GimpExportCapabilities  capabilities);
+GimpExportReturn   gimp_export_image                   (gint32                 *image_ID,
+                                                        gint32                 *drawable_ID,
+                                                        const gchar            *format_name,
+                                                        GimpExportCapabilities  capabilities);
+GtkWidget        * gimp_export_dialog_new              (const gchar            *format_name,
+                                                        const gchar            *role,
+                                                        const gchar            *help_id);
+GtkWidget        * gimp_export_dialog_get_content_area (GtkWidget              *dialog);
 
 
 G_END_DECLS
diff --git a/libgimp/gimpui.def b/libgimp/gimpui.def
index ac21516..a9acfd7 100644
--- a/libgimp/gimpui.def
+++ b/libgimp/gimpui.def
@@ -20,6 +20,8 @@ EXPORTS
 	gimp_drawable_preview_get_drawable
 	gimp_drawable_preview_get_type
 	gimp_drawable_preview_new
+	gimp_export_dialog_get_content_area
+	gimp_export_dialog_new
 	gimp_export_image
 	gimp_font_select_button_get_font
 	gimp_font_select_button_get_type



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]