[gimp] app: Only show 'File->Overwrite' if the source URI has an exporter
- From: Martin Nordholts <martinn src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] app: Only show 'File->Overwrite' if the source URI has an exporter
- Date: Fri, 21 Aug 2009 19:37:58 +0000 (UTC)
commit 51cd8c2981c480a0e2ff2ecf0c45f4763f5d4196
Author: Martin Nordholts <martinn src gnome org>
Date: Fri Aug 21 21:39:54 2009 +0200
app: Only show 'File->Overwrite' if the source URI has an exporter
app/actions/file-actions.c | 25 +++++++++++++++++--------
app/plug-in/gimppluginmanager-file.c | 7 +++++++
app/plug-in/gimppluginmanager-file.h | 2 ++
3 files changed, 26 insertions(+), 8 deletions(-)
---
diff --git a/app/actions/file-actions.c b/app/actions/file-actions.c
index 2b4deaf..83dc749 100644
--- a/app/actions/file-actions.c
+++ b/app/actions/file-actions.c
@@ -35,6 +35,8 @@
#include "file/file-utils.h"
#include "file/gimp-file.h"
+#include "plug-in/gimppluginmanager-file.h"
+
#include "widgets/gimpaction.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
@@ -246,10 +248,12 @@ void
file_actions_update (GimpActionGroup *group,
gpointer data)
{
- GimpImage *image = action_data_get_image (data);
- GimpDrawable *drawable = NULL;
- const gchar *source = NULL;
- const gchar *export_to = NULL;
+ Gimp *gimp = action_data_get_gimp (data);
+ GimpImage *image = action_data_get_image (data);
+ GimpDrawable *drawable = NULL;
+ const gchar *source = NULL;
+ const gchar *export_to = NULL;
+ gboolean show_overwrite = FALSE;
if (image)
{
@@ -260,6 +264,11 @@ file_actions_update (GimpActionGroup *group,
GIMP_FILE_EXPORT_TO_URI_KEY);
}
+ show_overwrite =
+ (source &&
+ gimp_plug_in_manager_uri_has_exporter (gimp->plug_in_manager,
+ source));
+
#define SET_VISIBLE(action,condition) \
gimp_action_group_set_action_visible (group, action, (condition) != 0)
#define SET_SENSITIVE(action,condition) \
@@ -270,9 +279,9 @@ file_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("file-save-a-copy", image && drawable);
SET_SENSITIVE ("file-revert", image && (GIMP_OBJECT (image)->name || source));
SET_SENSITIVE ("file-export-to", export_to);
- SET_VISIBLE ("file-export-to", export_to || ! source);
- SET_SENSITIVE ("file-overwrite", source);
- SET_VISIBLE ("file-overwrite", source);
+ SET_VISIBLE ("file-export-to", export_to || ! show_overwrite);
+ SET_SENSITIVE ("file-overwrite", show_overwrite);
+ SET_VISIBLE ("file-overwrite", show_overwrite);
SET_SENSITIVE ("file-export", image && drawable);
SET_SENSITIVE ("file-create-template", image);
@@ -284,7 +293,7 @@ file_actions_update (GimpActionGroup *group,
gimp_action_group_set_action_label (group, "file-export-to", label);
g_free (label);
}
- else if (source)
+ else if (show_overwrite)
{
gchar *label;
label = g_strdup_printf (_("Overwrite %s"),
diff --git a/app/plug-in/gimppluginmanager-file.c b/app/plug-in/gimppluginmanager-file.c
index 1903783..15d6aa3 100644
--- a/app/plug-in/gimppluginmanager-file.c
+++ b/app/plug-in/gimppluginmanager-file.c
@@ -203,3 +203,10 @@ gimp_plug_in_manager_register_thumb_loader (GimpPlugInManager *manager,
return TRUE;
}
+
+gboolean
+gimp_plug_in_manager_uri_has_exporter (GimpPlugInManager *manager,
+ const gchar *uri)
+{
+ return file_procedure_find (manager->export_procs, uri, NULL) != NULL;
+}
diff --git a/app/plug-in/gimppluginmanager-file.h b/app/plug-in/gimppluginmanager-file.h
index 50a31af..0aa3a2b 100644
--- a/app/plug-in/gimppluginmanager-file.h
+++ b/app/plug-in/gimppluginmanager-file.h
@@ -38,6 +38,8 @@ gboolean gimp_plug_in_manager_register_mime_type (GimpPlugInManager *manage
gboolean gimp_plug_in_manager_register_thumb_loader (GimpPlugInManager *manager,
const gchar *load_proc,
const gchar *thumb_proc);
+gboolean gimp_plug_in_manager_uri_has_exporter (GimpPlugInManager *manager,
+ const gchar *uri);
#endif /* __GIMP_PLUG_IN_MANAGER_FILE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]