mirror of https://github.com/GNOME/gimp.git
app: add gimp_plug_in_manager_get_file_procedures() for the file dialogs
Change GimpFileDialog's file-procs properties to enum GimpFileProcedureGroup and get them via the newly added API. Set properties common to all dialogs in the parent class.
This commit is contained in:
parent
eaa9230015
commit
dc53501ce9
|
@ -236,6 +236,31 @@ gimp_plug_in_manager_register_thumb_loader (GimpPlugInManager *manager,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
GSList *
|
||||
gimp_plug_in_manager_get_file_procedures (GimpPlugInManager *manager,
|
||||
GimpFileProcedureGroup group)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager), NULL);
|
||||
|
||||
switch (group)
|
||||
{
|
||||
case GIMP_FILE_PROCEDURE_GROUP_NONE:
|
||||
return NULL;
|
||||
|
||||
case GIMP_FILE_PROCEDURE_GROUP_OPEN:
|
||||
return manager->load_procs;
|
||||
|
||||
case GIMP_FILE_PROCEDURE_GROUP_SAVE:
|
||||
return manager->save_procs;
|
||||
|
||||
case GIMP_FILE_PROCEDURE_GROUP_EXPORT:
|
||||
return manager->export_procs;
|
||||
|
||||
default:
|
||||
g_return_val_if_reached (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
GimpPlugInProcedure *
|
||||
gimp_plug_in_manager_file_procedure_find (GimpPlugInManager *manager,
|
||||
GimpFileProcedureGroup group,
|
||||
|
@ -337,7 +362,7 @@ gimp_plug_in_manager_file_procedure_find_by_mime_type (GimpPlugInManager *m
|
|||
|
||||
/* private functions */
|
||||
|
||||
gboolean
|
||||
static gboolean
|
||||
file_procedure_in_group (GimpPlugInProcedure *file_proc,
|
||||
GimpFileProcedureGroup group)
|
||||
{
|
||||
|
@ -353,6 +378,9 @@ file_procedure_in_group (GimpPlugInProcedure *file_proc,
|
|||
|
||||
switch (group)
|
||||
{
|
||||
case GIMP_FILE_PROCEDURE_GROUP_NONE:
|
||||
return FALSE;
|
||||
|
||||
case GIMP_FILE_PROCEDURE_GROUP_SAVE:
|
||||
/* Only .xcf shall pass */
|
||||
return is_xcf_save || is_filter;
|
||||
|
|
|
@ -42,6 +42,9 @@ gboolean gimp_plug_in_manager_register_thumb_loader (GimpPlugInManager *manage
|
|||
const gchar *load_proc,
|
||||
const gchar *thumb_proc);
|
||||
|
||||
GSList * gimp_plug_in_manager_get_file_procedures (GimpPlugInManager *manager,
|
||||
GimpFileProcedureGroup group);
|
||||
|
||||
GimpPlugInProcedure *
|
||||
gimp_plug_in_manager_file_procedure_find (GimpPlugInManager *manager,
|
||||
GimpFileProcedureGroup group,
|
||||
|
|
|
@ -83,6 +83,7 @@ gimp_file_procedure_group_get_type (void)
|
|||
{
|
||||
static const GEnumValue values[] =
|
||||
{
|
||||
{ GIMP_FILE_PROCEDURE_GROUP_NONE, "GIMP_FILE_PROCEDURE_GROUP_NONE", "none" },
|
||||
{ GIMP_FILE_PROCEDURE_GROUP_ANY, "GIMP_FILE_PROCEDURE_GROUP_ANY", "any" },
|
||||
{ GIMP_FILE_PROCEDURE_GROUP_OPEN, "GIMP_FILE_PROCEDURE_GROUP_OPEN", "open" },
|
||||
{ GIMP_FILE_PROCEDURE_GROUP_SAVE, "GIMP_FILE_PROCEDURE_GROUP_SAVE", "save" },
|
||||
|
@ -92,6 +93,7 @@ gimp_file_procedure_group_get_type (void)
|
|||
|
||||
static const GimpEnumDesc descs[] =
|
||||
{
|
||||
{ GIMP_FILE_PROCEDURE_GROUP_NONE, "GIMP_FILE_PROCEDURE_GROUP_NONE", NULL },
|
||||
{ GIMP_FILE_PROCEDURE_GROUP_ANY, "GIMP_FILE_PROCEDURE_GROUP_ANY", NULL },
|
||||
{ GIMP_FILE_PROCEDURE_GROUP_OPEN, "GIMP_FILE_PROCEDURE_GROUP_OPEN", NULL },
|
||||
{ GIMP_FILE_PROCEDURE_GROUP_SAVE, "GIMP_FILE_PROCEDURE_GROUP_SAVE", NULL },
|
||||
|
|
|
@ -53,6 +53,7 @@ GType gimp_file_procedure_group_get_type (void) G_GNUC_CONST;
|
|||
|
||||
typedef enum /*< pdb-skip >*/
|
||||
{
|
||||
GIMP_FILE_PROCEDURE_GROUP_NONE,
|
||||
GIMP_FILE_PROCEDURE_GROUP_ANY,
|
||||
GIMP_FILE_PROCEDURE_GROUP_OPEN,
|
||||
GIMP_FILE_PROCEDURE_GROUP_SAVE,
|
||||
|
|
|
@ -34,10 +34,7 @@
|
|||
|
||||
#include "file/gimp-file.h"
|
||||
|
||||
#include "plug-in/gimppluginmanager.h"
|
||||
|
||||
#include "gimpexportdialog.h"
|
||||
#include "gimpfiledialog.h"
|
||||
#include "gimphelp-ids.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
@ -65,11 +62,9 @@ gimp_export_dialog_init (GimpExportDialog *dialog)
|
|||
GtkWidget *
|
||||
gimp_export_dialog_new (Gimp *gimp)
|
||||
{
|
||||
GimpExportDialog *dialog;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
|
||||
dialog = g_object_new (GIMP_TYPE_EXPORT_DIALOG,
|
||||
return g_object_new (GIMP_TYPE_EXPORT_DIALOG,
|
||||
"gimp", gimp,
|
||||
"title", _("Export Image"),
|
||||
"role", "gimp-file-export",
|
||||
|
@ -80,14 +75,10 @@ gimp_export_dialog_new (Gimp *gimp)
|
|||
"automatic-help-id", GIMP_HELP_FILE_SAVE_BY_EXTENSION,
|
||||
|
||||
"action", GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
"file-procs", gimp->plug_in_manager->export_procs,
|
||||
"file-procs-all-images", gimp->plug_in_manager->save_procs,
|
||||
"file-procs", GIMP_FILE_PROCEDURE_GROUP_EXPORT,
|
||||
"file-procs-all-images", GIMP_FILE_PROCEDURE_GROUP_SAVE,
|
||||
"file-filter-label", _("All export images"),
|
||||
"local-only", FALSE,
|
||||
"do-overwrite-confirmation", TRUE,
|
||||
NULL);
|
||||
|
||||
return GTK_WIDGET (dialog);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
|
||||
#include "pdb/gimppdb.h"
|
||||
|
||||
#include "plug-in/gimppluginmanager-file.h"
|
||||
#include "plug-in/gimppluginprocedure.h"
|
||||
|
||||
#include "gimpfiledialog.h"
|
||||
|
@ -213,14 +214,18 @@ gimp_file_dialog_class_init (GimpFileDialogClass *klass)
|
|||
G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_FILE_PROCS,
|
||||
g_param_spec_pointer ("file-procs",
|
||||
g_param_spec_enum ("file-procs",
|
||||
NULL, NULL,
|
||||
GIMP_TYPE_FILE_PROCEDURE_GROUP,
|
||||
GIMP_FILE_PROCEDURE_GROUP_NONE,
|
||||
GIMP_PARAM_WRITABLE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_FILE_PROCS_ALL_IMAGES,
|
||||
g_param_spec_pointer ("file-procs-all-images",
|
||||
g_param_spec_enum ("file-procs-all-images",
|
||||
NULL, NULL,
|
||||
GIMP_TYPE_FILE_PROCEDURE_GROUP,
|
||||
GIMP_FILE_PROCEDURE_GROUP_NONE,
|
||||
GIMP_PARAM_WRITABLE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
@ -273,10 +278,14 @@ gimp_file_dialog_set_property (GObject *object,
|
|||
dialog->file_filter_label = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_FILE_PROCS:
|
||||
dialog->file_procs = g_value_get_pointer (value);
|
||||
dialog->file_procs =
|
||||
gimp_plug_in_manager_get_file_procedures (dialog->gimp->plug_in_manager,
|
||||
g_value_get_enum (value));
|
||||
break;
|
||||
case PROP_FILE_PROCS_ALL_IMAGES:
|
||||
dialog->file_procs_all_images = g_value_get_pointer (value);
|
||||
dialog->file_procs_all_images =
|
||||
gimp_plug_in_manager_get_file_procedures (dialog->gimp->plug_in_manager,
|
||||
g_value_get_enum (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -325,6 +334,10 @@ gimp_file_dialog_constructed (GObject *object)
|
|||
GTK_RESPONSE_CANCEL,
|
||||
-1);
|
||||
|
||||
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (object), FALSE);
|
||||
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (object),
|
||||
TRUE);
|
||||
|
||||
if (dialog->help_id)
|
||||
{
|
||||
gimp_help_connect (GTK_WIDGET (dialog),
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
|
@ -33,9 +31,6 @@
|
|||
#include "core/gimp.h"
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "plug-in/gimppluginmanager.h"
|
||||
|
||||
#include "gimpfiledialog.h"
|
||||
#include "gimphelp-ids.h"
|
||||
#include "gimpopendialog.h"
|
||||
|
||||
|
@ -64,11 +59,9 @@ gimp_open_dialog_init (GimpOpenDialog *dialog)
|
|||
GtkWidget *
|
||||
gimp_open_dialog_new (Gimp *gimp)
|
||||
{
|
||||
GimpOpenDialog *dialog;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
|
||||
dialog = g_object_new (GIMP_TYPE_OPEN_DIALOG,
|
||||
return g_object_new (GIMP_TYPE_OPEN_DIALOG,
|
||||
"gimp", gimp,
|
||||
"title", _("Open Image"),
|
||||
"role", "gimp-file-open",
|
||||
|
@ -79,14 +72,10 @@ gimp_open_dialog_new (Gimp *gimp)
|
|||
"automatic-help-id", GIMP_HELP_FILE_OPEN_BY_EXTENSION,
|
||||
|
||||
"action", GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"file-procs", gimp->plug_in_manager->load_procs,
|
||||
"file-procs-all-images", NULL,
|
||||
"file-procs", GIMP_FILE_PROCEDURE_GROUP_OPEN,
|
||||
"file-procs-all-images", GIMP_FILE_PROCEDURE_GROUP_NONE,
|
||||
"file-filter-label", NULL,
|
||||
"local-only", FALSE,
|
||||
"do-overwrite-confirmation", TRUE,
|
||||
NULL);
|
||||
|
||||
return GTK_WIDGET (dialog);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#ifndef __GIMP_OPEN_DIALOG_H__
|
||||
#define __GIMP_OPEN_DIALOG_H__
|
||||
|
||||
#include "gimpfiledialog.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GIMP_TYPE_OPEN_DIALOG (gimp_open_dialog_get_type ())
|
||||
|
|
|
@ -35,9 +35,6 @@
|
|||
|
||||
#include "file/gimp-file.h"
|
||||
|
||||
#include "plug-in/gimppluginmanager.h"
|
||||
|
||||
#include "gimpfiledialog.h"
|
||||
#include "gimphelp-ids.h"
|
||||
#include "gimpsavedialog.h"
|
||||
|
||||
|
@ -134,11 +131,9 @@ gimp_save_dialog_load_state (GimpFileDialog *dialog,
|
|||
GtkWidget *
|
||||
gimp_save_dialog_new (Gimp *gimp)
|
||||
{
|
||||
GimpSaveDialog *dialog;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
|
||||
dialog = g_object_new (GIMP_TYPE_SAVE_DIALOG,
|
||||
return g_object_new (GIMP_TYPE_SAVE_DIALOG,
|
||||
"gimp", gimp,
|
||||
"title", _("Save Image"),
|
||||
"role", "gimp-file-save",
|
||||
|
@ -149,14 +144,10 @@ gimp_save_dialog_new (Gimp *gimp)
|
|||
"automatic-help-id", GIMP_HELP_FILE_SAVE_BY_EXTENSION,
|
||||
|
||||
"action", GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
"file-procs", gimp->plug_in_manager->save_procs,
|
||||
"file-procs-all-images", gimp->plug_in_manager->export_procs,
|
||||
"file-procs", GIMP_FILE_PROCEDURE_GROUP_SAVE,
|
||||
"file-procs-all-images", GIMP_FILE_PROCEDURE_GROUP_EXPORT,
|
||||
"file-filter-label", _("All XCF images"),
|
||||
"local-only", FALSE,
|
||||
"do-overwrite-confirmation", TRUE,
|
||||
NULL);
|
||||
|
||||
return GTK_WIDGET (dialog);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue