From ccf8ed69e74827793533e432c06a3e629902ca54 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Fri, 16 Jul 2004 21:24:39 +0000 Subject: [PATCH] app/widgets/Makefile.am app/widgets/widgets-types.h added new widget that 2004-07-16 Sven Neumann * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpfileprocview.[ch]: added new widget that offers a treeview on file procedures. * app/widgets/gimpfiledialog.[ch]: replaced the file type option menu with the new GimpFileProcView widget. (gimp_file_dialog_set_image): reset the file type to Automatic (fixes bug #141535). * app/actions/file-commands.c * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.[ch]: changed accordingly. * plug-ins/common/bz2.c * plug-ins/common/gz.c: don't register "xcf.gz" and "xcf.bz2" extension. It's redundant and breaks the code that sets the extension from the selected file-type. * plug-ins/common/dicom.c: register a shorter menu label. * plug-ins/common/gbr.c * plug-ins/common/gih.c * plug-ins/common/pat.c * plug-ins/common/url.c: register stock icons. --- ChangeLog | 36 ++- app/actions/file-commands.c | 18 +- app/dialogs/file-open-dialog.c | 41 ++-- app/dialogs/file-open-dialog.h | 9 +- app/dialogs/file-save-dialog.c | 74 +++---- app/dialogs/file-save-dialog.h | 10 +- app/gui/file-open-dialog.c | 41 ++-- app/gui/file-open-dialog.h | 9 +- app/gui/file-save-dialog.c | 74 +++---- app/gui/file-save-dialog.h | 10 +- app/widgets/Makefile.am | 2 + app/widgets/gimpfiledialog.c | 379 ++++++++++++++++++-------------- app/widgets/gimpfiledialog.h | 32 ++- app/widgets/gimpfileprocview.c | 348 +++++++++++++++++++++++++++++ app/widgets/gimpfileprocview.h | 65 ++++++ app/widgets/widgets-types.h | 2 + plug-ins/common/bz2.c | 4 +- plug-ins/common/compressor.c | 4 +- plug-ins/common/dicom.c | 6 +- plug-ins/common/gbr.c | 4 + plug-ins/common/gih.c | 4 + plug-ins/common/gz.c | 4 +- plug-ins/common/pat.c | 4 + plug-ins/common/url.c | 3 + plug-ins/uri/uri-backend-wget.c | 3 + plug-ins/uri/uri.c | 3 + po/ChangeLog | 4 + po/POTFILES.in | 1 + 28 files changed, 830 insertions(+), 364 deletions(-) create mode 100644 app/widgets/gimpfileprocview.c create mode 100644 app/widgets/gimpfileprocview.h diff --git a/ChangeLog b/ChangeLog index 0e431dccb0..6457e7e81d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,35 @@ +2004-07-16 Sven Neumann + + * app/widgets/Makefile.am + * app/widgets/widgets-types.h + * app/widgets/gimpfileprocview.[ch]: added new widget that offers + a treeview on file procedures. + + * app/widgets/gimpfiledialog.[ch]: replaced the file type option + menu with the new GimpFileProcView widget. + (gimp_file_dialog_set_image): reset the file type to Automatic + (fixes bug #141535). + + * app/actions/file-commands.c + * app/gui/file-open-dialog.[ch] + * app/gui/file-save-dialog.[ch]: changed accordingly. + + * plug-ins/common/bz2.c + * plug-ins/common/gz.c: don't register "xcf.gz" and "xcf.bz2" + extension. It's redundant and breaks the code that sets the + extension from the selected file-type. + + * plug-ins/common/dicom.c: register a shorter menu label. + + * plug-ins/common/gbr.c + * plug-ins/common/gih.c + * plug-ins/common/pat.c + * plug-ins/common/url.c: register stock icons. + 2004-07-16 Bill Skaggs - * plug-ins/Lighting/lighting_main.c - * plug-ins/Lighting/lighting_main.h - * plug-ins/Lighting/lighting_preview.c - * plug-ins/Lighting/lighting_preview.h + * plug-ins/Lighting/lighting_main.[ch] + * plug-ins/Lighting/lighting_preview.[ch] * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_ui.c: Made this plug-in support multiple light sources; implemented three, architecture now @@ -24,7 +50,7 @@ * tools/pdbgen/pdb/image.pdb: removed redundant #includes. * tools/pdbgen/pdb/plug_in.pdb: standardized "success" logic. - Consistetly fail if there is no currently queried plugin. + Consistently fail if there is no currently queried plugin. * app/pdb/*.c: regenerated. diff --git a/app/actions/file-commands.c b/app/actions/file-commands.c index 524cc023bd..620be3395d 100644 --- a/app/actions/file-commands.c +++ b/app/actions/file-commands.c @@ -79,7 +79,7 @@ file_open_cmd_callback (GtkAction *action, return_if_no_gimp (gimp, data); return_if_no_widget (widget, data); - file_open_dialog_show (gimp, NULL, NULL, global_menu_factory, widget); + file_open_dialog_show (gimp, NULL, NULL, widget); } void @@ -91,8 +91,7 @@ file_open_from_image_cmd_callback (GtkAction *action, return_if_no_gimp (gimp, data); return_if_no_widget (widget, data); - file_open_dialog_show (gimp, action_data_get_image (data), - NULL, global_menu_factory, widget); + file_open_dialog_show (gimp, action_data_get_image (data), NULL, widget); } void @@ -204,7 +203,7 @@ file_save_as_cmd_callback (GtkAction *action, GimpDisplay *gdisp; return_if_no_display (gdisp, data); - file_save_dialog_show (gdisp->gimage, global_menu_factory, gdisp->shell); + file_save_dialog_show (gdisp->gimage, gdisp->shell); } void @@ -214,8 +213,7 @@ file_save_a_copy_cmd_callback (GtkAction *action, GimpDisplay *gdisp; return_if_no_display (gdisp, data); - file_save_a_copy_dialog_show (gdisp->gimage, global_menu_factory, - gdisp->shell); + file_save_a_copy_dialog_show (gdisp->gimage, gdisp->shell); } void @@ -284,15 +282,15 @@ file_revert_cmd_callback (GtkAction *action, "disconnect", file_revert_confirm_callback, gdisp->gimage); - + g_free (text); g_object_set_data (G_OBJECT (gdisp->gimage), REVERT_DATA_KEY, query_box); - + gtk_window_set_transient_for (GTK_WINDOW (query_box), GTK_WINDOW (gdisp->shell)); - + gtk_widget_show (query_box); } } @@ -312,7 +310,7 @@ file_file_open_dialog (Gimp *gimp, const gchar *uri, GtkWidget *parent) { - file_open_dialog_show (gimp, NULL, uri, global_menu_factory, parent); + file_open_dialog_show (gimp, NULL, uri, parent); } diff --git a/app/dialogs/file-open-dialog.c b/app/dialogs/file-open-dialog.c index ad777b71c2..3a8dd7b623 100644 --- a/app/dialogs/file-open-dialog.c +++ b/app/dialogs/file-open-dialog.c @@ -36,7 +36,6 @@ #include "widgets/gimpdialogfactory.h" #include "widgets/gimpfiledialog.h" #include "widgets/gimphelp-ids.h" -#include "widgets/gimpmenufactory.h" #include "dialogs.h" #include "file-open-dialog.h" @@ -46,16 +45,15 @@ /* local function prototypes */ -static GtkWidget * file_open_dialog_create (Gimp *gimp, - GimpMenuFactory *menu_factory); -static void file_open_dialog_response (GtkWidget *open_dialog, - gint response_id, - Gimp *gimp); -static gboolean file_open_dialog_open_image (GtkWidget *open_dialog, - Gimp *gimp, - const gchar *uri, - const gchar *entered_filename, - PlugInProcDef *load_proc); +static GtkWidget * file_open_dialog_create (Gimp *gimp); +static void file_open_dialog_response (GtkWidget *open_dialog, + gint response_id, + Gimp *gimp); +static gboolean file_open_dialog_open_image (GtkWidget *open_dialog, + Gimp *gimp, + const gchar *uri, + const gchar *entered_filename, + PlugInProcDef *load_proc); /* private variables */ @@ -66,19 +64,17 @@ static GtkWidget *fileload = NULL; /* public functions */ void -file_open_dialog_show (Gimp *gimp, - GimpImage *gimage, - const gchar *uri, - GimpMenuFactory *menu_factory, - GtkWidget *parent) +file_open_dialog_show (Gimp *gimp, + GimpImage *gimage, + const gchar *uri, + GtkWidget *parent) { g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (gimage == NULL || GIMP_IS_IMAGE (gimage)); - g_return_if_fail (GIMP_IS_MENU_FACTORY (menu_factory)); g_return_if_fail (parent == NULL || GTK_IS_WIDGET (parent)); if (! fileload) - fileload = file_open_dialog_create (gimp, menu_factory); + fileload = file_open_dialog_create (gimp); gimp_file_dialog_set_uri (GIMP_FILE_DIALOG (fileload), gimage, uri); @@ -93,14 +89,12 @@ file_open_dialog_show (Gimp *gimp, /* private functions */ static GtkWidget * -file_open_dialog_create (Gimp *gimp, - GimpMenuFactory *menu_factory) +file_open_dialog_create (Gimp *gimp) { GtkWidget *dialog; - dialog = gimp_file_dialog_new (gimp, gimp->load_procs, + dialog = gimp_file_dialog_new (gimp, GTK_FILE_CHOOSER_ACTION_OPEN, - menu_factory, "", "/file-open-popup", _("Open Image"), "gimp-file-open", GTK_STOCK_OPEN, GIMP_HELP_FILE_OPEN); @@ -108,8 +102,7 @@ file_open_dialog_create (Gimp *gimp, gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE); gimp_dialog_factory_add_foreign (global_dialog_factory, - "gimp-file-open-dialog", - dialog); + "gimp-file-open-dialog", dialog); g_signal_connect (dialog, "response", G_CALLBACK (file_open_dialog_response), diff --git a/app/dialogs/file-open-dialog.h b/app/dialogs/file-open-dialog.h index 807563017a..0fc9036e34 100644 --- a/app/dialogs/file-open-dialog.h +++ b/app/dialogs/file-open-dialog.h @@ -20,11 +20,10 @@ #define __FILE_OPEN_DIALOG_H__ -void file_open_dialog_show (Gimp *gimp, - GimpImage *gimage, - const gchar *uri, - GimpMenuFactory *menu_factory, - GtkWidget *parent); +void file_open_dialog_show (Gimp *gimp, + GimpImage *gimage, + const gchar *uri, + GtkWidget *parent); #endif /* __FILE_OPEN_DIALOG_H__ */ diff --git a/app/dialogs/file-save-dialog.c b/app/dialogs/file-save-dialog.c index 45583f3149..5d11bc263b 100644 --- a/app/dialogs/file-save-dialog.c +++ b/app/dialogs/file-save-dialog.c @@ -47,24 +47,23 @@ /* local function prototypes */ -static GtkWidget * file_save_dialog_create (Gimp *gimp, - GimpMenuFactory *menu_factory); -static void file_save_dialog_response (GtkWidget *save_dialog, - gint response_id, - Gimp *gimp); -static void file_save_overwrite (GtkWidget *save_dialog, - const gchar *uri, - const gchar *raw_filename); -static void file_save_overwrite_callback (GtkWidget *widget, - gboolean overwrite, - gpointer data); -static gboolean file_save_dialog_save_image (GtkWidget *save_dialog, - GimpImage *gimage, - const gchar *uri, - const gchar *raw_filename, - PlugInProcDef *save_proc, - gboolean set_uri_and_proc, - gboolean set_image_clean); +static GtkWidget * file_save_dialog_create (Gimp *gimp); +static void file_save_dialog_response (GtkWidget *save_dialog, + gint response_id, + Gimp *gimp); +static void file_save_overwrite (GtkWidget *save_dialog, + const gchar *uri, + const gchar *raw_filename); +static void file_save_overwrite_callback (GtkWidget *widget, + gboolean overwrite, + gpointer data); +static gboolean file_save_dialog_save_image (GtkWidget *save_dialog, + GimpImage *gimage, + const gchar *uri, + const gchar *raw_filename, + PlugInProcDef *save_proc, + gboolean set_uri_and_proc, + gboolean set_image_clean); /* private variables */ @@ -75,19 +74,17 @@ static GtkWidget *filesave = NULL; /* public functions */ void -file_save_dialog_show (GimpImage *gimage, - GimpMenuFactory *menu_factory, - GtkWidget *parent) +file_save_dialog_show (GimpImage *gimage, + GtkWidget *parent) { g_return_if_fail (GIMP_IS_IMAGE (gimage)); - g_return_if_fail (GIMP_IS_MENU_FACTORY (menu_factory)); g_return_if_fail (parent == NULL || GTK_IS_WIDGET (parent)); if (! gimp_image_active_drawable (gimage)) return; if (! filesave) - filesave = file_save_dialog_create (gimage->gimp, menu_factory); + filesave = file_save_dialog_create (gimage->gimp); gtk_widget_set_sensitive (GTK_WIDGET (filesave), TRUE); @@ -106,19 +103,17 @@ file_save_dialog_show (GimpImage *gimage, } void -file_save_a_copy_dialog_show (GimpImage *gimage, - GimpMenuFactory *menu_factory, - GtkWidget *parent) +file_save_a_copy_dialog_show (GimpImage *gimage, + GtkWidget *parent) { g_return_if_fail (GIMP_IS_IMAGE (gimage)); - g_return_if_fail (GIMP_IS_MENU_FACTORY (menu_factory)); g_return_if_fail (parent == NULL || GTK_IS_WIDGET (parent)); if (! gimp_image_active_drawable (gimage)) return; if (! filesave) - filesave = file_save_dialog_create (gimage->gimp, menu_factory); + filesave = file_save_dialog_create (gimage->gimp); gtk_widget_set_sensitive (GTK_WIDGET (filesave), TRUE); @@ -140,27 +135,24 @@ file_save_a_copy_dialog_show (GimpImage *gimage, /* private functions */ static GtkWidget * -file_save_dialog_create (Gimp *gimp, - GimpMenuFactory *menu_factory) +file_save_dialog_create (Gimp *gimp) { - GtkWidget *save_dialog; + GtkWidget *dialog; - save_dialog = gimp_file_dialog_new (gimp, gimp->save_procs, - GTK_FILE_CHOOSER_ACTION_SAVE, - menu_factory, "", "/file-save-popup", - _("Save Image"), "gimp-file-save", - GTK_STOCK_SAVE, - GIMP_HELP_FILE_SAVE); + dialog = gimp_file_dialog_new (gimp, + GTK_FILE_CHOOSER_ACTION_SAVE, + _("Save Image"), "gimp-file-save", + GTK_STOCK_SAVE, + GIMP_HELP_FILE_SAVE); gimp_dialog_factory_add_foreign (global_dialog_factory, - "gimp-file-save-dialog", - save_dialog); + "gimp-file-save-dialog", dialog); - g_signal_connect (save_dialog, "response", + g_signal_connect (dialog, "response", G_CALLBACK (file_save_dialog_response), gimp); - return save_dialog; + return dialog; } static void diff --git a/app/dialogs/file-save-dialog.h b/app/dialogs/file-save-dialog.h index 5dc00997b3..d9770dc57a 100644 --- a/app/dialogs/file-save-dialog.h +++ b/app/dialogs/file-save-dialog.h @@ -20,12 +20,10 @@ #define __FILE_SAVE_DIALOG_H__ -void file_save_dialog_show (GimpImage *gimage, - GimpMenuFactory *menu_factory, - GtkWidget *parent); -void file_save_a_copy_dialog_show (GimpImage *gimage, - GimpMenuFactory *menu_factory, - GtkWidget *parent); +void file_save_dialog_show (GimpImage *gimage, + GtkWidget *parent); +void file_save_a_copy_dialog_show (GimpImage *gimage, + GtkWidget *parent); #endif /* __FILE_SAVE_DIALOG_H__ */ diff --git a/app/gui/file-open-dialog.c b/app/gui/file-open-dialog.c index ad777b71c2..3a8dd7b623 100644 --- a/app/gui/file-open-dialog.c +++ b/app/gui/file-open-dialog.c @@ -36,7 +36,6 @@ #include "widgets/gimpdialogfactory.h" #include "widgets/gimpfiledialog.h" #include "widgets/gimphelp-ids.h" -#include "widgets/gimpmenufactory.h" #include "dialogs.h" #include "file-open-dialog.h" @@ -46,16 +45,15 @@ /* local function prototypes */ -static GtkWidget * file_open_dialog_create (Gimp *gimp, - GimpMenuFactory *menu_factory); -static void file_open_dialog_response (GtkWidget *open_dialog, - gint response_id, - Gimp *gimp); -static gboolean file_open_dialog_open_image (GtkWidget *open_dialog, - Gimp *gimp, - const gchar *uri, - const gchar *entered_filename, - PlugInProcDef *load_proc); +static GtkWidget * file_open_dialog_create (Gimp *gimp); +static void file_open_dialog_response (GtkWidget *open_dialog, + gint response_id, + Gimp *gimp); +static gboolean file_open_dialog_open_image (GtkWidget *open_dialog, + Gimp *gimp, + const gchar *uri, + const gchar *entered_filename, + PlugInProcDef *load_proc); /* private variables */ @@ -66,19 +64,17 @@ static GtkWidget *fileload = NULL; /* public functions */ void -file_open_dialog_show (Gimp *gimp, - GimpImage *gimage, - const gchar *uri, - GimpMenuFactory *menu_factory, - GtkWidget *parent) +file_open_dialog_show (Gimp *gimp, + GimpImage *gimage, + const gchar *uri, + GtkWidget *parent) { g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (gimage == NULL || GIMP_IS_IMAGE (gimage)); - g_return_if_fail (GIMP_IS_MENU_FACTORY (menu_factory)); g_return_if_fail (parent == NULL || GTK_IS_WIDGET (parent)); if (! fileload) - fileload = file_open_dialog_create (gimp, menu_factory); + fileload = file_open_dialog_create (gimp); gimp_file_dialog_set_uri (GIMP_FILE_DIALOG (fileload), gimage, uri); @@ -93,14 +89,12 @@ file_open_dialog_show (Gimp *gimp, /* private functions */ static GtkWidget * -file_open_dialog_create (Gimp *gimp, - GimpMenuFactory *menu_factory) +file_open_dialog_create (Gimp *gimp) { GtkWidget *dialog; - dialog = gimp_file_dialog_new (gimp, gimp->load_procs, + dialog = gimp_file_dialog_new (gimp, GTK_FILE_CHOOSER_ACTION_OPEN, - menu_factory, "", "/file-open-popup", _("Open Image"), "gimp-file-open", GTK_STOCK_OPEN, GIMP_HELP_FILE_OPEN); @@ -108,8 +102,7 @@ file_open_dialog_create (Gimp *gimp, gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE); gimp_dialog_factory_add_foreign (global_dialog_factory, - "gimp-file-open-dialog", - dialog); + "gimp-file-open-dialog", dialog); g_signal_connect (dialog, "response", G_CALLBACK (file_open_dialog_response), diff --git a/app/gui/file-open-dialog.h b/app/gui/file-open-dialog.h index 807563017a..0fc9036e34 100644 --- a/app/gui/file-open-dialog.h +++ b/app/gui/file-open-dialog.h @@ -20,11 +20,10 @@ #define __FILE_OPEN_DIALOG_H__ -void file_open_dialog_show (Gimp *gimp, - GimpImage *gimage, - const gchar *uri, - GimpMenuFactory *menu_factory, - GtkWidget *parent); +void file_open_dialog_show (Gimp *gimp, + GimpImage *gimage, + const gchar *uri, + GtkWidget *parent); #endif /* __FILE_OPEN_DIALOG_H__ */ diff --git a/app/gui/file-save-dialog.c b/app/gui/file-save-dialog.c index 45583f3149..5d11bc263b 100644 --- a/app/gui/file-save-dialog.c +++ b/app/gui/file-save-dialog.c @@ -47,24 +47,23 @@ /* local function prototypes */ -static GtkWidget * file_save_dialog_create (Gimp *gimp, - GimpMenuFactory *menu_factory); -static void file_save_dialog_response (GtkWidget *save_dialog, - gint response_id, - Gimp *gimp); -static void file_save_overwrite (GtkWidget *save_dialog, - const gchar *uri, - const gchar *raw_filename); -static void file_save_overwrite_callback (GtkWidget *widget, - gboolean overwrite, - gpointer data); -static gboolean file_save_dialog_save_image (GtkWidget *save_dialog, - GimpImage *gimage, - const gchar *uri, - const gchar *raw_filename, - PlugInProcDef *save_proc, - gboolean set_uri_and_proc, - gboolean set_image_clean); +static GtkWidget * file_save_dialog_create (Gimp *gimp); +static void file_save_dialog_response (GtkWidget *save_dialog, + gint response_id, + Gimp *gimp); +static void file_save_overwrite (GtkWidget *save_dialog, + const gchar *uri, + const gchar *raw_filename); +static void file_save_overwrite_callback (GtkWidget *widget, + gboolean overwrite, + gpointer data); +static gboolean file_save_dialog_save_image (GtkWidget *save_dialog, + GimpImage *gimage, + const gchar *uri, + const gchar *raw_filename, + PlugInProcDef *save_proc, + gboolean set_uri_and_proc, + gboolean set_image_clean); /* private variables */ @@ -75,19 +74,17 @@ static GtkWidget *filesave = NULL; /* public functions */ void -file_save_dialog_show (GimpImage *gimage, - GimpMenuFactory *menu_factory, - GtkWidget *parent) +file_save_dialog_show (GimpImage *gimage, + GtkWidget *parent) { g_return_if_fail (GIMP_IS_IMAGE (gimage)); - g_return_if_fail (GIMP_IS_MENU_FACTORY (menu_factory)); g_return_if_fail (parent == NULL || GTK_IS_WIDGET (parent)); if (! gimp_image_active_drawable (gimage)) return; if (! filesave) - filesave = file_save_dialog_create (gimage->gimp, menu_factory); + filesave = file_save_dialog_create (gimage->gimp); gtk_widget_set_sensitive (GTK_WIDGET (filesave), TRUE); @@ -106,19 +103,17 @@ file_save_dialog_show (GimpImage *gimage, } void -file_save_a_copy_dialog_show (GimpImage *gimage, - GimpMenuFactory *menu_factory, - GtkWidget *parent) +file_save_a_copy_dialog_show (GimpImage *gimage, + GtkWidget *parent) { g_return_if_fail (GIMP_IS_IMAGE (gimage)); - g_return_if_fail (GIMP_IS_MENU_FACTORY (menu_factory)); g_return_if_fail (parent == NULL || GTK_IS_WIDGET (parent)); if (! gimp_image_active_drawable (gimage)) return; if (! filesave) - filesave = file_save_dialog_create (gimage->gimp, menu_factory); + filesave = file_save_dialog_create (gimage->gimp); gtk_widget_set_sensitive (GTK_WIDGET (filesave), TRUE); @@ -140,27 +135,24 @@ file_save_a_copy_dialog_show (GimpImage *gimage, /* private functions */ static GtkWidget * -file_save_dialog_create (Gimp *gimp, - GimpMenuFactory *menu_factory) +file_save_dialog_create (Gimp *gimp) { - GtkWidget *save_dialog; + GtkWidget *dialog; - save_dialog = gimp_file_dialog_new (gimp, gimp->save_procs, - GTK_FILE_CHOOSER_ACTION_SAVE, - menu_factory, "", "/file-save-popup", - _("Save Image"), "gimp-file-save", - GTK_STOCK_SAVE, - GIMP_HELP_FILE_SAVE); + dialog = gimp_file_dialog_new (gimp, + GTK_FILE_CHOOSER_ACTION_SAVE, + _("Save Image"), "gimp-file-save", + GTK_STOCK_SAVE, + GIMP_HELP_FILE_SAVE); gimp_dialog_factory_add_foreign (global_dialog_factory, - "gimp-file-save-dialog", - save_dialog); + "gimp-file-save-dialog", dialog); - g_signal_connect (save_dialog, "response", + g_signal_connect (dialog, "response", G_CALLBACK (file_save_dialog_response), gimp); - return save_dialog; + return dialog; } static void diff --git a/app/gui/file-save-dialog.h b/app/gui/file-save-dialog.h index 5dc00997b3..d9770dc57a 100644 --- a/app/gui/file-save-dialog.h +++ b/app/gui/file-save-dialog.h @@ -20,12 +20,10 @@ #define __FILE_SAVE_DIALOG_H__ -void file_save_dialog_show (GimpImage *gimage, - GimpMenuFactory *menu_factory, - GtkWidget *parent); -void file_save_a_copy_dialog_show (GimpImage *gimage, - GimpMenuFactory *menu_factory, - GtkWidget *parent); +void file_save_dialog_show (GimpImage *gimage, + GtkWidget *parent); +void file_save_a_copy_dialog_show (GimpImage *gimage, + GtkWidget *parent); #endif /* __FILE_SAVE_DIALOG_H__ */ diff --git a/app/widgets/Makefile.am b/app/widgets/Makefile.am index 040611b312..3fae1c38b8 100644 --- a/app/widgets/Makefile.am +++ b/app/widgets/Makefile.am @@ -131,6 +131,8 @@ libappwidgets_a_sources = \ gimpfgbgeditor.h \ gimpfiledialog.c \ gimpfiledialog.h \ + gimpfileprocview.c \ + gimpfileprocview.h \ gimpfontselect.c \ gimpfontselect.h \ gimpfontview.c \ diff --git a/app/widgets/gimpfiledialog.c b/app/widgets/gimpfiledialog.c index 9fd668c706..8bf9d918bb 100644 --- a/app/widgets/gimpfiledialog.c +++ b/app/widgets/gimpfiledialog.c @@ -37,11 +37,11 @@ #include "file/file-utils.h" #include "plug-in/plug-in-proc.h" +#include "plug-in/plug-ins.h" #include "gimpfiledialog.h" -#include "gimpmenufactory.h" +#include "gimpfileprocview.h" #include "gimpthumbbox.h" -#include "gimpuimanager.h" #include "gimppreviewrendererimagefile.h" #include "gimppreview.h" @@ -49,21 +49,29 @@ #include "gimp-intl.h" -static void gimp_file_dialog_class_init (GimpFileDialogClass *klass); -static void gimp_file_dialog_init (GimpFileDialog *dialog); +static void gimp_file_dialog_class_init (GimpFileDialogClass *klass); -static void gimp_file_dialog_destroy (GtkObject *object); +static gboolean gimp_file_dialog_delete_event (GtkWidget *widget, + GdkEventAny *event); -static gboolean gimp_file_dialog_delete_event (GtkWidget *widget, - GdkEventAny *event); +static void gimp_file_dialog_add_preview (GimpFileDialog *dialog, + Gimp *gimp); +static void gimp_file_dialog_add_filters (GimpFileDialog *dialog, + Gimp *gimp, + GSList *file_procs); +static void gimp_file_dialog_add_proc_selection (GimpFileDialog *dialog, + Gimp *gimp, + GSList *file_procs, + const gchar *automatic); -static void gimp_file_dialog_selection_changed (GtkFileChooser *chooser, - GimpFileDialog *dialog); -static void gimp_file_dialog_update_preview (GtkFileChooser *chooser, - GimpFileDialog *dialog); +static void gimp_file_dialog_selection_changed (GtkFileChooser *chooser, + GimpFileDialog *dialog); +static void gimp_file_dialog_update_preview (GtkFileChooser *chooser, + GimpFileDialog *dialog); +static void gimp_file_dialog_proc_changed (GimpFileProcView *view, + GimpFileDialog *dialog); -static GtkFileChooserDialogClass *parent_class = NULL; GType @@ -83,7 +91,7 @@ gimp_file_dialog_get_type (void) NULL, /* class_data */ sizeof (GimpFileDialog), 0, /* n_preallocs */ - (GInstanceInitFunc) gimp_file_dialog_init, + NULL, /* instance_init */ }; dialog_type = g_type_register_static (GTK_TYPE_FILE_CHOOSER_DIALOG, @@ -97,35 +105,11 @@ gimp_file_dialog_get_type (void) static void gimp_file_dialog_class_init (GimpFileDialogClass *klass) { - GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - - object_class->destroy = gimp_file_dialog_destroy; - widget_class->delete_event = gimp_file_dialog_delete_event; } -static void -gimp_file_dialog_init (GimpFileDialog *dialog) -{ -} - -static void -gimp_file_dialog_destroy (GtkObject *object) -{ - GimpFileDialog *dialog = GIMP_FILE_DIALOG (object); - - if (dialog->manager) - { - g_object_unref (dialog->manager); - dialog->manager = NULL; - } - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - static gboolean gimp_file_dialog_delete_event (GtkWidget *widget, GdkEventAny *event) @@ -138,33 +122,39 @@ gimp_file_dialog_delete_event (GtkWidget *widget, GtkWidget * gimp_file_dialog_new (Gimp *gimp, - GSList *file_procs, GtkFileChooserAction action, - GimpMenuFactory *menu_factory, - const gchar *menu_identifier, - const gchar *ui_path, const gchar *title, const gchar *role, const gchar *stock_id, const gchar *help_id) { GimpFileDialog *dialog; - GtkWidget *hbox; - GtkWidget *option_menu; - GtkWidget *label; - GtkFileFilter *filter; - GSList *list; + GSList *file_procs; + const gchar *automatic; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); - g_return_val_if_fail (file_procs != NULL, NULL); - g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL); - g_return_val_if_fail (menu_identifier != NULL, NULL); - g_return_val_if_fail (ui_path != NULL, NULL); g_return_val_if_fail (title != NULL, NULL); g_return_val_if_fail (role != NULL, NULL); g_return_val_if_fail (stock_id != NULL, NULL); g_return_val_if_fail (help_id != NULL, NULL); + switch (action) + { + case GTK_FILE_CHOOSER_ACTION_OPEN: + file_procs = gimp->load_procs; + automatic = _("Automatic"); + break; + + case GTK_FILE_CHOOSER_ACTION_SAVE: + file_procs = gimp->save_procs; + automatic = _("By Extension"); + break; + + default: + g_return_val_if_reached (NULL); + return NULL; + } + dialog = g_object_new (GIMP_TYPE_FILE_DIALOG, "title", title, "role", role, @@ -178,86 +168,14 @@ gimp_file_dialog_new (Gimp *gimp, gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - gimp_help_connect (GTK_WIDGET (dialog), gimp_standard_help_func, - help_id, NULL); + gimp_help_connect (GTK_WIDGET (dialog), + gimp_standard_help_func, help_id, NULL); - dialog->gimp = gimp; - dialog->manager = gimp_menu_factory_manager_new (menu_factory, - menu_identifier, - dialog, - FALSE); + gimp_file_dialog_add_preview (dialog, gimp); - hbox = gtk_hbox_new (FALSE, 6); - gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), hbox); - gtk_widget_show (hbox); + gimp_file_dialog_add_filters (dialog, gimp, file_procs); - option_menu = gtk_option_menu_new (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), - gimp_ui_manager_ui_get (dialog->manager, ui_path)); - gtk_box_pack_end (GTK_BOX (hbox), option_menu, FALSE, FALSE, 0); - gtk_widget_show (option_menu); - - label = gtk_label_new_with_mnemonic (_("Determine File _Type:")); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), option_menu); - gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - if (gimp->config->thumbnail_size > 0) - { - g_signal_connect (dialog, "selection-changed", - G_CALLBACK (gimp_file_dialog_selection_changed), - dialog); - g_signal_connect (dialog, "update-preview", - G_CALLBACK (gimp_file_dialog_update_preview), - dialog); - - dialog->thumb_box = gimp_thumb_box_new (gimp); - gtk_widget_set_sensitive (GTK_WIDGET (dialog->thumb_box), FALSE); - gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (dialog), - dialog->thumb_box); - gtk_widget_show (dialog->thumb_box); - -#ifdef ENABLE_FILE_SYSTEM_ICONS - GIMP_PREVIEW_RENDERER_IMAGEFILE (GIMP_PREVIEW (GIMP_THUMB_BOX (dialog->thumb_box)->preview)->renderer)->file_system = _gtk_file_chooser_get_file_system (GTK_FILE_CHOOSER (dialog)); -#endif - - gtk_file_chooser_set_use_preview_label (GTK_FILE_CHOOSER (dialog), FALSE); - } - - 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), filter); - gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter); - - for (list = file_procs; list; list = g_slist_next (list)) - { - PlugInProcDef *file_proc = list->data; - - if (file_proc->menu_paths && file_proc->extensions_list) - { - const gchar *name; - GSList *ext; - - if (file_proc->menu_label) - name = file_proc->menu_label; - else - name = strrchr (file_proc->menu_paths->data, '/') + 1; - - filter = gtk_file_filter_new (); - gtk_file_filter_set_name (filter, name); - - for (ext = file_proc->extensions_list; ext; ext = g_slist_next (ext)) - { - gchar *pattern = g_strdup_printf ("*.%s", (gchar *) ext->data); - - gtk_file_filter_add_pattern (filter, pattern); - g_free (pattern); - } - - gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); - } - } + gimp_file_dialog_add_proc_selection (dialog, gimp, file_procs, automatic); return GTK_WIDGET (dialog); } @@ -266,49 +184,11 @@ void gimp_file_dialog_set_file_proc (GimpFileDialog *dialog, PlugInProcDef *file_proc) { - GtkFileChooser *chooser; - g_return_if_fail (GIMP_IS_FILE_DIALOG (dialog)); - if (file_proc == dialog->file_proc) - return; - - dialog->file_proc = file_proc; - - chooser = GTK_FILE_CHOOSER (dialog); - - if (file_proc && file_proc->extensions_list && - gtk_file_chooser_get_action (chooser) == GTK_FILE_CHOOSER_ACTION_SAVE) - { - gchar *uri = gtk_file_chooser_get_uri (chooser); - - if (uri && strlen (uri)) - { - const gchar *last_dot = strrchr (uri, '.'); - - if (last_dot != uri) - { - GString *s = g_string_new (uri); - gchar *basename; - - if (last_dot) - g_string_truncate (s, last_dot - uri); - - g_string_append (s, "."); - g_string_append (s, (gchar *) file_proc->extensions_list->data); - - gtk_file_chooser_set_uri (chooser, s->str); - - basename = file_utils_uri_to_utf8_basename (s->str); - gtk_file_chooser_set_current_name (chooser, basename); - g_free (basename); - - g_string_free (s, TRUE); - } - } - - g_free (uri); - } + if (file_proc != dialog->file_proc) + gimp_file_proc_view_set_proc (GIMP_FILE_PROC_VIEW (dialog->proc_view), + file_proc); } void @@ -383,13 +263,117 @@ gimp_file_dialog_set_image (GimpFileDialog *dialog, else gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), ""); - gimp_ui_manager_update (dialog->manager, - gimp_image_active_drawable (gimage)); + gimp_file_dialog_set_file_proc (dialog, NULL); } /* private functions */ +static void +gimp_file_dialog_add_preview (GimpFileDialog *dialog, + Gimp *gimp) +{ + if (gimp->config->thumbnail_size <= 0) + return; + + gtk_file_chooser_set_use_preview_label (GTK_FILE_CHOOSER (dialog), FALSE); + + g_signal_connect (dialog, "selection-changed", + G_CALLBACK (gimp_file_dialog_selection_changed), + dialog); + g_signal_connect (dialog, "update-preview", + G_CALLBACK (gimp_file_dialog_update_preview), + dialog); + + dialog->thumb_box = gimp_thumb_box_new (gimp); + gtk_widget_set_sensitive (GTK_WIDGET (dialog->thumb_box), FALSE); + gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (dialog), + dialog->thumb_box); + gtk_widget_show (dialog->thumb_box); + +#ifdef ENABLE_FILE_SYSTEM_ICONS + GIMP_PREVIEW_RENDERER_IMAGEFILE (GIMP_PREVIEW (GIMP_THUMB_BOX (dialog->thumb_box)->preview)->renderer)->file_system = _gtk_file_chooser_get_file_system (GTK_FILE_CHOOSER (dialog)); +#endif +} + +static void +gimp_file_dialog_add_filters (GimpFileDialog *dialog, + Gimp *gimp, + GSList *file_procs) +{ + GtkFileFilter *filter; + GSList *list; + + 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), filter); + gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter); + + for (list = file_procs; list; list = g_slist_next (list)) + { + PlugInProcDef *file_proc = list->data; + + if (file_proc->menu_paths && file_proc->extensions_list) + { + const gchar *domain; + gchar *label; + GSList *ext; + + domain = plug_ins_locale_domain (gimp, file_proc->prog, NULL); + label = plug_in_proc_def_get_label (file_proc, domain); + + filter = gtk_file_filter_new (); + gtk_file_filter_set_name (filter, label); + g_free (label); + + for (ext = file_proc->extensions_list; + ext; + ext = g_slist_next (ext)) + { + gchar *pattern = g_strdup_printf ("*.%s", (gchar *) ext->data); + + gtk_file_filter_add_pattern (filter, pattern); + g_free (pattern); + } + + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); + } + } +} + +static void +gimp_file_dialog_add_proc_selection (GimpFileDialog *dialog, + Gimp *gimp, + GSList *file_procs, + const gchar *automatic) +{ + GtkWidget *scrolled; + + dialog->proc_expander = gtk_expander_new_with_mnemonic (NULL); + gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), + dialog->proc_expander); + gtk_widget_show (dialog->proc_expander); + + scrolled = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_container_add (GTK_CONTAINER (dialog->proc_expander), scrolled); + gtk_widget_show (scrolled); + + gtk_widget_set_size_request (scrolled, -1, 200); + + dialog->proc_view = gimp_file_proc_view_new (gimp, file_procs, automatic); + gtk_container_add (GTK_CONTAINER (scrolled), dialog->proc_view); + gtk_widget_show (dialog->proc_view); + + g_signal_connect (dialog->proc_view, "changed", + G_CALLBACK (gimp_file_dialog_proc_changed), + dialog); + + gimp_file_proc_view_set_proc (GIMP_FILE_PROC_VIEW (dialog->proc_view), NULL); +} + static void gimp_file_dialog_selection_changed (GtkFileChooser *chooser, GimpFileDialog *dialog) @@ -408,3 +392,58 @@ gimp_file_dialog_update_preview (GtkFileChooser *chooser, g_free (uri); } + +static void +gimp_file_dialog_proc_changed (GimpFileProcView *view, + GimpFileDialog *dialog) +{ + GtkFileChooser *chooser = GTK_FILE_CHOOSER (dialog); + gchar *name; + gchar *label; + + dialog->file_proc = gimp_file_proc_view_get_proc (view, &name); + + label = g_strdup_printf (_("Select File _Type (%s)"), name); + + gtk_expander_set_label (GTK_EXPANDER (dialog->proc_expander), label); + + g_free (label); + g_free (name); + + if (gtk_file_chooser_get_action (chooser) == GTK_FILE_CHOOSER_ACTION_SAVE) + { + PlugInProcDef *proc = dialog->file_proc; + + if (proc && proc->extensions_list) + { + gchar *uri = gtk_file_chooser_get_uri (chooser); + + if (uri && strlen (uri)) + { + const gchar *last_dot = strrchr (uri, '.'); + + if (last_dot != uri) + { + GString *s = g_string_new (uri); + gchar *basename; + + if (last_dot) + g_string_truncate (s, last_dot - uri); + + g_string_append (s, "."); + g_string_append (s, (gchar *) proc->extensions_list->data); + + gtk_file_chooser_set_uri (chooser, s->str); + + basename = file_utils_uri_to_utf8_basename (s->str); + gtk_file_chooser_set_current_name (chooser, basename); + g_free (basename); + + g_string_free (s, TRUE); + } + } + + g_free (uri); + } + } +} diff --git a/app/widgets/gimpfiledialog.h b/app/widgets/gimpfiledialog.h index 37533c4bd8..2342957662 100644 --- a/app/widgets/gimpfiledialog.h +++ b/app/widgets/gimpfiledialog.h @@ -39,15 +39,15 @@ struct _GimpFileDialog { GtkFileChooserDialog parent_instance; - Gimp *gimp; - GimpUIManager *manager; - PlugInProcDef *file_proc; + PlugInProcDef *file_proc; - GimpImage *gimage; - gboolean set_uri_and_proc; - gboolean set_image_clean; + GimpImage *gimage; + gboolean set_uri_and_proc; + gboolean set_image_clean; - GtkWidget *thumb_box; + GtkWidget *thumb_box; + GtkWidget *proc_expander; + GtkWidget *proc_view; }; struct _GimpFileDialogClass @@ -59,11 +59,7 @@ struct _GimpFileDialogClass GType gimp_file_dialog_get_type (void) G_GNUC_CONST; GtkWidget * gimp_file_dialog_new (Gimp *gimp, - GSList *file_procs, GtkFileChooserAction action, - GimpMenuFactory *menu_factory, - const gchar *menu_identifier, - const gchar *ui_path, const gchar *title, const gchar *role, const gchar *stock_id, @@ -72,13 +68,13 @@ GtkWidget * gimp_file_dialog_new (Gimp *gimp, void gimp_file_dialog_set_file_proc (GimpFileDialog *dialog, PlugInProcDef *file_proc); -void gimp_file_dialog_set_uri (GimpFileDialog *dialog, - GimpImage *gimage, - const gchar *uri); -void gimp_file_dialog_set_image (GimpFileDialog *dialog, - GimpImage *gimage, - gboolean set_uri_and_proc, - gboolean set_image_clean); +void gimp_file_dialog_set_uri (GimpFileDialog *dialog, + GimpImage *gimage, + const gchar *uri); +void gimp_file_dialog_set_image (GimpFileDialog *dialog, + GimpImage *gimage, + gboolean set_uri_and_proc, + gboolean set_image_clean); G_END_DECLS diff --git a/app/widgets/gimpfileprocview.c b/app/widgets/gimpfileprocview.c new file mode 100644 index 0000000000..8392bd8266 --- /dev/null +++ b/app/widgets/gimpfileprocview.c @@ -0,0 +1,348 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpfileprocview.c + * Copyright (C) 2004 Sven Neumann + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "config.h" + +#include + +#include + +#include "widgets-types.h" + +#include "core/gimp.h" +#include "core/gimpmarshal.h" + +#include "plug-in/plug-in-proc.h" +#include "plug-in/plug-ins.h" + +#include "gimpfileprocview.h" + +#include "gimp-intl.h" + + +enum +{ + COLUMN_PROC, + COLUMN_LABEL, + COLUMN_EXTENSIONS, + COLUMN_STOCK_ID, + COLUMN_PIXBUF, + NUM_COLUMNS +}; + +enum +{ + CHANGED, + LAST_SIGNAL +}; + + +static void gimp_file_proc_view_class_init (GimpFileProcViewClass *klass); + +static void gimp_file_proc_view_selection_changed (GtkTreeSelection *selection, + GimpFileProcView *view); +static gint gimp_file_proc_view_iter_compare (GtkTreeModel *model, + GtkTreeIter *a, + GtkTreeIter *b, + gpointer data); + + +static guint view_signals[LAST_SIGNAL] = { 0 }; + + +GType +gimp_file_proc_view_get_type (void) +{ + static GType view_type = 0; + + if (! view_type) + { + static const GTypeInfo view_info = + { + sizeof (GimpFileProcViewClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) gimp_file_proc_view_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GimpFileProcView), + 0, /* n_preallocs */ + NULL /* instance_init */ + }; + + view_type = g_type_register_static (GTK_TYPE_TREE_VIEW, + "GimpFileProcView", + &view_info, 0); + } + + return view_type; +} + +static void +gimp_file_proc_view_class_init (GimpFileProcViewClass *klass) +{ + klass->changed = NULL; + + view_signals[CHANGED] = g_signal_new ("changed", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GimpFileProcViewClass, + changed), + NULL, NULL, + gimp_marshal_VOID__VOID, + G_TYPE_NONE, 0); +} + + +GtkWidget * +gimp_file_proc_view_new (Gimp *gimp, + GSList *procedures, + const gchar *automatic) +{ + GtkTreeView *view; + GtkTreeViewColumn *column; + GtkCellRenderer *cell; + GtkListStore *store; + GSList *list; + GtkTreeIter iter; + + g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); + + store = gtk_list_store_new (NUM_COLUMNS, + G_TYPE_POINTER, /* COLUMN_PROC */ + G_TYPE_STRING, /* COLUMN_LABEL */ + G_TYPE_STRING, /* COLUMN_EXTENSIONS */ + G_TYPE_STRING, /* COLUMN_STOCK_ID */ + GDK_TYPE_PIXBUF); /* COLUMN_PIXBUF */ + + + gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (store), + COLUMN_LABEL, + gimp_file_proc_view_iter_compare, + NULL, NULL); + + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), + COLUMN_LABEL, + GTK_SORT_ASCENDING); + + for (list = procedures; list; list = g_slist_next (list)) + { + PlugInProcDef *proc = list->data; + const gchar *domain = plug_ins_locale_domain (gimp, + proc->prog, NULL); + gchar *label = plug_in_proc_def_get_label (proc, domain); + const gchar *stock_id = plug_in_proc_def_get_stock_id (proc); + GdkPixbuf *pixbuf = plug_in_proc_def_get_pixbuf (proc); + + if (label) + { + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, + COLUMN_PROC, proc, + COLUMN_LABEL, label, + COLUMN_EXTENSIONS, proc->extensions, + COLUMN_STOCK_ID, stock_id, + COLUMN_PIXBUF, pixbuf, + -1); + + g_free (label); + } + + if (pixbuf) + g_object_unref (pixbuf); + } + + if (automatic) + { + gtk_list_store_prepend (store, &iter); + + gtk_list_store_set (store, &iter, + COLUMN_PROC, NULL, + COLUMN_LABEL, automatic, + -1); + } + + view = g_object_new (GIMP_TYPE_FILE_PROC_VIEW, + "model", store, + "rules_hint", TRUE, + NULL); + + g_object_unref (store); + + column = gtk_tree_view_column_new (); + gtk_tree_view_column_set_title (column, _("File Type")); + gtk_tree_view_column_set_expand (column, TRUE); + + cell = gtk_cell_renderer_pixbuf_new (); + gtk_tree_view_column_pack_start (column, cell, FALSE); + gtk_tree_view_column_set_attributes (column, cell, + "stock_id", COLUMN_STOCK_ID, + "pixbuf", COLUMN_PIXBUF, + NULL); + + cell = gtk_cell_renderer_text_new (); + gtk_tree_view_column_pack_start (column, cell, TRUE); + gtk_tree_view_column_set_attributes (column, cell, + "text", COLUMN_LABEL, + NULL); + + gtk_tree_view_append_column (view, column); + + column = gtk_tree_view_column_new (); + gtk_tree_view_column_set_title (column, _("Extensions")); + + cell = gtk_cell_renderer_text_new (); + gtk_tree_view_column_pack_start (column, cell, TRUE); + gtk_tree_view_column_set_attributes (column, cell, + "text", COLUMN_EXTENSIONS, + NULL); + + gtk_tree_view_append_column (view, column); + + g_signal_connect (gtk_tree_view_get_selection (view), "changed", + G_CALLBACK (gimp_file_proc_view_selection_changed), + view); + + return GTK_WIDGET (view); +} + +PlugInProcDef * +gimp_file_proc_view_get_proc (GimpFileProcView *view, + gchar **label) +{ + GtkTreeModel *model; + GtkTreeSelection *selection; + GtkTreeIter iter; + + g_return_val_if_fail (GIMP_IS_FILE_PROC_VIEW (view), NULL); + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); + + if (gtk_tree_selection_get_selected (selection, &model, &iter)) + { + PlugInProcDef *proc; + + if (label) + gtk_tree_model_get (model, &iter, + COLUMN_PROC, &proc, + COLUMN_LABEL, label, + -1); + else + gtk_tree_model_get (model, &iter, + COLUMN_PROC, &proc, + -1); + + return proc; + } + + if (label) + label = NULL; + + return NULL; +} + + +gboolean +gimp_file_proc_view_set_proc (GimpFileProcView *view, + PlugInProcDef *proc) +{ + GtkTreeModel *model; + GtkTreeIter iter; + gboolean iter_valid; + + g_return_val_if_fail (GIMP_IS_FILE_PROC_VIEW (view), FALSE); + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (view)); + + for (iter_valid = gtk_tree_model_get_iter_first (model, &iter); + iter_valid; + iter_valid = gtk_tree_model_iter_next (model, &iter)) + { + PlugInProcDef *this; + + gtk_tree_model_get (model, &iter, + COLUMN_PROC, &this, + -1); + if (this == proc) + break; + } + + if (iter_valid) + { + GtkTreeSelection *selection; + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); + + gtk_tree_selection_select_iter (selection, &iter); + } + + return iter_valid; +} + +static void +gimp_file_proc_view_selection_changed (GtkTreeSelection *selection, + GimpFileProcView *view) +{ + g_signal_emit (view, view_signals[CHANGED], 0); +} + +static gint +gimp_file_proc_view_iter_compare (GtkTreeModel *model, + GtkTreeIter *a, + GtkTreeIter *b, + gpointer data) +{ + PlugInProcDef *proc_a; + PlugInProcDef *proc_b; + gchar *label_a; + gchar *label_b; + gint retval; + + gtk_tree_model_get (model, a, + COLUMN_PROC, &proc_a, + COLUMN_LABEL, &label_a, + -1); + gtk_tree_model_get (model, b, + COLUMN_PROC, &proc_b, + COLUMN_LABEL, &label_b, + -1); + + if (proc_a && proc_b) + { + if (strncmp (proc_a->prog, "gimp_xcf", 8) == 0) + retval = -1; + else if (strncmp (proc_b->prog, "gimp_xcf", 8) == 0) + retval = 1; + else + retval = g_utf8_collate (label_a, label_b); + } + else if (proc_a) + retval = 1; + else if (proc_b) + retval = -1; + else + retval = 0; + + g_free (label_a); + g_free (label_b); + + return retval; +} diff --git a/app/widgets/gimpfileprocview.h b/app/widgets/gimpfileprocview.h new file mode 100644 index 0000000000..51bc0d2b11 --- /dev/null +++ b/app/widgets/gimpfileprocview.h @@ -0,0 +1,65 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpfileprocview.h + * Copyright (C) 2004 Sven Neumann + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __GIMP_FILE_PROC_VIEW_H__ +#define __GIMP_FILE_PROC_VIEW_H__ + + +#include + + +#define GIMP_TYPE_FILE_PROC_VIEW (gimp_file_proc_view_get_type ()) +#define GIMP_FILE_PROC_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_FILE_PROC_VIEW, GimpFileProcView)) +#define GIMP_FILE_PROC_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_FILE_PROC_VIEW, GimpFileProcViewClass)) +#define GIMP_IS_FILE_PROC_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_FILE_PROC_VIEW)) +#define GIMP_IS_FILE_PROC_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_FILE_PROC_VIEW)) +#define GIMP_FILE_PROC_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_FILE_PROC_VIEW, GimpFileProcViewClass)) + + +typedef struct _GimpFileProcViewClass GimpFileProcViewClass; + +struct _GimpFileProcView +{ + GtkTreeView parent_instance; +}; + +struct _GimpFileProcViewClass +{ + GtkTreeViewClass parent_class; + + void (* changed) (GimpFileProcView *view); +}; + + +GType gimp_file_proc_view_get_type (void) G_GNUC_CONST; + +GtkWidget * gimp_file_proc_view_new (Gimp *gimp, + GSList *procedures, + const gchar *automatic); + +PlugInProcDef * gimp_file_proc_view_get_proc (GimpFileProcView *view, + gchar **label); +gboolean gimp_file_proc_view_set_proc (GimpFileProcView *view, + PlugInProcDef *proc); + + + +#endif /* __GIMP_FILE_PROC_VIEW_H__ */ diff --git a/app/widgets/widgets-types.h b/app/widgets/widgets-types.h index 805415f3eb..6ec62ea202 100644 --- a/app/widgets/widgets-types.h +++ b/app/widgets/widgets-types.h @@ -100,6 +100,8 @@ typedef struct _GimpLayerTreeView GimpLayerTreeView; typedef struct _GimpChannelTreeView GimpChannelTreeView; typedef struct _GimpVectorsTreeView GimpVectorsTreeView; +typedef struct _GimpFileProcView GimpFileProcView; + typedef struct _GimpContainerEditor GimpContainerEditor; typedef struct _GimpBufferView GimpBufferView; typedef struct _GimpDocumentView GimpDocumentView; diff --git a/plug-ins/common/bz2.c b/plug-ins/common/bz2.c index b082e33493..ef931e9a5d 100644 --- a/plug-ins/common/bz2.c +++ b/plug-ins/common/bz2.c @@ -116,7 +116,7 @@ query (void) gimp_plugin_menu_register ("file_bz2_load", ""); gimp_register_file_handler_mime ("file_bz2_load", "application/x-bzip"); gimp_register_magic_load_handler ("file_bz2_load", - "xcf.bz2,bz2,xcfbz2", + "bz2,xcfbz2", "", "0,string,BZh"); @@ -134,7 +134,7 @@ query (void) gimp_register_file_handler_mime ("file_bz2_save", "application/x-bzip"); gimp_register_save_handler ("file_bz2_save", - "xcf.bz2,bz2,xcfbz2", + "bz2,xcfbz2", ""); } diff --git a/plug-ins/common/compressor.c b/plug-ins/common/compressor.c index 684a56c64d..b31403fc9b 100644 --- a/plug-ins/common/compressor.c +++ b/plug-ins/common/compressor.c @@ -164,7 +164,7 @@ query (void) gimp_plugin_menu_register ("file_gz_load", ""); gimp_register_file_handler_mime ("file_gz_load", "application/x-gzip"); gimp_register_magic_load_handler ("file_gz_load", - "xcf.gz,gz,xcfgz", + "gz,xcfgz", "", "0,string,\037\213"); @@ -182,7 +182,7 @@ query (void) gimp_register_file_handler_mime ("file_gz_save", "application/x-gzip"); gimp_register_save_handler ("file_gz_save", - "xcf.gz,gz,xcfgz", + "gz,xcfgz", ""); } diff --git a/plug-ins/common/dicom.c b/plug-ins/common/dicom.c index 367de87e1a..ba2c28f3e7 100644 --- a/plug-ins/common/dicom.c +++ b/plug-ins/common/dicom.c @@ -131,7 +131,7 @@ query (void) "Dov Grobgeld", "Dov Grobgeld ", "2003", - N_("Digital Imaging and Communications in Medicine image"), + N_("DICOM image"), NULL, GIMP_PLUGIN, G_N_ELEMENTS (load_args), @@ -141,7 +141,7 @@ query (void) gimp_plugin_menu_register ("file_dicom_load", ""); gimp_register_file_handler_mime ("file_dicom_load", "image/x-dcm"); gimp_register_magic_load_handler ("file_dicom_load", - "dcm,DCM,dicom,DICOM", + "dcm,dicom", "", "128,string,DICM" ); @@ -166,7 +166,7 @@ query (void) gimp_plugin_menu_register ("file_dicom_save", ""); gimp_register_file_handler_mime ("file_dicom_save", "image/x-dcm"); gimp_register_save_handler ("file_dicom_save", - "dicom,dcm,DCM,DICOM", + "dcm,dicom", ""); } diff --git a/plug-ins/common/gbr.c b/plug-ins/common/gbr.c index e753e095eb..aeb2180f74 100644 --- a/plug-ins/common/gbr.c +++ b/plug-ins/common/gbr.c @@ -135,6 +135,8 @@ query (void) load_args, load_return_vals); gimp_plugin_menu_register ("file_gbr_load", ""); + gimp_plugin_icon_register ("file_gbr_load", + GIMP_ICON_TYPE_STOCK_ID, GIMP_STOCK_BRUSH); gimp_register_file_handler_mime ("file_gbr_load", "image/x-gimp-gbr"); gimp_register_magic_load_handler ("file_gbr_load", "gbr, gpb", @@ -154,6 +156,8 @@ query (void) save_args, NULL); gimp_plugin_menu_register ("file_gbr_save", ""); + gimp_plugin_icon_register ("file_gbr_save", + GIMP_ICON_TYPE_STOCK_ID, GIMP_STOCK_BRUSH); gimp_register_file_handler_mime ("file_gbr_save", "image/x-gimp-gbr"); gimp_register_save_handler ("file_gbr_save", "gbr", diff --git a/plug-ins/common/gih.c b/plug-ins/common/gih.c index 36b181e66c..d7059ea117 100644 --- a/plug-ins/common/gih.c +++ b/plug-ins/common/gih.c @@ -201,6 +201,8 @@ query (void) gih_load_args, gih_load_return_vals); gimp_plugin_menu_register ("file_gih_load", ""); + gimp_plugin_icon_register ("file_gih_load", + GIMP_ICON_TYPE_STOCK_ID, GIMP_STOCK_BRUSH); gimp_register_file_handler_mime ("file_gih_load", "image/x-gimp-gih"); gimp_register_magic_load_handler ("file_gih_load", "gih", @@ -220,6 +222,8 @@ query (void) gih_save_args, NULL); gimp_plugin_menu_register ("file_gih_save", ""); + gimp_plugin_icon_register ("file_gih_save", + GIMP_ICON_TYPE_STOCK_ID, GIMP_STOCK_BRUSH); gimp_register_file_handler_mime ("file_gih_save", "image/x-gimp-gih"); gimp_register_save_handler ("file_gih_save", "gih", diff --git a/plug-ins/common/gz.c b/plug-ins/common/gz.c index 684a56c64d..b31403fc9b 100644 --- a/plug-ins/common/gz.c +++ b/plug-ins/common/gz.c @@ -164,7 +164,7 @@ query (void) gimp_plugin_menu_register ("file_gz_load", ""); gimp_register_file_handler_mime ("file_gz_load", "application/x-gzip"); gimp_register_magic_load_handler ("file_gz_load", - "xcf.gz,gz,xcfgz", + "gz,xcfgz", "", "0,string,\037\213"); @@ -182,7 +182,7 @@ query (void) gimp_register_file_handler_mime ("file_gz_save", "application/x-gzip"); gimp_register_save_handler ("file_gz_save", - "xcf.gz,gz,xcfgz", + "gz,xcfgz", ""); } diff --git a/plug-ins/common/pat.c b/plug-ins/common/pat.c index c64e3a544c..a0aa2b6cea 100644 --- a/plug-ins/common/pat.c +++ b/plug-ins/common/pat.c @@ -109,6 +109,8 @@ query (void) load_args, load_return_vals); gimp_plugin_menu_register ("file_pat_load", ""); + gimp_plugin_icon_register ("file_pat_load", + GIMP_ICON_TYPE_STOCK_ID, GIMP_STOCK_PATTERN); gimp_register_file_handler_mime ("file_pat_load", "image/x-gimp-pat"); gimp_register_magic_load_handler ("file_pat_load", "pat", @@ -129,6 +131,8 @@ query (void) save_args, NULL); gimp_plugin_menu_register ("file_pat_save", ""); + gimp_plugin_icon_register ("file_pat_save", + GIMP_ICON_TYPE_STOCK_ID, GIMP_STOCK_PATTERN); gimp_register_file_handler_mime ("file_pat_save", "image/x-gimp-pat"); gimp_register_save_handler ("file_pat_save", "pat", diff --git a/plug-ins/common/url.c b/plug-ins/common/url.c index f534cd3069..f4c0a969ef 100644 --- a/plug-ins/common/url.c +++ b/plug-ins/common/url.c @@ -29,6 +29,7 @@ #include #include +#include #include "libgimp/stdplugins-intl.h" @@ -88,6 +89,8 @@ query (void) gimp_register_load_handler ("file_url_load", "", "http:,https:,ftp:"); + gimp_plugin_icon_register ("file_url_load", + GIMP_ICON_TYPE_STOCK_ID, GIMP_STOCK_WEB); } static void diff --git a/plug-ins/uri/uri-backend-wget.c b/plug-ins/uri/uri-backend-wget.c index f534cd3069..f4c0a969ef 100644 --- a/plug-ins/uri/uri-backend-wget.c +++ b/plug-ins/uri/uri-backend-wget.c @@ -29,6 +29,7 @@ #include #include +#include #include "libgimp/stdplugins-intl.h" @@ -88,6 +89,8 @@ query (void) gimp_register_load_handler ("file_url_load", "", "http:,https:,ftp:"); + gimp_plugin_icon_register ("file_url_load", + GIMP_ICON_TYPE_STOCK_ID, GIMP_STOCK_WEB); } static void diff --git a/plug-ins/uri/uri.c b/plug-ins/uri/uri.c index f534cd3069..f4c0a969ef 100644 --- a/plug-ins/uri/uri.c +++ b/plug-ins/uri/uri.c @@ -29,6 +29,7 @@ #include #include +#include #include "libgimp/stdplugins-intl.h" @@ -88,6 +89,8 @@ query (void) gimp_register_load_handler ("file_url_load", "", "http:,https:,ftp:"); + gimp_plugin_icon_register ("file_url_load", + GIMP_ICON_TYPE_STOCK_ID, GIMP_STOCK_WEB); } static void diff --git a/po/ChangeLog b/po/ChangeLog index bd8bcba8ea..6b90c79deb 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -1,3 +1,7 @@ +2004-07-16 Sven Neumann + + * POTFILES.in: added app/widgets/gimpfileprocview.c. + 2004-07-15 Dmitry G. Mastrukov * ru.po: Updated Russian translation diff --git a/po/POTFILES.in b/po/POTFILES.in index 8b58b3ba06..7ed479b44d 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -292,6 +292,7 @@ app/widgets/gimpdocumentview.c app/widgets/gimpdrawabletreeview.c app/widgets/gimperrorconsole.c app/widgets/gimpfiledialog.c +app/widgets/gimpfileprocview.c app/widgets/gimpgradienteditor.c app/widgets/gimpgrideditor.c app/widgets/gimphelp.c