2003-11-21 23:53:57 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
2000-02-26 11:41:06 +08:00
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
1999-03-14 07:03:11 +08:00
|
|
|
*
|
|
|
|
* gimppatheditor.c
|
2004-01-29 05:53:50 +08:00
|
|
|
* Copyright (C) 1999-2004 Michael Natterer <mitch@gimp.org>
|
1999-03-14 07:03:11 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* 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
|
1999-03-14 07:03:11 +08:00
|
|
|
* License as published by the Free Software Foundation; either
|
2009-01-18 06:28:01 +08:00
|
|
|
* version 3 of the License, or (at your option) any later version.
|
2003-11-21 23:53:57 +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
|
1999-03-14 07:03:11 +08:00
|
|
|
* 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
|
2009-01-18 06:28:01 +08:00
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
1999-03-14 07:03:11 +08:00
|
|
|
*/
|
2000-05-31 07:38:46 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1999-11-20 22:27:07 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2000-05-31 07:38:46 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "gimpwidgetstypes.h"
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2006-06-09 15:12:33 +08:00
|
|
|
#undef GIMP_DISABLE_DEPRECATED
|
2003-11-21 23:53:57 +08:00
|
|
|
#include "gimpfileentry.h"
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2006-06-09 15:12:33 +08:00
|
|
|
#include "gimppatheditor.h"
|
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
#include "libgimp/libgimp-intl.h"
|
|
|
|
|
2000-05-31 07:38:46 +08:00
|
|
|
|
2010-07-06 00:01:28 +08:00
|
|
|
/**
|
|
|
|
* SECTION: gimppatheditor
|
|
|
|
* @title: GimpPathEditor
|
|
|
|
* @short_description: Widget for editing a file search path.
|
|
|
|
* @see_also: #GimpFileEntry, #G_SEARCHPATH_SEPARATOR
|
|
|
|
*
|
|
|
|
* This widget is used to edit file search paths.
|
|
|
|
*
|
|
|
|
* It shows a list of all directories which are in the search
|
|
|
|
* path. You can click a directory to select it. The widget provides a
|
|
|
|
* #GimpFileEntry to change the currently selected directory.
|
|
|
|
*
|
|
|
|
* There are buttons to add or delete directories as well as "up" and
|
|
|
|
* "down" buttons to change the order in which the directories will be
|
|
|
|
* searched.
|
|
|
|
*
|
|
|
|
* Whenever the user adds, deletes, changes or reorders a directory of
|
|
|
|
* the search path, the "path_changed" signal will be emitted.
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
1999-11-20 22:27:07 +08:00
|
|
|
enum
|
|
|
|
{
|
1999-06-18 03:13:08 +08:00
|
|
|
PATH_CHANGED,
|
2004-01-29 05:53:50 +08:00
|
|
|
WRITABLE_CHANGED,
|
1999-03-14 07:03:11 +08:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
COLUMN_UTF8,
|
|
|
|
COLUMN_DIRECTORY,
|
|
|
|
COLUMN_WRITABLE,
|
|
|
|
NUM_COLUMNS
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
static void gimp_path_editor_new_clicked (GtkWidget *widget,
|
|
|
|
GimpPathEditor *editor);
|
|
|
|
static void gimp_path_editor_move_clicked (GtkWidget *widget,
|
|
|
|
GimpPathEditor *editor);
|
|
|
|
static void gimp_path_editor_delete_clicked (GtkWidget *widget,
|
|
|
|
GimpPathEditor *editor);
|
|
|
|
static void gimp_path_editor_file_entry_changed (GtkWidget *widget,
|
|
|
|
GimpPathEditor *editor);
|
|
|
|
static void gimp_path_editor_selection_changed (GtkTreeSelection *sel,
|
|
|
|
GimpPathEditor *editor);
|
|
|
|
static void gimp_path_editor_writable_toggled (GtkCellRendererToggle *toggle,
|
|
|
|
gchar *path_str,
|
|
|
|
GimpPathEditor *editor);
|
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
|
|
|
|
|
|
|
|
2011-07-28 01:53:34 +08:00
|
|
|
G_DEFINE_TYPE (GimpPathEditor, gimp_path_editor, GTK_TYPE_BOX)
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
#define parent_class gimp_path_editor_parent_class
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
static guint gimp_path_editor_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
|
|
|
|
|
|
|
|
1999-03-14 07:03:11 +08:00
|
|
|
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)
|
1999-03-14 07:03:11 +08:00
|
|
|
{
|
2003-12-18 21:29:16 +08:00
|
|
|
/**
|
|
|
|
* GimpPathEditor::path-changed:
|
|
|
|
*
|
|
|
|
* This signal is emitted whenever the user adds, deletes, modifies
|
|
|
|
* or reorders an element of the search path.
|
|
|
|
**/
|
2003-11-21 23:53:57 +08:00
|
|
|
gimp_path_editor_signals[PATH_CHANGED] =
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_new ("path-changed",
|
2006-04-12 18:53:28 +08:00
|
|
|
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);
|
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
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
/**
|
|
|
|
* GimpPathEditor::writable-changed:
|
|
|
|
*
|
|
|
|
* This signal is emitted whenever the "writable" column of a directory
|
|
|
|
* is changed, either by the user clicking on it or by calling
|
|
|
|
* gimp_path_editor_set_dir_writable().
|
|
|
|
**/
|
|
|
|
gimp_path_editor_signals[WRITABLE_CHANGED] =
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_new ("writable-changed",
|
2006-04-12 18:53:28 +08:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpPathEditorClass, writable_changed),
|
|
|
|
NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
2004-01-29 05:53:50 +08:00
|
|
|
|
|
|
|
klass->path_changed = NULL;
|
|
|
|
klass->writable_changed = NULL;
|
1999-03-14 07:03:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-12-18 21:29:16 +08:00
|
|
|
gimp_path_editor_init (GimpPathEditor *editor)
|
1999-03-14 07:03:11 +08:00
|
|
|
{
|
2004-01-29 05:53:50 +08:00
|
|
|
GtkWidget *button_box;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *image;
|
|
|
|
GtkWidget *scrolled_window;
|
|
|
|
GtkWidget *tv;
|
|
|
|
GtkTreeViewColumn *col;
|
|
|
|
GtkCellRenderer *renderer;
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
editor->file_entry = NULL;
|
|
|
|
editor->sel_path = NULL;
|
|
|
|
editor->num_items = 0;
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2011-07-28 01:53:34 +08:00
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (editor),
|
|
|
|
GTK_ORIENTATION_VERTICAL);
|
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
editor->upper_hbox = gtk_hbox_new (FALSE, 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (editor), editor->upper_hbox, FALSE, TRUE, 0);
|
|
|
|
gtk_widget_show (editor->upper_hbox);
|
1999-03-14 07:03:11 +08:00
|
|
|
|
|
|
|
button_box = gtk_hbox_new (TRUE, 0);
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (editor->upper_hbox), button_box, FALSE, TRUE, 0);
|
1999-03-14 07:03:11 +08:00
|
|
|
gtk_widget_show (button_box);
|
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
editor->new_button = button = gtk_button_new ();
|
2000-02-18 21:59:18 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (button_box), button, TRUE, TRUE, 0);
|
2001-08-05 04:38:54 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2002-01-14 04:59:56 +08:00
|
|
|
image = gtk_image_new_from_stock (GTK_STOCK_NEW, GTK_ICON_SIZE_BUTTON);
|
2001-08-05 04:38:54 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (button), image);
|
|
|
|
gtk_widget_show (image);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2003-11-21 23:53:57 +08:00
|
|
|
G_CALLBACK (gimp_path_editor_new_clicked),
|
2006-04-12 18:53:28 +08:00
|
|
|
editor);
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
editor->up_button = button = gtk_button_new ();
|
2000-02-18 21:59:18 +08:00
|
|
|
gtk_widget_set_sensitive (button, FALSE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (button_box), button, TRUE, TRUE, 0);
|
2001-08-05 04:38:54 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2002-01-14 04:59:56 +08:00
|
|
|
image = gtk_image_new_from_stock (GTK_STOCK_GO_UP, GTK_ICON_SIZE_BUTTON);
|
2001-08-05 04:38:54 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (button), image);
|
|
|
|
gtk_widget_show (image);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2003-11-21 23:53:57 +08:00
|
|
|
G_CALLBACK (gimp_path_editor_move_clicked),
|
2006-04-12 18:53:28 +08:00
|
|
|
editor);
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
editor->down_button = button = gtk_button_new ();
|
2000-02-18 21:59:18 +08:00
|
|
|
gtk_widget_set_sensitive (button, FALSE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (button_box), button, TRUE, TRUE, 0);
|
2001-08-05 04:38:54 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2002-01-14 04:59:56 +08:00
|
|
|
image = gtk_image_new_from_stock (GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_BUTTON);
|
2001-08-05 04:38:54 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (button), image);
|
|
|
|
gtk_widget_show (image);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2003-11-21 23:53:57 +08:00
|
|
|
G_CALLBACK (gimp_path_editor_move_clicked),
|
2006-04-12 18:53:28 +08:00
|
|
|
editor);
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
editor->delete_button = button = gtk_button_new ();
|
2000-02-18 21:59:18 +08:00
|
|
|
gtk_widget_set_sensitive (button, FALSE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (button_box), button, TRUE, TRUE, 0);
|
2001-08-05 04:38:54 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2002-01-14 04:59:56 +08:00
|
|
|
image = gtk_image_new_from_stock (GTK_STOCK_DELETE, GTK_ICON_SIZE_BUTTON);
|
2001-08-05 04:38:54 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (button), image);
|
|
|
|
gtk_widget_show (image);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2003-11-21 23:53:57 +08:00
|
|
|
G_CALLBACK (gimp_path_editor_delete_clicked),
|
2006-04-12 18:53:28 +08:00
|
|
|
editor);
|
1999-11-20 22:27:07 +08:00
|
|
|
|
|
|
|
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
2002-02-02 12:14:07 +08:00
|
|
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
|
2006-04-12 18:53:28 +08:00
|
|
|
GTK_SHADOW_IN);
|
1999-11-20 22:27:07 +08:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_ALWAYS);
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (editor), scrolled_window, TRUE, TRUE, 2);
|
1999-03-14 07:03:11 +08:00
|
|
|
gtk_widget_show (scrolled_window);
|
2003-11-21 23:53:57 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
editor->dir_list = gtk_list_store_new (NUM_COLUMNS,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_BOOLEAN);
|
2003-12-18 21:29:16 +08:00
|
|
|
tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (editor->dir_list));
|
|
|
|
g_object_unref (editor->dir_list);
|
2002-02-02 12:14:07 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
renderer = gtk_cell_renderer_toggle_new ();
|
|
|
|
|
|
|
|
g_signal_connect (renderer, "toggled",
|
|
|
|
G_CALLBACK (gimp_path_editor_writable_toggled),
|
|
|
|
editor);
|
|
|
|
|
|
|
|
editor->writable_column = col = gtk_tree_view_column_new ();
|
|
|
|
gtk_tree_view_column_set_title (col, _("Writable"));
|
|
|
|
gtk_tree_view_column_pack_start (col, renderer, FALSE);
|
|
|
|
gtk_tree_view_column_add_attribute (col, renderer, "active", COLUMN_WRITABLE);
|
|
|
|
|
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (tv), col);
|
|
|
|
|
|
|
|
gtk_tree_view_column_set_visible (col, FALSE);
|
|
|
|
|
2002-02-02 12:14:07 +08:00
|
|
|
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tv),
|
2006-04-12 18:53:28 +08:00
|
|
|
-1, _("Folder"),
|
|
|
|
gtk_cell_renderer_text_new (),
|
|
|
|
"text", COLUMN_UTF8,
|
|
|
|
NULL);
|
2002-02-02 12:14:07 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tv), TRUE);
|
2002-02-02 12:14:07 +08:00
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled_window), tv);
|
|
|
|
gtk_widget_show (tv);
|
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
editor->sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (tv));
|
|
|
|
g_signal_connect (editor->sel, "changed",
|
2006-04-12 18:53:28 +08:00
|
|
|
G_CALLBACK (gimp_path_editor_selection_changed),
|
|
|
|
editor);
|
1999-03-14 07:03:11 +08:00
|
|
|
}
|
|
|
|
|
2000-02-09 05:59:31 +08:00
|
|
|
/**
|
|
|
|
* gimp_path_editor_new:
|
2006-05-24 21:14:05 +08:00
|
|
|
* @title: The title of the #GtkFileChooser dialog which can be popped up.
|
|
|
|
* @path: The initial search path.
|
2000-02-09 05:59:31 +08:00
|
|
|
*
|
|
|
|
* 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.
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
1999-11-20 22:27:07 +08:00
|
|
|
GtkWidget *
|
2006-05-24 21:14:05 +08:00
|
|
|
gimp_path_editor_new (const gchar *title,
|
2006-04-12 18:53:28 +08:00
|
|
|
const gchar *path)
|
1999-03-14 07:03:11 +08:00
|
|
|
{
|
2003-12-18 21:29:16 +08:00
|
|
|
GimpPathEditor *editor;
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2006-05-24 21:14:05 +08:00
|
|
|
g_return_val_if_fail (title != NULL, NULL);
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
editor = g_object_new (GIMP_TYPE_PATH_EDITOR, NULL);
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2006-05-24 21:14:05 +08:00
|
|
|
editor->file_entry = gimp_file_entry_new (title, "", TRUE, TRUE);
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_widget_set_sensitive (editor->file_entry, FALSE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (editor->upper_hbox), editor->file_entry,
|
2003-11-21 23:53:57 +08:00
|
|
|
TRUE, TRUE, 0);
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_widget_show (editor->file_entry);
|
2002-11-20 02:41:59 +08:00
|
|
|
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_connect (editor->file_entry, "filename-changed",
|
2003-11-21 23:53:57 +08:00
|
|
|
G_CALLBACK (gimp_path_editor_file_entry_changed),
|
2006-04-12 18:53:28 +08:00
|
|
|
editor);
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2002-11-20 02:41:59 +08:00
|
|
|
if (path)
|
2003-12-18 21:29:16 +08:00
|
|
|
gimp_path_editor_set_path (editor, path);
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
return GTK_WIDGET (editor);
|
1999-03-14 07:03:11 +08:00
|
|
|
}
|
|
|
|
|
2000-02-09 05:59:31 +08:00
|
|
|
/**
|
|
|
|
* gimp_path_editor_get_path:
|
2003-12-18 21:29:16 +08:00
|
|
|
* @editor: The path editor you want to get the search path from.
|
2000-02-09 05:59:31 +08:00
|
|
|
*
|
|
|
|
* 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.
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
1999-11-20 22:27:07 +08:00
|
|
|
gchar *
|
2003-12-18 21:29:16 +08:00
|
|
|
gimp_path_editor_get_path (GimpPathEditor *editor)
|
1999-03-14 07:03:11 +08:00
|
|
|
{
|
2004-01-29 05:53:50 +08:00
|
|
|
GtkTreeModel *model;
|
|
|
|
GString *path;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gboolean iter_valid;
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PATH_EDITOR (editor), g_strdup (""));
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
model = GTK_TREE_MODEL (editor->dir_list);
|
|
|
|
|
2002-02-02 12:14:07 +08:00
|
|
|
path = g_string_new ("");
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
for (iter_valid = gtk_tree_model_get_iter_first (model, &iter);
|
|
|
|
iter_valid;
|
|
|
|
iter_valid = gtk_tree_model_iter_next (model, &iter))
|
|
|
|
{
|
|
|
|
gchar *dir;
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, &iter,
|
|
|
|
COLUMN_DIRECTORY, &dir,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
if (path->len > 0)
|
|
|
|
g_string_append_c (path, G_SEARCHPATH_SEPARATOR);
|
|
|
|
|
|
|
|
g_string_append (path, dir);
|
|
|
|
|
|
|
|
g_free (dir);
|
|
|
|
}
|
2002-02-02 12:14:07 +08:00
|
|
|
|
|
|
|
return g_string_free (path, FALSE);
|
1999-03-14 07:03:11 +08:00
|
|
|
}
|
|
|
|
|
2002-11-20 02:41:59 +08:00
|
|
|
/**
|
|
|
|
* gimp_path_editor_set_path:
|
2003-12-18 21:29:16 +08:00
|
|
|
* @editor: The path editor you want to set the search path from.
|
|
|
|
* @path: The new path to set.
|
2002-11-20 02:41:59 +08:00
|
|
|
*
|
|
|
|
* The elements of the initial search path must be separated with the
|
|
|
|
* #G_SEARCHPATH_SEPARATOR character.
|
|
|
|
**/
|
|
|
|
void
|
2003-12-18 21:29:16 +08:00
|
|
|
gimp_path_editor_set_path (GimpPathEditor *editor,
|
2002-11-20 02:41:59 +08:00
|
|
|
const gchar *path)
|
|
|
|
{
|
2004-01-29 05:53:50 +08:00
|
|
|
gchar *old_path;
|
|
|
|
GList *path_list;
|
|
|
|
GList *list;
|
2002-11-20 02:41:59 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PATH_EDITOR (editor));
|
2002-11-20 02:41:59 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
old_path = gimp_path_editor_get_path (editor);
|
|
|
|
|
2005-04-27 23:59:14 +08:00
|
|
|
if (old_path && path && strcmp (old_path, path) == 0)
|
2004-01-29 05:53:50 +08:00
|
|
|
{
|
|
|
|
g_free (old_path);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-04-27 23:59:14 +08:00
|
|
|
g_free (old_path);
|
|
|
|
|
2009-10-30 17:47:47 +08:00
|
|
|
path_list = gimp_path_parse (path, 16, FALSE, NULL);
|
2002-11-20 02:41:59 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_list_store_clear (editor->dir_list);
|
2002-11-20 02:41:59 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
for (list = path_list; list; list = g_list_next (list))
|
2002-11-20 02:41:59 +08:00
|
|
|
{
|
2004-01-29 05:53:50 +08:00
|
|
|
gchar *directory = list->data;
|
|
|
|
gchar *utf8;
|
|
|
|
GtkTreeIter iter;
|
2002-11-20 02:41:59 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
utf8 = g_filename_to_utf8 (directory, -1, NULL, NULL, NULL);
|
2002-11-20 02:41:59 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_list_store_append (editor->dir_list, &iter);
|
2004-01-29 05:53:50 +08:00
|
|
|
gtk_list_store_set (editor->dir_list, &iter,
|
|
|
|
COLUMN_UTF8, utf8,
|
|
|
|
COLUMN_DIRECTORY, directory,
|
|
|
|
COLUMN_WRITABLE, FALSE,
|
|
|
|
-1);
|
2002-11-20 02:41:59 +08:00
|
|
|
|
2004-02-18 04:17:49 +08:00
|
|
|
g_free (utf8);
|
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
editor->num_items++;
|
2002-11-20 02:41:59 +08:00
|
|
|
}
|
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
gimp_path_free (path_list);
|
2003-12-18 21:29:16 +08:00
|
|
|
|
|
|
|
g_signal_emit (editor, gimp_path_editor_signals[PATH_CHANGED], 0);
|
2002-11-20 02:41:59 +08:00
|
|
|
}
|
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
gchar *
|
|
|
|
gimp_path_editor_get_writable_path (GimpPathEditor *editor)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GString *path;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gboolean iter_valid;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PATH_EDITOR (editor), g_strdup (""));
|
|
|
|
|
|
|
|
model = GTK_TREE_MODEL (editor->dir_list);
|
|
|
|
|
|
|
|
path = g_string_new ("");
|
|
|
|
|
|
|
|
for (iter_valid = gtk_tree_model_get_iter_first (model, &iter);
|
|
|
|
iter_valid;
|
|
|
|
iter_valid = gtk_tree_model_iter_next (model, &iter))
|
|
|
|
{
|
|
|
|
gchar *dir;
|
|
|
|
gboolean dir_writable;
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, &iter,
|
|
|
|
COLUMN_DIRECTORY, &dir,
|
|
|
|
COLUMN_WRITABLE, &dir_writable,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
if (dir_writable)
|
|
|
|
{
|
|
|
|
if (path->len > 0)
|
|
|
|
g_string_append_c (path, G_SEARCHPATH_SEPARATOR);
|
|
|
|
|
|
|
|
g_string_append (path, dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
return g_string_free (path, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_path_editor_set_writable_path (GimpPathEditor *editor,
|
|
|
|
const gchar *path)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gboolean iter_valid;
|
|
|
|
GList *path_list;
|
|
|
|
gboolean writable_changed = FALSE;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_PATH_EDITOR (editor));
|
|
|
|
|
|
|
|
gtk_tree_view_column_set_visible (editor->writable_column, TRUE);
|
|
|
|
|
2009-10-30 17:47:47 +08:00
|
|
|
path_list = gimp_path_parse (path, 16, FALSE, NULL);
|
2004-01-29 05:53:50 +08:00
|
|
|
|
|
|
|
model = GTK_TREE_MODEL (editor->dir_list);
|
|
|
|
|
|
|
|
for (iter_valid = gtk_tree_model_get_iter_first (model, &iter);
|
|
|
|
iter_valid;
|
|
|
|
iter_valid = gtk_tree_model_iter_next (model, &iter))
|
|
|
|
{
|
|
|
|
gchar *dir;
|
|
|
|
gboolean dir_writable;
|
|
|
|
gboolean new_writable = FALSE;
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, &iter,
|
|
|
|
COLUMN_DIRECTORY, &dir,
|
|
|
|
COLUMN_WRITABLE, &dir_writable,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
if (g_list_find_custom (path_list, dir, (GCompareFunc) strcmp))
|
|
|
|
new_writable = TRUE;
|
|
|
|
|
|
|
|
g_free (dir);
|
|
|
|
|
|
|
|
if (dir_writable != new_writable)
|
|
|
|
{
|
|
|
|
gtk_list_store_set (editor->dir_list, &iter,
|
|
|
|
COLUMN_WRITABLE, new_writable,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
writable_changed = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_path_free (path_list);
|
|
|
|
|
|
|
|
if (writable_changed)
|
|
|
|
g_signal_emit (editor, gimp_path_editor_signals[WRITABLE_CHANGED], 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_path_editor_get_dir_writable (GimpPathEditor *editor,
|
|
|
|
const gchar *directory)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gboolean iter_valid;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PATH_EDITOR (editor), FALSE);
|
|
|
|
g_return_val_if_fail (directory != NULL, FALSE);
|
|
|
|
|
|
|
|
model = GTK_TREE_MODEL (editor->dir_list);
|
|
|
|
|
|
|
|
for (iter_valid = gtk_tree_model_get_iter_first (model, &iter);
|
|
|
|
iter_valid;
|
|
|
|
iter_valid = gtk_tree_model_iter_next (model, &iter))
|
|
|
|
{
|
|
|
|
gchar *dir;
|
|
|
|
gboolean dir_writable;
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, &iter,
|
|
|
|
COLUMN_DIRECTORY, &dir,
|
|
|
|
COLUMN_WRITABLE, &dir_writable,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
if (! strcmp (dir, directory))
|
|
|
|
{
|
|
|
|
g_free (dir);
|
|
|
|
|
|
|
|
return dir_writable;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_path_editor_set_dir_writable (GimpPathEditor *editor,
|
|
|
|
const gchar *directory,
|
|
|
|
gboolean writable)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gboolean iter_valid;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_PATH_EDITOR (editor));
|
|
|
|
g_return_if_fail (directory != NULL);
|
|
|
|
|
|
|
|
model = GTK_TREE_MODEL (editor->dir_list);
|
|
|
|
|
|
|
|
for (iter_valid = gtk_tree_model_get_iter_first (model, &iter);
|
|
|
|
iter_valid;
|
|
|
|
iter_valid = gtk_tree_model_iter_next (model, &iter))
|
|
|
|
{
|
|
|
|
gchar *dir;
|
|
|
|
gboolean dir_writable;
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, &iter,
|
|
|
|
COLUMN_DIRECTORY, &dir,
|
|
|
|
COLUMN_WRITABLE, &dir_writable,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
if (! strcmp (dir, directory) && dir_writable != writable)
|
|
|
|
{
|
|
|
|
gtk_list_store_set (editor->dir_list, &iter,
|
|
|
|
COLUMN_WRITABLE, writable ? TRUE : FALSE,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
g_signal_emit (editor, gimp_path_editor_signals[WRITABLE_CHANGED], 0);
|
|
|
|
|
|
|
|
g_free (dir);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (dir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2003-11-21 23:53:57 +08:00
|
|
|
/* private functions */
|
1999-03-14 07:03:11 +08:00
|
|
|
|
|
|
|
static void
|
2003-11-21 23:53:57 +08:00
|
|
|
gimp_path_editor_new_clicked (GtkWidget *widget,
|
2003-12-18 21:29:16 +08:00
|
|
|
GimpPathEditor *editor)
|
1999-03-14 07:03:11 +08:00
|
|
|
{
|
2003-12-18 21:29:16 +08:00
|
|
|
if (editor->sel_path)
|
1999-03-14 07:03:11 +08:00
|
|
|
{
|
2003-12-18 21:29:16 +08:00
|
|
|
g_signal_handlers_block_by_func (editor->sel,
|
2006-04-12 18:53:28 +08:00
|
|
|
gimp_path_editor_selection_changed,
|
2003-12-18 21:29:16 +08:00
|
|
|
editor);
|
2003-11-21 23:53:57 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_tree_selection_unselect_path (editor->sel, editor->sel_path);
|
2003-11-21 23:53:57 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
g_signal_handlers_unblock_by_func (editor->sel,
|
2006-04-12 18:53:28 +08:00
|
|
|
gimp_path_editor_selection_changed,
|
2003-12-18 21:29:16 +08:00
|
|
|
editor);
|
2002-02-02 12:14:07 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_tree_path_free (editor->sel_path);
|
|
|
|
editor->sel_path = NULL;
|
1999-03-14 07:03:11 +08:00
|
|
|
}
|
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_widget_set_sensitive (editor->delete_button, FALSE);
|
|
|
|
gtk_widget_set_sensitive (editor->up_button, FALSE);
|
|
|
|
gtk_widget_set_sensitive (editor->down_button, FALSE);
|
|
|
|
gtk_widget_set_sensitive (editor->file_entry, TRUE);
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2000-02-09 05:59:31 +08:00
|
|
|
gtk_editable_set_position
|
2003-12-18 21:29:16 +08:00
|
|
|
(GTK_EDITABLE (GIMP_FILE_ENTRY (editor->file_entry)->entry), -1);
|
2000-02-09 05:59:31 +08:00
|
|
|
gtk_widget_grab_focus
|
2003-12-18 21:29:16 +08:00
|
|
|
(GTK_WIDGET (GIMP_FILE_ENTRY (editor->file_entry)->entry));
|
1999-03-14 07:03:11 +08:00
|
|
|
}
|
|
|
|
|
1999-03-15 02:03:58 +08:00
|
|
|
static void
|
2003-11-21 23:53:57 +08:00
|
|
|
gimp_path_editor_move_clicked (GtkWidget *widget,
|
2003-12-18 21:29:16 +08:00
|
|
|
GimpPathEditor *editor)
|
1999-03-15 02:03:58 +08:00
|
|
|
{
|
2003-11-21 23:53:57 +08:00
|
|
|
GtkTreePath *path;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter1, iter2;
|
2004-01-29 05:53:50 +08:00
|
|
|
gchar *utf81, *utf82;
|
2003-11-21 23:53:57 +08:00
|
|
|
gchar *dir1, *dir2;
|
2004-01-29 05:53:50 +08:00
|
|
|
gboolean writable1, writable2;
|
1999-03-15 02:03:58 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
if (editor->sel_path == NULL)
|
1999-03-15 02:03:58 +08:00
|
|
|
return;
|
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
path = gtk_tree_path_copy (editor->sel_path);
|
2002-02-02 12:14:07 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
if (widget == editor->up_button)
|
2002-02-02 12:14:07 +08:00
|
|
|
gtk_tree_path_prev (path);
|
|
|
|
else
|
|
|
|
gtk_tree_path_next (path);
|
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
model = GTK_TREE_MODEL (editor->dir_list);
|
1999-03-15 02:03:58 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_tree_model_get_iter (model, &iter1, editor->sel_path);
|
2002-02-02 12:14:07 +08:00
|
|
|
gtk_tree_model_get_iter (model, &iter2, path);
|
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
gtk_tree_model_get (model, &iter1,
|
|
|
|
COLUMN_UTF8, &utf81,
|
|
|
|
COLUMN_DIRECTORY, &dir1,
|
|
|
|
COLUMN_WRITABLE, &writable1,
|
|
|
|
-1);
|
|
|
|
gtk_tree_model_get (model, &iter2,
|
|
|
|
COLUMN_UTF8, &utf82,
|
|
|
|
COLUMN_DIRECTORY, &dir2,
|
|
|
|
COLUMN_WRITABLE, &writable2,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
gtk_list_store_set (editor->dir_list, &iter1,
|
|
|
|
COLUMN_UTF8, utf82,
|
|
|
|
COLUMN_DIRECTORY, dir2,
|
|
|
|
COLUMN_WRITABLE, writable2,
|
|
|
|
-1);
|
|
|
|
gtk_list_store_set (editor->dir_list, &iter2,
|
|
|
|
COLUMN_UTF8, utf81,
|
|
|
|
COLUMN_DIRECTORY, dir1,
|
|
|
|
COLUMN_WRITABLE, writable1,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
g_free (utf81);
|
|
|
|
g_free (utf82);
|
2002-02-02 12:14:07 +08:00
|
|
|
|
|
|
|
g_free (dir2);
|
|
|
|
g_free (dir1);
|
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_tree_selection_select_iter (editor->sel, &iter2);
|
1999-03-15 02:03:58 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
g_signal_emit (editor, gimp_path_editor_signals[PATH_CHANGED], 0);
|
1999-03-15 02:03:58 +08:00
|
|
|
}
|
|
|
|
|
1999-03-14 07:03:11 +08:00
|
|
|
static void
|
2003-11-21 23:53:57 +08:00
|
|
|
gimp_path_editor_delete_clicked (GtkWidget *widget,
|
2003-12-18 21:29:16 +08:00
|
|
|
GimpPathEditor *editor)
|
1999-03-14 07:03:11 +08:00
|
|
|
{
|
2004-01-29 05:53:50 +08:00
|
|
|
GtkTreeIter iter;
|
|
|
|
gboolean dir_writable;
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
if (editor->sel_path == NULL)
|
1999-03-14 07:03:11 +08:00
|
|
|
return;
|
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_tree_model_get_iter (GTK_TREE_MODEL (editor->dir_list), &iter,
|
2006-04-12 18:53:28 +08:00
|
|
|
editor->sel_path);
|
2004-01-29 05:53:50 +08:00
|
|
|
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (editor->dir_list), &iter,
|
|
|
|
COLUMN_WRITABLE, &dir_writable,
|
|
|
|
-1);
|
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_list_store_remove (editor->dir_list, &iter);
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
editor->num_items--;
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
if (editor->num_items == 0)
|
1999-03-14 07:03:11 +08:00
|
|
|
{
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_tree_path_free (editor->sel_path);
|
|
|
|
editor->sel_path = NULL;
|
2002-02-02 12:14:07 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
g_signal_handlers_block_by_func (editor->file_entry,
|
2003-11-21 23:53:57 +08:00
|
|
|
gimp_path_editor_file_entry_changed,
|
2003-12-18 21:29:16 +08:00
|
|
|
editor);
|
2003-11-21 23:53:57 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
gimp_file_entry_set_filename (GIMP_FILE_ENTRY (editor->file_entry), "");
|
2003-11-21 23:53:57 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
g_signal_handlers_unblock_by_func (editor->file_entry,
|
2003-11-21 23:53:57 +08:00
|
|
|
gimp_path_editor_file_entry_changed,
|
2003-12-18 21:29:16 +08:00
|
|
|
editor);
|
2002-02-02 12:14:07 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_widget_set_sensitive (editor->delete_button, FALSE);
|
|
|
|
gtk_widget_set_sensitive (editor->up_button, FALSE);
|
|
|
|
gtk_widget_set_sensitive (editor->down_button, FALSE);
|
|
|
|
gtk_widget_set_sensitive (editor->file_entry, FALSE);
|
1999-03-14 07:03:11 +08:00
|
|
|
}
|
2004-01-29 05:53:50 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
gint *indices;
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
indices = gtk_tree_path_get_indices (editor->sel_path);
|
|
|
|
if ((indices[0] == editor->num_items) && (indices[0] > 0))
|
|
|
|
gtk_tree_path_prev (editor->sel_path);
|
2002-02-02 12:14:07 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
gtk_tree_selection_select_path (editor->sel, editor->sel_path);
|
|
|
|
}
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
g_signal_emit (editor, gimp_path_editor_signals[PATH_CHANGED], 0);
|
2004-01-29 05:53:50 +08:00
|
|
|
|
|
|
|
if (dir_writable)
|
|
|
|
g_signal_emit (editor, gimp_path_editor_signals[WRITABLE_CHANGED], 0);
|
1999-03-14 07:03:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-11-21 23:53:57 +08:00
|
|
|
gimp_path_editor_file_entry_changed (GtkWidget *widget,
|
2003-12-18 21:29:16 +08:00
|
|
|
GimpPathEditor *editor)
|
1999-03-14 07:03:11 +08:00
|
|
|
{
|
2004-01-29 05:53:50 +08:00
|
|
|
gchar *dir;
|
|
|
|
gchar *utf8;
|
2003-11-21 23:53:57 +08:00
|
|
|
GtkTreeIter iter;
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
dir = gimp_file_entry_get_filename (GIMP_FILE_ENTRY (widget));
|
|
|
|
if (strcmp (dir, "") == 0)
|
2002-02-02 12:14:07 +08:00
|
|
|
{
|
2004-01-29 05:53:50 +08:00
|
|
|
g_free (dir);
|
2002-02-02 12:14:07 +08:00
|
|
|
return;
|
|
|
|
}
|
1999-03-14 07:03:11 +08:00
|
|
|
|
2005-02-21 05:49:53 +08:00
|
|
|
utf8 = g_filename_display_name (dir);
|
2004-01-29 05:53:50 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
if (editor->sel_path == NULL)
|
1999-03-14 07:03:11 +08:00
|
|
|
{
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_list_store_append (editor->dir_list, &iter);
|
2004-01-29 05:53:50 +08:00
|
|
|
gtk_list_store_set (editor->dir_list, &iter,
|
|
|
|
COLUMN_UTF8, utf8,
|
|
|
|
COLUMN_DIRECTORY, dir,
|
|
|
|
COLUMN_WRITABLE, FALSE,
|
|
|
|
-1);
|
2003-12-18 21:29:16 +08:00
|
|
|
editor->num_items++;
|
2002-02-02 12:14:07 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_tree_selection_select_iter (editor->sel, &iter);
|
1999-03-14 07:03:11 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_tree_model_get_iter (GTK_TREE_MODEL (editor->dir_list), &iter,
|
2006-04-12 18:53:28 +08:00
|
|
|
editor->sel_path);
|
2004-01-29 05:53:50 +08:00
|
|
|
gtk_list_store_set (editor->dir_list, &iter,
|
|
|
|
COLUMN_UTF8, utf8,
|
|
|
|
COLUMN_DIRECTORY, dir,
|
|
|
|
-1);
|
1999-03-14 07:03:11 +08:00
|
|
|
}
|
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
g_free (dir);
|
|
|
|
g_free (utf8);
|
2002-02-02 12:14:07 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
g_signal_emit (editor, gimp_path_editor_signals[PATH_CHANGED], 0);
|
1999-03-14 07:03:11 +08:00
|
|
|
}
|
2003-11-21 23:53:57 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_path_editor_selection_changed (GtkTreeSelection *sel,
|
2003-12-18 21:29:16 +08:00
|
|
|
GimpPathEditor *editor)
|
2003-11-21 23:53:57 +08:00
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gchar *directory;
|
|
|
|
gint *indices;
|
|
|
|
|
|
|
|
if (gtk_tree_selection_get_selected (sel, NULL, &iter))
|
|
|
|
{
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (editor->dir_list), &iter,
|
2004-01-29 05:53:50 +08:00
|
|
|
0, &directory,
|
|
|
|
-1);
|
2003-11-21 23:53:57 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
g_signal_handlers_block_by_func (editor->file_entry,
|
2004-01-29 05:53:50 +08:00
|
|
|
gimp_path_editor_file_entry_changed,
|
|
|
|
editor);
|
2003-11-21 23:53:57 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
gimp_file_entry_set_filename (GIMP_FILE_ENTRY (editor->file_entry),
|
2003-11-21 23:53:57 +08:00
|
|
|
directory);
|
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
g_signal_handlers_unblock_by_func (editor->file_entry,
|
2004-01-29 05:53:50 +08:00
|
|
|
gimp_path_editor_file_entry_changed,
|
|
|
|
editor);
|
2003-11-21 23:53:57 +08:00
|
|
|
|
|
|
|
g_free (directory);
|
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
if (editor->sel_path)
|
2006-04-12 18:53:28 +08:00
|
|
|
gtk_tree_path_free (editor->sel_path);
|
2003-11-21 23:53:57 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
editor->sel_path =
|
|
|
|
gtk_tree_model_get_path (GTK_TREE_MODEL (editor->dir_list), &iter);
|
2003-11-21 23:53:57 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
indices = gtk_tree_path_get_indices (editor->sel_path);
|
2003-11-21 23:53:57 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_widget_set_sensitive (editor->delete_button, TRUE);
|
|
|
|
gtk_widget_set_sensitive (editor->up_button, (indices[0] > 0));
|
|
|
|
gtk_widget_set_sensitive (editor->down_button,
|
2004-01-29 05:53:50 +08:00
|
|
|
(indices[0] < (editor->num_items - 1)));
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_widget_set_sensitive (editor->file_entry, TRUE);
|
2003-11-21 23:53:57 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_signal_handlers_block_by_func (sel,
|
2004-01-29 05:53:50 +08:00
|
|
|
gimp_path_editor_selection_changed,
|
|
|
|
editor);
|
2003-11-21 23:53:57 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
gtk_tree_selection_select_path (editor->sel, editor->sel_path);
|
2003-11-21 23:53:57 +08:00
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (sel,
|
2004-01-29 05:53:50 +08:00
|
|
|
gimp_path_editor_selection_changed,
|
|
|
|
editor);
|
2003-11-21 23:53:57 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
static void
|
|
|
|
gimp_path_editor_writable_toggled (GtkCellRendererToggle *toggle,
|
|
|
|
gchar *path_str,
|
|
|
|
GimpPathEditor *editor)
|
2003-11-21 23:53:57 +08:00
|
|
|
{
|
2004-01-29 05:53:50 +08:00
|
|
|
GtkTreePath *path;
|
|
|
|
GtkTreeIter iter;
|
2003-11-21 23:53:57 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
path = gtk_tree_path_new_from_string (path_str);
|
2003-11-21 23:53:57 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (editor->dir_list), &iter, path))
|
|
|
|
{
|
|
|
|
gboolean dir_writable;
|
2003-11-21 23:53:57 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (editor->dir_list), &iter,
|
|
|
|
COLUMN_WRITABLE, &dir_writable,
|
|
|
|
-1);
|
2003-11-21 23:53:57 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
gtk_list_store_set (editor->dir_list, &iter,
|
|
|
|
COLUMN_WRITABLE, ! dir_writable,
|
|
|
|
-1);
|
2003-11-21 23:53:57 +08:00
|
|
|
|
2004-01-29 05:53:50 +08:00
|
|
|
g_signal_emit (editor, gimp_path_editor_signals[WRITABLE_CHANGED], 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
2003-11-21 23:53:57 +08:00
|
|
|
}
|