2006-12-09 13:33:38 -08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-07-08 14:44:52 -07:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
2009-01-17 14:28:01 -08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-07-08 14:44:52 -07:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 14:28:01 -08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-07-08 14:44:52 -07:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-11 14:47:19 -07:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2001-07-08 14:44:52 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2012-03-29 10:19:01 -07:00
|
|
|
#include <gegl.h>
|
2001-07-08 14:44:52 -07:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
2014-07-06 15:46:25 -07:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2004-05-11 09:05:21 -07:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
2004-04-20 06:25:55 -07:00
|
|
|
#include "actions-types.h"
|
2001-07-08 14:44:52 -07:00
|
|
|
|
2005-11-02 11:39:54 -08:00
|
|
|
#include "core/gimp.h"
|
2004-05-11 09:05:21 -07:00
|
|
|
#include "core/gimpcontainer.h"
|
|
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
|
#include "core/gimpdata.h"
|
|
|
|
|
#include "core/gimpdatafactory.h"
|
|
|
|
|
|
2005-01-13 12:22:53 -08:00
|
|
|
#include "file/file-open.h"
|
|
|
|
|
|
2005-11-01 03:01:44 -08:00
|
|
|
#include "widgets/gimpclipboard.h"
|
2004-05-11 09:05:21 -07:00
|
|
|
#include "widgets/gimpcontainerview.h"
|
2004-09-27 03:45:49 -07:00
|
|
|
#include "widgets/gimpdataeditor.h"
|
2001-07-08 14:44:52 -07:00
|
|
|
#include "widgets/gimpdatafactoryview.h"
|
2004-09-27 03:45:49 -07:00
|
|
|
#include "widgets/gimpdialogfactory.h"
|
2004-10-13 08:27:00 -07:00
|
|
|
#include "widgets/gimpmessagebox.h"
|
|
|
|
|
#include "widgets/gimpmessagedialog.h"
|
2014-05-01 18:01:23 -07:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2012-01-30 14:33:21 -08:00
|
|
|
#include "widgets/gimpwindowstrategy.h"
|
2014-05-02 11:20:46 -07:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2012-01-30 14:24:44 -08:00
|
|
|
|
2011-03-24 13:46:40 -07:00
|
|
|
#include "dialogs/data-delete-dialog.h"
|
|
|
|
|
|
2004-05-11 09:05:21 -07:00
|
|
|
#include "actions.h"
|
2001-07-08 14:44:52 -07:00
|
|
|
#include "data-commands.h"
|
|
|
|
|
|
2003-03-25 08:38:19 -08:00
|
|
|
#include "gimp-intl.h"
|
2001-07-08 14:44:52 -07:00
|
|
|
|
|
|
|
|
|
2004-09-27 05:30:04 -07:00
|
|
|
/* public functions */
|
|
|
|
|
|
2005-01-13 12:22:53 -08:00
|
|
|
void
|
|
|
|
|
data_open_as_image_cmd_callback (GtkAction *action,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GimpDataFactoryView *view = GIMP_DATA_FACTORY_VIEW (user_data);
|
|
|
|
|
GimpContext *context;
|
|
|
|
|
GimpData *data;
|
|
|
|
|
|
2006-08-08 14:06:36 -07:00
|
|
|
context =
|
|
|
|
|
gimp_container_view_get_context (GIMP_CONTAINER_EDITOR (view)->view);
|
2005-01-13 12:22:53 -08:00
|
|
|
|
|
|
|
|
data = (GimpData *)
|
|
|
|
|
gimp_context_get_by_type (context,
|
2008-12-20 04:27:52 -08:00
|
|
|
gimp_data_factory_view_get_children_type (view));
|
2005-01-13 12:22:53 -08:00
|
|
|
|
2014-06-30 16:19:35 -07:00
|
|
|
if (data && gimp_data_get_file (data))
|
2005-01-13 12:22:53 -08:00
|
|
|
{
|
2016-09-25 13:18:37 -07:00
|
|
|
GFile *file = gimp_data_get_file (data);
|
2014-07-06 15:46:25 -07:00
|
|
|
GtkWidget *widget = GTK_WIDGET (view);
|
|
|
|
|
GimpImage *image;
|
|
|
|
|
GimpPDBStatusType status;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
image = file_open_with_display (context->gimp, context, NULL,
|
|
|
|
|
file, FALSE,
|
|
|
|
|
G_OBJECT (gtk_widget_get_screen (widget)),
|
|
|
|
|
gimp_widget_get_monitor (widget),
|
|
|
|
|
&status, &error);
|
|
|
|
|
|
|
|
|
|
if (! image && status != GIMP_PDB_CANCEL)
|
2005-01-13 12:22:53 -08:00
|
|
|
{
|
2014-07-06 15:46:25 -07:00
|
|
|
gimp_message (context->gimp, G_OBJECT (view),
|
|
|
|
|
GIMP_MESSAGE_ERROR,
|
|
|
|
|
_("Opening '%s' failed:\n\n%s"),
|
|
|
|
|
gimp_file_get_utf8_name (file), error->message);
|
|
|
|
|
g_clear_error (&error);
|
2005-01-13 12:22:53 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-08 14:44:52 -07:00
|
|
|
void
|
2005-01-14 05:30:05 -08:00
|
|
|
data_new_cmd_callback (GtkAction *action,
|
|
|
|
|
gpointer user_data)
|
2001-07-08 14:44:52 -07:00
|
|
|
{
|
2004-05-11 09:05:21 -07:00
|
|
|
GimpDataFactoryView *view = GIMP_DATA_FACTORY_VIEW (user_data);
|
|
|
|
|
|
2008-12-20 04:27:52 -08:00
|
|
|
if (gimp_data_factory_view_has_data_new_func (view))
|
2004-05-11 09:05:21 -07:00
|
|
|
{
|
2010-04-05 04:24:54 -07:00
|
|
|
GimpDataFactory *factory;
|
|
|
|
|
GimpContext *context;
|
|
|
|
|
GimpData *data;
|
|
|
|
|
|
|
|
|
|
factory = gimp_data_factory_view_get_data_factory (view);
|
2004-05-11 09:05:21 -07:00
|
|
|
|
|
|
|
|
context =
|
|
|
|
|
gimp_container_view_get_context (GIMP_CONTAINER_EDITOR (view)->view);
|
2001-07-08 14:44:52 -07:00
|
|
|
|
2010-04-10 10:55:42 -07:00
|
|
|
data = gimp_data_factory_data_new (factory, context, _("Untitled"));
|
2004-05-11 09:05:21 -07:00
|
|
|
|
|
|
|
|
if (data)
|
2006-04-12 05:49:29 -07:00
|
|
|
{
|
|
|
|
|
gimp_context_set_by_type (context,
|
2008-12-20 04:27:52 -08:00
|
|
|
gimp_data_factory_view_get_children_type (view),
|
2006-04-12 05:49:29 -07:00
|
|
|
GIMP_OBJECT (data));
|
2004-05-11 09:05:21 -07:00
|
|
|
|
2008-12-20 04:08:28 -08:00
|
|
|
gtk_button_clicked (GTK_BUTTON (gimp_data_factory_view_get_edit_button (view)));
|
2006-04-12 05:49:29 -07:00
|
|
|
}
|
2004-05-11 09:05:21 -07:00
|
|
|
}
|
2001-07-08 14:44:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2005-01-14 05:30:05 -08:00
|
|
|
data_duplicate_cmd_callback (GtkAction *action,
|
|
|
|
|
gpointer user_data)
|
2001-07-08 14:44:52 -07:00
|
|
|
{
|
2004-05-11 09:05:21 -07:00
|
|
|
GimpDataFactoryView *view = GIMP_DATA_FACTORY_VIEW (user_data);
|
|
|
|
|
GimpContext *context;
|
|
|
|
|
GimpData *data;
|
|
|
|
|
|
|
|
|
|
context = gimp_container_view_get_context (GIMP_CONTAINER_EDITOR (view)->view);
|
|
|
|
|
|
|
|
|
|
data = (GimpData *)
|
|
|
|
|
gimp_context_get_by_type (context,
|
2008-12-20 04:27:52 -08:00
|
|
|
gimp_data_factory_view_get_children_type (view));
|
2001-07-08 14:44:52 -07:00
|
|
|
|
2016-09-25 13:18:37 -07:00
|
|
|
if (data && gimp_data_factory_view_have (view, GIMP_OBJECT (data)))
|
2004-05-11 09:05:21 -07:00
|
|
|
{
|
|
|
|
|
GimpData *new_data;
|
|
|
|
|
|
2008-12-20 04:08:28 -08:00
|
|
|
new_data = gimp_data_factory_data_duplicate (gimp_data_factory_view_get_data_factory (view), data);
|
2004-05-11 09:05:21 -07:00
|
|
|
|
|
|
|
|
if (new_data)
|
2006-04-12 05:49:29 -07:00
|
|
|
{
|
|
|
|
|
gimp_context_set_by_type (context,
|
2008-12-20 04:27:52 -08:00
|
|
|
gimp_data_factory_view_get_children_type (view),
|
2006-04-12 05:49:29 -07:00
|
|
|
GIMP_OBJECT (new_data));
|
2004-05-11 09:05:21 -07:00
|
|
|
|
2008-12-20 04:08:28 -08:00
|
|
|
gtk_button_clicked (GTK_BUTTON (gimp_data_factory_view_get_edit_button (view)));
|
2006-04-12 05:49:29 -07:00
|
|
|
}
|
2004-05-11 09:05:21 -07:00
|
|
|
}
|
2001-07-08 14:44:52 -07:00
|
|
|
}
|
|
|
|
|
|
2005-10-31 04:00:25 -08:00
|
|
|
void
|
|
|
|
|
data_copy_location_cmd_callback (GtkAction *action,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GimpDataFactoryView *view = GIMP_DATA_FACTORY_VIEW (user_data);
|
|
|
|
|
GimpContext *context;
|
|
|
|
|
GimpData *data;
|
|
|
|
|
|
|
|
|
|
context = gimp_container_view_get_context (GIMP_CONTAINER_EDITOR (view)->view);
|
|
|
|
|
|
|
|
|
|
data = (GimpData *)
|
|
|
|
|
gimp_context_get_by_type (context,
|
2008-12-20 04:27:52 -08:00
|
|
|
gimp_data_factory_view_get_children_type (view));
|
2005-10-31 04:00:25 -08:00
|
|
|
|
2009-10-31 07:24:57 -07:00
|
|
|
if (data)
|
2005-10-31 04:00:25 -08:00
|
|
|
{
|
2014-06-30 16:19:35 -07:00
|
|
|
GFile *file = gimp_data_get_file (data);
|
2005-10-31 04:00:25 -08:00
|
|
|
|
2014-06-30 16:19:35 -07:00
|
|
|
if (file)
|
2005-10-31 04:00:25 -08:00
|
|
|
{
|
2014-06-30 16:19:35 -07:00
|
|
|
gchar *uri = g_file_get_uri (file);
|
2009-10-31 07:24:57 -07:00
|
|
|
|
2014-06-30 16:19:35 -07:00
|
|
|
gimp_clipboard_set_text (context->gimp, uri);
|
|
|
|
|
g_free (uri);
|
2005-10-31 04:00:25 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-16 11:29:31 -08:00
|
|
|
void
|
|
|
|
|
data_show_in_file_manager_cmd_callback (GtkAction *action,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GimpDataFactoryView *view = GIMP_DATA_FACTORY_VIEW (user_data);
|
|
|
|
|
GimpContext *context;
|
|
|
|
|
GimpData *data;
|
|
|
|
|
|
|
|
|
|
context = gimp_container_view_get_context (GIMP_CONTAINER_EDITOR (view)->view);
|
|
|
|
|
|
|
|
|
|
data = (GimpData *)
|
|
|
|
|
gimp_context_get_by_type (context,
|
|
|
|
|
gimp_data_factory_view_get_children_type (view));
|
|
|
|
|
|
|
|
|
|
if (data)
|
|
|
|
|
{
|
|
|
|
|
GFile *file = gimp_data_get_file (data);
|
|
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
|
{
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
if (! gimp_file_show_in_file_manager (file, &error))
|
|
|
|
|
{
|
|
|
|
|
gimp_message (context->gimp, G_OBJECT (view),
|
|
|
|
|
GIMP_MESSAGE_ERROR,
|
|
|
|
|
_("Can't show file in file manager: %s"),
|
|
|
|
|
error->message);
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-08 14:44:52 -07:00
|
|
|
void
|
2005-01-14 05:30:05 -08:00
|
|
|
data_delete_cmd_callback (GtkAction *action,
|
|
|
|
|
gpointer user_data)
|
2001-07-08 14:44:52 -07:00
|
|
|
{
|
2004-05-11 09:05:21 -07:00
|
|
|
GimpDataFactoryView *view = GIMP_DATA_FACTORY_VIEW (user_data);
|
|
|
|
|
GimpContext *context;
|
|
|
|
|
GimpData *data;
|
|
|
|
|
|
2007-02-16 04:59:10 -08:00
|
|
|
context =
|
|
|
|
|
gimp_container_view_get_context (GIMP_CONTAINER_EDITOR (view)->view);
|
2004-05-11 09:05:21 -07:00
|
|
|
|
|
|
|
|
data = (GimpData *)
|
|
|
|
|
gimp_context_get_by_type (context,
|
2008-12-20 04:27:52 -08:00
|
|
|
gimp_data_factory_view_get_children_type (view));
|
2004-05-11 09:05:21 -07:00
|
|
|
|
2009-10-31 10:48:38 -07:00
|
|
|
if (data &&
|
|
|
|
|
gimp_data_is_deletable (data) &&
|
2016-09-25 13:18:37 -07:00
|
|
|
gimp_data_factory_view_have (view, GIMP_OBJECT (data)))
|
2004-05-11 09:05:21 -07:00
|
|
|
{
|
2011-03-24 13:46:40 -07:00
|
|
|
GimpDataFactory *factory;
|
|
|
|
|
GtkWidget *dialog;
|
2004-10-13 08:27:00 -07:00
|
|
|
|
2011-03-24 13:46:40 -07:00
|
|
|
factory = gimp_data_factory_view_get_data_factory (view);
|
2007-02-16 04:59:10 -08:00
|
|
|
|
2011-03-24 13:46:40 -07:00
|
|
|
dialog = data_delete_dialog_new (factory, data, context,
|
|
|
|
|
GTK_WIDGET (view));
|
2004-05-11 09:05:21 -07:00
|
|
|
gtk_widget_show (dialog);
|
|
|
|
|
}
|
2001-07-08 14:44:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2005-01-14 05:30:05 -08:00
|
|
|
data_refresh_cmd_callback (GtkAction *action,
|
|
|
|
|
gpointer user_data)
|
2001-07-08 14:44:52 -07:00
|
|
|
{
|
2004-05-11 09:05:21 -07:00
|
|
|
GimpDataFactoryView *view = GIMP_DATA_FACTORY_VIEW (user_data);
|
2005-10-31 03:29:01 -08:00
|
|
|
Gimp *gimp;
|
|
|
|
|
return_if_no_gimp (gimp, user_data);
|
2001-07-08 14:44:52 -07:00
|
|
|
|
2005-10-31 03:29:01 -08:00
|
|
|
gimp_set_busy (gimp);
|
2010-04-11 04:12:41 -07:00
|
|
|
gimp_data_factory_data_refresh (gimp_data_factory_view_get_data_factory (view),
|
|
|
|
|
action_data_get_context (user_data));
|
2005-10-31 03:29:01 -08:00
|
|
|
gimp_unset_busy (gimp);
|
2001-07-08 14:44:52 -07:00
|
|
|
}
|
2004-09-27 03:45:49 -07:00
|
|
|
|
|
|
|
|
void
|
2005-01-14 05:30:05 -08:00
|
|
|
data_edit_cmd_callback (GtkAction *action,
|
|
|
|
|
const gchar *value,
|
|
|
|
|
gpointer user_data)
|
2004-09-27 03:45:49 -07:00
|
|
|
{
|
|
|
|
|
GimpDataFactoryView *view = GIMP_DATA_FACTORY_VIEW (user_data);
|
|
|
|
|
GimpContext *context;
|
|
|
|
|
GimpData *data;
|
|
|
|
|
|
|
|
|
|
context = gimp_container_view_get_context (GIMP_CONTAINER_EDITOR (view)->view);
|
|
|
|
|
|
|
|
|
|
data = (GimpData *)
|
|
|
|
|
gimp_context_get_by_type (context,
|
2008-12-20 04:27:52 -08:00
|
|
|
gimp_data_factory_view_get_children_type (view));
|
2004-09-27 03:45:49 -07:00
|
|
|
|
2016-09-25 13:18:37 -07:00
|
|
|
if (data && gimp_data_factory_view_have (view, GIMP_OBJECT (data)))
|
2004-09-27 03:45:49 -07:00
|
|
|
{
|
2014-05-01 18:01:23 -07:00
|
|
|
GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (view));
|
|
|
|
|
gint monitor = gimp_widget_get_monitor (GTK_WIDGET (view));
|
2004-09-27 03:45:49 -07:00
|
|
|
GtkWidget *dockable;
|
|
|
|
|
|
2012-01-30 14:24:44 -08:00
|
|
|
dockable =
|
|
|
|
|
gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (context->gimp)),
|
|
|
|
|
context->gimp,
|
|
|
|
|
gimp_dialog_factory_get_singleton (),
|
|
|
|
|
screen,
|
2014-05-01 18:01:23 -07:00
|
|
|
monitor,
|
2012-01-30 14:24:44 -08:00
|
|
|
value);
|
2004-09-27 03:45:49 -07:00
|
|
|
|
2008-03-12 09:58:28 -07:00
|
|
|
gimp_data_editor_set_data (GIMP_DATA_EDITOR (gtk_bin_get_child (GTK_BIN (dockable))),
|
2004-09-27 03:45:49 -07:00
|
|
|
data);
|
|
|
|
|
}
|
|
|
|
|
}
|