1999-03-14 07:03:11 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
|
|
|
*
|
|
|
|
* gimppatheditor.c
|
2000-02-09 04:24:07 +08:00
|
|
|
* Copyright (C) 1999 Michael Natterer <mitch@gimp.org>
|
1999-03-14 07:03:11 +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
|
|
|
|
* 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
|
1999-03-14 07:03:11 +08:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
1999-11-20 22:27:07 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
1999-03-14 07:03:11 +08:00
|
|
|
#include "gimppatheditor.h"
|
|
|
|
|
|
|
|
#include "libgimp/gimpfileselection.h"
|
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
|
|
|
#include "pixmaps/new.xpm"
|
|
|
|
#include "pixmaps/delete.xpm"
|
|
|
|
#include "pixmaps/raise.xpm"
|
|
|
|
#include "pixmaps/lower.xpm"
|
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
/* forward declaration */
|
1999-11-20 22:27:07 +08:00
|
|
|
static void gimp_path_editor_realize (GtkWidget *widget);
|
1999-03-14 07:03:11 +08:00
|
|
|
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);
|
1999-03-15 02:03:58 +08:00
|
|
|
static void gimp_path_editor_delete_callback (GtkWidget *widget, gpointer data);
|
1999-03-14 07:03:11 +08:00
|
|
|
|
1999-11-20 22:27:07 +08:00
|
|
|
enum
|
|
|
|
{
|
1999-06-18 03:13:08 +08:00
|
|
|
PATH_CHANGED,
|
1999-03-14 07:03:11 +08:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
1999-12-07 06:44:40 +08:00
|
|
|
static guint gimp_path_editor_signals[LAST_SIGNAL] = { 0 };
|
1999-03-14 07:03:11 +08:00
|
|
|
|
|
|
|
static GtkVBoxClass *parent_class = NULL;
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_path_editor_class_init (GimpPathEditorClass *class)
|
|
|
|
{
|
|
|
|
GtkObjectClass *object_class;
|
1999-11-20 22:27:07 +08:00
|
|
|
GtkWidgetClass *widget_class;
|
1999-03-14 07:03:11 +08:00
|
|
|
|
1999-11-20 22:27:07 +08:00
|
|
|
object_class = (GtkObjectClass *) class;
|
|
|
|
widget_class = (GtkWidgetClass *) class;
|
1999-03-14 07:03:11 +08:00
|
|
|
|
|
|
|
parent_class = gtk_type_class (gtk_vbox_get_type ());
|
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
gimp_path_editor_signals[PATH_CHANGED] =
|
1999-11-20 22:27:07 +08:00
|
|
|
gtk_signal_new ("path_changed",
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpPathEditorClass,
|
|
|
|
path_changed),
|
|
|
|
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0);
|
1999-06-18 03:13:08 +08:00
|
|
|
|
1999-03-14 07:03:11 +08:00
|
|
|
gtk_object_class_add_signals (object_class, gimp_path_editor_signals,
|
|
|
|
LAST_SIGNAL);
|
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
class->path_changed = NULL;
|
1999-11-20 22:27:07 +08:00
|
|
|
|
|
|
|
widget_class->realize = gimp_path_editor_realize;
|
1999-03-14 07:03:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_path_editor_init (GimpPathEditor *gpe)
|
|
|
|
{
|
|
|
|
GtkWidget *button_box;
|
|
|
|
GtkWidget *scrolled_window;
|
|
|
|
|
|
|
|
gpe->file_selection = NULL;
|
|
|
|
gpe->selected_item = NULL;
|
|
|
|
gpe->number_of_items = 0;
|
|
|
|
|
1999-03-28 02:16:30 +08:00
|
|
|
gpe->upper_hbox = gtk_hbox_new (FALSE, 2);
|
1999-03-14 07:03:11 +08:00
|
|
|
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 = gtk_button_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (button_box), gpe->new_button, TRUE, TRUE, 0);
|
1999-11-20 22:27:07 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (gpe->new_button), "clicked",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_path_editor_new_callback),
|
|
|
|
gpe);
|
1999-03-14 07:03:11 +08:00
|
|
|
|
|
|
|
gpe->up_button = gtk_button_new ();
|
|
|
|
gtk_widget_set_sensitive (gpe->up_button, FALSE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (button_box), gpe->up_button, TRUE, TRUE, 0);
|
1999-11-20 22:27:07 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (gpe->up_button), "clicked",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_path_editor_move_callback),
|
|
|
|
gpe);
|
1999-03-14 07:03:11 +08:00
|
|
|
|
|
|
|
gpe->down_button = gtk_button_new ();
|
|
|
|
gtk_widget_set_sensitive (gpe->down_button, FALSE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (button_box), gpe->down_button, TRUE, TRUE, 0);
|
1999-11-20 22:27:07 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (gpe->down_button), "clicked",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_path_editor_move_callback),
|
|
|
|
gpe);
|
1999-03-14 07:03:11 +08:00
|
|
|
|
1999-03-15 02:03:58 +08:00
|
|
|
gpe->delete_button = gtk_button_new ();
|
|
|
|
gtk_widget_set_sensitive (gpe->delete_button, FALSE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (button_box), gpe->delete_button, TRUE, TRUE, 0);
|
1999-11-20 22:27:07 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (gpe->delete_button), "clicked",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_path_editor_delete_callback),
|
|
|
|
gpe);
|
|
|
|
|
|
|
|
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_ALWAYS);
|
1999-03-28 02:16:30 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (gpe), scrolled_window, TRUE, TRUE, 2);
|
1999-03-14 07:03:11 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
GtkType
|
1999-11-20 22:27:07 +08:00
|
|
|
gimp_path_editor_get_type (void)
|
1999-03-14 07:03:11 +08:00
|
|
|
{
|
1999-06-18 03:13:08 +08:00
|
|
|
static GtkType gpe_type = 0;
|
1999-03-14 07:03:11 +08:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-20 22:27:07 +08:00
|
|
|
GtkWidget *
|
1999-03-14 07:03:11 +08:00
|
|
|
gimp_path_editor_new (gchar *filesel_title,
|
|
|
|
gchar *path)
|
|
|
|
{
|
|
|
|
GimpPathEditor *gpe;
|
|
|
|
GtkWidget *list_item;
|
|
|
|
GList *directory_list;
|
|
|
|
gchar *directory;
|
|
|
|
|
|
|
|
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);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (gpe->file_selection), "filename_changed",
|
1999-11-20 22:27:07 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_path_editor_filesel_callback),
|
|
|
|
gpe);
|
1999-03-14 07:03:11 +08:00
|
|
|
gtk_widget_show (gpe->file_selection);
|
|
|
|
|
|
|
|
directory_list = NULL;
|
|
|
|
directory = path = g_strdup (path);
|
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
/* split up the path */
|
1999-03-14 07:03:11 +08:00
|
|
|
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);
|
|
|
|
gtk_object_set_data_full (GTK_OBJECT (list_item), "gimp_path_editor",
|
|
|
|
current_dir,
|
1999-11-20 22:27:07 +08:00
|
|
|
(GtkDestroyNotify) g_free);
|
1999-03-14 07:03:11 +08:00
|
|
|
directory_list = g_list_append (directory_list, list_item);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (list_item), "select",
|
1999-11-20 22:27:07 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_path_editor_select_callback),
|
1999-03-14 07:03:11 +08:00
|
|
|
gpe);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (list_item), "deselect",
|
1999-11-20 22:27:07 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_path_editor_deselect_callback),
|
1999-03-14 07:03:11 +08:00
|
|
|
gpe);
|
|
|
|
gtk_widget_show (list_item);
|
|
|
|
gpe->number_of_items++;
|
|
|
|
|
|
|
|
if (next_separator != NULL)
|
|
|
|
directory = next_separator + 1;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (path);
|
|
|
|
|
|
|
|
if (directory_list)
|
|
|
|
gtk_list_append_items (GTK_LIST (gpe->dir_list), directory_list);
|
|
|
|
|
|
|
|
return GTK_WIDGET (gpe);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-11-20 22:27:07 +08:00
|
|
|
gimp_path_editor_realize (GtkWidget *widget)
|
1999-03-14 07:03:11 +08:00
|
|
|
{
|
|
|
|
GimpPathEditor *gpe;
|
|
|
|
GtkStyle *style;
|
|
|
|
GdkPixmap *pixmap;
|
|
|
|
GdkBitmap *mask;
|
|
|
|
GtkWidget *gtk_pixmap;
|
|
|
|
/* GList *list = NULL; */
|
|
|
|
|
1999-11-20 22:27:07 +08:00
|
|
|
gpe = GIMP_PATH_EDITOR (widget);
|
1999-03-14 07:03:11 +08:00
|
|
|
|
1999-11-20 22:27:07 +08:00
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->realize)
|
|
|
|
(* GTK_WIDGET_CLASS (parent_class)->realize) (widget);
|
1999-03-14 07:03:11 +08:00
|
|
|
|
1999-11-20 22:27:07 +08:00
|
|
|
style = gtk_widget_get_style (widget);
|
1999-03-14 07:03:11 +08:00
|
|
|
|
1999-11-20 22:27:07 +08:00
|
|
|
pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
|
1999-03-14 07:03:11 +08:00
|
|
|
&mask,
|
|
|
|
&style->bg[GTK_STATE_NORMAL],
|
|
|
|
new_xpm);
|
|
|
|
gtk_pixmap = gtk_pixmap_new (pixmap, mask);
|
|
|
|
gtk_container_add (GTK_CONTAINER (gpe->new_button), gtk_pixmap);
|
|
|
|
gtk_widget_show (gtk_pixmap);
|
|
|
|
gtk_widget_show (gpe->new_button);
|
|
|
|
|
2000-02-09 04:24:07 +08:00
|
|
|
gdk_pixmap_unref (pixmap);
|
|
|
|
gdk_bitmap_unref (mask);
|
|
|
|
|
1999-11-20 22:27:07 +08:00
|
|
|
pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
|
1999-03-14 07:03:11 +08:00
|
|
|
&mask,
|
|
|
|
&style->bg[GTK_STATE_NORMAL],
|
|
|
|
raise_xpm);
|
|
|
|
gtk_pixmap = gtk_pixmap_new (pixmap, mask);
|
|
|
|
gtk_container_add (GTK_CONTAINER (gpe->up_button), gtk_pixmap);
|
|
|
|
gtk_widget_show (gtk_pixmap);
|
|
|
|
gtk_widget_show (gpe->up_button);
|
|
|
|
|
2000-02-09 04:24:07 +08:00
|
|
|
gdk_pixmap_unref (pixmap);
|
|
|
|
gdk_bitmap_unref (mask);
|
|
|
|
|
1999-11-20 22:27:07 +08:00
|
|
|
pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
|
1999-03-14 07:03:11 +08:00
|
|
|
&mask,
|
|
|
|
&style->bg[GTK_STATE_NORMAL],
|
|
|
|
lower_xpm);
|
|
|
|
gtk_pixmap = gtk_pixmap_new (pixmap, mask);
|
|
|
|
gtk_container_add (GTK_CONTAINER (gpe->down_button), gtk_pixmap);
|
|
|
|
gtk_widget_show (gtk_pixmap);
|
|
|
|
gtk_widget_show (gpe->down_button);
|
|
|
|
|
2000-02-09 04:24:07 +08:00
|
|
|
gdk_pixmap_unref (pixmap);
|
|
|
|
gdk_bitmap_unref (mask);
|
|
|
|
|
1999-11-20 22:27:07 +08:00
|
|
|
pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
|
1999-03-15 02:03:58 +08:00
|
|
|
&mask,
|
|
|
|
&style->bg[GTK_STATE_NORMAL],
|
|
|
|
delete_xpm);
|
|
|
|
gtk_pixmap = gtk_pixmap_new (pixmap, mask);
|
|
|
|
gtk_container_add (GTK_CONTAINER (gpe->delete_button), gtk_pixmap);
|
|
|
|
gtk_widget_show (gtk_pixmap);
|
|
|
|
gtk_widget_show (gpe->delete_button);
|
|
|
|
|
2000-02-09 04:24:07 +08:00
|
|
|
gdk_pixmap_unref (pixmap);
|
|
|
|
gdk_bitmap_unref (mask);
|
1999-03-14 07:03:11 +08:00
|
|
|
}
|
|
|
|
|
1999-11-20 22:27:07 +08:00
|
|
|
gchar *
|
1999-03-14 07:03:11 +08:00
|
|
|
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)
|
|
|
|
{
|
1999-11-20 22:27:07 +08:00
|
|
|
path =
|
|
|
|
g_strdup ((gchar *) gtk_object_get_data (GTK_OBJECT (list->data),
|
|
|
|
"gimp_path_editor"));
|
1999-03-14 07:03:11 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gchar *newpath;
|
|
|
|
|
|
|
|
newpath =
|
|
|
|
g_strconcat (path,
|
|
|
|
G_SEARCHPATH_SEPARATOR_S,
|
1999-11-20 22:27:07 +08:00
|
|
|
(gchar *) gtk_object_get_data (GTK_OBJECT (list->data),
|
|
|
|
"gimp_path_editor"),
|
1999-03-14 07:03:11 +08:00
|
|
|
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);
|
1999-11-20 22:27:07 +08:00
|
|
|
directory = (gchar *) gtk_object_get_data (GTK_OBJECT (widget),
|
|
|
|
"gimp_path_editor");
|
1999-03-14 07:03:11 +08:00
|
|
|
|
|
|
|
gtk_signal_handler_block_by_data (GTK_OBJECT (gpe->file_selection), gpe);
|
|
|
|
gimp_file_selection_set_filename (GIMP_FILE_SELECTION (gpe->file_selection),
|
|
|
|
directory);
|
|
|
|
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gpe->file_selection), 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);
|
1999-03-14 07:35:26 +08:00
|
|
|
gtk_widget_set_sensitive (gpe->file_selection, TRUE);
|
1999-03-14 07:03:11 +08:00
|
|
|
|
|
|
|
gtk_editable_set_position (GTK_EDITABLE (GIMP_FILE_SELECTION (gpe->file_selection)->entry), -1);
|
|
|
|
/* gtk_editable_select_region (GTK_EDITABLE (gpe->entry), 0, -1); */
|
|
|
|
gtk_widget_grab_focus (GTK_WIDGET (GIMP_FILE_SELECTION (gpe->file_selection)->entry));
|
|
|
|
}
|
|
|
|
|
1999-03-15 02:03:58 +08:00
|
|
|
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);
|
|
|
|
|
1999-11-20 22:27:07 +08:00
|
|
|
gtk_signal_emit (GTK_OBJECT (gpe), gimp_path_editor_signals[PATH_CHANGED]);
|
1999-03-15 02:03:58 +08:00
|
|
|
}
|
|
|
|
|
1999-03-14 07:03:11 +08:00
|
|
|
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;
|
|
|
|
gtk_signal_handler_block_by_data (GTK_OBJECT (gpe->file_selection), gpe);
|
|
|
|
gimp_file_selection_set_filename (GIMP_FILE_SELECTION (gpe->file_selection), "");
|
|
|
|
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gpe->file_selection), gpe);
|
|
|
|
gtk_widget_set_sensitive (gpe->delete_button, FALSE);
|
|
|
|
gtk_widget_set_sensitive (GIMP_FILE_SELECTION (gpe->file_selection)->entry, FALSE);
|
|
|
|
gtk_widget_set_sensitive (GIMP_FILE_SELECTION (gpe->file_selection)->browse_button, FALSE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((pos == gpe->number_of_items) && (pos > 0))
|
|
|
|
pos--;
|
|
|
|
gtk_list_select_item (GTK_LIST (gpe->dir_list), pos);
|
|
|
|
|
1999-11-20 22:27:07 +08:00
|
|
|
gtk_signal_emit (GTK_OBJECT (gpe), gimp_path_editor_signals[PATH_CHANGED]);
|
1999-03-14 07:03:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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));
|
1999-03-14 07:35:26 +08:00
|
|
|
if (strcmp (directory, "") == 0)
|
|
|
|
return;
|
1999-03-14 07:03:11 +08:00
|
|
|
|
|
|
|
if (gpe->selected_item == NULL)
|
|
|
|
{
|
|
|
|
list_item = gtk_list_item_new_with_label (directory);
|
|
|
|
gtk_object_set_data_full (GTK_OBJECT (list_item), "gimp_path_editor",
|
|
|
|
directory,
|
1999-11-20 22:27:07 +08:00
|
|
|
(GtkDestroyNotify) g_free);
|
1999-03-14 07:03:11 +08:00
|
|
|
append_list = g_list_append (append_list, list_item);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (list_item), "select",
|
1999-11-20 22:27:07 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_path_editor_select_callback),
|
1999-03-14 07:03:11 +08:00
|
|
|
gpe);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (list_item), "deselect",
|
1999-11-20 22:27:07 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_path_editor_deselect_callback),
|
1999-03-14 07:03:11 +08:00
|
|
|
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);
|
|
|
|
gtk_object_set_data_full (GTK_OBJECT (gpe->selected_item),
|
|
|
|
"gimp_path_editor",
|
|
|
|
directory,
|
1999-11-20 22:27:07 +08:00
|
|
|
(GtkDestroyNotify) g_free);
|
1999-03-14 07:03:11 +08:00
|
|
|
}
|
|
|
|
|
1999-11-20 22:27:07 +08:00
|
|
|
gtk_signal_emit (GTK_OBJECT (gpe), gimp_path_editor_signals[PATH_CHANGED]);
|
1999-03-14 07:03:11 +08:00
|
|
|
}
|