gimp/libgimpwidgets/gimpfileentry.c

437 lines
13 KiB
C
Raw Normal View History

added "wm_name", "wm_class", "display_name" and "monitor_number" to the 2003-11-07 Michael Natterer <mitch@gimp.org> * libgimpbase/gimpprotocol.[ch]: added "wm_name", "wm_class", "display_name" and "monitor_number" to the GPConfig message. Increased protocol version number. * libgimp/gimp.[ch] (gimp_config): read them from the GPConfig message and remember them. Added public accessors for the new config values. * libgimp/gimpui.c (gimp_ui_init): pass wm_name and wm_class to gtk_init() and export the display/screen to use to the environment. * app/core/gimp.[ch]: added vtable entries to get the values from the GUI. * app/gui/gui-vtable.c: implement the vtable entries. * app/plug-in/plug-in-run.c: fill in the GPConfig values using the new Gimp vtable functions. * app/display/gimpdisplayshell-layer-select.c * app/display/gimpdisplayshell.c * app/gui/about-dialog.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-dialog-utils.[ch] * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor-commands.c * app/gui/gradients-commands.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-dialog.[ch] * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/splash.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/tips-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcurvestool.c * app/tools/gimplevelstool.c * app/widgets/gimpdock.c * app/widgets/gimperrorconsole.c * app/widgets/gimptexteditor.c * app/widgets/gimptoolbox.c * app/widgets/gimpviewabledialog.[ch] * libgimpwidgets/gimpfileselection.c * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c * plug-ins/helpbrowser/dialog.c * plug-ins/ifscompose/ifscompose.c: replaced all calls to gtk_window_set_wmclass() by gtk_window_set_role() and all "const gchar *wmclass_name" parameters by "const gchar *role". Cleaned up the window role strings.
2003-11-08 01:29:02 +08:00
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpfileentry.c
* Copyright (C) 1999-2004 Michael Natterer <mitch@gimp.org>
*
* This library is free software: you can redistribute it and/or
1999-11-18 05:13:50 +08:00
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
added "wm_name", "wm_class", "display_name" and "monitor_number" to the 2003-11-07 Michael Natterer <mitch@gimp.org> * libgimpbase/gimpprotocol.[ch]: added "wm_name", "wm_class", "display_name" and "monitor_number" to the GPConfig message. Increased protocol version number. * libgimp/gimp.[ch] (gimp_config): read them from the GPConfig message and remember them. Added public accessors for the new config values. * libgimp/gimpui.c (gimp_ui_init): pass wm_name and wm_class to gtk_init() and export the display/screen to use to the environment. * app/core/gimp.[ch]: added vtable entries to get the values from the GUI. * app/gui/gui-vtable.c: implement the vtable entries. * app/plug-in/plug-in-run.c: fill in the GPConfig values using the new Gimp vtable functions. * app/display/gimpdisplayshell-layer-select.c * app/display/gimpdisplayshell.c * app/gui/about-dialog.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-dialog-utils.[ch] * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor-commands.c * app/gui/gradients-commands.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-dialog.[ch] * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/splash.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/tips-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcurvestool.c * app/tools/gimplevelstool.c * app/widgets/gimpdock.c * app/widgets/gimperrorconsole.c * app/widgets/gimptexteditor.c * app/widgets/gimptoolbox.c * app/widgets/gimpviewabledialog.[ch] * libgimpwidgets/gimpfileselection.c * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c * plug-ins/helpbrowser/dialog.c * plug-ins/ifscompose/ifscompose.c: replaced all calls to gtk_window_set_wmclass() by gtk_window_set_role() and all "const gchar *wmclass_name" parameters by "const gchar *role". Cleaned up the window role strings.
2003-11-08 01:29:02 +08:00
*
* This library 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
* Library General Public License for more details.
*
1999-11-18 05:13:50 +08:00
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
Makefile.am configure.in added the new library below. 2001-01-24 Michael Natterer <mitch@gimp.org> * Makefile.am * configure.in * gimptool.in: added the new library below. * libgimpwidgets/Makefile.am * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.[ch] * libgimpwidgets/gimpcolorbutton.[ch] * libgimpwidgets/gimpdialog.[ch] * libgimpwidgets/gimpfileselection.[ch] * libgimpwidgets/gimphelpui.[ch] * libgimpwidgets/gimppatheditor.[ch] * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpquerybox.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch] * libgimpwidgets/gimpwidgets.[ch] * libgimpwidgets/gimpwidgets.def * libgimpwidgets/gimpwidgetstypes.h: new shared library. Currently there are some ugly dependencies into libgimp. These will be removed and go to a "libgimpglue" library which will be a library for functions which share a common interface between plug-ins and the app but have different implementations. Include "libgimp/gimpunit.h" from "libgimpwidgets/gimpwidgetstypes.h" to simulate this upcoming separation. * libgimp/Makefile.am * libgimp/gimpchainbutton.[ch] * libgimp/gimpcolorarea.[ch] * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimpfileselection.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimppixmap.[ch] * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: removed from here. * libgimp/gimpui.h * libgimp/gimpuitypes.h * libgimp/makefile.mingw.in * libgimp/makefile.msc: changed accordingly. * app/[all ui files] * app/pdb/palette_cmds.c * app/pdb/tools_cmds.c * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: #include "libgimpwidgets/gimpwidgets.h" and removed useless includes. * app/apptypes.h: #include "libgimpwidgets/gimpwidgetstypes.h" * app/Makefile.am * plug-ins/[all makefiles which link against libgimpui]: link against libgimpwidgets.la * po-libgimp/POTFILES.in: changed file locations.
2001-01-25 06:36:18 +08:00
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "gimpwidgetstypes.h"
#undef GIMP_DISABLE_DEPRECATED
#include "gimpfileentry.h"
#include "gimphelpui.h"
Makefile.am configure.in added the new library below. 2001-01-24 Michael Natterer <mitch@gimp.org> * Makefile.am * configure.in * gimptool.in: added the new library below. * libgimpwidgets/Makefile.am * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.[ch] * libgimpwidgets/gimpcolorbutton.[ch] * libgimpwidgets/gimpdialog.[ch] * libgimpwidgets/gimpfileselection.[ch] * libgimpwidgets/gimphelpui.[ch] * libgimpwidgets/gimppatheditor.[ch] * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpquerybox.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch] * libgimpwidgets/gimpwidgets.[ch] * libgimpwidgets/gimpwidgets.def * libgimpwidgets/gimpwidgetstypes.h: new shared library. Currently there are some ugly dependencies into libgimp. These will be removed and go to a "libgimpglue" library which will be a library for functions which share a common interface between plug-ins and the app but have different implementations. Include "libgimp/gimpunit.h" from "libgimpwidgets/gimpwidgetstypes.h" to simulate this upcoming separation. * libgimp/Makefile.am * libgimp/gimpchainbutton.[ch] * libgimp/gimpcolorarea.[ch] * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimpfileselection.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimppixmap.[ch] * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: removed from here. * libgimp/gimpui.h * libgimp/gimpuitypes.h * libgimp/makefile.mingw.in * libgimp/makefile.msc: changed accordingly. * app/[all ui files] * app/pdb/palette_cmds.c * app/pdb/tools_cmds.c * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: #include "libgimpwidgets/gimpwidgets.h" and removed useless includes. * app/apptypes.h: #include "libgimpwidgets/gimpwidgetstypes.h" * app/Makefile.am * plug-ins/[all makefiles which link against libgimpui]: link against libgimpwidgets.la * po-libgimp/POTFILES.in: changed file locations.
2001-01-25 06:36:18 +08:00
#include "libgimp/libgimp-intl.h"
/**
* SECTION: gimpfileentry
* @title: GimpFileEntry
* @short_description: Widget for entering a filename.
* @see_also: #GimpPathEditor
*
* This widget is used to enter filenames or directories.
*
* There is a #GtkEntry for entering the filename manually and a "..."
* button which will pop up a #GtkFileChooserDialog.
*
* You can restrict the #GimpFileEntry to directories. In this
* case the filename listbox of the #GtkFileChooser dialog will be
* set to directory mode.
*
* If you specify @check_valid as #TRUE in gimp_file_entry_new() the
* entered filename will be checked for validity and a pixmap will be
* shown which indicates if the file exists or not.
*
* Whenever the user changes the filename, the "filename_changed"
* signal will be emitted.
**/
enum
{
FILENAME_CHANGED,
LAST_SIGNAL
};
static void gimp_file_entry_dispose (GObject *object);
static void gimp_file_entry_entry_activate (GtkWidget *widget,
GimpFileEntry *entry);
static gint gimp_file_entry_entry_focus_out (GtkWidget *widget,
GdkEvent *event,
GimpFileEntry *entry);
static void gimp_file_entry_browse_clicked (GtkWidget *widget,
GimpFileEntry *entry);
static void gimp_file_entry_check_filename (GimpFileEntry *entry);
G_DEFINE_TYPE (GimpFileEntry, gimp_file_entry, GTK_TYPE_BOX)
#define parent_class gimp_file_entry_parent_class
static guint gimp_file_entry_signals[LAST_SIGNAL] = { 0 };
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
static void
gimp_file_entry_class_init (GimpFileEntryClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
/**
* GimpFileEntry::filename-changed:
*
* This signal is emitted whenever the user changes the filename.
**/
gimp_file_entry_signals[FILENAME_CHANGED] =
g_signal_new ("filename-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpFileEntryClass, filename_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
object_class->dispose = gimp_file_entry_dispose;
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
klass->filename_changed = NULL;
}
static void
gimp_file_entry_init (GimpFileEntry *entry)
{
GtkWidget *image;
entry->title = NULL;
entry->file_dialog = NULL;
entry->check_valid = FALSE;
entry->file_exists = NULL;
gtk_orientable_set_orientation (GTK_ORIENTABLE (entry),
GTK_ORIENTATION_HORIZONTAL);
gtk_box_set_spacing (GTK_BOX (entry), 4);
gtk_box_set_homogeneous (GTK_BOX (entry), FALSE);
entry->browse_button = gtk_button_new ();
gtk_box_pack_end (GTK_BOX (entry), entry->browse_button, FALSE, FALSE, 0);
gtk_widget_show (entry->browse_button);
image = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON);
gtk_container_add (GTK_CONTAINER (entry->browse_button), image);
gtk_widget_show (image);
g_signal_connect (entry->browse_button, "clicked",
G_CALLBACK (gimp_file_entry_browse_clicked),
entry);
entry->entry = gtk_entry_new ();
gtk_box_pack_end (GTK_BOX (entry), entry->entry, TRUE, TRUE, 0);
gtk_widget_show (entry->entry);
g_signal_connect (entry->entry, "activate",
G_CALLBACK (gimp_file_entry_entry_activate),
entry);
g_signal_connect (entry->entry, "focus-out-event",
G_CALLBACK (gimp_file_entry_entry_focus_out),
entry);
}
register the button icons with GTK_ICON_SIZE_BUTTON, but set them as 2001-08-05 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpstock.[ch]: register the button icons with GTK_ICON_SIZE_BUTTON, but set them as scalable fallbacks for themselves so they get scaled for menus. * app/gui/menus.c: set stock icons for much more menu entries. * app/widgets/gimpwidgets-utils.[ch]: new utility function gimp_item_factory_popup_with_data(). * app/disp_callbacks.[ch] * app/gui/brushes-commands.c * app/gui/channels-commands.c * app/gui/gradients-commands.c * app/gui/layers-commands.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/patterns-commands.c: use the new function. * app/tools/gimpcolorbalancetool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c: s/_("Reset")/GIMP_STOCK_RESET/ * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpcontainerview.[ch]: moved the button_box utility functions from the container editor to GimpContainerView itself. * app/widgets/gimpbufferview.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpcontainergridview.[ch] * app/widgets/gimpdatafactoryview.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.[ch] * app/widgets/gimplayerlistitem.c * app/widgets/gimplayerlistview.c: changed accordingly. Removed lots of duplicated code and use stock images instead of pixmaps. * libgimpwidgets/gimpfileselection.[ch] * libgimpwidgets/gimppatheditor.c: use stock images instead of pixmaps. * pixmaps/Makefile.am: removed "yes" and "no", added "stroke". * pixmaps/anchor.xpm * pixmaps/delete.xpm * pixmaps/lower.xpm * pixmaps/new.xpm * pixmaps/paste-as-new.xpm * pixmaps/paste-into.xpm * pixmaps/paste.xpm * pixmaps/raise.xpm * pixmaps/refresh.xpm * pixmaps/toselection.xpm: made them all 16x16 so they are scaled nicely in menus. Should probably be 18x18.
2001-08-05 04:38:54 +08:00
static void
gimp_file_entry_dispose (GObject *object)
{
GimpFileEntry *entry = GIMP_FILE_ENTRY (object);
register the button icons with GTK_ICON_SIZE_BUTTON, but set them as 2001-08-05 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpstock.[ch]: register the button icons with GTK_ICON_SIZE_BUTTON, but set them as scalable fallbacks for themselves so they get scaled for menus. * app/gui/menus.c: set stock icons for much more menu entries. * app/widgets/gimpwidgets-utils.[ch]: new utility function gimp_item_factory_popup_with_data(). * app/disp_callbacks.[ch] * app/gui/brushes-commands.c * app/gui/channels-commands.c * app/gui/gradients-commands.c * app/gui/layers-commands.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/patterns-commands.c: use the new function. * app/tools/gimpcolorbalancetool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c: s/_("Reset")/GIMP_STOCK_RESET/ * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpcontainerview.[ch]: moved the button_box utility functions from the container editor to GimpContainerView itself. * app/widgets/gimpbufferview.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpcontainergridview.[ch] * app/widgets/gimpdatafactoryview.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.[ch] * app/widgets/gimplayerlistitem.c * app/widgets/gimplayerlistview.c: changed accordingly. Removed lots of duplicated code and use stock images instead of pixmaps. * libgimpwidgets/gimpfileselection.[ch] * libgimpwidgets/gimppatheditor.c: use stock images instead of pixmaps. * pixmaps/Makefile.am: removed "yes" and "no", added "stroke". * pixmaps/anchor.xpm * pixmaps/delete.xpm * pixmaps/lower.xpm * pixmaps/new.xpm * pixmaps/paste-as-new.xpm * pixmaps/paste-into.xpm * pixmaps/paste.xpm * pixmaps/raise.xpm * pixmaps/refresh.xpm * pixmaps/toselection.xpm: made them all 16x16 so they are scaled nicely in menus. Should probably be 18x18.
2001-08-05 04:38:54 +08:00
if (entry->file_dialog)
{
gtk_widget_destroy (entry->file_dialog);
entry->file_dialog = NULL;
register the button icons with GTK_ICON_SIZE_BUTTON, but set them as 2001-08-05 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpstock.[ch]: register the button icons with GTK_ICON_SIZE_BUTTON, but set them as scalable fallbacks for themselves so they get scaled for menus. * app/gui/menus.c: set stock icons for much more menu entries. * app/widgets/gimpwidgets-utils.[ch]: new utility function gimp_item_factory_popup_with_data(). * app/disp_callbacks.[ch] * app/gui/brushes-commands.c * app/gui/channels-commands.c * app/gui/gradients-commands.c * app/gui/layers-commands.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/patterns-commands.c: use the new function. * app/tools/gimpcolorbalancetool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c: s/_("Reset")/GIMP_STOCK_RESET/ * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpcontainerview.[ch]: moved the button_box utility functions from the container editor to GimpContainerView itself. * app/widgets/gimpbufferview.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpcontainergridview.[ch] * app/widgets/gimpdatafactoryview.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.[ch] * app/widgets/gimplayerlistitem.c * app/widgets/gimplayerlistview.c: changed accordingly. Removed lots of duplicated code and use stock images instead of pixmaps. * libgimpwidgets/gimpfileselection.[ch] * libgimpwidgets/gimppatheditor.c: use stock images instead of pixmaps. * pixmaps/Makefile.am: removed "yes" and "no", added "stroke". * pixmaps/anchor.xpm * pixmaps/delete.xpm * pixmaps/lower.xpm * pixmaps/new.xpm * pixmaps/paste-as-new.xpm * pixmaps/paste-into.xpm * pixmaps/paste.xpm * pixmaps/raise.xpm * pixmaps/refresh.xpm * pixmaps/toselection.xpm: made them all 16x16 so they are scaled nicely in menus. Should probably be 18x18.
2001-08-05 04:38:54 +08:00
}
if (entry->title)
register the button icons with GTK_ICON_SIZE_BUTTON, but set them as 2001-08-05 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpstock.[ch]: register the button icons with GTK_ICON_SIZE_BUTTON, but set them as scalable fallbacks for themselves so they get scaled for menus. * app/gui/menus.c: set stock icons for much more menu entries. * app/widgets/gimpwidgets-utils.[ch]: new utility function gimp_item_factory_popup_with_data(). * app/disp_callbacks.[ch] * app/gui/brushes-commands.c * app/gui/channels-commands.c * app/gui/gradients-commands.c * app/gui/layers-commands.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/patterns-commands.c: use the new function. * app/tools/gimpcolorbalancetool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c: s/_("Reset")/GIMP_STOCK_RESET/ * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpcontainerview.[ch]: moved the button_box utility functions from the container editor to GimpContainerView itself. * app/widgets/gimpbufferview.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpcontainergridview.[ch] * app/widgets/gimpdatafactoryview.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.[ch] * app/widgets/gimplayerlistitem.c * app/widgets/gimplayerlistview.c: changed accordingly. Removed lots of duplicated code and use stock images instead of pixmaps. * libgimpwidgets/gimpfileselection.[ch] * libgimpwidgets/gimppatheditor.c: use stock images instead of pixmaps. * pixmaps/Makefile.am: removed "yes" and "no", added "stroke". * pixmaps/anchor.xpm * pixmaps/delete.xpm * pixmaps/lower.xpm * pixmaps/new.xpm * pixmaps/paste-as-new.xpm * pixmaps/paste-into.xpm * pixmaps/paste.xpm * pixmaps/raise.xpm * pixmaps/refresh.xpm * pixmaps/toselection.xpm: made them all 16x16 so they are scaled nicely in menus. Should probably be 18x18.
2001-08-05 04:38:54 +08:00
{
g_free (entry->title);
entry->title = NULL;
}
register the button icons with GTK_ICON_SIZE_BUTTON, but set them as 2001-08-05 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpstock.[ch]: register the button icons with GTK_ICON_SIZE_BUTTON, but set them as scalable fallbacks for themselves so they get scaled for menus. * app/gui/menus.c: set stock icons for much more menu entries. * app/widgets/gimpwidgets-utils.[ch]: new utility function gimp_item_factory_popup_with_data(). * app/disp_callbacks.[ch] * app/gui/brushes-commands.c * app/gui/channels-commands.c * app/gui/gradients-commands.c * app/gui/layers-commands.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/patterns-commands.c: use the new function. * app/tools/gimpcolorbalancetool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c: s/_("Reset")/GIMP_STOCK_RESET/ * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpcontainerview.[ch]: moved the button_box utility functions from the container editor to GimpContainerView itself. * app/widgets/gimpbufferview.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpcontainergridview.[ch] * app/widgets/gimpdatafactoryview.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.[ch] * app/widgets/gimplayerlistitem.c * app/widgets/gimplayerlistview.c: changed accordingly. Removed lots of duplicated code and use stock images instead of pixmaps. * libgimpwidgets/gimpfileselection.[ch] * libgimpwidgets/gimppatheditor.c: use stock images instead of pixmaps. * pixmaps/Makefile.am: removed "yes" and "no", added "stroke". * pixmaps/anchor.xpm * pixmaps/delete.xpm * pixmaps/lower.xpm * pixmaps/new.xpm * pixmaps/paste-as-new.xpm * pixmaps/paste-into.xpm * pixmaps/paste.xpm * pixmaps/raise.xpm * pixmaps/refresh.xpm * pixmaps/toselection.xpm: made them all 16x16 so they are scaled nicely in menus. Should probably be 18x18.
2001-08-05 04:38:54 +08:00
G_OBJECT_CLASS (parent_class)->dispose (object);
}
/**
* gimp_file_entry_new:
* @title: The title of the #GimpFileEntry dialog.
* @filename: The initial filename.
* @dir_only: %TRUE if the file entry should accept directories only.
* @check_valid: %TRUE if the widget should check if the entered file
* really exists.
*
* You should use #GtkFileChooserButton instead.
*
* Returns: A pointer to the new #GimpFileEntry widget.
**/
GtkWidget *
gimp_file_entry_new (const gchar *title,
const gchar *filename,
gboolean dir_only,
gboolean check_valid)
{
GimpFileEntry *entry;
entry = g_object_new (GIMP_TYPE_FILE_ENTRY, NULL);
entry->title = g_strdup (title);
entry->dir_only = dir_only;
entry->check_valid = check_valid;
gimp_help_set_help_data (entry->browse_button,
dir_only ?
_("Open a file selector to browse your folders") :
_("Open a file selector to browse your files"),
NULL);
register the button icons with GTK_ICON_SIZE_BUTTON, but set them as 2001-08-05 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpstock.[ch]: register the button icons with GTK_ICON_SIZE_BUTTON, but set them as scalable fallbacks for themselves so they get scaled for menus. * app/gui/menus.c: set stock icons for much more menu entries. * app/widgets/gimpwidgets-utils.[ch]: new utility function gimp_item_factory_popup_with_data(). * app/disp_callbacks.[ch] * app/gui/brushes-commands.c * app/gui/channels-commands.c * app/gui/gradients-commands.c * app/gui/layers-commands.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/patterns-commands.c: use the new function. * app/tools/gimpcolorbalancetool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c: s/_("Reset")/GIMP_STOCK_RESET/ * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpcontainerview.[ch]: moved the button_box utility functions from the container editor to GimpContainerView itself. * app/widgets/gimpbufferview.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpcontainergridview.[ch] * app/widgets/gimpdatafactoryview.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.[ch] * app/widgets/gimplayerlistitem.c * app/widgets/gimplayerlistview.c: changed accordingly. Removed lots of duplicated code and use stock images instead of pixmaps. * libgimpwidgets/gimpfileselection.[ch] * libgimpwidgets/gimppatheditor.c: use stock images instead of pixmaps. * pixmaps/Makefile.am: removed "yes" and "no", added "stroke". * pixmaps/anchor.xpm * pixmaps/delete.xpm * pixmaps/lower.xpm * pixmaps/new.xpm * pixmaps/paste-as-new.xpm * pixmaps/paste-into.xpm * pixmaps/paste.xpm * pixmaps/raise.xpm * pixmaps/refresh.xpm * pixmaps/toselection.xpm: made them all 16x16 so they are scaled nicely in menus. Should probably be 18x18.
2001-08-05 04:38:54 +08:00
if (check_valid)
{
entry->file_exists = gtk_image_new_from_stock (GTK_STOCK_NO,
GTK_ICON_SIZE_BUTTON);
gtk_box_pack_start (GTK_BOX (entry), entry->file_exists, FALSE, FALSE, 0);
gtk_widget_show (entry->file_exists);
register the button icons with GTK_ICON_SIZE_BUTTON, but set them as 2001-08-05 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpstock.[ch]: register the button icons with GTK_ICON_SIZE_BUTTON, but set them as scalable fallbacks for themselves so they get scaled for menus. * app/gui/menus.c: set stock icons for much more menu entries. * app/widgets/gimpwidgets-utils.[ch]: new utility function gimp_item_factory_popup_with_data(). * app/disp_callbacks.[ch] * app/gui/brushes-commands.c * app/gui/channels-commands.c * app/gui/gradients-commands.c * app/gui/layers-commands.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/patterns-commands.c: use the new function. * app/tools/gimpcolorbalancetool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c: s/_("Reset")/GIMP_STOCK_RESET/ * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpcontainerview.[ch]: moved the button_box utility functions from the container editor to GimpContainerView itself. * app/widgets/gimpbufferview.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpcontainergridview.[ch] * app/widgets/gimpdatafactoryview.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.[ch] * app/widgets/gimplayerlistitem.c * app/widgets/gimplayerlistview.c: changed accordingly. Removed lots of duplicated code and use stock images instead of pixmaps. * libgimpwidgets/gimpfileselection.[ch] * libgimpwidgets/gimppatheditor.c: use stock images instead of pixmaps. * pixmaps/Makefile.am: removed "yes" and "no", added "stroke". * pixmaps/anchor.xpm * pixmaps/delete.xpm * pixmaps/lower.xpm * pixmaps/new.xpm * pixmaps/paste-as-new.xpm * pixmaps/paste-into.xpm * pixmaps/paste.xpm * pixmaps/raise.xpm * pixmaps/refresh.xpm * pixmaps/toselection.xpm: made them all 16x16 so they are scaled nicely in menus. Should probably be 18x18.
2001-08-05 04:38:54 +08:00
}
gimp_file_entry_set_filename (entry, filename);
return GTK_WIDGET (entry);
}
/**
* gimp_file_entry_get_filename:
* @entry: The file entry you want to know the filename from.
*
* Note that you have to g_free() the returned string.
*
* Returns: The file or directory the user has entered.
**/
gchar *
gimp_file_entry_get_filename (GimpFileEntry *entry)
{
Added infrastructure to make sure we don't write to the global brush, 2004-01-28 Michael Natterer <mitch@gimp.org> Added infrastructure to make sure we don't write to the global brush, pattern etc. directories. Needed to make this configurable because we can't rely on the global directories being read-only, having certain names or being otherwise detectable at runtime in a sane way. Fixes bug #132214. * libgimpbase/gimpdatafiles.[ch]: added "const gchar *dirname" to the GimpDataFileData struct so callbacks don't need to call g_path_get_dirname() for each file. * libgimpwidgets/gimpfileentry.c: made it work with non UTF-8 encoded filenames. * libgimpwidgets/gimppatheditor.[ch]: ditto. Added GUI and API for setting/getting a second "writable_path". The widget makes sure that the writable_path is always a subset of the path. * app/config/gimpconfig-utils.[ch]: added new function gimp_config_build_writable_path(). * app/config/gimpcoreconfig.[ch]: added separate properties for the writable brush, pattern, gradient, palette and font paths. * app/config/gimprc-blurbs.h: added (still empty) blurbs for the new properties. * app/core/gimpdata.[ch] (gimp_data_set_filename): added parameter "gboolean writable". Set data->writable to FALSE by default. If "writable" is passed as TRUE, still check if we can write to the file before setting data->writable to TRUE. (gimp_data_create_filename): changed "data_path" parameter to "dest_dir" and assume dest_dir is writable. (gimp_data_duplicate): set data->dirty to TRUE to make sure duplicated things will be saved. * app/core/gimpbrush.c * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c * app/core/gimpgradient.c * app/core/gimppalette.c * app/core/gimppattern.c: don't set the data's filename and don't touch data->dirty in the _load() functions because that's done by the data factory now. Don't touch data->dirty in the _duplicate() functions because that's done by gimp_data_duplicate() itself now. * app/core/gimpdatafactory.[ch] (gimp_data_factory_new): added "writable_property_name" and remember it. Added utility function gimp_data_factory_get_save_dir() which determines the directory to save new datas to. Added public function gimp_data_factory_data_save_single() which saves a single data object. Make sure new things get saved to the first writable directory as specified in preferences. * app/core/gimp.c (gimp_real_initialize): pass the writable_paths' property names to gimp_data_factory_new(). * app/widgets/gimpdataeditor.c (gimp_data_editor_save_dirty): use gimp_data_factory_data_save_single() instead of implementing saving here. * app/widgets/gimppropwidgets.[ch] (gimp_prop_path_editor_new): added "const gchar *writable_property_name" parameter (can be NULL). Added the needed callbacks to handle the writable_path and made the path_editor and file_entry code aware of non UTF-8 filename encodings. Some general cleanup. * app/gui/preferences-dialog.c: changed accordingly.
2004-01-29 05:53:50 +08:00
gchar *utf8;
gchar *filename;
g_return_val_if_fail (GIMP_IS_FILE_ENTRY (entry), NULL);
Added infrastructure to make sure we don't write to the global brush, 2004-01-28 Michael Natterer <mitch@gimp.org> Added infrastructure to make sure we don't write to the global brush, pattern etc. directories. Needed to make this configurable because we can't rely on the global directories being read-only, having certain names or being otherwise detectable at runtime in a sane way. Fixes bug #132214. * libgimpbase/gimpdatafiles.[ch]: added "const gchar *dirname" to the GimpDataFileData struct so callbacks don't need to call g_path_get_dirname() for each file. * libgimpwidgets/gimpfileentry.c: made it work with non UTF-8 encoded filenames. * libgimpwidgets/gimppatheditor.[ch]: ditto. Added GUI and API for setting/getting a second "writable_path". The widget makes sure that the writable_path is always a subset of the path. * app/config/gimpconfig-utils.[ch]: added new function gimp_config_build_writable_path(). * app/config/gimpcoreconfig.[ch]: added separate properties for the writable brush, pattern, gradient, palette and font paths. * app/config/gimprc-blurbs.h: added (still empty) blurbs for the new properties. * app/core/gimpdata.[ch] (gimp_data_set_filename): added parameter "gboolean writable". Set data->writable to FALSE by default. If "writable" is passed as TRUE, still check if we can write to the file before setting data->writable to TRUE. (gimp_data_create_filename): changed "data_path" parameter to "dest_dir" and assume dest_dir is writable. (gimp_data_duplicate): set data->dirty to TRUE to make sure duplicated things will be saved. * app/core/gimpbrush.c * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c * app/core/gimpgradient.c * app/core/gimppalette.c * app/core/gimppattern.c: don't set the data's filename and don't touch data->dirty in the _load() functions because that's done by the data factory now. Don't touch data->dirty in the _duplicate() functions because that's done by gimp_data_duplicate() itself now. * app/core/gimpdatafactory.[ch] (gimp_data_factory_new): added "writable_property_name" and remember it. Added utility function gimp_data_factory_get_save_dir() which determines the directory to save new datas to. Added public function gimp_data_factory_data_save_single() which saves a single data object. Make sure new things get saved to the first writable directory as specified in preferences. * app/core/gimp.c (gimp_real_initialize): pass the writable_paths' property names to gimp_data_factory_new(). * app/widgets/gimpdataeditor.c (gimp_data_editor_save_dirty): use gimp_data_factory_data_save_single() instead of implementing saving here. * app/widgets/gimppropwidgets.[ch] (gimp_prop_path_editor_new): added "const gchar *writable_property_name" parameter (can be NULL). Added the needed callbacks to handle the writable_path and made the path_editor and file_entry code aware of non UTF-8 filename encodings. Some general cleanup. * app/gui/preferences-dialog.c: changed accordingly.
2004-01-29 05:53:50 +08:00
utf8 = gtk_editable_get_chars (GTK_EDITABLE (entry->entry), 0, -1);
filename = g_filename_from_utf8 (utf8, -1, NULL, NULL, NULL);
g_free (utf8);
return filename;
}
/**
* gimp_file_entry_set_filename:
* @entry: The file entry you want to set the filename for.
* @filename: The new filename.
*
* If you specified @check_valid as %TRUE in gimp_file_entry_new()
* the #GimpFileEntry will immediately check the validity of the file
* name.
**/
void
gimp_file_entry_set_filename (GimpFileEntry *entry,
const gchar *filename)
{
Added infrastructure to make sure we don't write to the global brush, 2004-01-28 Michael Natterer <mitch@gimp.org> Added infrastructure to make sure we don't write to the global brush, pattern etc. directories. Needed to make this configurable because we can't rely on the global directories being read-only, having certain names or being otherwise detectable at runtime in a sane way. Fixes bug #132214. * libgimpbase/gimpdatafiles.[ch]: added "const gchar *dirname" to the GimpDataFileData struct so callbacks don't need to call g_path_get_dirname() for each file. * libgimpwidgets/gimpfileentry.c: made it work with non UTF-8 encoded filenames. * libgimpwidgets/gimppatheditor.[ch]: ditto. Added GUI and API for setting/getting a second "writable_path". The widget makes sure that the writable_path is always a subset of the path. * app/config/gimpconfig-utils.[ch]: added new function gimp_config_build_writable_path(). * app/config/gimpcoreconfig.[ch]: added separate properties for the writable brush, pattern, gradient, palette and font paths. * app/config/gimprc-blurbs.h: added (still empty) blurbs for the new properties. * app/core/gimpdata.[ch] (gimp_data_set_filename): added parameter "gboolean writable". Set data->writable to FALSE by default. If "writable" is passed as TRUE, still check if we can write to the file before setting data->writable to TRUE. (gimp_data_create_filename): changed "data_path" parameter to "dest_dir" and assume dest_dir is writable. (gimp_data_duplicate): set data->dirty to TRUE to make sure duplicated things will be saved. * app/core/gimpbrush.c * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c * app/core/gimpgradient.c * app/core/gimppalette.c * app/core/gimppattern.c: don't set the data's filename and don't touch data->dirty in the _load() functions because that's done by the data factory now. Don't touch data->dirty in the _duplicate() functions because that's done by gimp_data_duplicate() itself now. * app/core/gimpdatafactory.[ch] (gimp_data_factory_new): added "writable_property_name" and remember it. Added utility function gimp_data_factory_get_save_dir() which determines the directory to save new datas to. Added public function gimp_data_factory_data_save_single() which saves a single data object. Make sure new things get saved to the first writable directory as specified in preferences. * app/core/gimp.c (gimp_real_initialize): pass the writable_paths' property names to gimp_data_factory_new(). * app/widgets/gimpdataeditor.c (gimp_data_editor_save_dirty): use gimp_data_factory_data_save_single() instead of implementing saving here. * app/widgets/gimppropwidgets.[ch] (gimp_prop_path_editor_new): added "const gchar *writable_property_name" parameter (can be NULL). Added the needed callbacks to handle the writable_path and made the path_editor and file_entry code aware of non UTF-8 filename encodings. Some general cleanup. * app/gui/preferences-dialog.c: changed accordingly.
2004-01-29 05:53:50 +08:00
gchar *utf8;
g_return_if_fail (GIMP_IS_FILE_ENTRY (entry));
Added infrastructure to make sure we don't write to the global brush, 2004-01-28 Michael Natterer <mitch@gimp.org> Added infrastructure to make sure we don't write to the global brush, pattern etc. directories. Needed to make this configurable because we can't rely on the global directories being read-only, having certain names or being otherwise detectable at runtime in a sane way. Fixes bug #132214. * libgimpbase/gimpdatafiles.[ch]: added "const gchar *dirname" to the GimpDataFileData struct so callbacks don't need to call g_path_get_dirname() for each file. * libgimpwidgets/gimpfileentry.c: made it work with non UTF-8 encoded filenames. * libgimpwidgets/gimppatheditor.[ch]: ditto. Added GUI and API for setting/getting a second "writable_path". The widget makes sure that the writable_path is always a subset of the path. * app/config/gimpconfig-utils.[ch]: added new function gimp_config_build_writable_path(). * app/config/gimpcoreconfig.[ch]: added separate properties for the writable brush, pattern, gradient, palette and font paths. * app/config/gimprc-blurbs.h: added (still empty) blurbs for the new properties. * app/core/gimpdata.[ch] (gimp_data_set_filename): added parameter "gboolean writable". Set data->writable to FALSE by default. If "writable" is passed as TRUE, still check if we can write to the file before setting data->writable to TRUE. (gimp_data_create_filename): changed "data_path" parameter to "dest_dir" and assume dest_dir is writable. (gimp_data_duplicate): set data->dirty to TRUE to make sure duplicated things will be saved. * app/core/gimpbrush.c * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c * app/core/gimpgradient.c * app/core/gimppalette.c * app/core/gimppattern.c: don't set the data's filename and don't touch data->dirty in the _load() functions because that's done by the data factory now. Don't touch data->dirty in the _duplicate() functions because that's done by gimp_data_duplicate() itself now. * app/core/gimpdatafactory.[ch] (gimp_data_factory_new): added "writable_property_name" and remember it. Added utility function gimp_data_factory_get_save_dir() which determines the directory to save new datas to. Added public function gimp_data_factory_data_save_single() which saves a single data object. Make sure new things get saved to the first writable directory as specified in preferences. * app/core/gimp.c (gimp_real_initialize): pass the writable_paths' property names to gimp_data_factory_new(). * app/widgets/gimpdataeditor.c (gimp_data_editor_save_dirty): use gimp_data_factory_data_save_single() instead of implementing saving here. * app/widgets/gimppropwidgets.[ch] (gimp_prop_path_editor_new): added "const gchar *writable_property_name" parameter (can be NULL). Added the needed callbacks to handle the writable_path and made the path_editor and file_entry code aware of non UTF-8 filename encodings. Some general cleanup. * app/gui/preferences-dialog.c: changed accordingly.
2004-01-29 05:53:50 +08:00
if (filename)
utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
else
utf8 = g_strdup ("");
gtk_entry_set_text (GTK_ENTRY (entry->entry), utf8);
g_free (utf8);
/* update everything
*/
gimp_file_entry_entry_activate (entry->entry, entry);
}
static void
gimp_file_entry_entry_activate (GtkWidget *widget,
GimpFileEntry *entry)
{
Added infrastructure to make sure we don't write to the global brush, 2004-01-28 Michael Natterer <mitch@gimp.org> Added infrastructure to make sure we don't write to the global brush, pattern etc. directories. Needed to make this configurable because we can't rely on the global directories being read-only, having certain names or being otherwise detectable at runtime in a sane way. Fixes bug #132214. * libgimpbase/gimpdatafiles.[ch]: added "const gchar *dirname" to the GimpDataFileData struct so callbacks don't need to call g_path_get_dirname() for each file. * libgimpwidgets/gimpfileentry.c: made it work with non UTF-8 encoded filenames. * libgimpwidgets/gimppatheditor.[ch]: ditto. Added GUI and API for setting/getting a second "writable_path". The widget makes sure that the writable_path is always a subset of the path. * app/config/gimpconfig-utils.[ch]: added new function gimp_config_build_writable_path(). * app/config/gimpcoreconfig.[ch]: added separate properties for the writable brush, pattern, gradient, palette and font paths. * app/config/gimprc-blurbs.h: added (still empty) blurbs for the new properties. * app/core/gimpdata.[ch] (gimp_data_set_filename): added parameter "gboolean writable". Set data->writable to FALSE by default. If "writable" is passed as TRUE, still check if we can write to the file before setting data->writable to TRUE. (gimp_data_create_filename): changed "data_path" parameter to "dest_dir" and assume dest_dir is writable. (gimp_data_duplicate): set data->dirty to TRUE to make sure duplicated things will be saved. * app/core/gimpbrush.c * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c * app/core/gimpgradient.c * app/core/gimppalette.c * app/core/gimppattern.c: don't set the data's filename and don't touch data->dirty in the _load() functions because that's done by the data factory now. Don't touch data->dirty in the _duplicate() functions because that's done by gimp_data_duplicate() itself now. * app/core/gimpdatafactory.[ch] (gimp_data_factory_new): added "writable_property_name" and remember it. Added utility function gimp_data_factory_get_save_dir() which determines the directory to save new datas to. Added public function gimp_data_factory_data_save_single() which saves a single data object. Make sure new things get saved to the first writable directory as specified in preferences. * app/core/gimp.c (gimp_real_initialize): pass the writable_paths' property names to gimp_data_factory_new(). * app/widgets/gimpdataeditor.c (gimp_data_editor_save_dirty): use gimp_data_factory_data_save_single() instead of implementing saving here. * app/widgets/gimppropwidgets.[ch] (gimp_prop_path_editor_new): added "const gchar *writable_property_name" parameter (can be NULL). Added the needed callbacks to handle the writable_path and made the path_editor and file_entry code aware of non UTF-8 filename encodings. Some general cleanup. * app/gui/preferences-dialog.c: changed accordingly.
2004-01-29 05:53:50 +08:00
gchar *utf8;
gchar *filename;
gint len;
/* filenames still need more sanity checking
* (erase double G_DIR_SEPARATORS, ...)
*/
Added infrastructure to make sure we don't write to the global brush, 2004-01-28 Michael Natterer <mitch@gimp.org> Added infrastructure to make sure we don't write to the global brush, pattern etc. directories. Needed to make this configurable because we can't rely on the global directories being read-only, having certain names or being otherwise detectable at runtime in a sane way. Fixes bug #132214. * libgimpbase/gimpdatafiles.[ch]: added "const gchar *dirname" to the GimpDataFileData struct so callbacks don't need to call g_path_get_dirname() for each file. * libgimpwidgets/gimpfileentry.c: made it work with non UTF-8 encoded filenames. * libgimpwidgets/gimppatheditor.[ch]: ditto. Added GUI and API for setting/getting a second "writable_path". The widget makes sure that the writable_path is always a subset of the path. * app/config/gimpconfig-utils.[ch]: added new function gimp_config_build_writable_path(). * app/config/gimpcoreconfig.[ch]: added separate properties for the writable brush, pattern, gradient, palette and font paths. * app/config/gimprc-blurbs.h: added (still empty) blurbs for the new properties. * app/core/gimpdata.[ch] (gimp_data_set_filename): added parameter "gboolean writable". Set data->writable to FALSE by default. If "writable" is passed as TRUE, still check if we can write to the file before setting data->writable to TRUE. (gimp_data_create_filename): changed "data_path" parameter to "dest_dir" and assume dest_dir is writable. (gimp_data_duplicate): set data->dirty to TRUE to make sure duplicated things will be saved. * app/core/gimpbrush.c * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c * app/core/gimpgradient.c * app/core/gimppalette.c * app/core/gimppattern.c: don't set the data's filename and don't touch data->dirty in the _load() functions because that's done by the data factory now. Don't touch data->dirty in the _duplicate() functions because that's done by gimp_data_duplicate() itself now. * app/core/gimpdatafactory.[ch] (gimp_data_factory_new): added "writable_property_name" and remember it. Added utility function gimp_data_factory_get_save_dir() which determines the directory to save new datas to. Added public function gimp_data_factory_data_save_single() which saves a single data object. Make sure new things get saved to the first writable directory as specified in preferences. * app/core/gimp.c (gimp_real_initialize): pass the writable_paths' property names to gimp_data_factory_new(). * app/widgets/gimpdataeditor.c (gimp_data_editor_save_dirty): use gimp_data_factory_data_save_single() instead of implementing saving here. * app/widgets/gimppropwidgets.[ch] (gimp_prop_path_editor_new): added "const gchar *writable_property_name" parameter (can be NULL). Added the needed callbacks to handle the writable_path and made the path_editor and file_entry code aware of non UTF-8 filename encodings. Some general cleanup. * app/gui/preferences-dialog.c: changed accordingly.
2004-01-29 05:53:50 +08:00
utf8 = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
utf8 = g_strstrip (utf8);
Added infrastructure to make sure we don't write to the global brush, 2004-01-28 Michael Natterer <mitch@gimp.org> Added infrastructure to make sure we don't write to the global brush, pattern etc. directories. Needed to make this configurable because we can't rely on the global directories being read-only, having certain names or being otherwise detectable at runtime in a sane way. Fixes bug #132214. * libgimpbase/gimpdatafiles.[ch]: added "const gchar *dirname" to the GimpDataFileData struct so callbacks don't need to call g_path_get_dirname() for each file. * libgimpwidgets/gimpfileentry.c: made it work with non UTF-8 encoded filenames. * libgimpwidgets/gimppatheditor.[ch]: ditto. Added GUI and API for setting/getting a second "writable_path". The widget makes sure that the writable_path is always a subset of the path. * app/config/gimpconfig-utils.[ch]: added new function gimp_config_build_writable_path(). * app/config/gimpcoreconfig.[ch]: added separate properties for the writable brush, pattern, gradient, palette and font paths. * app/config/gimprc-blurbs.h: added (still empty) blurbs for the new properties. * app/core/gimpdata.[ch] (gimp_data_set_filename): added parameter "gboolean writable". Set data->writable to FALSE by default. If "writable" is passed as TRUE, still check if we can write to the file before setting data->writable to TRUE. (gimp_data_create_filename): changed "data_path" parameter to "dest_dir" and assume dest_dir is writable. (gimp_data_duplicate): set data->dirty to TRUE to make sure duplicated things will be saved. * app/core/gimpbrush.c * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c * app/core/gimpgradient.c * app/core/gimppalette.c * app/core/gimppattern.c: don't set the data's filename and don't touch data->dirty in the _load() functions because that's done by the data factory now. Don't touch data->dirty in the _duplicate() functions because that's done by gimp_data_duplicate() itself now. * app/core/gimpdatafactory.[ch] (gimp_data_factory_new): added "writable_property_name" and remember it. Added utility function gimp_data_factory_get_save_dir() which determines the directory to save new datas to. Added public function gimp_data_factory_data_save_single() which saves a single data object. Make sure new things get saved to the first writable directory as specified in preferences. * app/core/gimp.c (gimp_real_initialize): pass the writable_paths' property names to gimp_data_factory_new(). * app/widgets/gimpdataeditor.c (gimp_data_editor_save_dirty): use gimp_data_factory_data_save_single() instead of implementing saving here. * app/widgets/gimppropwidgets.[ch] (gimp_prop_path_editor_new): added "const gchar *writable_property_name" parameter (can be NULL). Added the needed callbacks to handle the writable_path and made the path_editor and file_entry code aware of non UTF-8 filename encodings. Some general cleanup. * app/gui/preferences-dialog.c: changed accordingly.
2004-01-29 05:53:50 +08:00
while (((len = strlen (utf8)) > 1) &&
(utf8[len - 1] == G_DIR_SEPARATOR))
Added infrastructure to make sure we don't write to the global brush, 2004-01-28 Michael Natterer <mitch@gimp.org> Added infrastructure to make sure we don't write to the global brush, pattern etc. directories. Needed to make this configurable because we can't rely on the global directories being read-only, having certain names or being otherwise detectable at runtime in a sane way. Fixes bug #132214. * libgimpbase/gimpdatafiles.[ch]: added "const gchar *dirname" to the GimpDataFileData struct so callbacks don't need to call g_path_get_dirname() for each file. * libgimpwidgets/gimpfileentry.c: made it work with non UTF-8 encoded filenames. * libgimpwidgets/gimppatheditor.[ch]: ditto. Added GUI and API for setting/getting a second "writable_path". The widget makes sure that the writable_path is always a subset of the path. * app/config/gimpconfig-utils.[ch]: added new function gimp_config_build_writable_path(). * app/config/gimpcoreconfig.[ch]: added separate properties for the writable brush, pattern, gradient, palette and font paths. * app/config/gimprc-blurbs.h: added (still empty) blurbs for the new properties. * app/core/gimpdata.[ch] (gimp_data_set_filename): added parameter "gboolean writable". Set data->writable to FALSE by default. If "writable" is passed as TRUE, still check if we can write to the file before setting data->writable to TRUE. (gimp_data_create_filename): changed "data_path" parameter to "dest_dir" and assume dest_dir is writable. (gimp_data_duplicate): set data->dirty to TRUE to make sure duplicated things will be saved. * app/core/gimpbrush.c * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c * app/core/gimpgradient.c * app/core/gimppalette.c * app/core/gimppattern.c: don't set the data's filename and don't touch data->dirty in the _load() functions because that's done by the data factory now. Don't touch data->dirty in the _duplicate() functions because that's done by gimp_data_duplicate() itself now. * app/core/gimpdatafactory.[ch] (gimp_data_factory_new): added "writable_property_name" and remember it. Added utility function gimp_data_factory_get_save_dir() which determines the directory to save new datas to. Added public function gimp_data_factory_data_save_single() which saves a single data object. Make sure new things get saved to the first writable directory as specified in preferences. * app/core/gimp.c (gimp_real_initialize): pass the writable_paths' property names to gimp_data_factory_new(). * app/widgets/gimpdataeditor.c (gimp_data_editor_save_dirty): use gimp_data_factory_data_save_single() instead of implementing saving here. * app/widgets/gimppropwidgets.[ch] (gimp_prop_path_editor_new): added "const gchar *writable_property_name" parameter (can be NULL). Added the needed callbacks to handle the writable_path and made the path_editor and file_entry code aware of non UTF-8 filename encodings. Some general cleanup. * app/gui/preferences-dialog.c: changed accordingly.
2004-01-29 05:53:50 +08:00
utf8[len - 1] = '\0';
filename = g_filename_from_utf8 (utf8, -1, NULL, NULL, NULL);
g_signal_handlers_block_by_func (entry->entry,
gimp_file_entry_entry_activate,
entry);
Added infrastructure to make sure we don't write to the global brush, 2004-01-28 Michael Natterer <mitch@gimp.org> Added infrastructure to make sure we don't write to the global brush, pattern etc. directories. Needed to make this configurable because we can't rely on the global directories being read-only, having certain names or being otherwise detectable at runtime in a sane way. Fixes bug #132214. * libgimpbase/gimpdatafiles.[ch]: added "const gchar *dirname" to the GimpDataFileData struct so callbacks don't need to call g_path_get_dirname() for each file. * libgimpwidgets/gimpfileentry.c: made it work with non UTF-8 encoded filenames. * libgimpwidgets/gimppatheditor.[ch]: ditto. Added GUI and API for setting/getting a second "writable_path". The widget makes sure that the writable_path is always a subset of the path. * app/config/gimpconfig-utils.[ch]: added new function gimp_config_build_writable_path(). * app/config/gimpcoreconfig.[ch]: added separate properties for the writable brush, pattern, gradient, palette and font paths. * app/config/gimprc-blurbs.h: added (still empty) blurbs for the new properties. * app/core/gimpdata.[ch] (gimp_data_set_filename): added parameter "gboolean writable". Set data->writable to FALSE by default. If "writable" is passed as TRUE, still check if we can write to the file before setting data->writable to TRUE. (gimp_data_create_filename): changed "data_path" parameter to "dest_dir" and assume dest_dir is writable. (gimp_data_duplicate): set data->dirty to TRUE to make sure duplicated things will be saved. * app/core/gimpbrush.c * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c * app/core/gimpgradient.c * app/core/gimppalette.c * app/core/gimppattern.c: don't set the data's filename and don't touch data->dirty in the _load() functions because that's done by the data factory now. Don't touch data->dirty in the _duplicate() functions because that's done by gimp_data_duplicate() itself now. * app/core/gimpdatafactory.[ch] (gimp_data_factory_new): added "writable_property_name" and remember it. Added utility function gimp_data_factory_get_save_dir() which determines the directory to save new datas to. Added public function gimp_data_factory_data_save_single() which saves a single data object. Make sure new things get saved to the first writable directory as specified in preferences. * app/core/gimp.c (gimp_real_initialize): pass the writable_paths' property names to gimp_data_factory_new(). * app/widgets/gimpdataeditor.c (gimp_data_editor_save_dirty): use gimp_data_factory_data_save_single() instead of implementing saving here. * app/widgets/gimppropwidgets.[ch] (gimp_prop_path_editor_new): added "const gchar *writable_property_name" parameter (can be NULL). Added the needed callbacks to handle the writable_path and made the path_editor and file_entry code aware of non UTF-8 filename encodings. Some general cleanup. * app/gui/preferences-dialog.c: changed accordingly.
2004-01-29 05:53:50 +08:00
gtk_entry_set_text (GTK_ENTRY (entry->entry), utf8);
g_signal_handlers_unblock_by_func (entry->entry,
gimp_file_entry_entry_activate,
entry);
if (entry->file_dialog)
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (entry->file_dialog),
filename);
Added infrastructure to make sure we don't write to the global brush, 2004-01-28 Michael Natterer <mitch@gimp.org> Added infrastructure to make sure we don't write to the global brush, pattern etc. directories. Needed to make this configurable because we can't rely on the global directories being read-only, having certain names or being otherwise detectable at runtime in a sane way. Fixes bug #132214. * libgimpbase/gimpdatafiles.[ch]: added "const gchar *dirname" to the GimpDataFileData struct so callbacks don't need to call g_path_get_dirname() for each file. * libgimpwidgets/gimpfileentry.c: made it work with non UTF-8 encoded filenames. * libgimpwidgets/gimppatheditor.[ch]: ditto. Added GUI and API for setting/getting a second "writable_path". The widget makes sure that the writable_path is always a subset of the path. * app/config/gimpconfig-utils.[ch]: added new function gimp_config_build_writable_path(). * app/config/gimpcoreconfig.[ch]: added separate properties for the writable brush, pattern, gradient, palette and font paths. * app/config/gimprc-blurbs.h: added (still empty) blurbs for the new properties. * app/core/gimpdata.[ch] (gimp_data_set_filename): added parameter "gboolean writable". Set data->writable to FALSE by default. If "writable" is passed as TRUE, still check if we can write to the file before setting data->writable to TRUE. (gimp_data_create_filename): changed "data_path" parameter to "dest_dir" and assume dest_dir is writable. (gimp_data_duplicate): set data->dirty to TRUE to make sure duplicated things will be saved. * app/core/gimpbrush.c * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c * app/core/gimpgradient.c * app/core/gimppalette.c * app/core/gimppattern.c: don't set the data's filename and don't touch data->dirty in the _load() functions because that's done by the data factory now. Don't touch data->dirty in the _duplicate() functions because that's done by gimp_data_duplicate() itself now. * app/core/gimpdatafactory.[ch] (gimp_data_factory_new): added "writable_property_name" and remember it. Added utility function gimp_data_factory_get_save_dir() which determines the directory to save new datas to. Added public function gimp_data_factory_data_save_single() which saves a single data object. Make sure new things get saved to the first writable directory as specified in preferences. * app/core/gimp.c (gimp_real_initialize): pass the writable_paths' property names to gimp_data_factory_new(). * app/widgets/gimpdataeditor.c (gimp_data_editor_save_dirty): use gimp_data_factory_data_save_single() instead of implementing saving here. * app/widgets/gimppropwidgets.[ch] (gimp_prop_path_editor_new): added "const gchar *writable_property_name" parameter (can be NULL). Added the needed callbacks to handle the writable_path and made the path_editor and file_entry code aware of non UTF-8 filename encodings. Some general cleanup. * app/gui/preferences-dialog.c: changed accordingly.
2004-01-29 05:53:50 +08:00
g_free (filename);
Added infrastructure to make sure we don't write to the global brush, 2004-01-28 Michael Natterer <mitch@gimp.org> Added infrastructure to make sure we don't write to the global brush, pattern etc. directories. Needed to make this configurable because we can't rely on the global directories being read-only, having certain names or being otherwise detectable at runtime in a sane way. Fixes bug #132214. * libgimpbase/gimpdatafiles.[ch]: added "const gchar *dirname" to the GimpDataFileData struct so callbacks don't need to call g_path_get_dirname() for each file. * libgimpwidgets/gimpfileentry.c: made it work with non UTF-8 encoded filenames. * libgimpwidgets/gimppatheditor.[ch]: ditto. Added GUI and API for setting/getting a second "writable_path". The widget makes sure that the writable_path is always a subset of the path. * app/config/gimpconfig-utils.[ch]: added new function gimp_config_build_writable_path(). * app/config/gimpcoreconfig.[ch]: added separate properties for the writable brush, pattern, gradient, palette and font paths. * app/config/gimprc-blurbs.h: added (still empty) blurbs for the new properties. * app/core/gimpdata.[ch] (gimp_data_set_filename): added parameter "gboolean writable". Set data->writable to FALSE by default. If "writable" is passed as TRUE, still check if we can write to the file before setting data->writable to TRUE. (gimp_data_create_filename): changed "data_path" parameter to "dest_dir" and assume dest_dir is writable. (gimp_data_duplicate): set data->dirty to TRUE to make sure duplicated things will be saved. * app/core/gimpbrush.c * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c * app/core/gimpgradient.c * app/core/gimppalette.c * app/core/gimppattern.c: don't set the data's filename and don't touch data->dirty in the _load() functions because that's done by the data factory now. Don't touch data->dirty in the _duplicate() functions because that's done by gimp_data_duplicate() itself now. * app/core/gimpdatafactory.[ch] (gimp_data_factory_new): added "writable_property_name" and remember it. Added utility function gimp_data_factory_get_save_dir() which determines the directory to save new datas to. Added public function gimp_data_factory_data_save_single() which saves a single data object. Make sure new things get saved to the first writable directory as specified in preferences. * app/core/gimp.c (gimp_real_initialize): pass the writable_paths' property names to gimp_data_factory_new(). * app/widgets/gimpdataeditor.c (gimp_data_editor_save_dirty): use gimp_data_factory_data_save_single() instead of implementing saving here. * app/widgets/gimppropwidgets.[ch] (gimp_prop_path_editor_new): added "const gchar *writable_property_name" parameter (can be NULL). Added the needed callbacks to handle the writable_path and made the path_editor and file_entry code aware of non UTF-8 filename encodings. Some general cleanup. * app/gui/preferences-dialog.c: changed accordingly.
2004-01-29 05:53:50 +08:00
g_free (utf8);
gimp_file_entry_check_filename (entry);
gtk_editable_set_position (GTK_EDITABLE (entry->entry), -1);
1999-05-19 01:33:39 +08:00
g_signal_emit (entry, gimp_file_entry_signals[FILENAME_CHANGED], 0);
}
static gboolean
gimp_file_entry_entry_focus_out (GtkWidget *widget,
GdkEvent *event,
GimpFileEntry *entry)
{
gimp_file_entry_entry_activate (widget, entry);
return FALSE;
}
/* local callback of gimp_file_entry_browse_clicked() */
static void
gimp_file_entry_chooser_response (GtkWidget *dialog,
gint response_id,
GimpFileEntry *entry)
{
if (response_id == GTK_RESPONSE_OK)
{
gchar *filename;
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
gimp_file_entry_set_filename (entry, filename);
g_free (filename);
}
gtk_widget_hide (dialog);
}
static void
gimp_file_entry_browse_clicked (GtkWidget *widget,
GimpFileEntry *entry)
{
GtkFileChooser *chooser;
gchar *utf8;
gchar *filename;
Added infrastructure to make sure we don't write to the global brush, 2004-01-28 Michael Natterer <mitch@gimp.org> Added infrastructure to make sure we don't write to the global brush, pattern etc. directories. Needed to make this configurable because we can't rely on the global directories being read-only, having certain names or being otherwise detectable at runtime in a sane way. Fixes bug #132214. * libgimpbase/gimpdatafiles.[ch]: added "const gchar *dirname" to the GimpDataFileData struct so callbacks don't need to call g_path_get_dirname() for each file. * libgimpwidgets/gimpfileentry.c: made it work with non UTF-8 encoded filenames. * libgimpwidgets/gimppatheditor.[ch]: ditto. Added GUI and API for setting/getting a second "writable_path". The widget makes sure that the writable_path is always a subset of the path. * app/config/gimpconfig-utils.[ch]: added new function gimp_config_build_writable_path(). * app/config/gimpcoreconfig.[ch]: added separate properties for the writable brush, pattern, gradient, palette and font paths. * app/config/gimprc-blurbs.h: added (still empty) blurbs for the new properties. * app/core/gimpdata.[ch] (gimp_data_set_filename): added parameter "gboolean writable". Set data->writable to FALSE by default. If "writable" is passed as TRUE, still check if we can write to the file before setting data->writable to TRUE. (gimp_data_create_filename): changed "data_path" parameter to "dest_dir" and assume dest_dir is writable. (gimp_data_duplicate): set data->dirty to TRUE to make sure duplicated things will be saved. * app/core/gimpbrush.c * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c * app/core/gimpgradient.c * app/core/gimppalette.c * app/core/gimppattern.c: don't set the data's filename and don't touch data->dirty in the _load() functions because that's done by the data factory now. Don't touch data->dirty in the _duplicate() functions because that's done by gimp_data_duplicate() itself now. * app/core/gimpdatafactory.[ch] (gimp_data_factory_new): added "writable_property_name" and remember it. Added utility function gimp_data_factory_get_save_dir() which determines the directory to save new datas to. Added public function gimp_data_factory_data_save_single() which saves a single data object. Make sure new things get saved to the first writable directory as specified in preferences. * app/core/gimp.c (gimp_real_initialize): pass the writable_paths' property names to gimp_data_factory_new(). * app/widgets/gimpdataeditor.c (gimp_data_editor_save_dirty): use gimp_data_factory_data_save_single() instead of implementing saving here. * app/widgets/gimppropwidgets.[ch] (gimp_prop_path_editor_new): added "const gchar *writable_property_name" parameter (can be NULL). Added the needed callbacks to handle the writable_path and made the path_editor and file_entry code aware of non UTF-8 filename encodings. Some general cleanup. * app/gui/preferences-dialog.c: changed accordingly.
2004-01-29 05:53:50 +08:00
utf8 = gtk_editable_get_chars (GTK_EDITABLE (entry->entry), 0, -1);
filename = g_filename_from_utf8 (utf8, -1, NULL, NULL, NULL);
g_free (utf8);
added "wm_name", "wm_class", "display_name" and "monitor_number" to the 2003-11-07 Michael Natterer <mitch@gimp.org> * libgimpbase/gimpprotocol.[ch]: added "wm_name", "wm_class", "display_name" and "monitor_number" to the GPConfig message. Increased protocol version number. * libgimp/gimp.[ch] (gimp_config): read them from the GPConfig message and remember them. Added public accessors for the new config values. * libgimp/gimpui.c (gimp_ui_init): pass wm_name and wm_class to gtk_init() and export the display/screen to use to the environment. * app/core/gimp.[ch]: added vtable entries to get the values from the GUI. * app/gui/gui-vtable.c: implement the vtable entries. * app/plug-in/plug-in-run.c: fill in the GPConfig values using the new Gimp vtable functions. * app/display/gimpdisplayshell-layer-select.c * app/display/gimpdisplayshell.c * app/gui/about-dialog.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-dialog-utils.[ch] * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor-commands.c * app/gui/gradients-commands.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-dialog.[ch] * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/splash.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/tips-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcurvestool.c * app/tools/gimplevelstool.c * app/widgets/gimpdock.c * app/widgets/gimperrorconsole.c * app/widgets/gimptexteditor.c * app/widgets/gimptoolbox.c * app/widgets/gimpviewabledialog.[ch] * libgimpwidgets/gimpfileselection.c * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c * plug-ins/helpbrowser/dialog.c * plug-ins/ifscompose/ifscompose.c: replaced all calls to gtk_window_set_wmclass() by gtk_window_set_role() and all "const gchar *wmclass_name" parameters by "const gchar *role". Cleaned up the window role strings.
2003-11-08 01:29:02 +08:00
if (! entry->file_dialog)
{
const gchar *title = entry->title;
if (! title)
{
if (entry->dir_only)
title = _("Select Folder");
else
title = _("Select File");
}
entry->file_dialog =
gtk_file_chooser_dialog_new (title, NULL,
entry->dir_only ?
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER :
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_alternative_button_order (GTK_DIALOG (entry->file_dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
chooser = GTK_FILE_CHOOSER (entry->file_dialog);
gtk_window_set_position (GTK_WINDOW (chooser), GTK_WIN_POS_MOUSE);
gtk_window_set_role (GTK_WINDOW (chooser),
"gimp-file-entry-file-dialog");
g_signal_connect (chooser, "response",
G_CALLBACK (gimp_file_entry_chooser_response),
entry);
g_signal_connect (chooser, "delete-event",
G_CALLBACK (gtk_true),
NULL);
g_signal_connect_swapped (entry, "unmap",
G_CALLBACK (gtk_widget_hide),
chooser);
}
else
{
chooser = GTK_FILE_CHOOSER (entry->file_dialog);
}
gtk_file_chooser_set_filename (chooser, filename);
g_free (filename);
gtk_window_set_screen (GTK_WINDOW (chooser), gtk_widget_get_screen (widget));
gtk_window_present (GTK_WINDOW (chooser));
}
static void
gimp_file_entry_check_filename (GimpFileEntry *entry)
{
Added infrastructure to make sure we don't write to the global brush, 2004-01-28 Michael Natterer <mitch@gimp.org> Added infrastructure to make sure we don't write to the global brush, pattern etc. directories. Needed to make this configurable because we can't rely on the global directories being read-only, having certain names or being otherwise detectable at runtime in a sane way. Fixes bug #132214. * libgimpbase/gimpdatafiles.[ch]: added "const gchar *dirname" to the GimpDataFileData struct so callbacks don't need to call g_path_get_dirname() for each file. * libgimpwidgets/gimpfileentry.c: made it work with non UTF-8 encoded filenames. * libgimpwidgets/gimppatheditor.[ch]: ditto. Added GUI and API for setting/getting a second "writable_path". The widget makes sure that the writable_path is always a subset of the path. * app/config/gimpconfig-utils.[ch]: added new function gimp_config_build_writable_path(). * app/config/gimpcoreconfig.[ch]: added separate properties for the writable brush, pattern, gradient, palette and font paths. * app/config/gimprc-blurbs.h: added (still empty) blurbs for the new properties. * app/core/gimpdata.[ch] (gimp_data_set_filename): added parameter "gboolean writable". Set data->writable to FALSE by default. If "writable" is passed as TRUE, still check if we can write to the file before setting data->writable to TRUE. (gimp_data_create_filename): changed "data_path" parameter to "dest_dir" and assume dest_dir is writable. (gimp_data_duplicate): set data->dirty to TRUE to make sure duplicated things will be saved. * app/core/gimpbrush.c * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c * app/core/gimpgradient.c * app/core/gimppalette.c * app/core/gimppattern.c: don't set the data's filename and don't touch data->dirty in the _load() functions because that's done by the data factory now. Don't touch data->dirty in the _duplicate() functions because that's done by gimp_data_duplicate() itself now. * app/core/gimpdatafactory.[ch] (gimp_data_factory_new): added "writable_property_name" and remember it. Added utility function gimp_data_factory_get_save_dir() which determines the directory to save new datas to. Added public function gimp_data_factory_data_save_single() which saves a single data object. Make sure new things get saved to the first writable directory as specified in preferences. * app/core/gimp.c (gimp_real_initialize): pass the writable_paths' property names to gimp_data_factory_new(). * app/widgets/gimpdataeditor.c (gimp_data_editor_save_dirty): use gimp_data_factory_data_save_single() instead of implementing saving here. * app/widgets/gimppropwidgets.[ch] (gimp_prop_path_editor_new): added "const gchar *writable_property_name" parameter (can be NULL). Added the needed callbacks to handle the writable_path and made the path_editor and file_entry code aware of non UTF-8 filename encodings. Some general cleanup. * app/gui/preferences-dialog.c: changed accordingly.
2004-01-29 05:53:50 +08:00
gchar *utf8;
gchar *filename;
gboolean exists;
if (! entry->check_valid || ! entry->file_exists)
return;
Added infrastructure to make sure we don't write to the global brush, 2004-01-28 Michael Natterer <mitch@gimp.org> Added infrastructure to make sure we don't write to the global brush, pattern etc. directories. Needed to make this configurable because we can't rely on the global directories being read-only, having certain names or being otherwise detectable at runtime in a sane way. Fixes bug #132214. * libgimpbase/gimpdatafiles.[ch]: added "const gchar *dirname" to the GimpDataFileData struct so callbacks don't need to call g_path_get_dirname() for each file. * libgimpwidgets/gimpfileentry.c: made it work with non UTF-8 encoded filenames. * libgimpwidgets/gimppatheditor.[ch]: ditto. Added GUI and API for setting/getting a second "writable_path". The widget makes sure that the writable_path is always a subset of the path. * app/config/gimpconfig-utils.[ch]: added new function gimp_config_build_writable_path(). * app/config/gimpcoreconfig.[ch]: added separate properties for the writable brush, pattern, gradient, palette and font paths. * app/config/gimprc-blurbs.h: added (still empty) blurbs for the new properties. * app/core/gimpdata.[ch] (gimp_data_set_filename): added parameter "gboolean writable". Set data->writable to FALSE by default. If "writable" is passed as TRUE, still check if we can write to the file before setting data->writable to TRUE. (gimp_data_create_filename): changed "data_path" parameter to "dest_dir" and assume dest_dir is writable. (gimp_data_duplicate): set data->dirty to TRUE to make sure duplicated things will be saved. * app/core/gimpbrush.c * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c * app/core/gimpgradient.c * app/core/gimppalette.c * app/core/gimppattern.c: don't set the data's filename and don't touch data->dirty in the _load() functions because that's done by the data factory now. Don't touch data->dirty in the _duplicate() functions because that's done by gimp_data_duplicate() itself now. * app/core/gimpdatafactory.[ch] (gimp_data_factory_new): added "writable_property_name" and remember it. Added utility function gimp_data_factory_get_save_dir() which determines the directory to save new datas to. Added public function gimp_data_factory_data_save_single() which saves a single data object. Make sure new things get saved to the first writable directory as specified in preferences. * app/core/gimp.c (gimp_real_initialize): pass the writable_paths' property names to gimp_data_factory_new(). * app/widgets/gimpdataeditor.c (gimp_data_editor_save_dirty): use gimp_data_factory_data_save_single() instead of implementing saving here. * app/widgets/gimppropwidgets.[ch] (gimp_prop_path_editor_new): added "const gchar *writable_property_name" parameter (can be NULL). Added the needed callbacks to handle the writable_path and made the path_editor and file_entry code aware of non UTF-8 filename encodings. Some general cleanup. * app/gui/preferences-dialog.c: changed accordingly.
2004-01-29 05:53:50 +08:00
utf8 = gtk_editable_get_chars (GTK_EDITABLE (entry->entry), 0, -1);
filename = g_filename_from_utf8 (utf8, -1, NULL, NULL, NULL);
g_free (utf8);
register the button icons with GTK_ICON_SIZE_BUTTON, but set them as 2001-08-05 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpstock.[ch]: register the button icons with GTK_ICON_SIZE_BUTTON, but set them as scalable fallbacks for themselves so they get scaled for menus. * app/gui/menus.c: set stock icons for much more menu entries. * app/widgets/gimpwidgets-utils.[ch]: new utility function gimp_item_factory_popup_with_data(). * app/disp_callbacks.[ch] * app/gui/brushes-commands.c * app/gui/channels-commands.c * app/gui/gradients-commands.c * app/gui/layers-commands.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/patterns-commands.c: use the new function. * app/tools/gimpcolorbalancetool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c: s/_("Reset")/GIMP_STOCK_RESET/ * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpcontainerview.[ch]: moved the button_box utility functions from the container editor to GimpContainerView itself. * app/widgets/gimpbufferview.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpcontainergridview.[ch] * app/widgets/gimpdatafactoryview.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.[ch] * app/widgets/gimplayerlistitem.c * app/widgets/gimplayerlistview.c: changed accordingly. Removed lots of duplicated code and use stock images instead of pixmaps. * libgimpwidgets/gimpfileselection.[ch] * libgimpwidgets/gimppatheditor.c: use stock images instead of pixmaps. * pixmaps/Makefile.am: removed "yes" and "no", added "stroke". * pixmaps/anchor.xpm * pixmaps/delete.xpm * pixmaps/lower.xpm * pixmaps/new.xpm * pixmaps/paste-as-new.xpm * pixmaps/paste-into.xpm * pixmaps/paste.xpm * pixmaps/raise.xpm * pixmaps/refresh.xpm * pixmaps/toselection.xpm: made them all 16x16 so they are scaled nicely in menus. Should probably be 18x18.
2001-08-05 04:38:54 +08:00
if (entry->dir_only)
exists = g_file_test (filename, G_FILE_TEST_IS_DIR);
else
exists = g_file_test (filename, G_FILE_TEST_IS_REGULAR);
1999-11-07 02:19:41 +08:00
g_free (filename);
gtk_image_set_from_stock (GTK_IMAGE (entry->file_exists),
added "wm_name", "wm_class", "display_name" and "monitor_number" to the 2003-11-07 Michael Natterer <mitch@gimp.org> * libgimpbase/gimpprotocol.[ch]: added "wm_name", "wm_class", "display_name" and "monitor_number" to the GPConfig message. Increased protocol version number. * libgimp/gimp.[ch] (gimp_config): read them from the GPConfig message and remember them. Added public accessors for the new config values. * libgimp/gimpui.c (gimp_ui_init): pass wm_name and wm_class to gtk_init() and export the display/screen to use to the environment. * app/core/gimp.[ch]: added vtable entries to get the values from the GUI. * app/gui/gui-vtable.c: implement the vtable entries. * app/plug-in/plug-in-run.c: fill in the GPConfig values using the new Gimp vtable functions. * app/display/gimpdisplayshell-layer-select.c * app/display/gimpdisplayshell.c * app/gui/about-dialog.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-dialog-utils.[ch] * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor-commands.c * app/gui/gradients-commands.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-dialog.[ch] * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/splash.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/tips-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcurvestool.c * app/tools/gimplevelstool.c * app/widgets/gimpdock.c * app/widgets/gimperrorconsole.c * app/widgets/gimptexteditor.c * app/widgets/gimptoolbox.c * app/widgets/gimpviewabledialog.[ch] * libgimpwidgets/gimpfileselection.c * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c * plug-ins/helpbrowser/dialog.c * plug-ins/ifscompose/ifscompose.c: replaced all calls to gtk_window_set_wmclass() by gtk_window_set_role() and all "const gchar *wmclass_name" parameters by "const gchar *role". Cleaned up the window role strings.
2003-11-08 01:29:02 +08:00
exists ? GTK_STOCK_YES : GTK_STOCK_NO,
GTK_ICON_SIZE_BUTTON);
}