mirror of https://github.com/GNOME/gimp.git
changed file_open_from_command_line() to deal with a single filename only.
2007-03-27 Sven Neumann <sven@gimp.org> * app/file/file-open.[ch]: changed file_open_from_command_line() to deal with a single filename only. * app/widgets/gimpdbusservice.[ch] * app/widgets/dbus-service.xml: changed the D-Bus Open method to take only a single filename. * app/app.c * app/main.c: changed accordingly. svn path=/trunk/; revision=22181
This commit is contained in:
parent
3ab0abce3c
commit
518b13d17b
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2007-03-27 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/file/file-open.[ch]: changed file_open_from_command_line()
|
||||
to deal with a single filename only.
|
||||
|
||||
* app/widgets/gimpdbusservice.[ch]
|
||||
* app/widgets/dbus-service.xml: changed the D-Bus Open method to
|
||||
take only a single filename.
|
||||
|
||||
* app/app.c
|
||||
* app/main.c: changed accordingly.
|
||||
|
||||
2007-03-26 Michael Schumacher <schumaml@cvs.gnome.org>
|
||||
|
||||
* plug-ins/common/compressor.c (save_image, load_image):
|
||||
|
|
|
@ -220,7 +220,12 @@ app_run (const gchar *full_prog_name,
|
|||
/* Load the images given on the command-line.
|
||||
*/
|
||||
if (filenames)
|
||||
file_open_from_command_line (gimp, filenames);
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; filenames[i] != NULL; i++)
|
||||
file_open_from_command_line (gimp, filenames[i]);
|
||||
}
|
||||
|
||||
#ifndef GIMP_CONSOLE_COMPILATION
|
||||
if (! no_interface)
|
||||
|
|
|
@ -462,60 +462,60 @@ file_open_layers (Gimp *gimp,
|
|||
/* This function is called for filenames passed on the command-line
|
||||
* or from the D-Bus service.
|
||||
*/
|
||||
void
|
||||
file_open_from_command_line (Gimp *gimp,
|
||||
const gchar **uris)
|
||||
gboolean
|
||||
file_open_from_command_line (Gimp *gimp,
|
||||
const gchar *filename)
|
||||
{
|
||||
gint i;
|
||||
GError *error = NULL;
|
||||
gchar *uri;
|
||||
gboolean success = FALSE;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (uris != NULL);
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
|
||||
g_return_val_if_fail (filename != NULL, FALSE);
|
||||
|
||||
for (i = 0; uris[i]; i++)
|
||||
/* we accept URI or filename */
|
||||
uri = file_utils_any_to_uri (gimp, filename, &error);
|
||||
|
||||
if (uri)
|
||||
{
|
||||
GError *error = NULL;
|
||||
gchar *uri;
|
||||
GimpImage *image;
|
||||
GimpPDBStatusType status;
|
||||
|
||||
/* we accept URIs and filenames */
|
||||
uri = file_utils_any_to_uri (gimp, uris[i], &error);
|
||||
image = file_open_with_display (gimp,
|
||||
gimp_get_user_context (gimp),
|
||||
NULL,
|
||||
uri,
|
||||
&status, &error);
|
||||
|
||||
if (uri)
|
||||
if (image)
|
||||
{
|
||||
GimpImage *image;
|
||||
GimpPDBStatusType status;
|
||||
|
||||
image = file_open_with_display (gimp,
|
||||
gimp_get_user_context (gimp),
|
||||
NULL,
|
||||
uri,
|
||||
&status, &error);
|
||||
|
||||
if (! image && status != GIMP_PDB_CANCEL)
|
||||
{
|
||||
gchar *filename = file_utils_uri_to_utf8_filename (uri);
|
||||
|
||||
g_message (_("Opening '%s' failed: %s"),
|
||||
filename, error->message);
|
||||
g_clear_error (&error);
|
||||
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
g_free (uri);
|
||||
success = TRUE;
|
||||
}
|
||||
else
|
||||
else if (status != GIMP_PDB_CANCEL)
|
||||
{
|
||||
g_printerr ("conversion filename -> uri failed: %s\n",
|
||||
error->message);
|
||||
gchar *filename = file_utils_uri_to_utf8_filename (uri);
|
||||
|
||||
g_message (_("Opening '%s' failed: %s"), filename, error->message);
|
||||
g_clear_error (&error);
|
||||
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
g_free (uri);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_printerr ("conversion filename -> uri failed: %s\n",
|
||||
error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
|
||||
static void
|
||||
file_open_sanitize_image (GimpImage *image)
|
||||
{
|
||||
|
|
|
@ -68,8 +68,8 @@ GList * file_open_layers (Gimp *gimp,
|
|||
GimpPDBStatusType *status,
|
||||
GError **error);
|
||||
|
||||
void file_open_from_command_line (Gimp *gimp,
|
||||
const gchar **uris);
|
||||
gboolean file_open_from_command_line (Gimp *gimp,
|
||||
const gchar *filename);
|
||||
|
||||
|
||||
#endif /* __FILE_OPEN_H__ */
|
||||
|
|
117
app/main.c
117
app/main.c
|
@ -105,6 +105,10 @@ static void gimp_open_console_window (void);
|
|||
#define gimp_open_console_window() /* as nothing */
|
||||
#endif
|
||||
|
||||
static gboolean gimp_dbus_open (const gchar **filenames,
|
||||
gboolean be_verbose);
|
||||
|
||||
|
||||
static const gchar *system_gimprc = NULL;
|
||||
static const gchar *user_gimprc = NULL;
|
||||
static const gchar *session_name = NULL;
|
||||
|
@ -356,56 +360,11 @@ main (int argc,
|
|||
if (no_interface)
|
||||
new_instance = TRUE;
|
||||
|
||||
#ifndef GIMP_CONSOLE_COMPILATION
|
||||
#if HAVE_DBUS_GLIB
|
||||
if (! new_instance)
|
||||
{
|
||||
DBusGConnection *connection;
|
||||
|
||||
connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
|
||||
|
||||
if (connection)
|
||||
{
|
||||
DBusGProxy *proxy;
|
||||
gboolean success;
|
||||
|
||||
proxy = dbus_g_proxy_new_for_name (connection,
|
||||
GIMP_DBUS_SERVICE_NAME,
|
||||
GIMP_DBUS_SERVICE_PATH,
|
||||
GIMP_DBUS_SERVICE_INTERFACE);
|
||||
|
||||
if (filenames)
|
||||
success = dbus_g_proxy_call (proxy, "Open", &error,
|
||||
G_TYPE_STRV, filenames,
|
||||
G_TYPE_INVALID, G_TYPE_INVALID);
|
||||
else
|
||||
success = dbus_g_proxy_call (proxy, "Activate", &error,
|
||||
G_TYPE_INVALID, G_TYPE_INVALID);
|
||||
|
||||
g_object_unref (proxy);
|
||||
dbus_g_connection_unref (connection);
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (be_verbose)
|
||||
g_print ("%s\n",
|
||||
_("Another GIMP instance is already running."));
|
||||
|
||||
gdk_notify_startup_complete ();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
else if (! (error->domain == DBUS_GERROR &&
|
||||
error->code == DBUS_GERROR_SERVICE_UNKNOWN))
|
||||
{
|
||||
g_print ("%s\n", error->message);
|
||||
}
|
||||
|
||||
g_clear_error (&error);
|
||||
}
|
||||
if (gimp_dbus_open (filenames, be_verbose))
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
abort_message = sanity_check ();
|
||||
if (abort_message)
|
||||
|
@ -718,3 +677,67 @@ gimp_sigfatal_handler (gint sig_num)
|
|||
}
|
||||
|
||||
#endif /* ! G_OS_WIN32 */
|
||||
|
||||
|
||||
static gboolean
|
||||
gimp_dbus_open (const gchar **filenames,
|
||||
gboolean be_verbose)
|
||||
{
|
||||
#ifndef GIMP_CONSOLE_COMPILATION
|
||||
#if HAVE_DBUS_GLIB
|
||||
DBusGConnection *connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
|
||||
|
||||
if (connection)
|
||||
{
|
||||
DBusGProxy *proxy;
|
||||
gboolean success;
|
||||
GError *error = NULL;
|
||||
|
||||
proxy = dbus_g_proxy_new_for_name (connection,
|
||||
GIMP_DBUS_SERVICE_NAME,
|
||||
GIMP_DBUS_SERVICE_PATH,
|
||||
GIMP_DBUS_SERVICE_INTERFACE);
|
||||
|
||||
if (filenames)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0, success = TRUE; filenames[i] && success; i++)
|
||||
{
|
||||
success = dbus_g_proxy_call (proxy, "Open", &error,
|
||||
G_TYPE_STRING, filenames[i],
|
||||
G_TYPE_INVALID, G_TYPE_INVALID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
success = dbus_g_proxy_call (proxy, "Activate", &error,
|
||||
G_TYPE_INVALID, G_TYPE_INVALID);
|
||||
}
|
||||
|
||||
g_object_unref (proxy);
|
||||
dbus_g_connection_unref (connection);
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (be_verbose)
|
||||
g_print ("%s\n",
|
||||
_("Another GIMP instance is already running."));
|
||||
|
||||
gdk_notify_startup_complete ();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else if (! (error->domain == DBUS_GERROR &&
|
||||
error->code == DBUS_GERROR_SERVICE_UNKNOWN))
|
||||
{
|
||||
g_print ("%s\n", error->message);
|
||||
}
|
||||
|
||||
g_clear_error (&error);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<annotation name="org.freedesktop.DBus.GLib.CSymbol"
|
||||
value="gimp_dbus_service" />
|
||||
<method name="Open">
|
||||
<arg type="as" name="uri" direction="in" />
|
||||
<arg type="s" name="filename" direction="in" />
|
||||
</method>
|
||||
<method name="Activate" />
|
||||
</interface>
|
||||
|
|
|
@ -70,13 +70,13 @@ gimp_dbus_service_new (Gimp *gimp)
|
|||
|
||||
gboolean
|
||||
gimp_dbus_service_open (GimpDBusService *service,
|
||||
const gchar **uris,
|
||||
const gchar *filename,
|
||||
GError **dbus_error)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_DBUS_SERVICE (service), FALSE);
|
||||
|
||||
if (uris)
|
||||
file_open_from_command_line (service->gimp, uris);
|
||||
if (filename != NULL)
|
||||
file_open_from_command_line (service->gimp, filename);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define GIMP_DBUS_SERVICE_NAME "org.gimp.GIMP.UI"
|
||||
#define GIMP_DBUS_SERVICE_PATH "/org/gimp/GIMP/UI"
|
||||
#define GIMP_DBUS_SERVICE_INTERFACE "org.gimp.GIMP.UI"
|
||||
#define GIMP_DBUS_SERVICE_NAME "org.gimp.GIMP.UI"
|
||||
#define GIMP_DBUS_SERVICE_PATH "/org/gimp/GIMP/UI"
|
||||
#define GIMP_DBUS_SERVICE_INTERFACE "org.gimp.GIMP.UI"
|
||||
|
||||
|
||||
#define GIMP_TYPE_DBUS_SERVICE (gimp_dbus_service_get_type ())
|
||||
|
@ -54,15 +54,15 @@ struct _GimpDBusServiceClass
|
|||
};
|
||||
|
||||
|
||||
GType gimp_dbus_service_get_type (void) G_GNUC_CONST;
|
||||
GType gimp_dbus_service_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GObject * gimp_dbus_service_new (Gimp *gimp);
|
||||
GObject * gimp_dbus_service_new (Gimp *gimp);
|
||||
|
||||
gboolean gimp_dbus_service_open (GimpDBusService *service,
|
||||
const gchar **uris,
|
||||
GError **dbus_error);
|
||||
gboolean gimp_dbus_service_activate (GimpDBusService *service,
|
||||
GError **dbus_error);
|
||||
gboolean gimp_dbus_service_open (GimpDBusService *service,
|
||||
const gchar *filename,
|
||||
GError **dbus_error);
|
||||
gboolean gimp_dbus_service_activate (GimpDBusService *service,
|
||||
GError **dbus_error);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
Loading…
Reference in New Issue