/* This function is called for filenames passed on the command-line * or from the D-Bus service. */ gboolean file_open_from_command_line (Gimp *gimp, const gchar *filename, gboolean as_new) { GError *error = NULL; gchar *uri; gboolean success = FALSE; g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE); g_return_val_if_fail (filename != NULL, FALSE); /* we accept URI or filename */ uri = file_utils_any_to_uri (gimp, filename, &error); if (uri) { GimpImage *image; GimpObject *display = gimp_get_empty_display (gimp); GimpPDBStatusType status; image = file_open_with_display (gimp, gimp_get_user_context (gimp), GIMP_PROGRESS (display), uri, as_new, &status, &error); if (image) { success = TRUE; g_object_set_data_full (G_OBJECT (gimp), GIMP_FILE_OPEN_LAST_URI_KEY, uri, (GDestroyNotify) g_free); } else if (status != GIMP_PDB_CANCEL) { gchar *filename = file_utils_uri_display_name (uri); gimp_message (gimp, G_OBJECT (display), GIMP_MESSAGE_ERROR, _("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; }
/* This function is called for filenames passed on the command-line * or from the D-Bus service. */ gboolean file_open_from_command_line (Gimp *gimp, GFile *file, gboolean as_new, GObject *screen, gint monitor) { GimpImage *image; GimpObject *display; GimpPDBStatusType status; gboolean success = FALSE; GError *error = NULL; g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE); g_return_val_if_fail (G_IS_FILE (file), FALSE); g_return_val_if_fail (screen == NULL || G_IS_OBJECT (screen), FALSE); display = gimp_get_empty_display (gimp); /* show the progress in the last opened display, see bug #704896 */ if (! display) display = gimp_context_get_display (gimp_get_user_context (gimp)); if (display) g_object_add_weak_pointer (G_OBJECT (display), (gpointer) &display); image = file_open_with_display (gimp, gimp_get_user_context (gimp), GIMP_PROGRESS (display), file, as_new, screen, monitor, &status, &error); if (image) { success = TRUE; g_object_set_data_full (G_OBJECT (gimp), GIMP_FILE_OPEN_LAST_FILE_KEY, g_object_ref (file), (GDestroyNotify) g_object_unref); } else if (status != GIMP_PDB_CANCEL && display) { gimp_message (gimp, G_OBJECT (display), GIMP_MESSAGE_ERROR, _("Opening '%s' failed: %s"), gimp_file_get_utf8_name (file), error->message); g_clear_error (&error); } if (display) g_object_remove_weak_pointer (G_OBJECT (display), (gpointer) &display); return success; }
/** * dialogs_restore_window: * @factory: * @screen: * @monitor: * @info: * * "restores" the image window. We don't really restore anything since * the image window is created earlier, so we just look for and return * the already-created image window. * * Returns: **/ static GtkWidget * dialogs_restore_window (GimpDialogFactory *factory, GdkScreen *screen, gint monitor, GimpSessionInfo *info) { Gimp *gimp = gimp_dialog_factory_get_context (factory)->gimp; GimpDisplay *display = GIMP_DISPLAY (gimp_get_empty_display (gimp)); GimpDisplayShell *shell = gimp_display_get_shell (display); GtkWidget *dialog; dialog = GTK_WIDGET (gimp_display_shell_get_window (shell)); return dialog; }