2001-04-28 15:11:29 +00:00
|
|
|
/* 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"
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_PARAM_H
|
|
|
|
#include <sys/param.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2002-01-25 18:34:33 +00:00
|
|
|
#include "gui-types.h"
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2001-05-15 11:25:25 +00:00
|
|
|
#include "base/temp-buf.h"
|
|
|
|
|
2001-07-05 16:21:36 +00:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
#include "core/gimpcontext.h"
|
2001-07-07 12:17:23 +00:00
|
|
|
#include "core/gimpcoreconfig.h"
|
2001-08-11 07:47:35 +00:00
|
|
|
#include "core/gimpdocuments.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
#include "core/gimpimage.h"
|
2002-04-16 23:03:23 +00:00
|
|
|
#include "core/gimpimage-new.h"
|
2002-04-16 20:25:27 +00:00
|
|
|
#include "core/gimpimagefile.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
|
2001-12-19 00:13:16 +00:00
|
|
|
#include "plug-in/plug-in-types.h"
|
|
|
|
#include "plug-in/plug-in-proc.h"
|
2001-12-01 00:14:14 +00:00
|
|
|
|
2001-10-25 13:30:01 +00:00
|
|
|
#include "file/file-open.h"
|
|
|
|
#include "file/file-utils.h"
|
|
|
|
|
2001-11-27 19:27:55 +00:00
|
|
|
#include "widgets/gimpitemfactory.h"
|
2002-04-16 20:25:27 +00:00
|
|
|
#include "widgets/gimppreview.h"
|
2001-11-27 19:27:55 +00:00
|
|
|
|
2001-04-28 15:11:29 +00:00
|
|
|
#include "file-dialog-utils.h"
|
|
|
|
#include "file-open-dialog.h"
|
2001-07-04 19:31:35 +00:00
|
|
|
|
2001-04-28 15:11:29 +00:00
|
|
|
#include "undo.h"
|
|
|
|
|
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
|
|
|
|
2001-07-09 17:58:56 +00:00
|
|
|
/* local function prototypes */
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2002-04-16 20:25:27 +00:00
|
|
|
static void file_open_dialog_create (Gimp *gimp);
|
|
|
|
static void file_open_genbutton_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void file_open_selchanged_callback (GtkTreeSelection *sel,
|
|
|
|
gpointer data);
|
|
|
|
static void file_open_ok_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void file_open_type_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void file_open_imagefile_info_changed (GimpImagefile *imagefile,
|
|
|
|
gpointer data);
|
2001-04-28 15:11:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2002-04-16 20:25:27 +00:00
|
|
|
static GtkWidget *fileload = NULL;
|
|
|
|
static GtkWidget *open_options = NULL;
|
|
|
|
static GimpImagefile *open_options_imagefile = NULL;
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2002-04-16 20:25:27 +00:00
|
|
|
static GtkWidget *open_options_label = NULL;
|
|
|
|
static GtkWidget *open_options_frame = NULL;
|
2001-04-28 15:11:29 +00:00
|
|
|
|
|
|
|
static PlugInProcDef *load_file_proc = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
void
|
2002-03-20 17:46:13 +00:00
|
|
|
file_open_dialog_menu_init (Gimp *gimp,
|
|
|
|
GimpItemFactory *item_factory)
|
2001-04-28 15:11:29 +00:00
|
|
|
{
|
|
|
|
GimpItemFactoryEntry entry;
|
|
|
|
PlugInProcDef *file_proc;
|
|
|
|
GSList *list;
|
|
|
|
|
2001-10-29 11:47:11 +00:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
2002-03-20 17:46:13 +00:00
|
|
|
g_return_if_fail (GIMP_IS_ITEM_FACTORY (item_factory));
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2001-10-29 11:47:11 +00:00
|
|
|
gimp->load_procs = g_slist_reverse (gimp->load_procs);
|
|
|
|
|
|
|
|
for (list = gimp->load_procs; list; list = g_slist_next (list))
|
2001-04-28 15:11:29 +00:00
|
|
|
{
|
2001-08-29 17:48:28 +00:00
|
|
|
gchar *basename;
|
|
|
|
gchar *lowercase_basename;
|
2001-04-28 15:11:29 +00:00
|
|
|
gchar *help_page;
|
|
|
|
|
|
|
|
file_proc = (PlugInProcDef *) list->data;
|
|
|
|
|
2001-08-29 17:48:28 +00:00
|
|
|
basename = g_path_get_basename (file_proc->prog);
|
|
|
|
|
2001-09-26 12:52:12 +00:00
|
|
|
lowercase_basename = g_ascii_strdown (basename, -1);
|
2001-08-29 17:48:28 +00:00
|
|
|
|
|
|
|
g_free (basename);
|
|
|
|
|
2001-04-28 15:11:29 +00:00
|
|
|
help_page = g_strconcat ("filters/",
|
2001-08-29 17:48:28 +00:00
|
|
|
lowercase_basename,
|
2001-04-28 15:11:29 +00:00
|
|
|
".html",
|
|
|
|
NULL);
|
2001-08-29 17:48:28 +00:00
|
|
|
|
|
|
|
g_free (lowercase_basename);
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2002-03-20 17:46:13 +00:00
|
|
|
entry.entry.path = strstr (file_proc->menu_path, "/");
|
2001-04-28 15:11:29 +00:00
|
|
|
entry.entry.accelerator = NULL;
|
|
|
|
entry.entry.callback = file_open_type_callback;
|
|
|
|
entry.entry.callback_action = 0;
|
|
|
|
entry.entry.item_type = NULL;
|
2001-07-09 17:58:56 +00:00
|
|
|
entry.quark_string = NULL;
|
2001-04-28 15:11:29 +00:00
|
|
|
entry.help_page = help_page;
|
|
|
|
entry.description = NULL;
|
|
|
|
|
2002-03-20 17:46:13 +00:00
|
|
|
gimp_item_factory_create_item (item_factory,
|
|
|
|
&entry,
|
|
|
|
file_proc, 2,
|
|
|
|
TRUE, FALSE);
|
2001-04-28 15:11:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-07-09 17:58:56 +00:00
|
|
|
file_open_dialog_menu_reset (void)
|
|
|
|
{
|
|
|
|
load_file_proc = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-10-29 11:47:11 +00:00
|
|
|
file_open_dialog_show (Gimp *gimp)
|
2001-04-28 15:11:29 +00:00
|
|
|
{
|
2001-10-29 11:47:11 +00:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
2001-07-09 17:58:56 +00:00
|
|
|
if (! fileload)
|
2001-10-29 11:47:11 +00:00
|
|
|
file_open_dialog_create (gimp);
|
2001-04-28 15:11:29 +00:00
|
|
|
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (fileload), TRUE);
|
|
|
|
if (GTK_WIDGET_VISIBLE (fileload))
|
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_file_selection_set_filename (GTK_FILE_SELECTION (fileload),
|
|
|
|
"." G_DIR_SEPARATOR_S);
|
2001-10-24 11:23:50 +00:00
|
|
|
gtk_window_set_title (GTK_WINDOW (fileload), _("Open Image"));
|
2001-04-28 15:11:29 +00:00
|
|
|
|
|
|
|
file_dialog_show (fileload);
|
|
|
|
}
|
|
|
|
|
2001-06-21 09:25:06 +00:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2001-04-28 15:11:29 +00:00
|
|
|
static void
|
2001-10-29 11:47:11 +00:00
|
|
|
file_open_dialog_create (Gimp *gimp)
|
2001-04-28 15:11:29 +00:00
|
|
|
{
|
2001-08-14 16:33:28 +00:00
|
|
|
GtkFileSelection *file_sel;
|
2002-02-10 19:51:20 +00:00
|
|
|
GtkTreeSelection *tree_sel;
|
2001-08-14 16:33:28 +00:00
|
|
|
|
2001-10-23 16:23:32 +00:00
|
|
|
fileload = gtk_file_selection_new (_("Open Image"));
|
2001-10-29 11:47:11 +00:00
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (fileload), "gimp", gimp);
|
|
|
|
|
2001-04-28 15:11:29 +00:00
|
|
|
gtk_window_set_position (GTK_WINDOW (fileload), GTK_WIN_POS_MOUSE);
|
|
|
|
gtk_window_set_wmclass (GTK_WINDOW (fileload), "load_image", "Gimp");
|
|
|
|
|
2001-08-14 16:33:28 +00:00
|
|
|
file_sel = GTK_FILE_SELECTION (fileload);
|
|
|
|
|
2001-04-28 15:11:29 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (fileload), 2);
|
2001-08-14 16:33:28 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (file_sel->button_area), 2);
|
|
|
|
|
|
|
|
g_signal_connect_swapped (G_OBJECT (file_sel->cancel_button), "clicked",
|
|
|
|
G_CALLBACK (file_dialog_hide),
|
|
|
|
fileload);
|
|
|
|
g_signal_connect (G_OBJECT (fileload), "delete_event",
|
|
|
|
G_CALLBACK (file_dialog_hide),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_signal_connect (G_OBJECT (file_sel->ok_button), "clicked",
|
|
|
|
G_CALLBACK (file_open_ok_callback),
|
|
|
|
fileload);
|
|
|
|
|
2002-02-17 00:46:56 +00:00
|
|
|
gtk_file_selection_set_select_multiple (GTK_FILE_SELECTION (fileload), TRUE);
|
2002-02-10 19:51:20 +00:00
|
|
|
tree_sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (GTK_FILE_SELECTION (fileload)->file_list));
|
|
|
|
|
2002-01-30 08:31:00 +00:00
|
|
|
/* Catch file-list clicks so we can update the preview thumbnail */
|
2002-02-10 19:51:20 +00:00
|
|
|
g_signal_connect (G_OBJECT (tree_sel), "changed",
|
2002-01-30 08:31:00 +00:00
|
|
|
G_CALLBACK (file_open_selchanged_callback),
|
2001-08-14 16:33:28 +00:00
|
|
|
fileload);
|
2001-04-28 15:11:29 +00:00
|
|
|
|
|
|
|
/* Connect the "F1" help key */
|
2001-07-31 23:28:56 +00:00
|
|
|
gimp_help_connect (fileload,
|
|
|
|
gimp_standard_help_func,
|
|
|
|
"open/dialogs/file_open.html");
|
2001-04-28 15:11:29 +00:00
|
|
|
|
|
|
|
{
|
2002-01-25 18:34:33 +00:00
|
|
|
GimpItemFactory *item_factory;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *option_menu;
|
|
|
|
GtkWidget *open_options_genbutton;
|
2002-04-16 20:25:27 +00:00
|
|
|
GtkWidget *preview;
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2002-04-16 20:25:27 +00:00
|
|
|
open_options = gtk_hbox_new (TRUE, 4);
|
2001-04-28 15:11:29 +00:00
|
|
|
|
|
|
|
/* format-chooser frame */
|
|
|
|
frame = gtk_frame_new (_("Determine File Type"));
|
2002-04-16 20:25:27 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (open_options), frame, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (frame);
|
2001-04-28 15:11:29 +00:00
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 2);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
2002-04-16 20:25:27 +00:00
|
|
|
gtk_widget_show (vbox);
|
2001-04-28 15:11:29 +00:00
|
|
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
option_menu = gtk_option_menu_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), option_menu, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (option_menu);
|
|
|
|
|
2002-01-25 18:34:33 +00:00
|
|
|
item_factory = gimp_item_factory_from_path ("<Load>");
|
2001-12-29 13:26:29 +00:00
|
|
|
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu),
|
2002-01-25 18:34:33 +00:00
|
|
|
GTK_ITEM_FACTORY (item_factory)->widget);
|
2001-04-28 15:11:29 +00:00
|
|
|
|
|
|
|
/* Preview frame */
|
2002-04-16 23:59:53 +00:00
|
|
|
open_options_frame = frame = gtk_frame_new (_("No Selection"));
|
2002-04-16 20:25:27 +00:00
|
|
|
gtk_box_pack_end (GTK_BOX (open_options), frame, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (frame);
|
2001-04-28 15:11:29 +00:00
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 2);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
2002-04-16 20:25:27 +00:00
|
|
|
gtk_widget_show (vbox);
|
2001-04-28 15:11:29 +00:00
|
|
|
|
|
|
|
hbox = gtk_hbox_new (TRUE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
open_options_genbutton = gtk_button_new ();
|
2002-04-16 20:25:27 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), open_options_genbutton, TRUE, FALSE, 0);
|
|
|
|
gtk_widget_show (open_options_genbutton);
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2001-08-14 16:33:28 +00:00
|
|
|
g_signal_connect (G_OBJECT (open_options_genbutton), "clicked",
|
|
|
|
G_CALLBACK (file_open_genbutton_callback),
|
|
|
|
fileload);
|
|
|
|
|
2002-04-16 20:25:27 +00:00
|
|
|
gimp_help_set_help_data (open_options_genbutton,
|
|
|
|
_("Click to create preview"), NULL);
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2002-04-16 20:25:27 +00:00
|
|
|
open_options_imagefile = gimp_imagefile_new (NULL);
|
|
|
|
|
|
|
|
preview = gimp_preview_new (GIMP_VIEWABLE (open_options_imagefile),
|
|
|
|
128, 0, FALSE);
|
|
|
|
gtk_container_add (GTK_CONTAINER (open_options_genbutton), preview);
|
|
|
|
gtk_widget_show (preview);
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2002-04-16 20:25:27 +00:00
|
|
|
g_signal_connect (G_OBJECT (open_options_imagefile), "info_changed",
|
|
|
|
G_CALLBACK (file_open_imagefile_info_changed),
|
|
|
|
NULL);
|
|
|
|
|
2002-04-16 23:59:53 +00:00
|
|
|
open_options_label = gtk_label_new (NULL);
|
2001-04-28 15:11:29 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), open_options_label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (open_options_label);
|
|
|
|
|
|
|
|
/* pack the containing open_options hbox into the open-dialog */
|
|
|
|
gtk_box_pack_end (GTK_BOX (GTK_FILE_SELECTION (fileload)->main_vbox),
|
|
|
|
open_options, FALSE, FALSE, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (open_options_frame), FALSE);
|
|
|
|
|
|
|
|
gtk_widget_show (open_options);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_open_type_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
PlugInProcDef *proc = (PlugInProcDef *) data;
|
|
|
|
|
2001-08-14 16:33:28 +00:00
|
|
|
file_dialog_update_name (proc, GTK_FILE_SELECTION (fileload));
|
2001-04-28 15:11:29 +00:00
|
|
|
|
|
|
|
load_file_proc = proc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-04-16 20:25:27 +00:00
|
|
|
file_open_imagefile_info_changed (GimpImagefile *imagefile,
|
|
|
|
gpointer data)
|
2001-04-28 15:11:29 +00:00
|
|
|
{
|
2002-04-16 20:25:27 +00:00
|
|
|
const gchar *uri;
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2002-04-16 20:25:27 +00:00
|
|
|
uri = gimp_object_get_name (GIMP_OBJECT (imagefile));
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2002-04-16 20:25:27 +00:00
|
|
|
if (! uri)
|
2001-04-28 15:11:29 +00:00
|
|
|
{
|
2002-04-16 23:59:53 +00:00
|
|
|
gtk_frame_set_label (GTK_FRAME (open_options_frame), _("No Selection"));
|
|
|
|
gtk_label_set_text (GTK_LABEL (open_options_label), NULL);
|
2001-04-28 15:11:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-04-16 23:59:53 +00:00
|
|
|
gchar *basename = file_utils_uri_to_utf8_basename (uri);
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2002-04-16 20:25:27 +00:00
|
|
|
gtk_frame_set_label (GTK_FRAME (open_options_frame), basename);
|
|
|
|
g_free (basename);
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2002-04-16 20:25:27 +00:00
|
|
|
gtk_label_set_text (GTK_LABEL (open_options_label),
|
2002-04-16 23:59:53 +00:00
|
|
|
gimp_imagefile_get_description (imagefile));
|
2001-04-28 15:11:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-01-31 08:50:14 +00:00
|
|
|
static void
|
|
|
|
selchanged_foreach (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
gboolean *selected = data;
|
|
|
|
|
|
|
|
*selected = TRUE;
|
|
|
|
}
|
|
|
|
|
2001-04-28 15:11:29 +00:00
|
|
|
static void
|
2002-01-30 08:31:00 +00:00
|
|
|
file_open_selchanged_callback (GtkTreeSelection *sel,
|
|
|
|
gpointer data)
|
2001-04-28 15:11:29 +00:00
|
|
|
{
|
2001-10-29 11:47:11 +00:00
|
|
|
GtkFileSelection *fileload;
|
|
|
|
Gimp *gimp;
|
|
|
|
const gchar *fullfname;
|
2002-01-31 08:50:14 +00:00
|
|
|
gboolean selected = FALSE;
|
2001-10-29 11:47:11 +00:00
|
|
|
|
2002-01-31 08:50:14 +00:00
|
|
|
gtk_tree_selection_selected_foreach (sel,
|
|
|
|
selchanged_foreach,
|
|
|
|
&selected);
|
|
|
|
if (selected)
|
2002-01-30 08:31:00 +00:00
|
|
|
{
|
2002-04-16 20:25:27 +00:00
|
|
|
gchar *uri;
|
|
|
|
|
2002-01-30 08:31:00 +00:00
|
|
|
fileload = GTK_FILE_SELECTION (data);
|
2001-10-29 11:47:11 +00:00
|
|
|
|
2002-01-30 08:31:00 +00:00
|
|
|
gimp = GIMP (g_object_get_data (G_OBJECT (fileload), "gimp"));
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2002-01-30 08:31:00 +00:00
|
|
|
fullfname = gtk_file_selection_get_filename (fileload);
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2002-01-30 08:31:00 +00:00
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (open_options_frame), TRUE);
|
2002-04-16 20:25:27 +00:00
|
|
|
|
|
|
|
uri = file_utils_filename_to_uri (gimp->load_procs, fullfname, NULL);
|
|
|
|
|
|
|
|
gimp_object_set_name (GIMP_OBJECT (open_options_imagefile), uri);
|
|
|
|
|
|
|
|
g_free (uri);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_object_set_name (GIMP_OBJECT (open_options_imagefile), NULL);
|
2002-01-30 08:31:00 +00:00
|
|
|
}
|
2002-04-16 20:25:27 +00:00
|
|
|
|
|
|
|
gimp_imagefile_update (open_options_imagefile);
|
2001-04-28 15:11:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_open_genbutton_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2002-02-17 00:46:56 +00:00
|
|
|
GtkFileSelection *fs;
|
2002-04-16 20:25:27 +00:00
|
|
|
Gimp *gimp;
|
2002-02-17 00:46:56 +00:00
|
|
|
gchar **selections;
|
|
|
|
gint i;
|
2001-04-28 15:11:29 +00:00
|
|
|
|
|
|
|
fs = GTK_FILE_SELECTION (data);
|
|
|
|
|
2001-10-29 11:47:11 +00:00
|
|
|
gimp = GIMP (g_object_get_data (G_OBJECT (fs), "gimp"));
|
|
|
|
|
|
|
|
gimp_set_busy (gimp);
|
2002-04-16 20:25:27 +00:00
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (fs), FALSE);
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2002-02-17 00:46:56 +00:00
|
|
|
selections = gtk_file_selection_get_selections (fs);
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2002-02-17 00:46:56 +00:00
|
|
|
for (i = 0; selections[i] != NULL; i++)
|
2001-11-09 01:04:46 +00:00
|
|
|
{
|
2002-04-16 20:25:27 +00:00
|
|
|
if (g_file_test (selections[i], G_FILE_TEST_IS_REGULAR))
|
2001-11-09 01:04:46 +00:00
|
|
|
{
|
2002-04-16 20:25:27 +00:00
|
|
|
gchar *uri = g_filename_to_uri (selections[i], NULL, NULL);
|
|
|
|
|
|
|
|
if (gimp->config->write_thumbnails)
|
|
|
|
{
|
|
|
|
gimp_object_set_name (GIMP_OBJECT (open_options_imagefile),
|
|
|
|
uri);
|
|
|
|
gimp_imagefile_create_thumbnail (open_options_imagefile);
|
2001-11-09 01:04:46 +00:00
|
|
|
}
|
2002-04-16 20:25:27 +00:00
|
|
|
|
|
|
|
#if 0
|
2001-11-09 01:04:46 +00:00
|
|
|
{
|
|
|
|
gtk_label_set_text (GTK_LABEL (open_options_label),
|
2001-11-26 17:12:29 +00:00
|
|
|
_("Failed to generate preview."));
|
2001-11-09 01:04:46 +00:00
|
|
|
}
|
2002-04-16 20:25:27 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
g_free (uri);
|
|
|
|
}
|
2001-11-09 01:04:46 +00:00
|
|
|
}
|
|
|
|
|
2002-02-17 00:46:56 +00:00
|
|
|
g_strfreev (selections);
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2002-04-16 20:25:27 +00:00
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (fs), TRUE);
|
2001-10-29 11:47:11 +00:00
|
|
|
gimp_unset_busy (gimp);
|
2001-04-28 15:11:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_open_ok_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2002-02-17 00:46:56 +00:00
|
|
|
GtkFileSelection *fs;
|
|
|
|
Gimp *gimp;
|
2002-04-16 20:25:27 +00:00
|
|
|
gchar *entered_filename;
|
2002-02-17 00:46:56 +00:00
|
|
|
GimpPDBStatusType status;
|
|
|
|
gchar **selections;
|
|
|
|
gint i;
|
2002-04-16 20:25:27 +00:00
|
|
|
gchar *uri;
|
2001-04-28 15:11:29 +00:00
|
|
|
|
|
|
|
fs = GTK_FILE_SELECTION (data);
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-24 21:27:11 +00:00
|
|
|
|
2001-10-29 11:47:11 +00:00
|
|
|
gimp = GIMP (g_object_get_data (G_OBJECT (fs), "gimp"));
|
|
|
|
|
2002-02-17 00:46:56 +00:00
|
|
|
selections = gtk_file_selection_get_selections (fs);
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2002-02-17 00:46:56 +00:00
|
|
|
if (selections == NULL)
|
2001-04-28 15:11:29 +00:00
|
|
|
return;
|
|
|
|
|
2002-04-16 20:25:27 +00:00
|
|
|
if (g_file_test (selections[0], G_FILE_TEST_IS_DIR))
|
2001-04-28 15:11:29 +00:00
|
|
|
{
|
2002-04-16 20:25:27 +00:00
|
|
|
if (selections[0][strlen (selections[0]) - 1] != G_DIR_SEPARATOR)
|
2001-04-28 15:11:29 +00:00
|
|
|
{
|
2002-04-16 20:25:27 +00:00
|
|
|
gchar *s = g_strconcat (selections[0], G_DIR_SEPARATOR_S, NULL);
|
2001-04-28 15:11:29 +00:00
|
|
|
gtk_file_selection_set_filename (fs, s);
|
|
|
|
g_free (s);
|
|
|
|
}
|
|
|
|
else
|
2001-10-24 15:56:33 +00:00
|
|
|
{
|
2002-04-16 20:25:27 +00:00
|
|
|
gtk_file_selection_set_filename (fs, selections[0]);
|
2001-10-24 15:56:33 +00:00
|
|
|
}
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2002-02-17 00:46:56 +00:00
|
|
|
g_strfreev (selections);
|
|
|
|
|
2001-04-28 15:11:29 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-04-16 20:25:27 +00:00
|
|
|
entered_filename =
|
|
|
|
g_strdup (gtk_entry_get_text (GTK_ENTRY (fs->selection_entry)));
|
|
|
|
|
2001-04-28 15:11:29 +00:00
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (fs), FALSE);
|
|
|
|
|
2002-04-16 20:25:27 +00:00
|
|
|
if (! g_file_test (selections[0], G_FILE_TEST_EXISTS))
|
|
|
|
{
|
|
|
|
/* try with the entered filename in case the user typed an URI */
|
|
|
|
|
|
|
|
uri = g_strdup (entered_filename);
|
2002-04-14 14:38:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-04-16 20:25:27 +00:00
|
|
|
uri = g_filename_to_uri (selections[0], NULL, NULL);
|
2002-04-14 14:38:55 +00:00
|
|
|
}
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2001-10-29 11:47:11 +00:00
|
|
|
status = file_open_with_proc_and_display (gimp,
|
2002-04-16 20:25:27 +00:00
|
|
|
uri,
|
|
|
|
entered_filename,
|
2001-06-21 09:25:06 +00:00
|
|
|
load_file_proc);
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2002-04-16 20:25:27 +00:00
|
|
|
g_free (entered_filename);
|
|
|
|
g_free (uri);
|
2002-04-14 14:38:55 +00:00
|
|
|
|
2001-05-21 13:58:46 +00:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
2001-04-28 15:11:29 +00:00
|
|
|
{
|
|
|
|
file_dialog_hide (data);
|
|
|
|
}
|
2001-05-21 13:58:46 +00:00
|
|
|
else if (status != GIMP_PDB_CANCEL)
|
2001-04-28 15:11:29 +00:00
|
|
|
{
|
2001-11-26 17:12:29 +00:00
|
|
|
/* Hackery required. Please add error message. --bex */
|
2002-04-16 20:25:27 +00:00
|
|
|
g_message (_("Opening '%s' failed."), uri);
|
2001-04-28 15:11:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2002-01-30 08:31:00 +00:00
|
|
|
* Now deal with multiple selections from the filesel list
|
2001-04-28 15:11:29 +00:00
|
|
|
*/
|
|
|
|
|
2002-02-17 00:46:56 +00:00
|
|
|
for (i = 1; selections[i] != NULL; i++)
|
2001-11-09 01:04:46 +00:00
|
|
|
{
|
2002-04-16 20:25:27 +00:00
|
|
|
if (g_file_test (selections[i], G_FILE_TEST_IS_REGULAR))
|
2002-04-14 14:38:55 +00:00
|
|
|
{
|
2002-04-16 20:25:27 +00:00
|
|
|
uri = g_filename_to_uri (selections[i], NULL, NULL);
|
2002-04-14 14:38:55 +00:00
|
|
|
|
2002-02-17 00:46:56 +00:00
|
|
|
status = file_open_with_proc_and_display (gimp,
|
2002-04-14 14:38:55 +00:00
|
|
|
uri,
|
2002-04-16 20:25:27 +00:00
|
|
|
uri,
|
2002-02-17 00:46:56 +00:00
|
|
|
load_file_proc);
|
2002-04-14 14:38:55 +00:00
|
|
|
|
2002-02-17 00:46:56 +00:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
|
|
|
{
|
|
|
|
file_dialog_hide (data);
|
|
|
|
}
|
|
|
|
else if (status != GIMP_PDB_CANCEL)
|
|
|
|
{
|
|
|
|
/* same as previous. --bex */
|
2002-04-14 14:38:55 +00:00
|
|
|
g_message (_("Opening '%s' failed."), uri);
|
2002-02-17 00:46:56 +00:00
|
|
|
}
|
2002-04-14 14:38:55 +00:00
|
|
|
|
|
|
|
g_free (uri);
|
2002-02-17 00:46:56 +00:00
|
|
|
}
|
2001-11-09 01:04:46 +00:00
|
|
|
}
|
2001-04-28 15:11:29 +00:00
|
|
|
|
2002-02-17 00:46:56 +00:00
|
|
|
g_strfreev (selections);
|
2001-11-09 01:04:46 +00:00
|
|
|
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (fs), TRUE);
|
2001-04-28 15:11:29 +00:00
|
|
|
}
|