mirror of https://github.com/GNOME/gimp.git
Allow other applications to open images in GIMP as if they were new images
2007-04-17 Sven Neumann <sven@gimp.org> Allow other applications to open images in GIMP as if they were new images (without associating a filename). Fixes bug #423118. * app/file/file-open.[ch]: added parameter 'as_new' to file_open_image() and its variants. * app/actions/data-commands.c * app/actions/documents-commands.c * app/actions/file-commands.c * app/core/gimpimagefile.c * app/dialogs/file-open-dialog.c * app/dialogs/file-open-location-dialog.c * app/widgets/gimptoolbox.c * app/widgets/gimptoolbox-dnd.c: changed accordingly. * app/app.[ch] * app/main.c: added new command-line option '--as-new'. * app/widgets/gimpdbusservice.[ch] * app/widgets/dbus-service.xml: added new method "OpenAsNew" to the D-Bus interface. * docs/gimp.1.in: document the new command-line option. svn path=/trunk/; revision=22264
This commit is contained in:
parent
ef339861d7
commit
49b8176aa5
26
ChangeLog
26
ChangeLog
|
@ -1,3 +1,29 @@
|
|||
2007-04-17 Sven Neumann <sven@gimp.org>
|
||||
|
||||
Allow other applications to open images in GIMP as if they were
|
||||
new images (without associating a filename). Fixes bug #423118.
|
||||
|
||||
* app/file/file-open.[ch]: added parameter 'as_new' to
|
||||
file_open_image() and its variants.
|
||||
|
||||
* app/actions/data-commands.c
|
||||
* app/actions/documents-commands.c
|
||||
* app/actions/file-commands.c
|
||||
* app/core/gimpimagefile.c
|
||||
* app/dialogs/file-open-dialog.c
|
||||
* app/dialogs/file-open-location-dialog.c
|
||||
* app/widgets/gimptoolbox.c
|
||||
* app/widgets/gimptoolbox-dnd.c: changed accordingly.
|
||||
|
||||
* app/app.[ch]
|
||||
* app/main.c: added new command-line option '--as-new'.
|
||||
|
||||
* app/widgets/gimpdbusservice.[ch]
|
||||
* app/widgets/dbus-service.xml: added new method "OpenAsNew" to the
|
||||
D-Bus interface.
|
||||
|
||||
* docs/gimp.1.in: document the new command-line option.
|
||||
|
||||
2007-04-17 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/script-fu/scripts/neon-logo.scm: applied slightly
|
||||
|
|
|
@ -92,7 +92,8 @@ data_open_as_image_cmd_callback (GtkAction *action,
|
|||
GimpPDBStatusType status;
|
||||
GError *error = NULL;
|
||||
|
||||
image = file_open_with_display (context->gimp, context, NULL, uri,
|
||||
image = file_open_with_display (context->gimp, context, NULL,
|
||||
uri, FALSE,
|
||||
&status, &error);
|
||||
|
||||
if (! image && status != GIMP_PDB_CANCEL)
|
||||
|
|
|
@ -309,8 +309,8 @@ documents_open_image (GimpContext *context,
|
|||
|
||||
uri = gimp_object_get_name (GIMP_OBJECT (imagefile));
|
||||
|
||||
image = file_open_with_display (context->gimp, context, NULL,
|
||||
uri, &status, &error);
|
||||
image = file_open_with_display (context->gimp, context, NULL, uri, FALSE,
|
||||
&status, &error);
|
||||
|
||||
if (! image && status != GIMP_PDB_CANCEL)
|
||||
{
|
||||
|
|
|
@ -157,7 +157,7 @@ file_last_opened_cmd_callback (GtkAction *action,
|
|||
|
||||
image = file_open_with_display (gimp, action_data_get_context (data),
|
||||
NULL,
|
||||
GIMP_OBJECT (imagefile)->name,
|
||||
GIMP_OBJECT (imagefile)->name, FALSE,
|
||||
&status, &error);
|
||||
|
||||
if (! image && status != GIMP_PDB_CANCEL)
|
||||
|
@ -566,7 +566,7 @@ file_revert_confirm_response (GtkWidget *dialog,
|
|||
|
||||
new_image = file_open_image (gimp, gimp_get_user_context (gimp),
|
||||
GIMP_PROGRESS (display),
|
||||
uri, uri, NULL,
|
||||
uri, uri, FALSE, NULL,
|
||||
GIMP_RUN_INTERACTIVE,
|
||||
&status, NULL, &error);
|
||||
|
||||
|
|
|
@ -121,6 +121,7 @@ app_run (const gchar *full_prog_name,
|
|||
const gchar *session_name,
|
||||
const gchar *batch_interpreter,
|
||||
const gchar **batch_commands,
|
||||
gboolean as_new,
|
||||
gboolean no_interface,
|
||||
gboolean no_data,
|
||||
gboolean no_fonts,
|
||||
|
@ -224,7 +225,7 @@ app_run (const gchar *full_prog_name,
|
|||
gint i;
|
||||
|
||||
for (i = 0; filenames[i] != NULL; i++)
|
||||
file_open_from_command_line (gimp, filenames[i]);
|
||||
file_open_from_command_line (gimp, filenames[i], as_new);
|
||||
}
|
||||
|
||||
#ifndef GIMP_CONSOLE_COMPILATION
|
||||
|
|
|
@ -38,6 +38,7 @@ void app_run (const gchar *full_prog_name,
|
|||
const gchar *session_name,
|
||||
const gchar *batch_interpreter,
|
||||
const gchar **batch_commands,
|
||||
gboolean as_new,
|
||||
gboolean no_interface,
|
||||
gboolean no_data,
|
||||
gboolean no_fonts,
|
||||
|
|
|
@ -261,8 +261,9 @@ gimp_imagefile_create_thumbnail (GimpImagefile *imagefile,
|
|||
GimpPDBStatusType status;
|
||||
|
||||
image = file_open_image (imagefile->gimp, context, progress,
|
||||
thumbnail->image_uri, thumbnail->image_uri,
|
||||
NULL, GIMP_RUN_NONINTERACTIVE,
|
||||
thumbnail->image_uri,
|
||||
thumbnail->image_uri,
|
||||
FALSE, NULL, GIMP_RUN_NONINTERACTIVE,
|
||||
&status, &mime_type, NULL);
|
||||
|
||||
if (image)
|
||||
|
|
|
@ -187,11 +187,9 @@ file_open_dialog_open_image (GtkWidget *open_dialog,
|
|||
image = file_open_with_proc_and_display (gimp,
|
||||
gimp_get_user_context (gimp),
|
||||
GIMP_PROGRESS (open_dialog),
|
||||
uri,
|
||||
entered_filename,
|
||||
uri, entered_filename, FALSE,
|
||||
load_proc,
|
||||
&status,
|
||||
&error);
|
||||
&status, &error);
|
||||
|
||||
if (image)
|
||||
{
|
||||
|
|
|
@ -202,7 +202,7 @@ file_open_location_response (GtkDialog *dialog,
|
|||
image = file_open_with_proc_and_display (gimp,
|
||||
gimp_get_user_context (gimp),
|
||||
GIMP_PROGRESS (box),
|
||||
uri, text, NULL,
|
||||
uri, text, FALSE, NULL,
|
||||
&status, &error);
|
||||
|
||||
if (image == NULL && status != GIMP_PDB_CANCEL)
|
||||
|
|
|
@ -70,7 +70,8 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
static void file_open_sanitize_image (GimpImage *image);
|
||||
static void file_open_sanitize_image (GimpImage *image,
|
||||
gboolean as_new);
|
||||
static void file_open_handle_color_profile (GimpImage *image,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
|
@ -85,6 +86,7 @@ file_open_image (Gimp *gimp,
|
|||
GimpProgress *progress,
|
||||
const gchar *uri,
|
||||
const gchar *entered_filename,
|
||||
gboolean as_new,
|
||||
GimpPlugInProcedure *file_proc,
|
||||
GimpRunMode run_mode,
|
||||
GimpPDBStatusType *status,
|
||||
|
@ -158,7 +160,7 @@ file_open_image (Gimp *gimp,
|
|||
|
||||
if (image)
|
||||
{
|
||||
file_open_sanitize_image (image);
|
||||
file_open_sanitize_image (image, as_new);
|
||||
|
||||
if (mime_type)
|
||||
*mime_type = file_proc->mime_type;
|
||||
|
@ -255,7 +257,7 @@ file_open_thumbnail (Gimp *gimp,
|
|||
|
||||
if (image)
|
||||
{
|
||||
file_open_sanitize_image (image);
|
||||
file_open_sanitize_image (image, FALSE);
|
||||
|
||||
*mime_type = file_proc->mime_type;
|
||||
|
||||
|
@ -279,11 +281,13 @@ file_open_with_display (Gimp *gimp,
|
|||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const gchar *uri,
|
||||
gboolean as_new,
|
||||
GimpPDBStatusType *status,
|
||||
GError **error)
|
||||
{
|
||||
return file_open_with_proc_and_display (gimp, context, progress,
|
||||
uri, uri, NULL, status, error);
|
||||
uri, uri, as_new, NULL,
|
||||
status, error);
|
||||
}
|
||||
|
||||
GimpImage *
|
||||
|
@ -292,6 +296,7 @@ file_open_with_proc_and_display (Gimp *gimp,
|
|||
GimpProgress *progress,
|
||||
const gchar *uri,
|
||||
const gchar *entered_filename,
|
||||
gboolean as_new,
|
||||
GimpPlugInProcedure *file_proc,
|
||||
GimpPDBStatusType *status,
|
||||
GError **error)
|
||||
|
@ -307,6 +312,7 @@ file_open_with_proc_and_display (Gimp *gimp,
|
|||
image = file_open_image (gimp, context, progress,
|
||||
uri,
|
||||
entered_filename,
|
||||
as_new,
|
||||
file_proc,
|
||||
GIMP_RUN_INTERACTIVE,
|
||||
status,
|
||||
|
@ -314,12 +320,14 @@ file_open_with_proc_and_display (Gimp *gimp,
|
|||
error);
|
||||
|
||||
if (image)
|
||||
{
|
||||
gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0);
|
||||
|
||||
if (! as_new)
|
||||
{
|
||||
GimpDocumentList *documents = GIMP_DOCUMENT_LIST (gimp->documents);
|
||||
GimpImagefile *imagefile;
|
||||
|
||||
gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0);
|
||||
|
||||
imagefile = gimp_document_list_add_uri (documents, uri, mime_type);
|
||||
|
||||
/* can only create a thumbnail if the passed uri and the
|
||||
|
@ -336,6 +344,7 @@ file_open_with_proc_and_display (Gimp *gimp,
|
|||
|
||||
if (gimp->config->save_document_history)
|
||||
gimp_recent_list_add_uri (uri, mime_type);
|
||||
}
|
||||
|
||||
/* the display owns the image now */
|
||||
g_object_unref (image);
|
||||
|
@ -369,7 +378,7 @@ file_open_layers (Gimp *gimp,
|
|||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
new_image = file_open_image (gimp, context, progress,
|
||||
uri, uri,
|
||||
uri, uri, FALSE,
|
||||
file_proc,
|
||||
run_mode,
|
||||
status, &mime_type, error);
|
||||
|
@ -464,7 +473,8 @@ file_open_layers (Gimp *gimp,
|
|||
*/
|
||||
gboolean
|
||||
file_open_from_command_line (Gimp *gimp,
|
||||
const gchar *filename)
|
||||
const gchar *filename,
|
||||
gboolean as_new)
|
||||
{
|
||||
GError *error = NULL;
|
||||
gchar *uri;
|
||||
|
@ -484,7 +494,7 @@ file_open_from_command_line (Gimp *gimp,
|
|||
image = file_open_with_display (gimp,
|
||||
gimp_get_user_context (gimp),
|
||||
NULL,
|
||||
uri,
|
||||
uri, as_new,
|
||||
&status, &error);
|
||||
|
||||
if (image)
|
||||
|
@ -517,8 +527,12 @@ file_open_from_command_line (Gimp *gimp,
|
|||
/* private functions */
|
||||
|
||||
static void
|
||||
file_open_sanitize_image (GimpImage *image)
|
||||
file_open_sanitize_image (GimpImage *image,
|
||||
gboolean as_new)
|
||||
{
|
||||
if (as_new)
|
||||
gimp_object_set_name (GIMP_OBJECT (image), NULL);
|
||||
|
||||
/* clear all undo steps */
|
||||
gimp_image_undo_free (image);
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ GimpImage * file_open_image (Gimp *gimp,
|
|||
GimpProgress *progress,
|
||||
const gchar *uri,
|
||||
const gchar *entered_filename,
|
||||
gboolean as_new,
|
||||
GimpPlugInProcedure *file_proc,
|
||||
GimpRunMode run_mode,
|
||||
GimpPDBStatusType *status,
|
||||
|
@ -45,6 +46,7 @@ GimpImage * file_open_with_display (Gimp *gimp,
|
|||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const gchar *uri,
|
||||
gboolean as_new,
|
||||
GimpPDBStatusType *status,
|
||||
GError **error);
|
||||
|
||||
|
@ -53,6 +55,7 @@ GimpImage * file_open_with_proc_and_display (Gimp *gimp,
|
|||
GimpProgress *progress,
|
||||
const gchar *uri,
|
||||
const gchar *entered_filename,
|
||||
gboolean as_new,
|
||||
GimpPlugInProcedure *file_proc,
|
||||
GimpPDBStatusType *status,
|
||||
GError **error);
|
||||
|
@ -69,7 +72,8 @@ GList * file_open_layers (Gimp *gimp,
|
|||
GError **error);
|
||||
|
||||
gboolean file_open_from_command_line (Gimp *gimp,
|
||||
const gchar *filename);
|
||||
const gchar *filename,
|
||||
gboolean as_new);
|
||||
|
||||
|
||||
#endif /* __FILE_OPEN_H__ */
|
||||
|
|
14
app/main.c
14
app/main.c
|
@ -106,6 +106,7 @@ static void gimp_open_console_window (void);
|
|||
#endif
|
||||
|
||||
static gboolean gimp_dbus_open (const gchar **filenames,
|
||||
gboolean as_new,
|
||||
gboolean be_verbose);
|
||||
|
||||
|
||||
|
@ -115,6 +116,7 @@ static const gchar *session_name = NULL;
|
|||
static const gchar *batch_interpreter = NULL;
|
||||
static const gchar **batch_commands = NULL;
|
||||
static const gchar **filenames = NULL;
|
||||
static gboolean as_new = FALSE;
|
||||
static gboolean no_interface = FALSE;
|
||||
static gboolean no_data = FALSE;
|
||||
static gboolean no_fonts = FALSE;
|
||||
|
@ -160,6 +162,11 @@ static const GOptionEntry main_entries[] =
|
|||
G_OPTION_ARG_NONE, &new_instance,
|
||||
N_("Start a new GIMP instance"), NULL
|
||||
},
|
||||
{
|
||||
"as-new", 'a', 0,
|
||||
G_OPTION_ARG_NONE, &as_new,
|
||||
N_("Open images as new"), NULL
|
||||
},
|
||||
{
|
||||
"no-interface", 'i', 0,
|
||||
G_OPTION_ARG_NONE, &no_interface,
|
||||
|
@ -362,7 +369,7 @@ main (int argc,
|
|||
|
||||
if (! new_instance)
|
||||
{
|
||||
if (gimp_dbus_open (filenames, be_verbose))
|
||||
if (gimp_dbus_open (filenames, as_new, be_verbose))
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -379,6 +386,7 @@ main (int argc,
|
|||
session_name,
|
||||
batch_interpreter,
|
||||
batch_commands,
|
||||
as_new,
|
||||
no_interface,
|
||||
no_data,
|
||||
no_fonts,
|
||||
|
@ -681,6 +689,7 @@ gimp_sigfatal_handler (gint sig_num)
|
|||
|
||||
static gboolean
|
||||
gimp_dbus_open (const gchar **filenames,
|
||||
gboolean as_new,
|
||||
gboolean be_verbose)
|
||||
{
|
||||
#ifndef GIMP_CONSOLE_COMPILATION
|
||||
|
@ -700,13 +709,14 @@ gimp_dbus_open (const gchar **filenames,
|
|||
|
||||
if (filenames)
|
||||
{
|
||||
const gchar *method = as_new ? "OpenAsNew" : "Open";
|
||||
gint i;
|
||||
|
||||
for (i = 0, success = TRUE; filenames[i] && success; i++)
|
||||
{
|
||||
gboolean retval; /* ignored */
|
||||
|
||||
success = dbus_g_proxy_call (proxy, "Open", &error,
|
||||
success = dbus_g_proxy_call (proxy, method, &error,
|
||||
G_TYPE_STRING, filenames[i],
|
||||
G_TYPE_INVALID,
|
||||
G_TYPE_BOOLEAN, &retval,
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
<arg type="s" name="filename" direction="in" />
|
||||
<arg type="b" name="success" direction="out" />
|
||||
</method>
|
||||
<method name="OpenAsNew">
|
||||
<arg type="s" name="filename" direction="in" />
|
||||
<arg type="b" name="success" direction="out" />
|
||||
</method>
|
||||
<method name="Activate" />
|
||||
</interface>
|
||||
|
||||
|
|
|
@ -78,7 +78,22 @@ gimp_dbus_service_open (GimpDBusService *service,
|
|||
g_return_val_if_fail (filename != NULL, FALSE);
|
||||
g_return_val_if_fail (success != NULL, FALSE);
|
||||
|
||||
*success = file_open_from_command_line (service->gimp, filename);
|
||||
*success = file_open_from_command_line (service->gimp, filename, FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_dbus_service_open_as_new (GimpDBusService *service,
|
||||
const gchar *filename,
|
||||
gboolean *success,
|
||||
GError **dbus_error)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_DBUS_SERVICE (service), FALSE);
|
||||
g_return_val_if_fail (filename != NULL, FALSE);
|
||||
g_return_val_if_fail (success != NULL, FALSE);
|
||||
|
||||
*success = file_open_from_command_line (service->gimp, filename, TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -62,6 +62,10 @@ gboolean gimp_dbus_service_open (GimpDBusService *service,
|
|||
const gchar *filename,
|
||||
gboolean *success,
|
||||
GError **dbus_error);
|
||||
gboolean gimp_dbus_service_open_as_new (GimpDBusService *service,
|
||||
const gchar *filename,
|
||||
gboolean *success,
|
||||
GError **dbus_error);
|
||||
gboolean gimp_dbus_service_activate (GimpDBusService *service,
|
||||
GError **dbus_error);
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ gimp_toolbox_drop_uri_list (GtkWidget *widget,
|
|||
GError *error = NULL;
|
||||
|
||||
image = file_open_with_display (context->gimp, context, NULL,
|
||||
uri, &status, &error);
|
||||
uri, FALSE, &status, &error);
|
||||
|
||||
if (! image && status != GIMP_PDB_CANCEL)
|
||||
{
|
||||
|
|
|
@ -902,7 +902,7 @@ toolbox_paste_received (GtkClipboard *clipboard,
|
|||
GError *error = NULL;
|
||||
|
||||
image = file_open_with_display (context->gimp, context, NULL,
|
||||
copy, &status, &error);
|
||||
copy, FALSE, &status, &error);
|
||||
|
||||
if (! image && status != GIMP_PDB_CANCEL)
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@ gimp - an image manipulation and paint program.
|
|||
.SH SYNOPSIS
|
||||
.B gimp
|
||||
[\-h] [\-\-help] [\-\-help-all] [\-\-help-gtk] [-v] [\-\-version]
|
||||
[\-\-license] [\-\-verbose] [\-n] [\-\-new\-instance]
|
||||
[\-\-license] [\-\-verbose] [\-n] [\-\-new\-instance] [\-a] [\-\-as\-new]
|
||||
[\-i] [\-\-no\-interface] [\-d] [\-\-no\-data] [\-f] [\-\-no\-fonts]
|
||||
[\-s] [\-\-no\-splash] [\-\-no\-shm] [\-\-no\-cpu\-accel]
|
||||
[\-\-display \fIdisplay\fP] [\-\-session \fI<name>\fP]
|
||||
|
@ -69,13 +69,17 @@ Output license information and exit.
|
|||
.B \-\-verbose
|
||||
Be verbose and create information on standard output.
|
||||
.TP 8
|
||||
.B \-i, \-\-no\-interface
|
||||
Run without a user interface.
|
||||
.TP 8
|
||||
.B \-n, \-\-new\-instance
|
||||
Do not attempt to reuse an already running GIMP instance. Always start a
|
||||
new one.
|
||||
.TP 8
|
||||
.B \-a, \-\-as\-new
|
||||
Open filenames passed on the command-line as new images, don't set the
|
||||
filename on them.
|
||||
.TP 8
|
||||
.B \-i, \-\-no\-interface
|
||||
Run without a user interface.
|
||||
.TP 8
|
||||
.B \-d, \-\-no\-data
|
||||
Do not load patterns, gradients, palettes, or brushes. Often useful
|
||||
in non-interactive situations where startup time is to be minimized.
|
||||
|
|
Loading…
Reference in New Issue