gimp/libgimpwidgets/gimppatheditor.c

493 lines
16 KiB
C
Raw Normal View History

/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimppatheditor.c
* Copyright (C) 1999 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 2 of the License, or (at your option) any later version.
*
* 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
#include "config.h"
#include <string.h>
#include <gtk/gtk.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 "gimpwidgetstypes.h"
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
#include "gimppatheditor.h"
#include "gimpfileselection.h"
#include "gimpwidgets.h"
#include "pixmaps/new.xpm"
#include "pixmaps/delete.xpm"
#include "pixmaps/raise.xpm"
#include "pixmaps/lower.xpm"
enum
{
PATH_CHANGED,
LAST_SIGNAL
};
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_path_editor_class_init (GimpPathEditorClass *klass);
static void gimp_path_editor_init (GimpPathEditor *gpe);
static void gimp_path_editor_select_callback (GtkWidget *widget,
gpointer data);
static void gimp_path_editor_deselect_callback (GtkWidget *widget,
gpointer data);
static void gimp_path_editor_new_callback (GtkWidget *widget,
gpointer data);
static void gimp_path_editor_move_callback (GtkWidget *widget,
gpointer data);
static void gimp_path_editor_filesel_callback (GtkWidget *widget,
gpointer data);
static void gimp_path_editor_delete_callback (GtkWidget *widget,
gpointer data);
1999-12-07 06:44:40 +08:00
static guint gimp_path_editor_signals[LAST_SIGNAL] = { 0 };
static GtkVBoxClass *parent_class = NULL;
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
GType
gimp_path_editor_get_type (void)
{
static GType gpe_type = 0;
if (! gpe_type)
{
GtkTypeInfo gpe_info =
{
"GimpPathEditor",
sizeof (GimpPathEditor),
sizeof (GimpPathEditorClass),
(GtkClassInitFunc) gimp_path_editor_class_init,
(GtkObjectInitFunc) gimp_path_editor_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
gpe_type = gtk_type_unique (gtk_vbox_get_type (), &gpe_info);
}
return gpe_type;
}
static void
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
gimp_path_editor_class_init (GimpPathEditorClass *klass)
{
GtkObjectClass *object_class;
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
object_class = (GtkObjectClass *) klass;
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
parent_class = g_type_class_peek_parent (klass);
gimp_path_editor_signals[PATH_CHANGED] =
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
g_signal_new ("path_changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpPathEditorClass, path_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
klass->path_changed = NULL;
}
static void
gimp_path_editor_init (GimpPathEditor *gpe)
{
GtkWidget *button_box;
GtkWidget *button;
GtkWidget *scrolled_window;
gpe->file_selection = NULL;
gpe->selected_item = NULL;
gpe->number_of_items = 0;
gpe->upper_hbox = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (gpe), gpe->upper_hbox, FALSE, TRUE, 0);
gtk_widget_show (gpe->upper_hbox);
button_box = gtk_hbox_new (TRUE, 0);
gtk_box_pack_start (GTK_BOX (gpe->upper_hbox), button_box, FALSE, TRUE, 0);
gtk_widget_show (button_box);
gpe->new_button = button = gimp_pixmap_button_new (new_xpm, NULL);
gtk_box_pack_start (GTK_BOX (button_box), button, TRUE, TRUE, 0);
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (gimp_path_editor_new_callback),
gpe);
gtk_widget_show (button);
gpe->up_button = button = gimp_pixmap_button_new (raise_xpm, NULL);
gtk_widget_set_sensitive (button, FALSE);
gtk_box_pack_start (GTK_BOX (button_box), button, TRUE, TRUE, 0);
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (gimp_path_editor_move_callback),
gpe);
gtk_widget_show (button);
gpe->down_button = button = gimp_pixmap_button_new (lower_xpm, NULL);
gtk_widget_set_sensitive (button, FALSE);
gtk_box_pack_start (GTK_BOX (button_box), button, TRUE, TRUE, 0);
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (gimp_path_editor_move_callback),
gpe);
gtk_widget_show (button);
gpe->delete_button = button = gimp_pixmap_button_new (delete_xpm, NULL);
gtk_widget_set_sensitive (button, FALSE);
gtk_box_pack_start (GTK_BOX (button_box), button, TRUE, TRUE, 0);
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (gimp_path_editor_delete_callback),
gpe);
gtk_widget_show (button);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_ALWAYS);
gtk_box_pack_start (GTK_BOX (gpe), scrolled_window, TRUE, TRUE, 2);
gtk_widget_show (scrolled_window);
gpe->dir_list = gtk_list_new ();
gtk_list_set_selection_mode (GTK_LIST (gpe->dir_list), GTK_SELECTION_SINGLE);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window),
gpe->dir_list);
gtk_widget_show (gpe->dir_list);
}
/**
* gimp_path_editor_new:
* @filesel_title: The title of the #GtkFileSelection dialog which can be
* popped up by the attached #GimpFileSelection.
* @path: The initial search path.
*
* Creates a new #GimpPathEditor widget.
*
* The elements of the initial search path must be separated with the
* #G_SEARCHPATH_SEPARATOR character.
*
* Returns: A pointer to the new #GimpPathEditor widget.
**/
GtkWidget *
gimp_path_editor_new (const gchar *filesel_title,
const gchar *path)
{
GimpPathEditor *gpe;
GtkWidget *list_item;
GList *directory_list;
gchar *directory;
gchar *mypath;
g_return_val_if_fail ((filesel_title != NULL), NULL);
g_return_val_if_fail ((path != NULL), NULL);
gpe = gtk_type_new (gimp_path_editor_get_type ());
gpe->file_selection = gimp_file_selection_new (filesel_title, "", TRUE, TRUE);
gtk_widget_set_sensitive (gpe->file_selection, FALSE);
gtk_box_pack_start (GTK_BOX (gpe->upper_hbox), gpe->file_selection,
TRUE, TRUE, 0);
g_signal_connect (G_OBJECT (gpe->file_selection), "filename_changed",
G_CALLBACK (gimp_path_editor_filesel_callback),
gpe);
gtk_widget_show (gpe->file_selection);
directory_list = NULL;
directory = mypath = g_strdup (path);
/* split up the path */
while (strlen (directory))
{
gchar *current_dir;
gchar *next_separator;
next_separator = strchr (directory, G_SEARCHPATH_SEPARATOR);
if (next_separator != NULL)
*next_separator = '\0';
current_dir = g_strdup (directory);
list_item = gtk_list_item_new_with_label (current_dir);
g_object_set_data_full (G_OBJECT (list_item), "gimp_path_editor",
current_dir,
(GDestroyNotify) g_free);
directory_list = g_list_append (directory_list, list_item);
g_signal_connect (G_OBJECT (list_item), "select",
G_CALLBACK (gimp_path_editor_select_callback),
gpe);
g_signal_connect (G_OBJECT (list_item), "deselect",
G_CALLBACK (gimp_path_editor_deselect_callback),
gpe);
gtk_widget_show (list_item);
gpe->number_of_items++;
if (next_separator != NULL)
directory = next_separator + 1;
else
break;
}
g_free (mypath);
if (directory_list)
gtk_list_append_items (GTK_LIST (gpe->dir_list), directory_list);
return GTK_WIDGET (gpe);
}
/**
* gimp_path_editor_get_path:
* @gpe: The path editor you want to get the search path from.
*
* The elements of the returned search path string are separated with the
* #G_SEARCHPATH_SEPARATOR character.
*
* Note that you have to g_free() the returned string.
*
* Returns: The search path the user has selected in the path editor.
**/
gchar *
gimp_path_editor_get_path (GimpPathEditor *gpe)
{
GList *list;
gchar *path = NULL;
g_return_val_if_fail (gpe != NULL, g_strdup (""));
g_return_val_if_fail (GIMP_IS_PATH_EDITOR (gpe), g_strdup (""));
for (list = GTK_LIST (gpe->dir_list)->children; list; list = list->next)
{
if (path == NULL)
{
path =
g_strdup ((gchar *) g_object_get_data (G_OBJECT (list->data),
"gimp_path_editor"));
}
else
{
gchar *newpath;
newpath =
g_strconcat (path,
G_SEARCHPATH_SEPARATOR_S,
(gchar *) g_object_get_data (G_OBJECT (list->data),
"gimp_path_editor"),
NULL);
g_free (path);
path = newpath;
}
}
return path;
}
static void
gimp_path_editor_select_callback (GtkWidget *widget,
gpointer data)
{
GimpPathEditor *gpe;
gint pos;
gchar *directory;
gpe = GIMP_PATH_EDITOR (data);
directory = (gchar *) g_object_get_data (G_OBJECT (widget),
"gimp_path_editor");
g_signal_handlers_block_by_func (G_OBJECT (gpe->file_selection),
gimp_path_editor_filesel_callback,
gpe);
gimp_file_selection_set_filename (GIMP_FILE_SELECTION (gpe->file_selection),
directory);
g_signal_handlers_unblock_by_func (G_OBJECT (gpe->file_selection),
gimp_path_editor_filesel_callback,
gpe);
gpe->selected_item = widget;
pos = gtk_list_child_position (GTK_LIST (gpe->dir_list), gpe->selected_item);
gtk_widget_set_sensitive (gpe->delete_button, TRUE);
gtk_widget_set_sensitive (gpe->up_button, (pos > 0));
gtk_widget_set_sensitive (gpe->down_button,
(pos < (gpe->number_of_items - 1)));
gtk_widget_set_sensitive (gpe->file_selection, TRUE);
}
/* the selected directory may never be deselected except by the 'new'
* button, so catch the "deselect" signal and reselect it
*/
static void
gimp_path_editor_deselect_callback (GtkWidget *widget,
gpointer data)
{
GimpPathEditor *gpe;
gpe = GIMP_PATH_EDITOR (data);
if (widget != gpe->selected_item)
return;
gtk_signal_handler_block_by_data (GTK_OBJECT (gpe->selected_item), gpe);
gtk_list_select_child (GTK_LIST (gpe->dir_list), gpe->selected_item);
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gpe->selected_item), gpe);
}
static void
gimp_path_editor_new_callback (GtkWidget *widget,
gpointer data)
{
GimpPathEditor *gpe;
gpe = GIMP_PATH_EDITOR (data);
if (gpe->selected_item)
{
gtk_signal_handler_block_by_data (GTK_OBJECT (gpe->selected_item), gpe);
gtk_list_unselect_child (GTK_LIST (gpe->dir_list), gpe->selected_item);
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gpe->selected_item), gpe);
}
gpe->selected_item = NULL;
gtk_widget_set_sensitive (gpe->delete_button, FALSE);
gtk_widget_set_sensitive (gpe->up_button, FALSE);
gtk_widget_set_sensitive (gpe->down_button, FALSE);
gtk_widget_set_sensitive (gpe->file_selection, TRUE);
gtk_editable_set_position
(GTK_EDITABLE (GIMP_FILE_SELECTION (gpe->file_selection)->entry), -1);
gtk_widget_grab_focus
(GTK_WIDGET (GIMP_FILE_SELECTION (gpe->file_selection)->entry));
}
static void
gimp_path_editor_move_callback (GtkWidget *widget,
gpointer data)
{
GimpPathEditor *gpe = GIMP_PATH_EDITOR (data);
GList *move_list = NULL;
gint pos;
gint distance;
if (gpe->selected_item == NULL)
return;
pos = gtk_list_child_position (GTK_LIST (gpe->dir_list), gpe->selected_item);
distance = (widget == gpe->up_button) ? - 1 : 1;
move_list = g_list_append (move_list, gpe->selected_item);
gtk_signal_handler_block_by_data (GTK_OBJECT (gpe->selected_item), gpe);
gtk_list_remove_items_no_unref (GTK_LIST (gpe->dir_list), move_list);
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gpe->selected_item), gpe);
gtk_list_insert_items (GTK_LIST (gpe->dir_list), move_list, pos + distance);
gtk_list_select_item (GTK_LIST (gpe->dir_list), pos + distance);
g_signal_emit (G_OBJECT (gpe), gimp_path_editor_signals[PATH_CHANGED], 0);
}
static void
gimp_path_editor_delete_callback (GtkWidget *widget,
gpointer data)
{
GimpPathEditor *gpe = GIMP_PATH_EDITOR (data);
GList *delete_list = NULL;
gint pos;
if (gpe->selected_item == NULL)
return;
pos = gtk_list_child_position (GTK_LIST (gpe->dir_list), gpe->selected_item);
delete_list = g_list_append (delete_list, gpe->selected_item);
gtk_list_remove_items (GTK_LIST (gpe->dir_list), delete_list);
gpe->number_of_items--;
if (gpe->number_of_items == 0)
{
gpe->selected_item = NULL;
g_signal_handlers_block_by_func (G_OBJECT (gpe->file_selection),
gimp_path_editor_filesel_callback,
gpe);
gimp_file_selection_set_filename (GIMP_FILE_SELECTION (gpe->file_selection), "");
g_signal_handlers_unblock_by_func (G_OBJECT (gpe->file_selection),
gimp_path_editor_filesel_callback,
gpe);
gtk_widget_set_sensitive (gpe->delete_button, FALSE);
gtk_widget_set_sensitive (gpe->file_selection, FALSE);
return;
}
if ((pos == gpe->number_of_items) && (pos > 0))
pos--;
gtk_list_select_item (GTK_LIST (gpe->dir_list), pos);
g_signal_emit (G_OBJECT (gpe), gimp_path_editor_signals[PATH_CHANGED], 0);
}
static void
gimp_path_editor_filesel_callback (GtkWidget *widget,
gpointer data)
{
GimpPathEditor *gpe = GIMP_PATH_EDITOR (data);
GList *append_list = NULL;
GtkWidget *list_item = NULL;
gchar *directory;
directory = gimp_file_selection_get_filename (GIMP_FILE_SELECTION (widget));
if (strcmp (directory, "") == 0)
return;
if (gpe->selected_item == NULL)
{
list_item = gtk_list_item_new_with_label (directory);
g_object_set_data_full (G_OBJECT (list_item), "gimp_path_editor",
directory,
(GDestroyNotify) g_free);
append_list = g_list_append (append_list, list_item);
g_signal_connect (G_OBJECT (list_item), "select",
G_CALLBACK (gimp_path_editor_select_callback),
gpe);
g_signal_connect (G_OBJECT (list_item), "deselect",
G_CALLBACK (gimp_path_editor_deselect_callback),
gpe);
gtk_widget_show (list_item);
gpe->number_of_items++;
gtk_list_append_items (GTK_LIST (gpe->dir_list), append_list);
gtk_list_select_item (GTK_LIST (gpe->dir_list), gpe->number_of_items - 1);
}
else
{
gtk_label_set_text (GTK_LABEL (GTK_BIN (gpe->selected_item)->child),
directory);
g_object_set_data_full (G_OBJECT (gpe->selected_item),
"gimp_path_editor",
directory,
(GDestroyNotify) g_free);
}
g_signal_emit (G_OBJECT (gpe), gimp_path_editor_signals[PATH_CHANGED], 0);
}