From a03ad36ca1ef89fea431ac1360b528fd78c92512 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Mon, 31 May 2004 14:40:10 +0000 Subject: [PATCH] app/Makefile.am app/actions/file-actions.c app/actions/file-commands.[ch] 2004-05-31 Sven Neumann * app/Makefile.am * app/actions/file-actions.c * app/actions/file-commands.[ch] * app/gui/Makefile.am * app/gui/file-open-location-dialog.[ch] * app/widgets/gimphelp-ids.h * menus/image-menu.xml.in * menus/toolbox-menu.xml.in: added a rudimentary "Open Location" dialog. --- ChangeLog | 12 ++ app/Makefile.am | 1 + app/actions/file-actions.c | 7 +- app/actions/file-commands.c | 13 +++ app/actions/file-commands.h | 2 + app/dialogs/file-open-location-dialog.c | 142 ++++++++++++++++++++++++ app/dialogs/file-open-location-dialog.h | 27 +++++ app/gui/Makefile.am | 2 + app/gui/file-open-location-dialog.c | 142 ++++++++++++++++++++++++ app/gui/file-open-location-dialog.h | 27 +++++ app/widgets/gimphelp-ids.h | 1 + menus/image-menu.xml.in | 1 + menus/toolbox-menu.xml.in | 1 + po/ChangeLog | 4 + po/POTFILES.in | 1 + 15 files changed, 382 insertions(+), 1 deletion(-) create mode 100644 app/dialogs/file-open-location-dialog.c create mode 100644 app/dialogs/file-open-location-dialog.h create mode 100644 app/gui/file-open-location-dialog.c create mode 100644 app/gui/file-open-location-dialog.h diff --git a/ChangeLog b/ChangeLog index 4ad1940c53..b57590410b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2004-05-31 Sven Neumann + + * app/Makefile.am + * app/actions/file-actions.c + * app/actions/file-commands.[ch] + * app/gui/Makefile.am + * app/gui/file-open-location-dialog.[ch] + * app/widgets/gimphelp-ids.h + * menus/image-menu.xml.in + * menus/toolbox-menu.xml.in: added a rudimentary "Open Location" + dialog. + 2004-05-31 Sven Neumann * plug-ins/common/mblur.c (mblur_zoom): push pixels outwards not diff --git a/app/Makefile.am b/app/Makefile.am index 7a83429843..4d12eeb056 100644 --- a/app/Makefile.am +++ b/app/Makefile.am @@ -92,6 +92,7 @@ gimp_2_1_LDFLAGS = \ -u $(SYMPREFIX)resize_dialog_new \ -u $(SYMPREFIX)stroke_dialog_new \ -u $(SYMPREFIX)file_open_dialog_show \ + -u $(SYMPREFIX)file_open_location_dialog_show \ -u $(SYMPREFIX)file_save_dialog_show \ -u $(SYMPREFIX)color_notebook_new diff --git a/app/actions/file-actions.c b/app/actions/file-actions.c index 2eba6609e0..12dda25bf6 100644 --- a/app/actions/file-actions.c +++ b/app/actions/file-actions.c @@ -60,7 +60,7 @@ static GimpActionEntry file_actions[] = { { "file-menu", NULL, N_("_File") }, - { "file-open-recent-menu", GTK_STOCK_OPEN, + { "file-open-recent-menu", NULL, N_("Open _Recent"), "", NULL }, { "file-acquire-menu", NULL, @@ -76,6 +76,11 @@ static GimpActionEntry file_actions[] = G_CALLBACK (file_open_from_image_cmd_callback), GIMP_HELP_FILE_OPEN }, + { "file-open-location", NULL, + N_("_Open Location..."), NULL, NULL, + G_CALLBACK (file_open_location_cmd_callback), + GIMP_HELP_FILE_OPEN_LOCATION }, + { "file-save", GTK_STOCK_SAVE, N_("_Save"), "S", NULL, G_CALLBACK (file_save_cmd_callback), diff --git a/app/actions/file-commands.c b/app/actions/file-commands.c index a4e84d2a98..54cb1d6f36 100644 --- a/app/actions/file-commands.c +++ b/app/actions/file-commands.c @@ -46,6 +46,7 @@ #include "menus/menus.h" #include "gui/file-open-dialog.h" +#include "gui/file-open-location-dialog.h" #include "gui/file-save-dialog.h" #include "actions.h" @@ -94,6 +95,18 @@ file_open_from_image_cmd_callback (GtkAction *action, NULL, global_menu_factory, widget); } +void +file_open_location_cmd_callback (GtkAction *action, + gpointer data) +{ + Gimp *gimp; + GtkWidget *widget; + return_if_no_gimp (gimp, data); + return_if_no_widget (widget, data); + + file_open_location_dialog_show (gimp, widget); +} + void file_last_opened_cmd_callback (GtkAction *action, gint value, diff --git a/app/actions/file-commands.h b/app/actions/file-commands.h index ce03ff70e8..8f6881c9b4 100644 --- a/app/actions/file-commands.h +++ b/app/actions/file-commands.h @@ -22,6 +22,8 @@ void file_open_cmd_callback (GtkAction *action, gpointer data); +void file_open_location_cmd_callback (GtkAction *action, + gpointer data); void file_open_from_image_cmd_callback (GtkAction *action, gpointer data); void file_last_opened_cmd_callback (GtkAction *action, diff --git a/app/dialogs/file-open-location-dialog.c b/app/dialogs/file-open-location-dialog.c new file mode 100644 index 0000000000..d07a6883bf --- /dev/null +++ b/app/dialogs/file-open-location-dialog.c @@ -0,0 +1,142 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995, 1996, 1997 Spencer Kimball and Peter Mattis + * Copyright (C) 1997 Josh MacDonald + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (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 + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "config.h" + +#include + +#include + +#include "libgimpwidgets/gimpwidgets.h" + +#include "gui-types.h" + +#include "core/gimp.h" + +#include "file/file-open.h" +#include "file/file-utils.h" + +#include "widgets/gimphelp-ids.h" + +#include "file-open-location-dialog.h" + +#include "gimp-intl.h" + + +static void file_open_location_response (GtkWidget *dialog, + gint response_id, + Gimp *gimp); + + +/* public functions */ + +void +file_open_location_dialog_show (Gimp *gimp, + GtkWidget *parent) +{ + GtkWidget *dialog; + GtkWidget *vbox; + GtkWidget *label; + GtkWidget *entry; + + g_return_if_fail (GIMP_IS_GIMP (gimp)); + g_return_if_fail (parent == NULL || GTK_IS_WIDGET (parent)); + + dialog = gimp_dialog_new (_("Open Location"), + "gimp-file-open-location", + parent, 0, + gimp_standard_help_func, + GIMP_HELP_FILE_OPEN_LOCATION, + + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_OK, + + NULL); + + g_signal_connect (dialog, "response", + G_CALLBACK (file_open_location_response), + gimp); + + vbox = gtk_vbox_new (FALSE, 6); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), + vbox, FALSE, FALSE, 0); + gtk_widget_show (vbox); + + label = gtk_label_new (_("Enter location (URI):")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 1.0); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + + entry = gtk_entry_new (); + gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0); + gtk_widget_show (entry); + + g_object_set_data (G_OBJECT (dialog), "location-entry", entry); + + gtk_widget_show (dialog); +} + +static void +file_open_location_response (GtkWidget *dialog, + gint response_id, + Gimp *gimp) +{ + if (response_id == GTK_RESPONSE_OK) + { + GtkWidget *entry; + const gchar *text = NULL; + + gtk_widget_set_sensitive (dialog, FALSE); + + entry = g_object_get_data (G_OBJECT (dialog), "location-entry"); + + text = gtk_entry_get_text (GTK_ENTRY (entry)); + + if (text && strlen (text)) + { + GimpImage *image; + gchar *uri; + GError *error = NULL; + GimpPDBStatusType status; + + uri = file_utils_filename_to_uri (gimp->load_procs, text, NULL); + + image = file_open_with_proc_and_display (gimp, + gimp_get_user_context (gimp), + uri, text, NULL, + &status, &error); + + if (image == NULL && status != GIMP_PDB_CANCEL) + { + gchar *filename = file_utils_uri_to_utf8_filename (uri); + + g_message (_("Opening '%s' failed:\n\n%s"), + filename, error->message); + g_clear_error (&error); + + g_free (filename); + } + + g_free (uri); + } + } + + gtk_widget_destroy (dialog); +} diff --git a/app/dialogs/file-open-location-dialog.h b/app/dialogs/file-open-location-dialog.h new file mode 100644 index 0000000000..28a9d6a7d5 --- /dev/null +++ b/app/dialogs/file-open-location-dialog.h @@ -0,0 +1,27 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (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 + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __FILE_OPEN_LOCATION_DIALOG_H__ +#define __FILE_OPEN_LOCATION_DIALOG_H__ + + +void file_open_location_dialog_show (Gimp *gimp, + GtkWidget *parent); + + +#endif /* __FILE_OPEN_LOCATION_DIALOG_H__ */ diff --git a/app/gui/Makefile.am b/app/gui/Makefile.am index 4f09513773..7059011c85 100644 --- a/app/gui/Makefile.am +++ b/app/gui/Makefile.am @@ -21,6 +21,8 @@ dialogs_sources = \ file-new-dialog.h \ file-open-dialog.c \ file-open-dialog.h \ + file-open-location-dialog.c \ + file-open-location-dialog.h \ file-save-dialog.c \ file-save-dialog.h \ font-select.c \ diff --git a/app/gui/file-open-location-dialog.c b/app/gui/file-open-location-dialog.c new file mode 100644 index 0000000000..d07a6883bf --- /dev/null +++ b/app/gui/file-open-location-dialog.c @@ -0,0 +1,142 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995, 1996, 1997 Spencer Kimball and Peter Mattis + * Copyright (C) 1997 Josh MacDonald + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (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 + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "config.h" + +#include + +#include + +#include "libgimpwidgets/gimpwidgets.h" + +#include "gui-types.h" + +#include "core/gimp.h" + +#include "file/file-open.h" +#include "file/file-utils.h" + +#include "widgets/gimphelp-ids.h" + +#include "file-open-location-dialog.h" + +#include "gimp-intl.h" + + +static void file_open_location_response (GtkWidget *dialog, + gint response_id, + Gimp *gimp); + + +/* public functions */ + +void +file_open_location_dialog_show (Gimp *gimp, + GtkWidget *parent) +{ + GtkWidget *dialog; + GtkWidget *vbox; + GtkWidget *label; + GtkWidget *entry; + + g_return_if_fail (GIMP_IS_GIMP (gimp)); + g_return_if_fail (parent == NULL || GTK_IS_WIDGET (parent)); + + dialog = gimp_dialog_new (_("Open Location"), + "gimp-file-open-location", + parent, 0, + gimp_standard_help_func, + GIMP_HELP_FILE_OPEN_LOCATION, + + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_OK, + + NULL); + + g_signal_connect (dialog, "response", + G_CALLBACK (file_open_location_response), + gimp); + + vbox = gtk_vbox_new (FALSE, 6); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), + vbox, FALSE, FALSE, 0); + gtk_widget_show (vbox); + + label = gtk_label_new (_("Enter location (URI):")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 1.0); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + + entry = gtk_entry_new (); + gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0); + gtk_widget_show (entry); + + g_object_set_data (G_OBJECT (dialog), "location-entry", entry); + + gtk_widget_show (dialog); +} + +static void +file_open_location_response (GtkWidget *dialog, + gint response_id, + Gimp *gimp) +{ + if (response_id == GTK_RESPONSE_OK) + { + GtkWidget *entry; + const gchar *text = NULL; + + gtk_widget_set_sensitive (dialog, FALSE); + + entry = g_object_get_data (G_OBJECT (dialog), "location-entry"); + + text = gtk_entry_get_text (GTK_ENTRY (entry)); + + if (text && strlen (text)) + { + GimpImage *image; + gchar *uri; + GError *error = NULL; + GimpPDBStatusType status; + + uri = file_utils_filename_to_uri (gimp->load_procs, text, NULL); + + image = file_open_with_proc_and_display (gimp, + gimp_get_user_context (gimp), + uri, text, NULL, + &status, &error); + + if (image == NULL && status != GIMP_PDB_CANCEL) + { + gchar *filename = file_utils_uri_to_utf8_filename (uri); + + g_message (_("Opening '%s' failed:\n\n%s"), + filename, error->message); + g_clear_error (&error); + + g_free (filename); + } + + g_free (uri); + } + } + + gtk_widget_destroy (dialog); +} diff --git a/app/gui/file-open-location-dialog.h b/app/gui/file-open-location-dialog.h new file mode 100644 index 0000000000..28a9d6a7d5 --- /dev/null +++ b/app/gui/file-open-location-dialog.h @@ -0,0 +1,27 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (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 + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __FILE_OPEN_LOCATION_DIALOG_H__ +#define __FILE_OPEN_LOCATION_DIALOG_H__ + + +void file_open_location_dialog_show (Gimp *gimp, + GtkWidget *parent); + + +#endif /* __FILE_OPEN_LOCATION_DIALOG_H__ */ diff --git a/app/widgets/gimphelp-ids.h b/app/widgets/gimphelp-ids.h index 8d6919eed9..81154182bc 100644 --- a/app/widgets/gimphelp-ids.h +++ b/app/widgets/gimphelp-ids.h @@ -28,6 +28,7 @@ #define GIMP_HELP_FILE_NEW "gimp-file-new" #define GIMP_HELP_FILE_NEW_CONFIRM "gimp-file-new-confirm" #define GIMP_HELP_FILE_OPEN "gimp-file-open" +#define GIMP_HELP_FILE_OPEN_LOCATION "gimp-file-open-location" #define GIMP_HELP_FILE_OPEN_BY_EXTENSION "gimp-file-open-by-extension" #define GIMP_HELP_FILE_OPEN_XCF "gimp-file-open-xcf" #define GIMP_HELP_FILE_OPEN_RECENT "gimp-file-open-recent" diff --git a/menus/image-menu.xml.in b/menus/image-menu.xml.in index f80c363747..ef374757d3 100644 --- a/menus/image-menu.xml.in +++ b/menus/image-menu.xml.in @@ -10,6 +10,7 @@ + diff --git a/menus/toolbox-menu.xml.in b/menus/toolbox-menu.xml.in index caffddaf84..2bfcaeb4f5 100644 --- a/menus/toolbox-menu.xml.in +++ b/menus/toolbox-menu.xml.in @@ -10,6 +10,7 @@ + diff --git a/po/ChangeLog b/po/ChangeLog index a82def4bb7..76c6030a93 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -1,3 +1,7 @@ +2004-05-31 Sven Neumann + + * POTFILES.in: updated. + 2004-05-28 Andras Timar * hu.po: Updated Hungarian translation. diff --git a/po/POTFILES.in b/po/POTFILES.in index 95884a505f..6b087e9e73 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -140,6 +140,7 @@ app/gui/convert-dialog.c app/gui/dialogs-constructors.c app/gui/file-new-dialog.c app/gui/file-open-dialog.c +app/gui/file-open-location-dialog.c app/gui/file-save-dialog.c app/gui/font-select.c app/gui/gradient-select.c