2001-04-28 23:11:29 +08: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"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2002-04-18 09:18:24 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-10-17 19:33:43 +08:00
|
|
|
#include "gui-types.h"
|
2001-05-26 00:04:54 +08:00
|
|
|
|
2002-04-18 09:18:24 +08:00
|
|
|
#include "core/gimp.h"
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "plug-in/plug-in-proc.h"
|
2001-12-01 08:14:14 +08:00
|
|
|
|
2003-05-04 07:02:26 +08:00
|
|
|
#include "widgets/gimpdialogfactory.h"
|
2001-11-28 03:27:55 +08:00
|
|
|
#include "widgets/gimpitemfactory.h"
|
2003-01-11 01:55:53 +08:00
|
|
|
#include "widgets/gimpmenufactory.h"
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2001-12-01 08:14:14 +08:00
|
|
|
#include "file-dialog-utils.h"
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2002-04-18 09:18:24 +08:00
|
|
|
|
|
|
|
|
|
|
|
GtkWidget *
|
2003-05-04 07:02:26 +08:00
|
|
|
file_dialog_new (Gimp *gimp,
|
|
|
|
GimpDialogFactory *dialog_factory,
|
|
|
|
const gchar *dialog_identifier,
|
|
|
|
GimpMenuFactory *menu_factory,
|
|
|
|
const gchar *menu_identifier,
|
|
|
|
const gchar *title,
|
2003-11-08 01:29:02 +08:00
|
|
|
const gchar *role,
|
2003-08-24 03:35:05 +08:00
|
|
|
const gchar *help_id,
|
2003-05-04 07:02:26 +08:00
|
|
|
GCallback ok_callback)
|
2002-04-18 09:18:24 +08:00
|
|
|
{
|
|
|
|
GtkWidget *filesel;
|
|
|
|
GtkFileSelection *fs;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
2003-05-04 07:02:26 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL);
|
|
|
|
g_return_val_if_fail (dialog_identifier != NULL, NULL);
|
2003-01-11 01:55:53 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
|
|
|
|
g_return_val_if_fail (menu_identifier != NULL, NULL);
|
2002-04-18 09:18:24 +08:00
|
|
|
g_return_val_if_fail (title != NULL, NULL);
|
2003-11-08 01:29:02 +08:00
|
|
|
g_return_val_if_fail (role != NULL, NULL);
|
2003-08-24 03:35:05 +08:00
|
|
|
g_return_val_if_fail (help_id != NULL, NULL);
|
2002-04-18 09:18:24 +08:00
|
|
|
g_return_val_if_fail (ok_callback != NULL, NULL);
|
|
|
|
|
|
|
|
filesel = gtk_file_selection_new (title);
|
|
|
|
|
|
|
|
fs = GTK_FILE_SELECTION (filesel);
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (filesel), "gimp", gimp);
|
|
|
|
|
|
|
|
gtk_window_set_position (GTK_WINDOW (filesel), GTK_WIN_POS_MOUSE);
|
2003-11-08 01:29:02 +08:00
|
|
|
gtk_window_set_role (GTK_WINDOW (filesel), role);
|
2002-04-18 09:18:24 +08:00
|
|
|
|
2003-08-24 03:35:05 +08:00
|
|
|
gimp_help_connect (filesel, gimp_standard_help_func, help_id, NULL);
|
2002-04-18 09:18:24 +08:00
|
|
|
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (fs->button_area), 2);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (filesel), 2);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect_swapped (fs->cancel_button, "clicked",
|
2002-04-18 09:18:24 +08:00
|
|
|
G_CALLBACK (file_dialog_hide),
|
|
|
|
filesel);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (filesel, "delete_event",
|
2002-04-18 09:18:24 +08:00
|
|
|
G_CALLBACK (file_dialog_hide),
|
|
|
|
NULL);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (fs->ok_button, "clicked",
|
2002-04-18 09:18:24 +08:00
|
|
|
G_CALLBACK (ok_callback),
|
|
|
|
filesel);
|
|
|
|
|
|
|
|
/* The file type menu */
|
|
|
|
{
|
2003-01-11 01:55:53 +08:00
|
|
|
GimpItemFactory *item_factory;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *option_menu;
|
|
|
|
GtkWidget *label;
|
2002-04-18 09:18:24 +08:00
|
|
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
2003-01-11 01:55:53 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (fs->main_vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
2002-04-18 09:18:24 +08:00
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
item_factory = gimp_menu_factory_menu_new (menu_factory,
|
|
|
|
menu_identifier,
|
|
|
|
GTK_TYPE_MENU,
|
|
|
|
gimp,
|
|
|
|
FALSE);
|
2003-01-31 19:54:16 +08:00
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (filesel), "gimp-item-factory", item_factory);
|
|
|
|
|
2002-04-18 09:18:24 +08:00
|
|
|
option_menu = gtk_option_menu_new ();
|
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), option_menu, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (option_menu);
|
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
g_object_weak_ref (G_OBJECT (option_menu),
|
|
|
|
(GWeakNotify) g_object_unref,
|
|
|
|
item_factory);
|
|
|
|
|
2002-04-18 09:18:24 +08:00
|
|
|
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu),
|
|
|
|
GTK_ITEM_FACTORY (item_factory)->widget);
|
|
|
|
|
2003-08-26 23:12:47 +08:00
|
|
|
label = gtk_label_new_with_mnemonic (_("Determine File _Type:"));
|
2002-04-18 09:18:24 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
2003-08-26 23:12:47 +08:00
|
|
|
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), option_menu);
|
2002-04-18 09:18:24 +08:00
|
|
|
}
|
|
|
|
|
2003-05-04 07:02:26 +08:00
|
|
|
gimp_dialog_factory_add_foreign (dialog_factory, dialog_identifier, filesel);
|
|
|
|
|
2002-04-18 09:18:24 +08:00
|
|
|
return filesel;
|
|
|
|
}
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
file_dialog_show (GtkWidget *filesel)
|
|
|
|
{
|
2002-12-11 00:38:16 +08:00
|
|
|
gimp_item_factories_set_sensitive ("<Toolbox>", "/File/Open...", FALSE);
|
2002-03-21 01:46:13 +08:00
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
gimp_item_factories_set_sensitive ("<Image>", "/File/Open...", FALSE);
|
|
|
|
gimp_item_factories_set_sensitive ("<Image>", "/File/Save", FALSE);
|
|
|
|
gimp_item_factories_set_sensitive ("<Image>", "/File/Save as...", FALSE);
|
|
|
|
gimp_item_factories_set_sensitive ("<Image>", "/File/Save a Copy...", FALSE);
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
gtk_widget_grab_focus (GTK_FILE_SELECTION (filesel)->selection_entry);
|
2003-05-04 07:02:26 +08:00
|
|
|
gtk_window_present (GTK_WINDOW (filesel));
|
2001-04-28 23:11:29 +08:00
|
|
|
}
|
|
|
|
|
2001-08-15 00:33:28 +08:00
|
|
|
gboolean
|
2001-04-28 23:11:29 +08:00
|
|
|
file_dialog_hide (GtkWidget *filesel)
|
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
gtk_widget_hide (filesel);
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
gimp_item_factories_set_sensitive ("<Toolbox>", "/File/Open...", TRUE);
|
|
|
|
|
|
|
|
gimp_item_factories_set_sensitive ("<Image>", "/File/Open...", TRUE);
|
|
|
|
gimp_item_factories_set_sensitive ("<Image>", "/File/Save", TRUE);
|
|
|
|
gimp_item_factories_set_sensitive ("<Image>", "/File/Save as...", TRUE);
|
|
|
|
gimp_item_factories_set_sensitive ("<Image>", "/File/Save a Copy...", TRUE);
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2001-10-17 19:33:43 +08:00
|
|
|
/* return TRUE because we are used as "delete_event" handler */
|
|
|
|
return TRUE;
|
2001-04-28 23:11:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-08-15 00:33:28 +08:00
|
|
|
file_dialog_update_name (PlugInProcDef *proc,
|
|
|
|
GtkFileSelection *filesel)
|
2001-04-28 23:11:29 +08:00
|
|
|
{
|
|
|
|
if (proc->extensions_list)
|
|
|
|
{
|
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-25 05:27:11 +08:00
|
|
|
const gchar *text;
|
|
|
|
gchar *last_dot;
|
|
|
|
GString *s;
|
2001-04-28 23:11:29 +08:00
|
|
|
|
2001-08-15 00:33:28 +08:00
|
|
|
text = gtk_entry_get_text (GTK_ENTRY (filesel->selection_entry));
|
2001-04-28 23:11:29 +08:00
|
|
|
last_dot = strrchr (text, '.');
|
|
|
|
|
|
|
|
if (last_dot == text || !text[0])
|
|
|
|
return;
|
|
|
|
|
|
|
|
s = g_string_new (text);
|
|
|
|
|
|
|
|
if (last_dot)
|
|
|
|
g_string_truncate (s, last_dot-text);
|
|
|
|
|
|
|
|
g_string_append (s, ".");
|
|
|
|
g_string_append (s, (gchar *) proc->extensions_list->data);
|
|
|
|
|
2001-08-15 00:33:28 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (filesel->selection_entry), s->str);
|
2001-04-28 23:11:29 +08:00
|
|
|
|
|
|
|
g_string_free (s, TRUE);
|
|
|
|
}
|
|
|
|
}
|