mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-10-06 17:52:42 +02:00
app, menus, pdb: new file-open-as-link-layers action.
Revert the logic of opening all files as link layers back into loading their current content as normal layers. Instead just add a new action dedicated to open images as link layers and add it to the File menu. Per UX discussions with Aryeom.
This commit is contained in:
@@ -82,6 +82,12 @@ static const GimpActionEntry file_actions[] =
|
|||||||
file_open_as_layers_cmd_callback,
|
file_open_as_layers_cmd_callback,
|
||||||
GIMP_HELP_FILE_OPEN_AS_LAYER },
|
GIMP_HELP_FILE_OPEN_AS_LAYER },
|
||||||
|
|
||||||
|
{ "file-open-as-link-layers", GIMP_ICON_LAYER,
|
||||||
|
NC_("file-action", "Op_en as Link Layer..."), NULL, { "<primary><alt><shift>O", NULL },
|
||||||
|
NC_("file-action", "Open an image file as Link layer"),
|
||||||
|
file_open_as_link_layer_cmd_callback,
|
||||||
|
GIMP_HELP_FILE_OPEN_AS_LAYER },
|
||||||
|
|
||||||
{ "file-open-location", GIMP_ICON_WEB,
|
{ "file-open-location", GIMP_ICON_WEB,
|
||||||
NC_("file-action", "Open _Location..."), NULL, { NULL },
|
NC_("file-action", "Open _Location..."), NULL, { NULL },
|
||||||
NC_("file-action", "Open an image file from a specified location"),
|
NC_("file-action", "Open an image file from a specified location"),
|
||||||
|
@@ -73,7 +73,8 @@ static void file_open_dialog_show (Gimp *gimp,
|
|||||||
const gchar *title,
|
const gchar *title,
|
||||||
GimpImage *image,
|
GimpImage *image,
|
||||||
GFile *file,
|
GFile *file,
|
||||||
gboolean open_as_layers);
|
gboolean open_as_layers,
|
||||||
|
gboolean open_as_link);
|
||||||
static GtkWidget * file_save_dialog_show (Gimp *gimp,
|
static GtkWidget * file_save_dialog_show (Gimp *gimp,
|
||||||
GimpImage *image,
|
GimpImage *image,
|
||||||
GtkWidget *parent,
|
GtkWidget *parent,
|
||||||
@@ -118,7 +119,7 @@ file_open_cmd_callback (GimpAction *action,
|
|||||||
|
|
||||||
file_open_dialog_show (gimp, widget,
|
file_open_dialog_show (gimp, widget,
|
||||||
_("Open Image"),
|
_("Open Image"),
|
||||||
image, NULL, FALSE);
|
image, NULL, FALSE, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -140,7 +141,29 @@ file_open_as_layers_cmd_callback (GimpAction *action,
|
|||||||
|
|
||||||
file_open_dialog_show (gimp, widget,
|
file_open_dialog_show (gimp, widget,
|
||||||
_("Open Image as Layers"),
|
_("Open Image as Layers"),
|
||||||
image, NULL, TRUE);
|
image, NULL, TRUE, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
file_open_as_link_layer_cmd_callback (GimpAction *action,
|
||||||
|
GVariant *value,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
Gimp *gimp;
|
||||||
|
GtkWidget *widget;
|
||||||
|
GimpDisplay *display;
|
||||||
|
GimpImage *image = NULL;
|
||||||
|
return_if_no_gimp (gimp, data);
|
||||||
|
return_if_no_widget (widget, data);
|
||||||
|
|
||||||
|
display = action_data_get_display (data);
|
||||||
|
|
||||||
|
if (display)
|
||||||
|
image = gimp_display_get_image (display);
|
||||||
|
|
||||||
|
file_open_dialog_show (gimp, widget,
|
||||||
|
_("Open Image as Link Layer"),
|
||||||
|
image, NULL, TRUE, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -577,7 +600,7 @@ file_file_open_dialog (Gimp *gimp,
|
|||||||
{
|
{
|
||||||
file_open_dialog_show (gimp, parent,
|
file_open_dialog_show (gimp, parent,
|
||||||
_("Open Image"),
|
_("Open Image"),
|
||||||
NULL, file, FALSE);
|
NULL, file, FALSE, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -589,7 +612,8 @@ file_open_dialog_show (Gimp *gimp,
|
|||||||
const gchar *title,
|
const gchar *title,
|
||||||
GimpImage *image,
|
GimpImage *image,
|
||||||
GFile *file,
|
GFile *file,
|
||||||
gboolean open_as_layers)
|
gboolean open_as_layers,
|
||||||
|
gboolean open_as_link)
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
|
|
||||||
@@ -621,7 +645,7 @@ file_open_dialog_show (Gimp *gimp,
|
|||||||
gtk_window_set_title (GTK_WINDOW (dialog), title);
|
gtk_window_set_title (GTK_WINDOW (dialog), title);
|
||||||
|
|
||||||
gimp_open_dialog_set_image (GIMP_OPEN_DIALOG (dialog),
|
gimp_open_dialog_set_image (GIMP_OPEN_DIALOG (dialog),
|
||||||
image, open_as_layers);
|
image, open_as_layers, open_as_link);
|
||||||
|
|
||||||
gtk_window_set_transient_for (GTK_WINDOW (dialog),
|
gtk_window_set_transient_for (GTK_WINDOW (dialog),
|
||||||
GTK_WINDOW (gtk_widget_get_toplevel (parent)));
|
GTK_WINDOW (gtk_widget_get_toplevel (parent)));
|
||||||
|
@@ -24,6 +24,9 @@ void file_open_cmd_callback (GimpAction *action,
|
|||||||
void file_open_as_layers_cmd_callback (GimpAction *action,
|
void file_open_as_layers_cmd_callback (GimpAction *action,
|
||||||
GVariant *value,
|
GVariant *value,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
void file_open_as_link_layer_cmd_callback (GimpAction *action,
|
||||||
|
GVariant *value,
|
||||||
|
gpointer data);
|
||||||
void file_open_location_cmd_callback (GimpAction *action,
|
void file_open_location_cmd_callback (GimpAction *action,
|
||||||
GVariant *value,
|
GVariant *value,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
@@ -55,11 +55,13 @@ static void file_open_dialog_response (GtkWidget *dialog,
|
|||||||
static GimpImage *file_open_dialog_open_image (GtkWidget *dialog,
|
static GimpImage *file_open_dialog_open_image (GtkWidget *dialog,
|
||||||
Gimp *gimp,
|
Gimp *gimp,
|
||||||
GFile *file,
|
GFile *file,
|
||||||
GimpPlugInProcedure *load_proc);
|
GimpPlugInProcedure *load_proc,
|
||||||
|
gboolean as_link);
|
||||||
static gboolean file_open_dialog_open_layers (GtkWidget *dialog,
|
static gboolean file_open_dialog_open_layers (GtkWidget *dialog,
|
||||||
GimpImage *image,
|
GimpImage *image,
|
||||||
GFile *file,
|
GFile *file,
|
||||||
GimpPlugInProcedure *load_proc);
|
GimpPlugInProcedure *load_proc,
|
||||||
|
gboolean as_link);
|
||||||
|
|
||||||
|
|
||||||
/* public functions */
|
/* public functions */
|
||||||
@@ -147,13 +149,14 @@ file_open_dialog_response (GtkWidget *dialog,
|
|||||||
{
|
{
|
||||||
if (! file_dialog->image)
|
if (! file_dialog->image)
|
||||||
{
|
{
|
||||||
gimp_open_dialog_set_image (
|
gimp_open_dialog_set_image (open_dialog,
|
||||||
open_dialog,
|
file_open_dialog_open_image (dialog,
|
||||||
file_open_dialog_open_image (dialog,
|
gimp,
|
||||||
gimp,
|
file,
|
||||||
file,
|
file_dialog->file_proc,
|
||||||
file_dialog->file_proc),
|
open_dialog->open_as_link),
|
||||||
TRUE);
|
TRUE,
|
||||||
|
open_dialog->open_as_link);
|
||||||
|
|
||||||
if (file_dialog->image)
|
if (file_dialog->image)
|
||||||
{
|
{
|
||||||
@@ -170,7 +173,8 @@ file_open_dialog_response (GtkWidget *dialog,
|
|||||||
else if (file_open_dialog_open_layers (dialog,
|
else if (file_open_dialog_open_layers (dialog,
|
||||||
file_dialog->image,
|
file_dialog->image,
|
||||||
file,
|
file,
|
||||||
file_dialog->file_proc))
|
file_dialog->file_proc,
|
||||||
|
open_dialog->open_as_link))
|
||||||
{
|
{
|
||||||
success = TRUE;
|
success = TRUE;
|
||||||
}
|
}
|
||||||
@@ -180,7 +184,8 @@ file_open_dialog_response (GtkWidget *dialog,
|
|||||||
if (file_open_dialog_open_image (dialog,
|
if (file_open_dialog_open_image (dialog,
|
||||||
gimp,
|
gimp,
|
||||||
file,
|
file,
|
||||||
file_dialog->file_proc))
|
file_dialog->file_proc,
|
||||||
|
open_dialog->open_as_link))
|
||||||
{
|
{
|
||||||
success = TRUE;
|
success = TRUE;
|
||||||
|
|
||||||
@@ -227,7 +232,8 @@ static GimpImage *
|
|||||||
file_open_dialog_open_image (GtkWidget *dialog,
|
file_open_dialog_open_image (GtkWidget *dialog,
|
||||||
Gimp *gimp,
|
Gimp *gimp,
|
||||||
GFile *file,
|
GFile *file,
|
||||||
GimpPlugInProcedure *load_proc)
|
GimpPlugInProcedure *load_proc,
|
||||||
|
gboolean as_link)
|
||||||
{
|
{
|
||||||
GimpImage *image;
|
GimpImage *image;
|
||||||
GimpPDBStatusType status;
|
GimpPDBStatusType status;
|
||||||
@@ -236,7 +242,7 @@ file_open_dialog_open_image (GtkWidget *dialog,
|
|||||||
image = file_open_with_proc_and_display (gimp,
|
image = file_open_with_proc_and_display (gimp,
|
||||||
gimp_get_user_context (gimp),
|
gimp_get_user_context (gimp),
|
||||||
GIMP_PROGRESS (dialog),
|
GIMP_PROGRESS (dialog),
|
||||||
file, FALSE,
|
file, FALSE, as_link,
|
||||||
load_proc,
|
load_proc,
|
||||||
G_OBJECT (gimp_widget_get_monitor (dialog)),
|
G_OBJECT (gimp_widget_get_monitor (dialog)),
|
||||||
&status, &error);
|
&status, &error);
|
||||||
@@ -256,7 +262,8 @@ static gboolean
|
|||||||
file_open_dialog_open_layers (GtkWidget *dialog,
|
file_open_dialog_open_layers (GtkWidget *dialog,
|
||||||
GimpImage *image,
|
GimpImage *image,
|
||||||
GFile *file,
|
GFile *file,
|
||||||
GimpPlugInProcedure *load_proc)
|
GimpPlugInProcedure *load_proc,
|
||||||
|
gboolean as_link)
|
||||||
{
|
{
|
||||||
GList *new_layers;
|
GList *new_layers;
|
||||||
GimpPDBStatusType status;
|
GimpPDBStatusType status;
|
||||||
@@ -265,7 +272,7 @@ file_open_dialog_open_layers (GtkWidget *dialog,
|
|||||||
new_layers = file_open_layers (image->gimp,
|
new_layers = file_open_layers (image->gimp,
|
||||||
gimp_get_user_context (image->gimp),
|
gimp_get_user_context (image->gimp),
|
||||||
GIMP_PROGRESS (dialog),
|
GIMP_PROGRESS (dialog),
|
||||||
image, FALSE,
|
image, FALSE, as_link,
|
||||||
file, GIMP_RUN_INTERACTIVE, load_proc,
|
file, GIMP_RUN_INTERACTIVE, load_proc,
|
||||||
&status, &error);
|
&status, &error);
|
||||||
|
|
||||||
|
@@ -204,7 +204,7 @@ file_open_location_response (GtkDialog *dialog,
|
|||||||
image = file_open_with_proc_and_display (gimp,
|
image = file_open_with_proc_and_display (gimp,
|
||||||
gimp_get_user_context (gimp),
|
gimp_get_user_context (gimp),
|
||||||
GIMP_PROGRESS (box),
|
GIMP_PROGRESS (box),
|
||||||
file, FALSE, NULL,
|
file, FALSE, FALSE, NULL,
|
||||||
G_OBJECT (gimp_widget_get_monitor (entry)),
|
G_OBJECT (gimp_widget_get_monitor (entry)),
|
||||||
&status, &error);
|
&status, &error);
|
||||||
|
|
||||||
|
@@ -571,7 +571,7 @@ gimp_display_shell_drop_uri_list (GtkWidget *widget,
|
|||||||
|
|
||||||
new_layers = file_open_layers (shell->display->gimp, context,
|
new_layers = file_open_layers (shell->display->gimp, context,
|
||||||
GIMP_PROGRESS (shell->display),
|
GIMP_PROGRESS (shell->display),
|
||||||
image, FALSE,
|
image, FALSE, FALSE,
|
||||||
file, GIMP_RUN_INTERACTIVE, NULL,
|
file, GIMP_RUN_INTERACTIVE, NULL,
|
||||||
&status, &error);
|
&status, &error);
|
||||||
|
|
||||||
|
@@ -55,7 +55,7 @@
|
|||||||
#include "gimp-intl.h"
|
#include "gimp-intl.h"
|
||||||
|
|
||||||
|
|
||||||
static GimpImage * file_open_or_link_image (Gimp *gimp,
|
static GimpImage * file_open_link_image (Gimp *gimp,
|
||||||
GimpContext *context,
|
GimpContext *context,
|
||||||
GimpProgress *progress,
|
GimpProgress *progress,
|
||||||
GFile *file,
|
GFile *file,
|
||||||
@@ -78,6 +78,8 @@ static GList * file_open_get_layers (GimpImage *image,
|
|||||||
gboolean merge_visible,
|
gboolean merge_visible,
|
||||||
gint *n_visible);
|
gint *n_visible);
|
||||||
static gboolean file_open_file_proc_is_import (GimpPlugInProcedure *file_proc);
|
static gboolean file_open_file_proc_is_import (GimpPlugInProcedure *file_proc);
|
||||||
|
static gboolean file_open_valid_permissions (GFile *file,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
|
||||||
/* public functions */
|
/* public functions */
|
||||||
@@ -135,46 +137,8 @@ file_open_image (Gimp *gimp,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME enable these tests for remote files again, needs testing */
|
if (! file_open_valid_permissions (file, error))
|
||||||
if (g_file_is_native (file))
|
return NULL;
|
||||||
{
|
|
||||||
GFileInfo *info;
|
|
||||||
|
|
||||||
info = g_file_query_info (file,
|
|
||||||
G_FILE_ATTRIBUTE_STANDARD_TYPE ","
|
|
||||||
G_FILE_ATTRIBUTE_ACCESS_CAN_READ,
|
|
||||||
G_FILE_QUERY_INFO_NONE,
|
|
||||||
NULL, error);
|
|
||||||
|
|
||||||
if (info != NULL)
|
|
||||||
{
|
|
||||||
if (g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_STANDARD_TYPE) != G_FILE_TYPE_REGULAR)
|
|
||||||
{
|
|
||||||
g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
|
||||||
_("Not a regular file"));
|
|
||||||
g_object_unref (info);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! g_file_info_get_attribute_boolean (info,
|
|
||||||
G_FILE_ATTRIBUTE_ACCESS_CAN_READ))
|
|
||||||
{
|
|
||||||
g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
|
||||||
_("Permission denied"));
|
|
||||||
g_object_unref (info);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_unref (info);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* File likely does not exists. error will already have a more
|
|
||||||
* accurate reason.
|
|
||||||
*/
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! file_proc)
|
if (! file_proc)
|
||||||
file_proc = gimp_plug_in_manager_file_procedure_find (gimp->plug_in_manager,
|
file_proc = gimp_plug_in_manager_file_procedure_find (gimp->plug_in_manager,
|
||||||
@@ -519,9 +483,8 @@ file_open_with_display (Gimp *gimp,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
return file_open_with_proc_and_display (gimp, context, progress,
|
return file_open_with_proc_and_display (gimp, context, progress,
|
||||||
file, as_new, NULL,
|
file, as_new, FALSE, NULL,
|
||||||
monitor,
|
monitor, status, error);
|
||||||
status, error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GimpImage *
|
GimpImage *
|
||||||
@@ -530,6 +493,7 @@ file_open_with_proc_and_display (Gimp *gimp,
|
|||||||
GimpProgress *progress,
|
GimpProgress *progress,
|
||||||
GFile *file,
|
GFile *file,
|
||||||
gboolean as_new,
|
gboolean as_new,
|
||||||
|
gboolean as_link,
|
||||||
GimpPlugInProcedure *file_proc,
|
GimpPlugInProcedure *file_proc,
|
||||||
GObject *monitor,
|
GObject *monitor,
|
||||||
GimpPDBStatusType *status,
|
GimpPDBStatusType *status,
|
||||||
@@ -549,15 +513,26 @@ file_open_with_proc_and_display (Gimp *gimp,
|
|||||||
if (gimp->no_interface)
|
if (gimp->no_interface)
|
||||||
run_mode = GIMP_RUN_NONINTERACTIVE;
|
run_mode = GIMP_RUN_NONINTERACTIVE;
|
||||||
|
|
||||||
image = file_open_or_link_image (gimp, context, progress,
|
if (as_link)
|
||||||
file, 0, 0,
|
image = file_open_link_image (gimp, context, progress,
|
||||||
as_new,
|
file, 0, 0,
|
||||||
file_proc,
|
as_new,
|
||||||
run_mode,
|
file_proc,
|
||||||
NULL,
|
run_mode,
|
||||||
status,
|
NULL,
|
||||||
&mime_type,
|
status,
|
||||||
error);
|
&mime_type,
|
||||||
|
error);
|
||||||
|
else
|
||||||
|
image = file_open_image (gimp, context, progress,
|
||||||
|
file, 0, 0,
|
||||||
|
as_new,
|
||||||
|
file_proc,
|
||||||
|
run_mode,
|
||||||
|
NULL,
|
||||||
|
status,
|
||||||
|
&mime_type,
|
||||||
|
error);
|
||||||
|
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
@@ -636,6 +611,7 @@ file_open_layers (Gimp *gimp,
|
|||||||
GimpProgress *progress,
|
GimpProgress *progress,
|
||||||
GimpImage *dest_image,
|
GimpImage *dest_image,
|
||||||
gboolean merge_visible,
|
gboolean merge_visible,
|
||||||
|
gboolean as_link,
|
||||||
GFile *file,
|
GFile *file,
|
||||||
GimpRunMode run_mode,
|
GimpRunMode run_mode,
|
||||||
GimpPlugInProcedure *file_proc,
|
GimpPlugInProcedure *file_proc,
|
||||||
@@ -654,14 +630,24 @@ file_open_layers (Gimp *gimp,
|
|||||||
g_return_val_if_fail (status != NULL, NULL);
|
g_return_val_if_fail (status != NULL, NULL);
|
||||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||||
|
|
||||||
new_image = file_open_or_link_image (gimp, context, progress,
|
if (as_link)
|
||||||
file,
|
new_image = file_open_link_image (gimp, context, progress,
|
||||||
gimp_image_get_width (dest_image),
|
file,
|
||||||
gimp_image_get_height (dest_image),
|
gimp_image_get_width (dest_image),
|
||||||
FALSE,
|
gimp_image_get_height (dest_image),
|
||||||
file_proc,
|
FALSE,
|
||||||
run_mode,
|
file_proc,
|
||||||
NULL, status, &mime_type, error);
|
run_mode,
|
||||||
|
NULL, status, &mime_type, error);
|
||||||
|
else
|
||||||
|
new_image = file_open_image (gimp, context, progress,
|
||||||
|
file,
|
||||||
|
gimp_image_get_width (dest_image),
|
||||||
|
gimp_image_get_height (dest_image),
|
||||||
|
FALSE,
|
||||||
|
file_proc,
|
||||||
|
run_mode,
|
||||||
|
NULL, status, &mime_type, error);
|
||||||
|
|
||||||
if (new_image)
|
if (new_image)
|
||||||
{
|
{
|
||||||
@@ -769,30 +755,38 @@ file_open_from_command_line (Gimp *gimp,
|
|||||||
/* private functions */
|
/* private functions */
|
||||||
|
|
||||||
static GimpImage *
|
static GimpImage *
|
||||||
file_open_or_link_image (Gimp *gimp,
|
file_open_link_image (Gimp *gimp,
|
||||||
GimpContext *context,
|
GimpContext *context,
|
||||||
GimpProgress *progress,
|
GimpProgress *progress,
|
||||||
GFile *file,
|
GFile *file,
|
||||||
gint vector_width,
|
gint vector_width,
|
||||||
gint vector_height,
|
gint vector_height,
|
||||||
gboolean as_new,
|
gboolean as_new,
|
||||||
GimpPlugInProcedure *file_proc,
|
GimpPlugInProcedure *file_proc,
|
||||||
GimpRunMode run_mode,
|
GimpRunMode run_mode,
|
||||||
gboolean *file_proc_handles_vector,
|
gboolean *file_proc_handles_vector,
|
||||||
GimpPDBStatusType *status,
|
GimpPDBStatusType *status,
|
||||||
const gchar **mime_type,
|
const gchar **mime_type,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GimpImage *image = NULL;
|
GimpImage *image = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||||
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
||||||
|
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
|
||||||
|
g_return_val_if_fail (G_IS_FILE (file), NULL);
|
||||||
|
g_return_val_if_fail (status != NULL, NULL);
|
||||||
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||||
|
|
||||||
if (! file_proc)
|
if (! file_proc)
|
||||||
file_proc = gimp_plug_in_manager_file_procedure_find (gimp->plug_in_manager,
|
file_proc = gimp_plug_in_manager_file_procedure_find (gimp->plug_in_manager,
|
||||||
GIMP_FILE_PROCEDURE_GROUP_OPEN,
|
GIMP_FILE_PROCEDURE_GROUP_OPEN,
|
||||||
file, error);
|
file, error);
|
||||||
|
|
||||||
if (g_file_is_native (file) &&
|
if (! file_open_valid_permissions (file, error))
|
||||||
file_proc != NULL &&
|
return NULL;
|
||||||
file_open_file_proc_is_import (file_proc))
|
|
||||||
|
if (g_file_is_native (file) && file_proc != NULL)
|
||||||
{
|
{
|
||||||
GimpLink *link = gimp_link_new (gimp, file, progress, error);
|
GimpLink *link = gimp_link_new (gimp, file, progress, error);
|
||||||
|
|
||||||
@@ -825,18 +819,16 @@ file_open_or_link_image (Gimp *gimp,
|
|||||||
|
|
||||||
g_clear_object (&link);
|
g_clear_object (&link);
|
||||||
}
|
}
|
||||||
else
|
else if (! g_file_is_native (file))
|
||||||
{
|
{
|
||||||
image = file_open_image (gimp, context, progress,
|
gchar *uri = g_file_get_uri (file);
|
||||||
file,
|
|
||||||
vector_width, vector_height,
|
if (error && ! *error)
|
||||||
as_new,
|
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||||
file_proc,
|
_("Only platform-native file paths are supported: '%s' cannot be opened as link."),
|
||||||
run_mode,
|
uri);
|
||||||
file_proc_handles_vector,
|
|
||||||
status,
|
g_free (uri);
|
||||||
mime_type,
|
|
||||||
error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
@@ -954,3 +946,53 @@ file_open_file_proc_is_import (GimpPlugInProcedure *file_proc)
|
|||||||
g_strcmp0 (proc_name, "file-bz2-load") != 0 &&
|
g_strcmp0 (proc_name, "file-bz2-load") != 0 &&
|
||||||
g_strcmp0 (proc_name, "file-xz-load") != 0);
|
g_strcmp0 (proc_name, "file-xz-load") != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
file_open_valid_permissions (GFile *file,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
/* FIXME enable these tests for remote files again, needs testing */
|
||||||
|
if (g_file_is_native (file))
|
||||||
|
{
|
||||||
|
GFileInfo *info;
|
||||||
|
|
||||||
|
info = g_file_query_info (file,
|
||||||
|
G_FILE_ATTRIBUTE_STANDARD_TYPE ","
|
||||||
|
G_FILE_ATTRIBUTE_ACCESS_CAN_READ,
|
||||||
|
G_FILE_QUERY_INFO_NONE,
|
||||||
|
NULL, error);
|
||||||
|
|
||||||
|
if (info != NULL)
|
||||||
|
{
|
||||||
|
if (g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_STANDARD_TYPE) != G_FILE_TYPE_REGULAR)
|
||||||
|
{
|
||||||
|
g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||||
|
_("Not a regular file"));
|
||||||
|
g_object_unref (info);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! g_file_info_get_attribute_boolean (info,
|
||||||
|
G_FILE_ATTRIBUTE_ACCESS_CAN_READ))
|
||||||
|
{
|
||||||
|
g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||||
|
_("Permission denied"));
|
||||||
|
g_object_unref (info);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref (info);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* File likely does not exists. error will already have a more
|
||||||
|
* accurate reason.
|
||||||
|
*/
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
@@ -59,6 +59,7 @@ GimpImage * file_open_with_proc_and_display (Gimp *gimp,
|
|||||||
GimpProgress *progress,
|
GimpProgress *progress,
|
||||||
GFile *file,
|
GFile *file,
|
||||||
gboolean as_new,
|
gboolean as_new,
|
||||||
|
gboolean as_link,
|
||||||
GimpPlugInProcedure *file_proc,
|
GimpPlugInProcedure *file_proc,
|
||||||
GObject *monitor,
|
GObject *monitor,
|
||||||
GimpPDBStatusType *status,
|
GimpPDBStatusType *status,
|
||||||
@@ -69,6 +70,7 @@ GList * file_open_layers (Gimp *gimp,
|
|||||||
GimpProgress *progress,
|
GimpProgress *progress,
|
||||||
GimpImage *dest_image,
|
GimpImage *dest_image,
|
||||||
gboolean merge_visible,
|
gboolean merge_visible,
|
||||||
|
gboolean as_link,
|
||||||
GFile *file,
|
GFile *file,
|
||||||
GimpRunMode run_mode,
|
GimpRunMode run_mode,
|
||||||
GimpPlugInProcedure *file_proc,
|
GimpPlugInProcedure *file_proc,
|
||||||
|
@@ -135,7 +135,7 @@ file_load_layer_invoker (GimpProcedure *procedure,
|
|||||||
GimpPDBStatusType status;
|
GimpPDBStatusType status;
|
||||||
|
|
||||||
layers = file_open_layers (gimp, context, progress,
|
layers = file_open_layers (gimp, context, progress,
|
||||||
image, FALSE,
|
image, FALSE, FALSE,
|
||||||
file, run_mode, NULL, &status, error);
|
file, run_mode, NULL, &status, error);
|
||||||
|
|
||||||
if (layers)
|
if (layers)
|
||||||
@@ -181,7 +181,7 @@ file_load_layers_invoker (GimpProcedure *procedure,
|
|||||||
GimpPDBStatusType status;
|
GimpPDBStatusType status;
|
||||||
|
|
||||||
layer_list = file_open_layers (gimp, context, progress,
|
layer_list = file_open_layers (gimp, context, progress,
|
||||||
image, FALSE,
|
image, FALSE, FALSE,
|
||||||
file, run_mode, NULL, &status, error);
|
file, run_mode, NULL, &status, error);
|
||||||
|
|
||||||
if (layer_list)
|
if (layer_list)
|
||||||
|
@@ -774,7 +774,7 @@ gimp_layer_tree_view_drop_uri_list (GimpContainerTreeView *view,
|
|||||||
new_layers = file_open_layers (image->gimp,
|
new_layers = file_open_layers (image->gimp,
|
||||||
gimp_container_view_get_context (cont_view),
|
gimp_container_view_get_context (cont_view),
|
||||||
NULL,
|
NULL,
|
||||||
image, FALSE,
|
image, FALSE, FALSE,
|
||||||
file, GIMP_RUN_INTERACTIVE, NULL,
|
file, GIMP_RUN_INTERACTIVE, NULL,
|
||||||
&status, &error);
|
&status, &error);
|
||||||
|
|
||||||
|
@@ -66,7 +66,7 @@ gimp_open_dialog_init (GimpOpenDialog *dialog)
|
|||||||
static void
|
static void
|
||||||
gimp_open_dialog_dispose (GObject *object)
|
gimp_open_dialog_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
gimp_open_dialog_set_image (GIMP_OPEN_DIALOG (object), NULL, FALSE);
|
gimp_open_dialog_set_image (GIMP_OPEN_DIALOG (object), NULL, FALSE, FALSE);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
@@ -99,16 +99,19 @@ gimp_open_dialog_new (Gimp *gimp)
|
|||||||
void
|
void
|
||||||
gimp_open_dialog_set_image (GimpOpenDialog *dialog,
|
gimp_open_dialog_set_image (GimpOpenDialog *dialog,
|
||||||
GimpImage *image,
|
GimpImage *image,
|
||||||
gboolean open_as_layers)
|
gboolean open_as_layers,
|
||||||
|
gboolean open_as_link)
|
||||||
{
|
{
|
||||||
GimpFileDialog *file_dialog;
|
GimpFileDialog *file_dialog;
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_OPEN_DIALOG (dialog));
|
g_return_if_fail (GIMP_IS_OPEN_DIALOG (dialog));
|
||||||
g_return_if_fail (image == NULL || GIMP_IS_IMAGE (image));
|
g_return_if_fail (image == NULL || GIMP_IS_IMAGE (image));
|
||||||
|
g_return_if_fail (! open_as_link || open_as_layers);
|
||||||
|
|
||||||
file_dialog = GIMP_FILE_DIALOG (dialog);
|
file_dialog = GIMP_FILE_DIALOG (dialog);
|
||||||
|
|
||||||
g_set_weak_pointer (&file_dialog->image, image);
|
g_set_weak_pointer (&file_dialog->image, image);
|
||||||
|
|
||||||
dialog->open_as_layers = open_as_layers;
|
dialog->open_as_layers = open_as_layers;
|
||||||
|
dialog->open_as_link = open_as_link;
|
||||||
}
|
}
|
||||||
|
@@ -38,6 +38,7 @@ struct _GimpOpenDialog
|
|||||||
GimpFileDialog parent_instance;
|
GimpFileDialog parent_instance;
|
||||||
|
|
||||||
gboolean open_as_layers;
|
gboolean open_as_layers;
|
||||||
|
gboolean open_as_link;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GimpOpenDialogClass
|
struct _GimpOpenDialogClass
|
||||||
@@ -52,4 +53,5 @@ GtkWidget * gimp_open_dialog_new (Gimp *gimp);
|
|||||||
|
|
||||||
void gimp_open_dialog_set_image (GimpOpenDialog *dialog,
|
void gimp_open_dialog_set_image (GimpOpenDialog *dialog,
|
||||||
GimpImage *image,
|
GimpImage *image,
|
||||||
gboolean open_as_layers);
|
gboolean open_as_layers,
|
||||||
|
gboolean open_as_link);
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
</submenu>
|
</submenu>
|
||||||
<item><attribute name="action">app.file-open</attribute></item>
|
<item><attribute name="action">app.file-open</attribute></item>
|
||||||
<item><attribute name="action">app.file-open-as-layers</attribute></item>
|
<item><attribute name="action">app.file-open-as-layers</attribute></item>
|
||||||
|
<item><attribute name="action">app.file-open-as-link-layers</attribute></item>
|
||||||
<item><attribute name="action">app.file-open-location</attribute></item>
|
<item><attribute name="action">app.file-open-location</attribute></item>
|
||||||
<submenu>
|
<submenu>
|
||||||
<attribute name="label" translatable="yes" context="file-action">Open _Recent</attribute>
|
<attribute name="label" translatable="yes" context="file-action">Open _Recent</attribute>
|
||||||
|
@@ -138,7 +138,7 @@ HELP
|
|||||||
GimpPDBStatusType status;
|
GimpPDBStatusType status;
|
||||||
|
|
||||||
layers = file_open_layers (gimp, context, progress,
|
layers = file_open_layers (gimp, context, progress,
|
||||||
image, FALSE,
|
image, FALSE, FALSE,
|
||||||
file, run_mode, NULL, &status, error);
|
file, run_mode, NULL, &status, error);
|
||||||
|
|
||||||
if (layers)
|
if (layers)
|
||||||
@@ -186,7 +186,7 @@ HELP
|
|||||||
GimpPDBStatusType status;
|
GimpPDBStatusType status;
|
||||||
|
|
||||||
layer_list = file_open_layers (gimp, context, progress,
|
layer_list = file_open_layers (gimp, context, progress,
|
||||||
image, FALSE,
|
image, FALSE, FALSE,
|
||||||
file, run_mode, NULL, &status, error);
|
file, run_mode, NULL, &status, error);
|
||||||
|
|
||||||
if (layer_list)
|
if (layer_list)
|
||||||
|
Reference in New Issue
Block a user