removed...
2003-11-21 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpfileselection.[ch]: removed... * libgimpwidgets/gimpfileentry.[ch]: ...and added under a new name. * libgimpwidgets/Makefile.am * libgimpwidgets/gimpwidgets.h * libgimpwidgets/gimpwidgetstypes.h * libgimpwidgets/gimppatheditor.[ch] * app/widgets/gimppropwidgets.c * plug-ins/script-fu/script-fu-scripts.c: changed accordingly. * libgimp/gimpcompat.h: added compat #defines. 2003-11-21 Michael Natterer <mitch@gimp.org> * libgimpwidgets/tmpl/gimpfileselection.sgml: removed. * libgimpwidgets/tmpl/gimpfileentry.sgml: added. * libgimpwidgets/libgimpwidgets-docs.sgml * libgimpwidgets/libgimpwidgets-sections.txt * libgimpwidgets/libgimpwidgets.types * libgimpwidgets/tmpl/gimpdialog.sgml * libgimpwidgets/tmpl/gimppatheditor.sgml: updated.
This commit is contained in:

committed by
Michael Natterer

parent
1f60967d50
commit
a70db0bb44
15
ChangeLog
15
ChangeLog
@ -1,3 +1,18 @@
|
||||
2003-11-21 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* libgimpwidgets/gimpfileselection.[ch]: removed...
|
||||
|
||||
* libgimpwidgets/gimpfileentry.[ch]: ...and added under a new name.
|
||||
|
||||
* libgimpwidgets/Makefile.am
|
||||
* libgimpwidgets/gimpwidgets.h
|
||||
* libgimpwidgets/gimpwidgetstypes.h
|
||||
* libgimpwidgets/gimppatheditor.[ch]
|
||||
* app/widgets/gimppropwidgets.c
|
||||
* plug-ins/script-fu/script-fu-scripts.c: changed accordingly.
|
||||
|
||||
* libgimp/gimpcompat.h: added compat #defines.
|
||||
|
||||
2003-11-21 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* configure.in: added a check for little cms.
|
||||
|
@ -1302,11 +1302,11 @@ gimp_prop_text_buffer_notify (GObject *config,
|
||||
/****************/
|
||||
|
||||
|
||||
static void gimp_prop_file_entry_callback (GimpFileSelection *entry,
|
||||
static void gimp_prop_file_entry_callback (GimpFileEntry *entry,
|
||||
GObject *config);
|
||||
static void gimp_prop_file_entry_notify (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GimpFileSelection *entry);
|
||||
GimpFileEntry *entry);
|
||||
|
||||
GtkWidget *
|
||||
gimp_prop_file_entry_new (GObject *config,
|
||||
@ -1331,14 +1331,13 @@ gimp_prop_file_entry_new (GObject *config,
|
||||
|
||||
filename = value ? gimp_config_path_expand (value, FALSE, NULL) : NULL;
|
||||
|
||||
entry = gimp_file_selection_new (filesel_title,
|
||||
filename, dir_only, check_valid);
|
||||
entry = gimp_file_entry_new (filesel_title, filename, dir_only, check_valid);
|
||||
|
||||
g_free (value);
|
||||
g_free (filename);
|
||||
|
||||
set_param_spec (G_OBJECT (entry),
|
||||
GIMP_FILE_SELECTION (entry)->entry,
|
||||
GIMP_FILE_ENTRY (entry)->entry,
|
||||
param_spec);
|
||||
|
||||
g_signal_connect (entry, "filename_changed",
|
||||
@ -1353,7 +1352,7 @@ gimp_prop_file_entry_new (GObject *config,
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_prop_file_entry_callback (GimpFileSelection *entry,
|
||||
gimp_prop_file_entry_callback (GimpFileEntry *entry,
|
||||
GObject *config)
|
||||
{
|
||||
GParamSpec *param_spec;
|
||||
@ -1363,7 +1362,7 @@ gimp_prop_file_entry_callback (GimpFileSelection *entry,
|
||||
if (! param_spec)
|
||||
return;
|
||||
|
||||
value = gimp_file_selection_get_filename (entry);
|
||||
value = gimp_file_entry_get_filename (entry);
|
||||
|
||||
g_object_set (config,
|
||||
param_spec->name, value,
|
||||
@ -1375,7 +1374,7 @@ gimp_prop_file_entry_callback (GimpFileSelection *entry,
|
||||
static void
|
||||
gimp_prop_file_entry_notify (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GimpFileSelection *entry)
|
||||
GimpFileEntry *entry)
|
||||
{
|
||||
gchar *value;
|
||||
|
||||
@ -1387,7 +1386,7 @@ gimp_prop_file_entry_notify (GObject *config,
|
||||
gimp_prop_file_entry_callback,
|
||||
config);
|
||||
|
||||
gimp_file_selection_set_filename (entry, value);
|
||||
gimp_file_entry_set_filename (entry, value);
|
||||
|
||||
g_signal_handlers_unblock_by_func (entry,
|
||||
gimp_prop_file_entry_callback,
|
||||
|
@ -1,3 +1,15 @@
|
||||
2003-11-21 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* libgimpwidgets/tmpl/gimpfileselection.sgml: removed.
|
||||
|
||||
* libgimpwidgets/tmpl/gimpfileentry.sgml: added.
|
||||
|
||||
* libgimpwidgets/libgimpwidgets-docs.sgml
|
||||
* libgimpwidgets/libgimpwidgets-sections.txt
|
||||
* libgimpwidgets/libgimpwidgets.types
|
||||
* libgimpwidgets/tmpl/gimpdialog.sgml
|
||||
* libgimpwidgets/tmpl/gimppatheditor.sgml: updated.
|
||||
|
||||
2003-11-19 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* libgimpwidgets/tmpl/gimphelpui.sgml: updated.
|
||||
|
@ -26,7 +26,7 @@
|
||||
<xi:include href="xml/gimpcolorscale.xml" />
|
||||
<xi:include href="xml/gimpcolorselection.xml" />
|
||||
<xi:include href="xml/gimpdialog.xml" />
|
||||
<xi:include href="xml/gimpfileselection.xml" />
|
||||
<xi:include href="xml/gimpfileentry.xml" />
|
||||
<xi:include href="xml/gimpmemsizeentry.xml" />
|
||||
<xi:include href="xml/gimpoffsetarea.xml" />
|
||||
<xi:include href="xml/gimppatheditor.xml" />
|
||||
|
@ -104,21 +104,21 @@ GIMP_COLOR_SELECTION_GET_CLASS
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gimpfileselection</FILE>
|
||||
<TITLE>GimpFileSelection</TITLE>
|
||||
GimpFileSelection
|
||||
gimp_file_selection_new
|
||||
gimp_file_selection_get_filename
|
||||
gimp_file_selection_set_filename
|
||||
<FILE>gimpfileentry</FILE>
|
||||
<TITLE>GimpFileEntry</TITLE>
|
||||
GimpFileEntry
|
||||
gimp_file_entry_new
|
||||
gimp_file_entry_get_filename
|
||||
gimp_file_entry_set_filename
|
||||
<SUBSECTION Standard>
|
||||
GIMP_FILE_SELECTION
|
||||
GIMP_IS_FILE_SELECTION
|
||||
GIMP_TYPE_FILE_SELECTION
|
||||
gimp_file_selection_get_type
|
||||
GimpFileSelectionClass
|
||||
GIMP_FILE_SELECTION_CLASS
|
||||
GIMP_IS_FILE_SELECTION_CLASS
|
||||
GIMP_FILE_SELECTION_GET_CLASS
|
||||
GIMP_FILE_ENTRY
|
||||
GIMP_IS_FILE_ENTRY
|
||||
GIMP_TYPE_FILE_ENTRY
|
||||
gimp_file_entry_get_type
|
||||
GimpFileEntryClass
|
||||
GIMP_FILE_ENTRY_CLASS
|
||||
GIMP_IS_FILE_ENTRY_CLASS
|
||||
GIMP_FILE_ENTRY_GET_CLASS
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
|
@ -16,7 +16,7 @@ gimp_color_selector_get_type
|
||||
gimp_color_select_get_type
|
||||
gimp_color_selection_get_type
|
||||
gimp_dialog_get_type
|
||||
gimp_file_selection_get_type
|
||||
gimp_file_entry_get_type
|
||||
gimp_memsize_entry_get_type
|
||||
gimp_offset_area_get_type
|
||||
gimp_path_editor_get_type
|
||||
|
@ -69,3 +69,8 @@ dialog-related stuff.
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### ARG GimpDialog:role ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!-- ##### SECTION Title ##### -->
|
||||
GimpFileSelection
|
||||
GimpFileEntry
|
||||
|
||||
<!-- ##### SECTION Short_Description ##### -->
|
||||
Widget for entering a filename.
|
||||
@ -17,7 +17,7 @@ You can restrict the #GimpFileSelection to directories. In this case
|
||||
the filename listbox of the #GtkFileSelection dialog will be hidden.
|
||||
</para>
|
||||
<para>
|
||||
If you specify @check_valid as #TRUE in gimp_file_selection_new()
|
||||
If you specify @check_valid as #TRUE in gimp_file_entry_new()
|
||||
the entered filename will be checked for validity and a pixmap will be
|
||||
shown which indicates if the file exists or not.
|
||||
</para>
|
||||
@ -31,13 +31,14 @@ will be emitted.
|
||||
#GimpPathEditor
|
||||
</para>
|
||||
|
||||
<!-- ##### STRUCT GimpFileSelection ##### -->
|
||||
|
||||
<!-- ##### STRUCT GimpFileEntry ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_file_selection_new ##### -->
|
||||
<!-- ##### FUNCTION gimp_file_entry_new ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
@ -49,28 +50,28 @@ will be emitted.
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_file_selection_get_filename ##### -->
|
||||
<!-- ##### FUNCTION gimp_file_entry_get_filename ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@selection:
|
||||
@entry:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_file_selection_set_filename ##### -->
|
||||
<!-- ##### FUNCTION gimp_file_entry_set_filename ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@selection:
|
||||
@entry:
|
||||
@filename:
|
||||
|
||||
|
||||
<!-- ##### SIGNAL GimpFileSelection::filename-changed ##### -->
|
||||
<!-- ##### SIGNAL GimpFileEntry::filename-changed ##### -->
|
||||
<para>
|
||||
This signal is emitted whenever the user changes the filename.
|
||||
|
||||
</para>
|
||||
|
||||
@gimpfileselection: the object which received the signal.
|
||||
@gimpfileentry: the object which received the signal.
|
||||
|
@ -11,7 +11,7 @@ This widget is used to edit file search paths.
|
||||
<para>
|
||||
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
|
||||
#GimpFileSelection to change the currently selected directory.
|
||||
#GimpFileEntry to change the currently selected directory.
|
||||
</para>
|
||||
<para>
|
||||
There are buttons to add or delete directories as well as "up" and "down"
|
||||
@ -24,7 +24,7 @@ the search path, the "path_changed" signal will be emitted.
|
||||
|
||||
<!-- ##### SECTION See_Also ##### -->
|
||||
<para>
|
||||
#GimpFileSelection
|
||||
#GimpFileEntry
|
||||
</para>
|
||||
<para>
|
||||
#G_SEARCHPATH_SEPARATOR
|
||||
|
@ -69,11 +69,18 @@ G_BEGIN_DECLS
|
||||
#define gimp_pattern_select_widget gimp_pattern_select_widget_new
|
||||
#define gimp_pattern_select_widget_set_popup gimp_pattern_select_widget_set
|
||||
#define gimp_pattern_select_widget_close_popup gimp_pattern_select_widget_close
|
||||
|
||||
#define INTENSITY(r,g,b) GIMP_RGB_INTENSITY(r,g,b)
|
||||
#define INTENSITY_RED GIMP_RGB_INTENSITY_RED
|
||||
#define INTENSITY_GREEN GIMP_RGB_INTENSITY_GREEN
|
||||
#define INTENSITY_BLUE GIMP_RGB_INTENSITY_BLUE
|
||||
|
||||
#define gimp_file_selection_ gimp_file_entry_
|
||||
#define GimpFileSelection GimpFileEntry
|
||||
#define GIMP_TYPE_FILE_SELECTION GIMP_TYPE_FILE_ENTRY
|
||||
#define GIMP_FILE_SELECTION GIMP_FILE_ENTRY
|
||||
#define GIMP_IS_FILE_SELECTION GIMP_IS_FILE_ENTRY
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -88,8 +88,8 @@ libgimpwidgets_1_3_la_sources = \
|
||||
gimpcolorselection.h \
|
||||
gimpdialog.c \
|
||||
gimpdialog.h \
|
||||
gimpfileselection.c \
|
||||
gimpfileselection.h \
|
||||
gimpfileentry.c \
|
||||
gimpfileentry.h \
|
||||
gimphelpui.c \
|
||||
gimphelpui.h \
|
||||
gimpmemsizeentry.c \
|
||||
@ -143,7 +143,7 @@ libgimpwidgetsinclude_HEADERS = \
|
||||
gimpcolorselect.h \
|
||||
gimpcolorselection.h \
|
||||
gimpdialog.h \
|
||||
gimpfileselection.h \
|
||||
gimpfileentry.h \
|
||||
gimphelpui.h \
|
||||
gimpmemsizeentry.h \
|
||||
gimpoffsetarea.h \
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpfileselection.c
|
||||
* Copyright (C) 1999-2000 Michael Natterer <mitch@gimp.org>
|
||||
* gimpfileentry.c
|
||||
* Copyright (C) 1999-2003 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
#include "gimpwidgetstypes.h"
|
||||
|
||||
#include "gimpfileselection.h"
|
||||
#include "gimpfileentry.h"
|
||||
|
||||
#include "libgimp/libgimp-intl.h"
|
||||
|
||||
@ -47,212 +47,209 @@ enum
|
||||
};
|
||||
|
||||
|
||||
static void gimp_file_selection_class_init (GimpFileSelectionClass *klass);
|
||||
static void gimp_file_selection_init (GimpFileSelection *selection);
|
||||
static void gimp_file_entry_class_init (GimpFileEntryClass *klass);
|
||||
static void gimp_file_entry_init (GimpFileEntry *entry);
|
||||
|
||||
static void gimp_file_selection_destroy (GtkObject *object);
|
||||
static void gimp_file_entry_destroy (GtkObject *object);
|
||||
|
||||
static void gimp_file_selection_entry_activate (GtkWidget *widget,
|
||||
GimpFileSelection *selection);
|
||||
static gint gimp_file_selection_entry_focus_out (GtkWidget *widget,
|
||||
static void gimp_file_entry_entry_activate (GtkWidget *widget,
|
||||
GimpFileEntry *entry);
|
||||
static gint gimp_file_entry_entry_focus_out (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
GimpFileSelection *selection);
|
||||
static void gimp_file_selection_browse_clicked (GtkWidget *widget,
|
||||
GimpFileSelection *selection);
|
||||
static void gimp_file_selection_check_filename (GimpFileSelection *selection);
|
||||
GimpFileEntry *entry);
|
||||
static void gimp_file_entry_browse_clicked (GtkWidget *widget,
|
||||
GimpFileEntry *entry);
|
||||
static void gimp_file_entry_check_filename (GimpFileEntry *entry);
|
||||
|
||||
|
||||
static guint gimp_file_selection_signals[LAST_SIGNAL] = { 0 };
|
||||
static guint gimp_file_entry_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static GtkHBoxClass *parent_class = NULL;
|
||||
|
||||
|
||||
GType
|
||||
gimp_file_selection_get_type (void)
|
||||
gimp_file_entry_get_type (void)
|
||||
{
|
||||
static GType selection_type = 0;
|
||||
static GType entry_type = 0;
|
||||
|
||||
if (! selection_type)
|
||||
if (! entry_type)
|
||||
{
|
||||
static const GTypeInfo selection_info =
|
||||
static const GTypeInfo entry_info =
|
||||
{
|
||||
sizeof (GimpFileSelectionClass),
|
||||
sizeof (GimpFileEntryClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gimp_file_selection_class_init,
|
||||
(GClassInitFunc) gimp_file_entry_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpFileSelection),
|
||||
sizeof (GimpFileEntry),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_file_selection_init,
|
||||
(GInstanceInitFunc) gimp_file_entry_init,
|
||||
};
|
||||
|
||||
selection_type = g_type_register_static (GTK_TYPE_HBOX,
|
||||
"GimpFileSelection",
|
||||
&selection_info, 0);
|
||||
entry_type = g_type_register_static (GTK_TYPE_HBOX,
|
||||
"GimpFileEntry",
|
||||
&entry_info, 0);
|
||||
}
|
||||
|
||||
return selection_type;
|
||||
return entry_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_file_selection_class_init (GimpFileSelectionClass *klass)
|
||||
gimp_file_entry_class_init (GimpFileEntryClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
object_class = (GtkObjectClass *) klass;
|
||||
object_class = GTK_OBJECT_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
gimp_file_selection_signals[FILENAME_CHANGED] =
|
||||
gimp_file_entry_signals[FILENAME_CHANGED] =
|
||||
g_signal_new ("filename_changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpFileSelectionClass, filename_changed),
|
||||
G_STRUCT_OFFSET (GimpFileEntryClass, filename_changed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
object_class->destroy = gimp_file_selection_destroy;
|
||||
object_class->destroy = gimp_file_entry_destroy;
|
||||
|
||||
klass->filename_changed = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_file_selection_init (GimpFileSelection *selection)
|
||||
gimp_file_entry_init (GimpFileEntry *entry)
|
||||
{
|
||||
selection->title = NULL;
|
||||
selection->file_selection = NULL;
|
||||
selection->check_valid = FALSE;
|
||||
entry->title = NULL;
|
||||
entry->file_selection = NULL;
|
||||
entry->check_valid = FALSE;
|
||||
|
||||
selection->file_exists = NULL;
|
||||
entry->file_exists = NULL;
|
||||
|
||||
gtk_box_set_spacing (GTK_BOX (selection), 2);
|
||||
gtk_box_set_homogeneous (GTK_BOX (selection), FALSE);
|
||||
gtk_box_set_spacing (GTK_BOX (entry), 4);
|
||||
gtk_box_set_homogeneous (GTK_BOX (entry), FALSE);
|
||||
|
||||
selection->browse_button = gtk_button_new_with_label (" ... ");
|
||||
gtk_box_pack_end (GTK_BOX (selection),
|
||||
selection->browse_button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (selection->browse_button);
|
||||
entry->browse_button = gtk_button_new_with_label (" ... ");
|
||||
gtk_box_pack_end (GTK_BOX (entry), entry->browse_button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (entry->browse_button);
|
||||
|
||||
g_signal_connect (selection->browse_button, "clicked",
|
||||
G_CALLBACK (gimp_file_selection_browse_clicked),
|
||||
selection);
|
||||
g_signal_connect (entry->browse_button, "clicked",
|
||||
G_CALLBACK (gimp_file_entry_browse_clicked),
|
||||
entry);
|
||||
|
||||
selection->entry = gtk_entry_new ();
|
||||
gtk_box_pack_end (GTK_BOX (selection), selection->entry, TRUE, TRUE, 0);
|
||||
gtk_widget_show (selection->entry);
|
||||
entry->entry = gtk_entry_new ();
|
||||
gtk_box_pack_end (GTK_BOX (entry), entry->entry, TRUE, TRUE, 0);
|
||||
gtk_widget_show (entry->entry);
|
||||
|
||||
g_signal_connect (selection->entry, "activate",
|
||||
G_CALLBACK (gimp_file_selection_entry_activate),
|
||||
selection);
|
||||
g_signal_connect (selection->entry, "focus_out_event",
|
||||
G_CALLBACK (gimp_file_selection_entry_focus_out),
|
||||
selection);
|
||||
g_signal_connect (entry->entry, "activate",
|
||||
G_CALLBACK (gimp_file_entry_entry_activate),
|
||||
entry);
|
||||
g_signal_connect (entry->entry, "focus_out_event",
|
||||
G_CALLBACK (gimp_file_entry_entry_focus_out),
|
||||
entry);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_file_selection_destroy (GtkObject *object)
|
||||
gimp_file_entry_destroy (GtkObject *object)
|
||||
{
|
||||
GimpFileSelection *selection = GIMP_FILE_SELECTION (object);
|
||||
GimpFileEntry *entry = GIMP_FILE_ENTRY (object);
|
||||
|
||||
if (selection->file_selection)
|
||||
if (entry->file_selection)
|
||||
{
|
||||
gtk_widget_destroy (selection->file_selection);
|
||||
selection->file_selection = NULL;
|
||||
gtk_widget_destroy (entry->file_selection);
|
||||
entry->file_selection = NULL;
|
||||
}
|
||||
|
||||
if (selection->title)
|
||||
if (entry->title)
|
||||
{
|
||||
g_free (selection->title);
|
||||
selection->title = NULL;
|
||||
g_free (entry->title);
|
||||
entry->title = NULL;
|
||||
}
|
||||
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_file_selection_new:
|
||||
* @title: The title of the #GtkFileSelection dialog.
|
||||
* gimp_file_entry_new:
|
||||
* @title: The title of the #GtkFileEntry dialog.
|
||||
* @filename: The initial filename.
|
||||
* @dir_only: %TRUE if the file selection should accept directories only.
|
||||
* @dir_only: %TRUE if the file entry should accept directories only.
|
||||
* @check_valid: %TRUE if the widget should check if the entered file
|
||||
* really exists.
|
||||
*
|
||||
* Creates a new #GimpFileSelection widget.
|
||||
* Creates a new #GimpFileEntry widget.
|
||||
*
|
||||
* Returns: A pointer to the new #GimpFileSelection widget.
|
||||
* Returns: A pointer to the new #GimpFileEntry widget.
|
||||
**/
|
||||
GtkWidget *
|
||||
gimp_file_selection_new (const gchar *title,
|
||||
gimp_file_entry_new (const gchar *title,
|
||||
const gchar *filename,
|
||||
gboolean dir_only,
|
||||
gboolean check_valid)
|
||||
{
|
||||
GimpFileSelection *selection;
|
||||
GimpFileEntry *entry;
|
||||
|
||||
selection = g_object_new (GIMP_TYPE_FILE_SELECTION, NULL);
|
||||
entry = g_object_new (GIMP_TYPE_FILE_ENTRY, NULL);
|
||||
|
||||
selection->title = g_strdup (title);
|
||||
selection->dir_only = dir_only;
|
||||
selection->check_valid = check_valid;
|
||||
entry->title = g_strdup (title);
|
||||
entry->dir_only = dir_only;
|
||||
entry->check_valid = check_valid;
|
||||
|
||||
if (check_valid)
|
||||
{
|
||||
selection->file_exists = gtk_image_new_from_stock (GTK_STOCK_NO,
|
||||
entry->file_exists = gtk_image_new_from_stock (GTK_STOCK_NO,
|
||||
GTK_ICON_SIZE_BUTTON);
|
||||
gtk_box_pack_start (GTK_BOX (selection),
|
||||
selection->file_exists, FALSE, FALSE, 0);
|
||||
gtk_widget_show (selection->file_exists);
|
||||
gtk_box_pack_start (GTK_BOX (entry), entry->file_exists, FALSE, FALSE, 0);
|
||||
gtk_widget_show (entry->file_exists);
|
||||
}
|
||||
|
||||
gimp_file_selection_set_filename (selection, filename);
|
||||
gimp_file_entry_set_filename (entry, filename);
|
||||
|
||||
return GTK_WIDGET (selection);
|
||||
return GTK_WIDGET (entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_file_selection_get_filename:
|
||||
* @selection: The file selection you want to know the filename from.
|
||||
* gimp_file_entry_get_filename:
|
||||
* @entry: The file entry you want to know the filename from.
|
||||
*
|
||||
* Note that you have to g_free() the returned string.
|
||||
*
|
||||
* Returns: The file or directory the user has entered.
|
||||
**/
|
||||
gchar *
|
||||
gimp_file_selection_get_filename (GimpFileSelection *selection)
|
||||
gimp_file_entry_get_filename (GimpFileEntry *entry)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_FILE_SELECTION (selection), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_FILE_ENTRY (entry), NULL);
|
||||
|
||||
return gtk_editable_get_chars (GTK_EDITABLE (selection->entry), 0, -1);
|
||||
return gtk_editable_get_chars (GTK_EDITABLE (entry->entry), 0, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_file_selection_set_filename:
|
||||
* @selection: The file selection you want to set the filename for.
|
||||
* gimp_file_entry_set_filename:
|
||||
* @entry: The file entry you want to set the filename for.
|
||||
* @filename: The new filename.
|
||||
*
|
||||
* If you specified @check_valid as %TRUE in gimp_file_selection_new()
|
||||
* the #GimpFileSelection will immediately check the validity of the file
|
||||
* If you specified @check_valid as %TRUE in gimp_file_entry_new()
|
||||
* the #GimpFileEntry will immediately check the validity of the file
|
||||
* name.
|
||||
*
|
||||
*/
|
||||
**/
|
||||
void
|
||||
gimp_file_selection_set_filename (GimpFileSelection *selection,
|
||||
gimp_file_entry_set_filename (GimpFileEntry *entry,
|
||||
const gchar *filename)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_FILE_SELECTION (selection));
|
||||
g_return_if_fail (GIMP_IS_FILE_ENTRY (entry));
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (selection->entry), filename ? filename : "");
|
||||
gtk_entry_set_text (GTK_ENTRY (entry->entry), filename ? filename : "");
|
||||
|
||||
/* update everything
|
||||
*/
|
||||
gimp_file_selection_entry_activate (selection->entry, selection);
|
||||
gimp_file_entry_entry_activate (entry->entry, entry);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_file_selection_entry_activate (GtkWidget *widget,
|
||||
GimpFileSelection *selection)
|
||||
gimp_file_entry_entry_activate (GtkWidget *widget,
|
||||
GimpFileEntry *entry)
|
||||
{
|
||||
gchar *filename;
|
||||
gint len;
|
||||
@ -267,41 +264,41 @@ gimp_file_selection_entry_activate (GtkWidget *widget,
|
||||
(filename[len - 1] == G_DIR_SEPARATOR))
|
||||
filename[len - 1] = '\0';
|
||||
|
||||
g_signal_handlers_block_by_func (selection->entry,
|
||||
gimp_file_selection_entry_activate,
|
||||
selection);
|
||||
gtk_entry_set_text (GTK_ENTRY (selection->entry), filename);
|
||||
g_signal_handlers_unblock_by_func (selection->entry,
|
||||
gimp_file_selection_entry_activate,
|
||||
selection);
|
||||
g_signal_handlers_block_by_func (entry->entry,
|
||||
gimp_file_entry_entry_activate,
|
||||
entry);
|
||||
gtk_entry_set_text (GTK_ENTRY (entry->entry), filename);
|
||||
g_signal_handlers_unblock_by_func (entry->entry,
|
||||
gimp_file_entry_entry_activate,
|
||||
entry);
|
||||
|
||||
if (selection->file_selection)
|
||||
gtk_file_selection_set_filename (GTK_FILE_SELECTION (selection->file_selection),
|
||||
if (entry->file_selection)
|
||||
gtk_file_selection_set_filename (GTK_FILE_SELECTION (entry->file_selection),
|
||||
filename);
|
||||
g_free (filename);
|
||||
|
||||
gimp_file_selection_check_filename (selection);
|
||||
gimp_file_entry_check_filename (entry);
|
||||
|
||||
gtk_editable_set_position (GTK_EDITABLE (selection->entry), -1);
|
||||
gtk_editable_set_position (GTK_EDITABLE (entry->entry), -1);
|
||||
|
||||
g_signal_emit (selection, gimp_file_selection_signals[FILENAME_CHANGED], 0);
|
||||
g_signal_emit (entry, gimp_file_entry_signals[FILENAME_CHANGED], 0);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_file_selection_entry_focus_out (GtkWidget *widget,
|
||||
gimp_file_entry_entry_focus_out (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
GimpFileSelection *selection)
|
||||
GimpFileEntry *entry)
|
||||
{
|
||||
gimp_file_selection_entry_activate (widget, selection);
|
||||
gimp_file_entry_entry_activate (widget, entry);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* local callback of gimp_file_selection_browse_clicked() */
|
||||
/* local callback of gimp_file_entry_browse_clicked() */
|
||||
static void
|
||||
gimp_file_selection_filesel_response (GtkWidget *dialog,
|
||||
gimp_file_entry_filesel_response (GtkWidget *dialog,
|
||||
gint response_id,
|
||||
GimpFileSelection *selection)
|
||||
GimpFileEntry *entry)
|
||||
{
|
||||
if (response_id == GTK_RESPONSE_OK)
|
||||
{
|
||||
@ -309,96 +306,95 @@ gimp_file_selection_filesel_response (GtkWidget *dialog,
|
||||
|
||||
filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (dialog));
|
||||
|
||||
gimp_file_selection_set_filename (selection, filename);
|
||||
gimp_file_entry_set_filename (entry, filename);
|
||||
}
|
||||
|
||||
gtk_widget_hide (selection->file_selection);
|
||||
|
||||
gtk_widget_hide (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_file_selection_browse_clicked (GtkWidget *widget,
|
||||
GimpFileSelection *selection)
|
||||
gimp_file_entry_browse_clicked (GtkWidget *widget,
|
||||
GimpFileEntry *entry)
|
||||
{
|
||||
gchar *filename;
|
||||
|
||||
filename = gtk_editable_get_chars (GTK_EDITABLE (selection->entry), 0, -1);
|
||||
filename = gtk_editable_get_chars (GTK_EDITABLE (entry->entry), 0, -1);
|
||||
|
||||
if (! selection->file_selection)
|
||||
if (! entry->file_selection)
|
||||
{
|
||||
GtkFileSelection *filesel;
|
||||
|
||||
if (selection->dir_only)
|
||||
if (entry->dir_only)
|
||||
{
|
||||
selection->file_selection =
|
||||
gtk_file_selection_new (selection->title ?
|
||||
selection->title : _("Select Folder"));
|
||||
entry->file_selection = gtk_file_selection_new (entry->title ?
|
||||
entry->title :
|
||||
_("Select Folder"));
|
||||
|
||||
/* hiding these widgets uses internal gtk+ knowledge, but it's
|
||||
* easier than creating my own directory browser -- michael
|
||||
*/
|
||||
gtk_widget_hide
|
||||
(GTK_FILE_SELECTION (selection->file_selection)->fileop_del_file);
|
||||
(GTK_FILE_SELECTION (entry->file_selection)->fileop_del_file);
|
||||
gtk_widget_hide
|
||||
(GTK_FILE_SELECTION (selection->file_selection)->file_list->parent);
|
||||
(GTK_FILE_SELECTION (entry->file_selection)->file_list->parent);
|
||||
}
|
||||
else
|
||||
{
|
||||
selection->file_selection =
|
||||
gtk_file_selection_new (selection->title ?
|
||||
selection->title : _("Select File"));
|
||||
entry->file_selection = gtk_file_selection_new (entry->title ?
|
||||
entry->title :
|
||||
_("Select File"));
|
||||
}
|
||||
|
||||
filesel = GTK_FILE_SELECTION (selection->file_selection);
|
||||
filesel = GTK_FILE_SELECTION (entry->file_selection);
|
||||
|
||||
gtk_window_set_position (GTK_WINDOW (selection->file_selection),
|
||||
gtk_window_set_position (GTK_WINDOW (entry->file_selection),
|
||||
GTK_WIN_POS_MOUSE);
|
||||
gtk_window_set_role (GTK_WINDOW (selection->file_selection),
|
||||
gtk_window_set_role (GTK_WINDOW (entry->file_selection),
|
||||
"gimp-file-entry-file-selection");
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (filesel), 6);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (filesel->button_area), 4);
|
||||
|
||||
g_signal_connect (filesel, "response",
|
||||
G_CALLBACK (gimp_file_selection_filesel_response),
|
||||
selection);
|
||||
G_CALLBACK (gimp_file_entry_filesel_response),
|
||||
entry);
|
||||
g_signal_connect (filesel, "delete_event",
|
||||
G_CALLBACK (gtk_true),
|
||||
NULL);
|
||||
|
||||
g_signal_connect_swapped (selection, "unmap",
|
||||
g_signal_connect_swapped (entry, "unmap",
|
||||
G_CALLBACK (gtk_widget_hide),
|
||||
filesel);
|
||||
}
|
||||
|
||||
gtk_file_selection_set_filename
|
||||
(GTK_FILE_SELECTION (selection->file_selection), filename);
|
||||
gtk_file_selection_set_filename (GTK_FILE_SELECTION (entry->file_selection),
|
||||
filename);
|
||||
|
||||
gtk_window_set_screen (GTK_WINDOW (selection->file_selection),
|
||||
gtk_window_set_screen (GTK_WINDOW (entry->file_selection),
|
||||
gtk_widget_get_screen (widget));
|
||||
|
||||
gtk_window_present (GTK_WINDOW (selection->file_selection));
|
||||
gtk_window_present (GTK_WINDOW (entry->file_selection));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_file_selection_check_filename (GimpFileSelection *selection)
|
||||
gimp_file_entry_check_filename (GimpFileEntry *entry)
|
||||
{
|
||||
gchar *filename;
|
||||
gboolean exists;
|
||||
|
||||
if (! selection->check_valid || ! selection->file_exists)
|
||||
if (! entry->check_valid || ! entry->file_exists)
|
||||
return;
|
||||
|
||||
filename = gtk_editable_get_chars (GTK_EDITABLE (selection->entry), 0, -1);
|
||||
filename = gtk_editable_get_chars (GTK_EDITABLE (entry->entry), 0, -1);
|
||||
|
||||
if (selection->dir_only)
|
||||
if (entry->dir_only)
|
||||
exists = g_file_test (filename, G_FILE_TEST_IS_DIR);
|
||||
else
|
||||
exists = g_file_test (filename, G_FILE_TEST_IS_REGULAR);
|
||||
|
||||
g_free (filename);
|
||||
|
||||
gtk_image_set_from_stock (GTK_IMAGE (selection->file_exists),
|
||||
gtk_image_set_from_stock (GTK_IMAGE (entry->file_exists),
|
||||
exists ? GTK_STOCK_YES : GTK_STOCK_NO,
|
||||
GTK_ICON_SIZE_BUTTON);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpfileselection.h
|
||||
* Copyright (C) 1999 Michael Natterer <mitch@gimp.org>
|
||||
* gimpfileentry.h
|
||||
* Copyright (C) 1999-2003 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,25 +20,25 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_FILE_SELECTION_H__
|
||||
#define __GIMP_FILE_SELECTION_H__
|
||||
#ifndef __GIMP_FILE_ENTRY_H__
|
||||
#define __GIMP_FILE_ENTRY_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* For information look into the C source or the html documentation */
|
||||
|
||||
|
||||
#define GIMP_TYPE_FILE_SELECTION (gimp_file_selection_get_type ())
|
||||
#define GIMP_FILE_SELECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_FILE_SELECTION, GimpFileSelection))
|
||||
#define GIMP_FILE_SELECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_FILE_SELECTION, GimpFileSelectionClass))
|
||||
#define GIMP_IS_FILE_SELECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GIMP_TYPE_FILE_SELECTION))
|
||||
#define GIMP_IS_FILE_SELECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_FILE_SELECTION))
|
||||
#define GIMP_FILE_SELECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_FILE_SELECTION, GimpFileSelectionClass))
|
||||
#define GIMP_TYPE_FILE_ENTRY (gimp_file_entry_get_type ())
|
||||
#define GIMP_FILE_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_FILE_ENTRY, GimpFileEntry))
|
||||
#define GIMP_FILE_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_FILE_ENTRY, GimpFileEntryClass))
|
||||
#define GIMP_IS_FILE_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GIMP_TYPE_FILE_ENTRY))
|
||||
#define GIMP_IS_FILE_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_FILE_ENTRY))
|
||||
#define GIMP_FILE_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_FILE_ENTRY, GimpFileEntryClass))
|
||||
|
||||
|
||||
typedef struct _GimpFileSelectionClass GimpFileSelectionClass;
|
||||
typedef struct _GimpFileEntryClass GimpFileEntryClass;
|
||||
|
||||
struct _GimpFileSelection
|
||||
struct _GimpFileEntry
|
||||
{
|
||||
GtkHBox parent_instance;
|
||||
|
||||
@ -53,27 +53,26 @@ struct _GimpFileSelection
|
||||
gboolean check_valid;
|
||||
};
|
||||
|
||||
struct _GimpFileSelectionClass
|
||||
struct _GimpFileEntryClass
|
||||
{
|
||||
GtkHBoxClass parent_class;
|
||||
|
||||
void (* filename_changed) (GimpFileSelection *selection);
|
||||
void (* filename_changed) (GimpFileEntry *entry);
|
||||
};
|
||||
|
||||
|
||||
GType gimp_file_selection_get_type (void) G_GNUC_CONST;
|
||||
GType gimp_file_entry_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_file_selection_new (const gchar *title,
|
||||
GtkWidget * gimp_file_entry_new (const gchar *title,
|
||||
const gchar *filename,
|
||||
gboolean dir_only,
|
||||
gboolean check_valid);
|
||||
|
||||
gchar * gimp_file_selection_get_filename (GimpFileSelection *selection);
|
||||
|
||||
void gimp_file_selection_set_filename (GimpFileSelection *selection,
|
||||
gchar * gimp_file_entry_get_filename (GimpFileEntry *entry);
|
||||
void gimp_file_entry_set_filename (GimpFileEntry *entry,
|
||||
const gchar *filename);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GIMP_FILE_SELECTION_H__ */
|
||||
#endif /* __GIMP_FILE_ENTRY_H__ */
|
||||
|
@ -1,404 +0,0 @@
|
||||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpfileselection.c
|
||||
* Copyright (C) 1999-2000 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h> /* Needed here by Win32 gcc compilation */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gimpwidgetstypes.h"
|
||||
|
||||
#include "gimpfileselection.h"
|
||||
|
||||
#include "libgimp/libgimp-intl.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
FILENAME_CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
||||
static void gimp_file_selection_class_init (GimpFileSelectionClass *klass);
|
||||
static void gimp_file_selection_init (GimpFileSelection *selection);
|
||||
|
||||
static void gimp_file_selection_destroy (GtkObject *object);
|
||||
|
||||
static void gimp_file_selection_entry_activate (GtkWidget *widget,
|
||||
GimpFileSelection *selection);
|
||||
static gint gimp_file_selection_entry_focus_out (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
GimpFileSelection *selection);
|
||||
static void gimp_file_selection_browse_clicked (GtkWidget *widget,
|
||||
GimpFileSelection *selection);
|
||||
static void gimp_file_selection_check_filename (GimpFileSelection *selection);
|
||||
|
||||
|
||||
static guint gimp_file_selection_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static GtkHBoxClass *parent_class = NULL;
|
||||
|
||||
|
||||
GType
|
||||
gimp_file_selection_get_type (void)
|
||||
{
|
||||
static GType selection_type = 0;
|
||||
|
||||
if (! selection_type)
|
||||
{
|
||||
static const GTypeInfo selection_info =
|
||||
{
|
||||
sizeof (GimpFileSelectionClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gimp_file_selection_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpFileSelection),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_file_selection_init,
|
||||
};
|
||||
|
||||
selection_type = g_type_register_static (GTK_TYPE_HBOX,
|
||||
"GimpFileSelection",
|
||||
&selection_info, 0);
|
||||
}
|
||||
|
||||
return selection_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_file_selection_class_init (GimpFileSelectionClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
object_class = (GtkObjectClass *) klass;
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
gimp_file_selection_signals[FILENAME_CHANGED] =
|
||||
g_signal_new ("filename_changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpFileSelectionClass, filename_changed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
object_class->destroy = gimp_file_selection_destroy;
|
||||
|
||||
klass->filename_changed = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_file_selection_init (GimpFileSelection *selection)
|
||||
{
|
||||
selection->title = NULL;
|
||||
selection->file_selection = NULL;
|
||||
selection->check_valid = FALSE;
|
||||
|
||||
selection->file_exists = NULL;
|
||||
|
||||
gtk_box_set_spacing (GTK_BOX (selection), 2);
|
||||
gtk_box_set_homogeneous (GTK_BOX (selection), FALSE);
|
||||
|
||||
selection->browse_button = gtk_button_new_with_label (" ... ");
|
||||
gtk_box_pack_end (GTK_BOX (selection),
|
||||
selection->browse_button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (selection->browse_button);
|
||||
|
||||
g_signal_connect (selection->browse_button, "clicked",
|
||||
G_CALLBACK (gimp_file_selection_browse_clicked),
|
||||
selection);
|
||||
|
||||
selection->entry = gtk_entry_new ();
|
||||
gtk_box_pack_end (GTK_BOX (selection), selection->entry, TRUE, TRUE, 0);
|
||||
gtk_widget_show (selection->entry);
|
||||
|
||||
g_signal_connect (selection->entry, "activate",
|
||||
G_CALLBACK (gimp_file_selection_entry_activate),
|
||||
selection);
|
||||
g_signal_connect (selection->entry, "focus_out_event",
|
||||
G_CALLBACK (gimp_file_selection_entry_focus_out),
|
||||
selection);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_file_selection_destroy (GtkObject *object)
|
||||
{
|
||||
GimpFileSelection *selection = GIMP_FILE_SELECTION (object);
|
||||
|
||||
if (selection->file_selection)
|
||||
{
|
||||
gtk_widget_destroy (selection->file_selection);
|
||||
selection->file_selection = NULL;
|
||||
}
|
||||
|
||||
if (selection->title)
|
||||
{
|
||||
g_free (selection->title);
|
||||
selection->title = NULL;
|
||||
}
|
||||
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_file_selection_new:
|
||||
* @title: The title of the #GtkFileSelection dialog.
|
||||
* @filename: The initial filename.
|
||||
* @dir_only: %TRUE if the file selection should accept directories only.
|
||||
* @check_valid: %TRUE if the widget should check if the entered file
|
||||
* really exists.
|
||||
*
|
||||
* Creates a new #GimpFileSelection widget.
|
||||
*
|
||||
* Returns: A pointer to the new #GimpFileSelection widget.
|
||||
**/
|
||||
GtkWidget *
|
||||
gimp_file_selection_new (const gchar *title,
|
||||
const gchar *filename,
|
||||
gboolean dir_only,
|
||||
gboolean check_valid)
|
||||
{
|
||||
GimpFileSelection *selection;
|
||||
|
||||
selection = g_object_new (GIMP_TYPE_FILE_SELECTION, NULL);
|
||||
|
||||
selection->title = g_strdup (title);
|
||||
selection->dir_only = dir_only;
|
||||
selection->check_valid = check_valid;
|
||||
|
||||
if (check_valid)
|
||||
{
|
||||
selection->file_exists = gtk_image_new_from_stock (GTK_STOCK_NO,
|
||||
GTK_ICON_SIZE_BUTTON);
|
||||
gtk_box_pack_start (GTK_BOX (selection),
|
||||
selection->file_exists, FALSE, FALSE, 0);
|
||||
gtk_widget_show (selection->file_exists);
|
||||
}
|
||||
|
||||
gimp_file_selection_set_filename (selection, filename);
|
||||
|
||||
return GTK_WIDGET (selection);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_file_selection_get_filename:
|
||||
* @selection: The file selection you want to know the filename from.
|
||||
*
|
||||
* Note that you have to g_free() the returned string.
|
||||
*
|
||||
* Returns: The file or directory the user has entered.
|
||||
**/
|
||||
gchar *
|
||||
gimp_file_selection_get_filename (GimpFileSelection *selection)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_FILE_SELECTION (selection), NULL);
|
||||
|
||||
return gtk_editable_get_chars (GTK_EDITABLE (selection->entry), 0, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_file_selection_set_filename:
|
||||
* @selection: The file selection you want to set the filename for.
|
||||
* @filename: The new filename.
|
||||
*
|
||||
* If you specified @check_valid as %TRUE in gimp_file_selection_new()
|
||||
* the #GimpFileSelection will immediately check the validity of the file
|
||||
* name.
|
||||
*
|
||||
*/
|
||||
void
|
||||
gimp_file_selection_set_filename (GimpFileSelection *selection,
|
||||
const gchar *filename)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_FILE_SELECTION (selection));
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (selection->entry), filename ? filename : "");
|
||||
|
||||
/* update everything
|
||||
*/
|
||||
gimp_file_selection_entry_activate (selection->entry, selection);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_file_selection_entry_activate (GtkWidget *widget,
|
||||
GimpFileSelection *selection)
|
||||
{
|
||||
gchar *filename;
|
||||
gint len;
|
||||
|
||||
/* filenames still need more sanity checking
|
||||
* (erase double G_DIR_SEPARATORS, ...)
|
||||
*/
|
||||
filename = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
|
||||
filename = g_strstrip (filename);
|
||||
|
||||
while (((len = strlen (filename)) > 1) &&
|
||||
(filename[len - 1] == G_DIR_SEPARATOR))
|
||||
filename[len - 1] = '\0';
|
||||
|
||||
g_signal_handlers_block_by_func (selection->entry,
|
||||
gimp_file_selection_entry_activate,
|
||||
selection);
|
||||
gtk_entry_set_text (GTK_ENTRY (selection->entry), filename);
|
||||
g_signal_handlers_unblock_by_func (selection->entry,
|
||||
gimp_file_selection_entry_activate,
|
||||
selection);
|
||||
|
||||
if (selection->file_selection)
|
||||
gtk_file_selection_set_filename (GTK_FILE_SELECTION (selection->file_selection),
|
||||
filename);
|
||||
g_free (filename);
|
||||
|
||||
gimp_file_selection_check_filename (selection);
|
||||
|
||||
gtk_editable_set_position (GTK_EDITABLE (selection->entry), -1);
|
||||
|
||||
g_signal_emit (selection, gimp_file_selection_signals[FILENAME_CHANGED], 0);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_file_selection_entry_focus_out (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
GimpFileSelection *selection)
|
||||
{
|
||||
gimp_file_selection_entry_activate (widget, selection);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* local callback of gimp_file_selection_browse_clicked() */
|
||||
static void
|
||||
gimp_file_selection_filesel_response (GtkWidget *dialog,
|
||||
gint response_id,
|
||||
GimpFileSelection *selection)
|
||||
{
|
||||
if (response_id == GTK_RESPONSE_OK)
|
||||
{
|
||||
const gchar *filename;
|
||||
|
||||
filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (dialog));
|
||||
|
||||
gimp_file_selection_set_filename (selection, filename);
|
||||
}
|
||||
|
||||
gtk_widget_hide (selection->file_selection);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_file_selection_browse_clicked (GtkWidget *widget,
|
||||
GimpFileSelection *selection)
|
||||
{
|
||||
gchar *filename;
|
||||
|
||||
filename = gtk_editable_get_chars (GTK_EDITABLE (selection->entry), 0, -1);
|
||||
|
||||
if (! selection->file_selection)
|
||||
{
|
||||
GtkFileSelection *filesel;
|
||||
|
||||
if (selection->dir_only)
|
||||
{
|
||||
selection->file_selection =
|
||||
gtk_file_selection_new (selection->title ?
|
||||
selection->title : _("Select Folder"));
|
||||
|
||||
/* hiding these widgets uses internal gtk+ knowledge, but it's
|
||||
* easier than creating my own directory browser -- michael
|
||||
*/
|
||||
gtk_widget_hide
|
||||
(GTK_FILE_SELECTION (selection->file_selection)->fileop_del_file);
|
||||
gtk_widget_hide
|
||||
(GTK_FILE_SELECTION (selection->file_selection)->file_list->parent);
|
||||
}
|
||||
else
|
||||
{
|
||||
selection->file_selection =
|
||||
gtk_file_selection_new (selection->title ?
|
||||
selection->title : _("Select File"));
|
||||
}
|
||||
|
||||
filesel = GTK_FILE_SELECTION (selection->file_selection);
|
||||
|
||||
gtk_window_set_position (GTK_WINDOW (selection->file_selection),
|
||||
GTK_WIN_POS_MOUSE);
|
||||
gtk_window_set_role (GTK_WINDOW (selection->file_selection),
|
||||
"gimp-file-entry-file-selection");
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (filesel), 6);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (filesel->button_area), 4);
|
||||
|
||||
g_signal_connect (filesel, "response",
|
||||
G_CALLBACK (gimp_file_selection_filesel_response),
|
||||
selection);
|
||||
g_signal_connect (filesel, "delete_event",
|
||||
G_CALLBACK (gtk_true),
|
||||
NULL);
|
||||
|
||||
g_signal_connect_swapped (selection, "unmap",
|
||||
G_CALLBACK (gtk_widget_hide),
|
||||
filesel);
|
||||
}
|
||||
|
||||
gtk_file_selection_set_filename
|
||||
(GTK_FILE_SELECTION (selection->file_selection), filename);
|
||||
|
||||
gtk_window_set_screen (GTK_WINDOW (selection->file_selection),
|
||||
gtk_widget_get_screen (widget));
|
||||
|
||||
gtk_window_present (GTK_WINDOW (selection->file_selection));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_file_selection_check_filename (GimpFileSelection *selection)
|
||||
{
|
||||
gchar *filename;
|
||||
gboolean exists;
|
||||
|
||||
if (! selection->check_valid || ! selection->file_exists)
|
||||
return;
|
||||
|
||||
filename = gtk_editable_get_chars (GTK_EDITABLE (selection->entry), 0, -1);
|
||||
|
||||
if (selection->dir_only)
|
||||
exists = g_file_test (filename, G_FILE_TEST_IS_DIR);
|
||||
else
|
||||
exists = g_file_test (filename, G_FILE_TEST_IS_REGULAR);
|
||||
|
||||
g_free (filename);
|
||||
|
||||
gtk_image_set_from_stock (GTK_IMAGE (selection->file_exists),
|
||||
exists ? GTK_STOCK_YES : GTK_STOCK_NO,
|
||||
GTK_ICON_SIZE_BUTTON);
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpfileselection.h
|
||||
* Copyright (C) 1999 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_FILE_SELECTION_H__
|
||||
#define __GIMP_FILE_SELECTION_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* For information look into the C source or the html documentation */
|
||||
|
||||
|
||||
#define GIMP_TYPE_FILE_SELECTION (gimp_file_selection_get_type ())
|
||||
#define GIMP_FILE_SELECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_FILE_SELECTION, GimpFileSelection))
|
||||
#define GIMP_FILE_SELECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_FILE_SELECTION, GimpFileSelectionClass))
|
||||
#define GIMP_IS_FILE_SELECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GIMP_TYPE_FILE_SELECTION))
|
||||
#define GIMP_IS_FILE_SELECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_FILE_SELECTION))
|
||||
#define GIMP_FILE_SELECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_FILE_SELECTION, GimpFileSelectionClass))
|
||||
|
||||
|
||||
typedef struct _GimpFileSelectionClass GimpFileSelectionClass;
|
||||
|
||||
struct _GimpFileSelection
|
||||
{
|
||||
GtkHBox parent_instance;
|
||||
|
||||
GtkWidget *file_exists;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *browse_button;
|
||||
|
||||
GtkWidget *file_selection;
|
||||
|
||||
gchar *title;
|
||||
gboolean dir_only;
|
||||
gboolean check_valid;
|
||||
};
|
||||
|
||||
struct _GimpFileSelectionClass
|
||||
{
|
||||
GtkHBoxClass parent_class;
|
||||
|
||||
void (* filename_changed) (GimpFileSelection *selection);
|
||||
};
|
||||
|
||||
|
||||
GType gimp_file_selection_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_file_selection_new (const gchar *title,
|
||||
const gchar *filename,
|
||||
gboolean dir_only,
|
||||
gboolean check_valid);
|
||||
|
||||
gchar * gimp_file_selection_get_filename (GimpFileSelection *selection);
|
||||
|
||||
void gimp_file_selection_set_filename (GimpFileSelection *selection,
|
||||
const gchar *filename);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GIMP_FILE_SELECTION_H__ */
|
@ -2,7 +2,7 @@
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimppatheditor.c
|
||||
* Copyright (C) 1999 Michael Natterer <mitch@gimp.org>
|
||||
* Copyright (C) 1999-2003 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -29,8 +29,7 @@
|
||||
#include "gimpwidgetstypes.h"
|
||||
|
||||
#include "gimppatheditor.h"
|
||||
#include "gimpfileselection.h"
|
||||
#include "gimpwidgets.h"
|
||||
#include "gimpfileentry.h"
|
||||
|
||||
|
||||
enum
|
||||
@ -43,16 +42,16 @@ enum
|
||||
static void gimp_path_editor_class_init (GimpPathEditorClass *klass);
|
||||
static void gimp_path_editor_init (GimpPathEditor *gpe);
|
||||
|
||||
static void gimp_path_editor_select_callback (GtkTreeSelection *sel,
|
||||
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);
|
||||
static void gimp_path_editor_new_clicked (GtkWidget *widget,
|
||||
GimpPathEditor *gpe);
|
||||
static void gimp_path_editor_move_clicked (GtkWidget *widget,
|
||||
GimpPathEditor *gpe);
|
||||
static void gimp_path_editor_delete_clicked (GtkWidget *widget,
|
||||
GimpPathEditor *gpe);
|
||||
static void gimp_path_editor_file_entry_changed (GtkWidget *widget,
|
||||
GimpPathEditor *gpe);
|
||||
static void gimp_path_editor_selection_changed (GtkTreeSelection *sel,
|
||||
GimpPathEditor *gpe);
|
||||
|
||||
static gboolean build_path (GtkTreeModel *model,
|
||||
GtkTreePath *tpath,
|
||||
@ -119,7 +118,7 @@ gimp_path_editor_init (GimpPathEditor *gpe)
|
||||
GtkWidget *scrolled_window;
|
||||
GtkWidget *tv;
|
||||
|
||||
gpe->file_selection = NULL;
|
||||
gpe->file_entry = NULL;
|
||||
gpe->sel_path = NULL;
|
||||
gpe->num_items = 0;
|
||||
|
||||
@ -140,7 +139,7 @@ gimp_path_editor_init (GimpPathEditor *gpe)
|
||||
gtk_widget_show (image);
|
||||
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (gimp_path_editor_new_callback),
|
||||
G_CALLBACK (gimp_path_editor_new_clicked),
|
||||
gpe);
|
||||
|
||||
gpe->up_button = button = gtk_button_new ();
|
||||
@ -153,7 +152,7 @@ gimp_path_editor_init (GimpPathEditor *gpe)
|
||||
gtk_widget_show (image);
|
||||
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (gimp_path_editor_move_callback),
|
||||
G_CALLBACK (gimp_path_editor_move_clicked),
|
||||
gpe);
|
||||
|
||||
gpe->down_button = button = gtk_button_new ();
|
||||
@ -166,7 +165,7 @@ gimp_path_editor_init (GimpPathEditor *gpe)
|
||||
gtk_widget_show (image);
|
||||
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (gimp_path_editor_move_callback),
|
||||
G_CALLBACK (gimp_path_editor_move_clicked),
|
||||
gpe);
|
||||
|
||||
gpe->delete_button = button = gtk_button_new ();
|
||||
@ -179,7 +178,7 @@ gimp_path_editor_init (GimpPathEditor *gpe)
|
||||
gtk_widget_show (image);
|
||||
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (gimp_path_editor_delete_callback),
|
||||
G_CALLBACK (gimp_path_editor_delete_clicked),
|
||||
gpe);
|
||||
|
||||
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
||||
@ -208,7 +207,7 @@ gimp_path_editor_init (GimpPathEditor *gpe)
|
||||
|
||||
gpe->sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (tv));
|
||||
g_signal_connect (gpe->sel, "changed",
|
||||
G_CALLBACK (gimp_path_editor_select_callback),
|
||||
G_CALLBACK (gimp_path_editor_selection_changed),
|
||||
gpe);
|
||||
}
|
||||
|
||||
@ -235,14 +234,14 @@ gimp_path_editor_new (const gchar *filesel_title,
|
||||
|
||||
gpe = g_object_new (GIMP_TYPE_PATH_EDITOR, NULL);
|
||||
|
||||
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,
|
||||
gpe->file_entry = gimp_file_entry_new (filesel_title, "", TRUE, TRUE);
|
||||
gtk_widget_set_sensitive (gpe->file_entry, FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (gpe->upper_hbox), gpe->file_entry,
|
||||
TRUE, TRUE, 0);
|
||||
gtk_widget_show (gpe->file_selection);
|
||||
gtk_widget_show (gpe->file_entry);
|
||||
|
||||
g_signal_connect (gpe->file_selection, "filename_changed",
|
||||
G_CALLBACK (gimp_path_editor_filesel_callback),
|
||||
g_signal_connect (gpe->file_entry, "filename_changed",
|
||||
G_CALLBACK (gimp_path_editor_file_entry_changed),
|
||||
gpe);
|
||||
|
||||
if (path)
|
||||
@ -251,27 +250,6 @@ gimp_path_editor_new (const gchar *filesel_title,
|
||||
return GTK_WIDGET (gpe);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
build_path (GtkTreeModel *model,
|
||||
GtkTreePath *tpath,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
{
|
||||
gchar *buf;
|
||||
GString *path = data;
|
||||
|
||||
gtk_tree_model_get (model, iter, 0, &buf, -1);
|
||||
|
||||
if (path->len > 0)
|
||||
g_string_append_c (path, G_SEARCHPATH_SEPARATOR);
|
||||
|
||||
g_string_append (path, buf);
|
||||
|
||||
g_free (buf);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_path_editor_get_path:
|
||||
* @gpe: The path editor you want to get the search path from.
|
||||
@ -342,73 +320,24 @@ gimp_path_editor_set_path (GimpPathEditor *gpe,
|
||||
g_free (mypath);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_path_editor_select_callback (GtkTreeSelection *sel,
|
||||
gpointer data)
|
||||
{
|
||||
GimpPathEditor *gpe = GIMP_PATH_EDITOR (data);
|
||||
GtkTreeIter iter;
|
||||
gchar *directory;
|
||||
gint *indices;
|
||||
|
||||
if (gtk_tree_selection_get_selected (sel, NULL, &iter))
|
||||
{
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (gpe->dir_list), &iter,
|
||||
0, &directory,
|
||||
-1);
|
||||
|
||||
g_signal_handlers_block_by_func (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 (gpe->file_selection,
|
||||
gimp_path_editor_filesel_callback,
|
||||
gpe);
|
||||
|
||||
g_free (directory);
|
||||
|
||||
if (gpe->sel_path)
|
||||
gtk_tree_path_free (gpe->sel_path);
|
||||
|
||||
gpe->sel_path = gtk_tree_model_get_path (GTK_TREE_MODEL (gpe->dir_list),
|
||||
&iter);
|
||||
|
||||
indices = gtk_tree_path_get_indices (gpe->sel_path);
|
||||
|
||||
gtk_widget_set_sensitive (gpe->delete_button, TRUE);
|
||||
gtk_widget_set_sensitive (gpe->up_button, (indices[0] > 0));
|
||||
gtk_widget_set_sensitive (gpe->down_button,
|
||||
(indices[0] < (gpe->num_items - 1)));
|
||||
gtk_widget_set_sensitive (gpe->file_selection, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_signal_handlers_block_by_func (sel,
|
||||
gimp_path_editor_select_callback,
|
||||
gpe);
|
||||
gtk_tree_selection_select_path (gpe->sel, gpe->sel_path);
|
||||
g_signal_handlers_unblock_by_func (sel,
|
||||
gimp_path_editor_select_callback,
|
||||
gpe);
|
||||
}
|
||||
}
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
gimp_path_editor_new_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
gimp_path_editor_new_clicked (GtkWidget *widget,
|
||||
GimpPathEditor *gpe)
|
||||
{
|
||||
GimpPathEditor *gpe;
|
||||
|
||||
gpe = GIMP_PATH_EDITOR (data);
|
||||
|
||||
if (gpe->sel_path)
|
||||
{
|
||||
g_signal_handlers_block_by_func (gpe->sel,
|
||||
gimp_path_editor_select_callback, gpe);
|
||||
gimp_path_editor_selection_changed,
|
||||
gpe);
|
||||
|
||||
gtk_tree_selection_unselect_path (gpe->sel, gpe->sel_path);
|
||||
|
||||
g_signal_handlers_unblock_by_func (gpe->sel,
|
||||
gimp_path_editor_select_callback, gpe);
|
||||
gimp_path_editor_selection_changed,
|
||||
gpe);
|
||||
|
||||
gtk_tree_path_free (gpe->sel_path);
|
||||
gpe->sel_path = NULL;
|
||||
@ -417,19 +346,18 @@ gimp_path_editor_new_callback (GtkWidget *widget,
|
||||
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_widget_set_sensitive (gpe->file_entry, TRUE);
|
||||
|
||||
gtk_editable_set_position
|
||||
(GTK_EDITABLE (GIMP_FILE_SELECTION (gpe->file_selection)->entry), -1);
|
||||
(GTK_EDITABLE (GIMP_FILE_ENTRY (gpe->file_entry)->entry), -1);
|
||||
gtk_widget_grab_focus
|
||||
(GTK_WIDGET (GIMP_FILE_SELECTION (gpe->file_selection)->entry));
|
||||
(GTK_WIDGET (GIMP_FILE_ENTRY (gpe->file_entry)->entry));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_path_editor_move_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
gimp_path_editor_move_clicked (GtkWidget *widget,
|
||||
GimpPathEditor *gpe)
|
||||
{
|
||||
GimpPathEditor *gpe = GIMP_PATH_EDITOR (data);
|
||||
GtkTreePath *path;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter1, iter2;
|
||||
@ -465,12 +393,11 @@ gimp_path_editor_move_callback (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_path_editor_delete_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
gimp_path_editor_delete_clicked (GtkWidget *widget,
|
||||
GimpPathEditor *gpe)
|
||||
{
|
||||
GimpPathEditor *gpe = GIMP_PATH_EDITOR (data);
|
||||
gint *indices;
|
||||
GtkTreeIter iter;
|
||||
gint *indices;
|
||||
|
||||
if (gpe->sel_path == NULL)
|
||||
return;
|
||||
@ -486,19 +413,20 @@ gimp_path_editor_delete_callback (GtkWidget *widget,
|
||||
gtk_tree_path_free (gpe->sel_path);
|
||||
gpe->sel_path = NULL;
|
||||
|
||||
g_signal_handlers_block_by_func (gpe->file_selection,
|
||||
gimp_path_editor_filesel_callback,
|
||||
g_signal_handlers_block_by_func (gpe->file_entry,
|
||||
gimp_path_editor_file_entry_changed,
|
||||
gpe);
|
||||
gimp_file_selection_set_filename
|
||||
(GIMP_FILE_SELECTION (gpe->file_selection), "");
|
||||
g_signal_handlers_unblock_by_func (gpe->file_selection,
|
||||
gimp_path_editor_filesel_callback,
|
||||
|
||||
gimp_file_entry_set_filename (GIMP_FILE_ENTRY (gpe->file_entry), "");
|
||||
|
||||
g_signal_handlers_unblock_by_func (gpe->file_entry,
|
||||
gimp_path_editor_file_entry_changed,
|
||||
gpe);
|
||||
|
||||
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, FALSE);
|
||||
gtk_widget_set_sensitive (gpe->file_entry, FALSE);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -513,14 +441,13 @@ gimp_path_editor_delete_callback (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_path_editor_filesel_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
gimp_path_editor_file_entry_changed (GtkWidget *widget,
|
||||
GimpPathEditor *gpe)
|
||||
{
|
||||
GimpPathEditor *gpe = GIMP_PATH_EDITOR (data);
|
||||
gchar *directory;
|
||||
GtkTreeIter iter;
|
||||
|
||||
directory = gimp_file_selection_get_filename (GIMP_FILE_SELECTION (widget));
|
||||
directory = gimp_file_entry_get_filename (GIMP_FILE_ENTRY (widget));
|
||||
if (strcmp (directory, "") == 0)
|
||||
{
|
||||
g_free (directory);
|
||||
@ -546,3 +473,79 @@ gimp_path_editor_filesel_callback (GtkWidget *widget,
|
||||
|
||||
g_signal_emit (gpe, gimp_path_editor_signals[PATH_CHANGED], 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_path_editor_selection_changed (GtkTreeSelection *sel,
|
||||
GimpPathEditor *gpe)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
gchar *directory;
|
||||
gint *indices;
|
||||
|
||||
if (gtk_tree_selection_get_selected (sel, NULL, &iter))
|
||||
{
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (gpe->dir_list), &iter,
|
||||
0, &directory,
|
||||
-1);
|
||||
|
||||
g_signal_handlers_block_by_func (gpe->file_entry,
|
||||
gimp_path_editor_file_entry_changed,
|
||||
gpe);
|
||||
|
||||
gimp_file_entry_set_filename (GIMP_FILE_ENTRY (gpe->file_entry),
|
||||
directory);
|
||||
|
||||
g_signal_handlers_unblock_by_func (gpe->file_entry,
|
||||
gimp_path_editor_file_entry_changed,
|
||||
gpe);
|
||||
|
||||
g_free (directory);
|
||||
|
||||
if (gpe->sel_path)
|
||||
gtk_tree_path_free (gpe->sel_path);
|
||||
|
||||
gpe->sel_path = gtk_tree_model_get_path (GTK_TREE_MODEL (gpe->dir_list),
|
||||
&iter);
|
||||
|
||||
indices = gtk_tree_path_get_indices (gpe->sel_path);
|
||||
|
||||
gtk_widget_set_sensitive (gpe->delete_button, TRUE);
|
||||
gtk_widget_set_sensitive (gpe->up_button, (indices[0] > 0));
|
||||
gtk_widget_set_sensitive (gpe->down_button,
|
||||
(indices[0] < (gpe->num_items - 1)));
|
||||
gtk_widget_set_sensitive (gpe->file_entry, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_signal_handlers_block_by_func (sel,
|
||||
gimp_path_editor_selection_changed,
|
||||
gpe);
|
||||
|
||||
gtk_tree_selection_select_path (gpe->sel, gpe->sel_path);
|
||||
|
||||
g_signal_handlers_unblock_by_func (sel,
|
||||
gimp_path_editor_selection_changed,
|
||||
gpe);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
build_path (GtkTreeModel *model,
|
||||
GtkTreePath *tpath,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
{
|
||||
gchar *buf;
|
||||
GString *path = data;
|
||||
|
||||
gtk_tree_model_get (model, iter, 0, &buf, -1);
|
||||
|
||||
if (path->len > 0)
|
||||
g_string_append_c (path, G_SEARCHPATH_SEPARATOR);
|
||||
|
||||
g_string_append (path, buf);
|
||||
|
||||
g_free (buf);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimppatheditor.h
|
||||
* Copyright (C) 1999 Michael Natterer <mitch@gimp.org>
|
||||
* Copyright (C) 1999-2003 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -49,7 +49,7 @@ struct _GimpPathEditor
|
||||
GtkWidget *down_button;
|
||||
GtkWidget *delete_button;
|
||||
|
||||
GtkWidget *file_selection;
|
||||
GtkWidget *file_entry;
|
||||
|
||||
GtkListStore *dir_list;
|
||||
|
||||
|
@ -1302,11 +1302,11 @@ gimp_prop_text_buffer_notify (GObject *config,
|
||||
/****************/
|
||||
|
||||
|
||||
static void gimp_prop_file_entry_callback (GimpFileSelection *entry,
|
||||
static void gimp_prop_file_entry_callback (GimpFileEntry *entry,
|
||||
GObject *config);
|
||||
static void gimp_prop_file_entry_notify (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GimpFileSelection *entry);
|
||||
GimpFileEntry *entry);
|
||||
|
||||
GtkWidget *
|
||||
gimp_prop_file_entry_new (GObject *config,
|
||||
@ -1331,14 +1331,13 @@ gimp_prop_file_entry_new (GObject *config,
|
||||
|
||||
filename = value ? gimp_config_path_expand (value, FALSE, NULL) : NULL;
|
||||
|
||||
entry = gimp_file_selection_new (filesel_title,
|
||||
filename, dir_only, check_valid);
|
||||
entry = gimp_file_entry_new (filesel_title, filename, dir_only, check_valid);
|
||||
|
||||
g_free (value);
|
||||
g_free (filename);
|
||||
|
||||
set_param_spec (G_OBJECT (entry),
|
||||
GIMP_FILE_SELECTION (entry)->entry,
|
||||
GIMP_FILE_ENTRY (entry)->entry,
|
||||
param_spec);
|
||||
|
||||
g_signal_connect (entry, "filename_changed",
|
||||
@ -1353,7 +1352,7 @@ gimp_prop_file_entry_new (GObject *config,
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_prop_file_entry_callback (GimpFileSelection *entry,
|
||||
gimp_prop_file_entry_callback (GimpFileEntry *entry,
|
||||
GObject *config)
|
||||
{
|
||||
GParamSpec *param_spec;
|
||||
@ -1363,7 +1362,7 @@ gimp_prop_file_entry_callback (GimpFileSelection *entry,
|
||||
if (! param_spec)
|
||||
return;
|
||||
|
||||
value = gimp_file_selection_get_filename (entry);
|
||||
value = gimp_file_entry_get_filename (entry);
|
||||
|
||||
g_object_set (config,
|
||||
param_spec->name, value,
|
||||
@ -1375,7 +1374,7 @@ gimp_prop_file_entry_callback (GimpFileSelection *entry,
|
||||
static void
|
||||
gimp_prop_file_entry_notify (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GimpFileSelection *entry)
|
||||
GimpFileEntry *entry)
|
||||
{
|
||||
gchar *value;
|
||||
|
||||
@ -1387,7 +1386,7 @@ gimp_prop_file_entry_notify (GObject *config,
|
||||
gimp_prop_file_entry_callback,
|
||||
config);
|
||||
|
||||
gimp_file_selection_set_filename (entry, value);
|
||||
gimp_file_entry_set_filename (entry, value);
|
||||
|
||||
g_signal_handlers_unblock_by_func (entry,
|
||||
gimp_prop_file_entry_callback,
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include <libgimpwidgets/gimpcolorselect.h>
|
||||
#include <libgimpwidgets/gimpcolorselection.h>
|
||||
#include <libgimpwidgets/gimpdialog.h>
|
||||
#include <libgimpwidgets/gimpfileselection.h>
|
||||
#include <libgimpwidgets/gimpfileentry.h>
|
||||
#include <libgimpwidgets/gimphelpui.h>
|
||||
#include <libgimpwidgets/gimpmemsizeentry.h>
|
||||
#include <libgimpwidgets/gimpoffsetarea.h>
|
||||
|
@ -67,7 +67,7 @@ typedef struct _GimpColorSelector GimpColorSelector;
|
||||
typedef struct _GimpColorSelect GimpColorSelect;
|
||||
typedef struct _GimpColorSelection GimpColorSelection;
|
||||
typedef struct _GimpDialog GimpDialog;
|
||||
typedef struct _GimpFileSelection GimpFileSelection;
|
||||
typedef struct _GimpFileEntry GimpFileEntry;
|
||||
typedef struct _GimpMemsizeEntry GimpMemsizeEntry;
|
||||
typedef struct _GimpOffsetArea GimpOffsetArea;
|
||||
typedef struct _GimpPathEditor GimpPathEditor;
|
||||
|
@ -67,7 +67,7 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget *fileselection;
|
||||
GtkWidget *file_entry;
|
||||
gchar *filename;
|
||||
} SFFilename;
|
||||
|
||||
@ -169,29 +169,29 @@ static void script_fu_response (GtkWidget *widget,
|
||||
static void script_fu_ok (SFScript *script);
|
||||
static void script_fu_reset (SFScript *script);
|
||||
static void script_fu_about_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
SFScript *script);
|
||||
static void script_fu_menu_callback (gint32 id,
|
||||
gpointer data);
|
||||
|
||||
static void script_fu_file_selection_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void script_fu_file_entry_callback (GtkWidget *widget,
|
||||
SFFilename *fil);
|
||||
|
||||
static void script_fu_pattern_preview (const gchar *name,
|
||||
static void script_fu_pattern_callback (const gchar *name,
|
||||
gint width,
|
||||
gint height,
|
||||
gint bytes,
|
||||
const guchar *mask_data,
|
||||
gboolean closing,
|
||||
gpointer data);
|
||||
static void script_fu_gradient_preview (const gchar *name,
|
||||
static void script_fu_gradient_callback (const gchar *name,
|
||||
gint width,
|
||||
const gdouble *mask_data,
|
||||
gboolean closing,
|
||||
gpointer data);
|
||||
static void script_fu_font_preview (const gchar *name,
|
||||
static void script_fu_font_callback (const gchar *name,
|
||||
gboolean closing,
|
||||
gpointer data);
|
||||
static void script_fu_brush_preview (const gchar *name,
|
||||
static void script_fu_brush_callback (const gchar *name,
|
||||
gdouble opacity,
|
||||
gint spacing,
|
||||
GimpLayerModeEffects paint_mode,
|
||||
@ -519,7 +519,7 @@ script_fu_add_script (LISP a)
|
||||
#endif
|
||||
script->arg_values[i].sfa_file.filename =
|
||||
g_strdup (script->arg_defaults[i].sfa_file.filename);
|
||||
script->arg_values[i].sfa_file.fileselection = NULL;
|
||||
script->arg_values[i].sfa_file.file_entry = NULL;
|
||||
|
||||
args[i + 1].type = GIMP_PDB_STRING;
|
||||
args[i + 1].name = (script->arg_types[i] == SF_FILENAME ?
|
||||
@ -1319,18 +1319,18 @@ script_fu_interface (SFScript *script)
|
||||
widget_leftalign = FALSE;
|
||||
|
||||
if (script->arg_types[i] == SF_FILENAME)
|
||||
widget = gimp_file_selection_new (_("Script-Fu File Selection"),
|
||||
widget = gimp_file_entry_new (_("Script-Fu File Selection"),
|
||||
script->arg_values[i].sfa_file.filename,
|
||||
FALSE, TRUE);
|
||||
else
|
||||
widget = gimp_file_selection_new (_("Script-Fu Folder Selection"),
|
||||
widget = gimp_file_entry_new (_("Script-Fu Folder Selection"),
|
||||
script->arg_values[i].sfa_file.filename,
|
||||
TRUE, TRUE);
|
||||
|
||||
script->arg_values[i].sfa_file.fileselection = widget;
|
||||
script->arg_values[i].sfa_file.file_entry = widget;
|
||||
|
||||
g_signal_connect (widget, "filename_changed",
|
||||
G_CALLBACK (script_fu_file_selection_callback),
|
||||
G_CALLBACK (script_fu_file_entry_callback),
|
||||
&script->arg_values[i].sfa_file);
|
||||
break;
|
||||
|
||||
@ -1339,20 +1339,20 @@ script_fu_interface (SFScript *script)
|
||||
|
||||
widget = gimp_font_select_widget_new (_("Script-Fu Font Selection"),
|
||||
script->arg_values[i].sfa_font,
|
||||
script_fu_font_preview,
|
||||
script_fu_font_callback,
|
||||
&script->arg_values[i].sfa_font);
|
||||
break;
|
||||
|
||||
case SF_PATTERN:
|
||||
widget = gimp_pattern_select_widget_new (_("Script-fu Pattern Selection"),
|
||||
script->arg_values[i].sfa_pattern,
|
||||
script_fu_pattern_preview,
|
||||
script_fu_pattern_callback,
|
||||
&script->arg_values[i].sfa_pattern);
|
||||
break;
|
||||
case SF_GRADIENT:
|
||||
widget = gimp_gradient_select_widget_new (_("Script-Fu Gradient Selection"),
|
||||
script->arg_values[i].sfa_gradient,
|
||||
script_fu_gradient_preview,
|
||||
script_fu_gradient_callback,
|
||||
&script->arg_values[i].sfa_gradient);
|
||||
break;
|
||||
|
||||
@ -1362,7 +1362,7 @@ script_fu_interface (SFScript *script)
|
||||
script->arg_values[i].sfa_brush.opacity,
|
||||
script->arg_values[i].sfa_brush.spacing,
|
||||
script->arg_values[i].sfa_brush.paint_mode,
|
||||
script_fu_brush_preview,
|
||||
script_fu_brush_callback,
|
||||
&script->arg_values[i].sfa_brush);
|
||||
break;
|
||||
|
||||
@ -1461,7 +1461,7 @@ script_fu_interface_quit (SFScript *script)
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_pattern_preview (const gchar *name,
|
||||
script_fu_pattern_callback (const gchar *name,
|
||||
gint width,
|
||||
gint height,
|
||||
gint bytes,
|
||||
@ -1469,44 +1469,38 @@ script_fu_pattern_preview (const gchar *name,
|
||||
gboolean closing,
|
||||
gpointer data)
|
||||
{
|
||||
gchar **pname;
|
||||
|
||||
pname = (gchar **) data;
|
||||
gchar **pname = data;
|
||||
|
||||
g_free (*pname);
|
||||
*pname = g_strdup (name);
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_gradient_preview (const gchar *name,
|
||||
script_fu_gradient_callback (const gchar *name,
|
||||
gint width,
|
||||
const gdouble *mask_data,
|
||||
gboolean closing,
|
||||
gpointer data)
|
||||
{
|
||||
gchar **gname;
|
||||
|
||||
gname = (gchar **) data;
|
||||
gchar **gname = data;
|
||||
|
||||
g_free (*gname);
|
||||
*gname = g_strdup (name);
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_font_preview (const gchar *name,
|
||||
script_fu_font_callback (const gchar *name,
|
||||
gboolean closing,
|
||||
gpointer data)
|
||||
{
|
||||
gchar **fname;
|
||||
|
||||
fname = (gchar **) data;
|
||||
gchar **fname = data;
|
||||
|
||||
g_free (*fname);
|
||||
*fname = g_strdup (name);
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_brush_preview (const gchar *name,
|
||||
script_fu_brush_callback (const gchar *name,
|
||||
gdouble opacity,
|
||||
gint spacing,
|
||||
GimpLayerModeEffects paint_mode,
|
||||
@ -1516,9 +1510,7 @@ script_fu_brush_preview (const gchar *name,
|
||||
gboolean closing,
|
||||
gpointer data)
|
||||
{
|
||||
SFBrush *brush;
|
||||
|
||||
brush = (SFBrush *) data;
|
||||
SFBrush *brush = data;
|
||||
|
||||
g_free (brush->name);
|
||||
|
||||
@ -1541,8 +1533,7 @@ script_fu_response (GtkWidget *widget,
|
||||
|
||||
case GTK_RESPONSE_OK:
|
||||
script_fu_ok (script);
|
||||
gtk_widget_destroy (sf_interface->dialog);
|
||||
break;
|
||||
/* fallthru */
|
||||
|
||||
default:
|
||||
gtk_widget_destroy (sf_interface->dialog);
|
||||
@ -1826,8 +1817,8 @@ script_fu_reset (SFScript *script)
|
||||
g_free (script->arg_values[i].sfa_file.filename);
|
||||
script->arg_values[i].sfa_file.filename =
|
||||
g_strdup (script->arg_defaults[i].sfa_file.filename);
|
||||
gimp_file_selection_set_filename
|
||||
(GIMP_FILE_SELECTION (script->arg_values[i].sfa_file.fileselection),
|
||||
gimp_file_entry_set_filename
|
||||
(GIMP_FILE_ENTRY (script->arg_values[i].sfa_file.file_entry),
|
||||
script->arg_values[i].sfa_file.filename);
|
||||
break;
|
||||
|
||||
@ -1868,7 +1859,7 @@ script_fu_reset (SFScript *script)
|
||||
|
||||
static void
|
||||
script_fu_about_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
SFScript *script)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *frame;
|
||||
@ -1879,8 +1870,6 @@ script_fu_about_callback (GtkWidget *widget,
|
||||
GtkWidget *text_view;
|
||||
GtkTextBuffer *text_buffer;
|
||||
|
||||
SFScript *script = (SFScript *) data;
|
||||
|
||||
if (sf_interface->about_dialog == NULL)
|
||||
{
|
||||
sf_interface->about_dialog = dialog =
|
||||
@ -1990,23 +1979,19 @@ script_fu_menu_callback (gint32 id,
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_file_selection_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
script_fu_file_entry_callback (GtkWidget *widget,
|
||||
SFFilename *file)
|
||||
{
|
||||
SFFilename *file;
|
||||
|
||||
file = (SFFilename *) data;
|
||||
|
||||
if (file->filename)
|
||||
g_free (file->filename);
|
||||
|
||||
file->filename =
|
||||
gimp_file_selection_get_filename (GIMP_FILE_SELECTION (file->fileselection));
|
||||
gimp_file_entry_get_filename (GIMP_FILE_ENTRY(file->file_entry));
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_error_msg (const gchar *command)
|
||||
{
|
||||
g_message (_("Script-Fu Error while executing\n %s\n%s"),
|
||||
g_message (_("Error while executing\n%s\n%s"),
|
||||
command, siod_err_msg);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget *fileselection;
|
||||
GtkWidget *file_entry;
|
||||
gchar *filename;
|
||||
} SFFilename;
|
||||
|
||||
@ -169,29 +169,29 @@ static void script_fu_response (GtkWidget *widget,
|
||||
static void script_fu_ok (SFScript *script);
|
||||
static void script_fu_reset (SFScript *script);
|
||||
static void script_fu_about_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
SFScript *script);
|
||||
static void script_fu_menu_callback (gint32 id,
|
||||
gpointer data);
|
||||
|
||||
static void script_fu_file_selection_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void script_fu_file_entry_callback (GtkWidget *widget,
|
||||
SFFilename *fil);
|
||||
|
||||
static void script_fu_pattern_preview (const gchar *name,
|
||||
static void script_fu_pattern_callback (const gchar *name,
|
||||
gint width,
|
||||
gint height,
|
||||
gint bytes,
|
||||
const guchar *mask_data,
|
||||
gboolean closing,
|
||||
gpointer data);
|
||||
static void script_fu_gradient_preview (const gchar *name,
|
||||
static void script_fu_gradient_callback (const gchar *name,
|
||||
gint width,
|
||||
const gdouble *mask_data,
|
||||
gboolean closing,
|
||||
gpointer data);
|
||||
static void script_fu_font_preview (const gchar *name,
|
||||
static void script_fu_font_callback (const gchar *name,
|
||||
gboolean closing,
|
||||
gpointer data);
|
||||
static void script_fu_brush_preview (const gchar *name,
|
||||
static void script_fu_brush_callback (const gchar *name,
|
||||
gdouble opacity,
|
||||
gint spacing,
|
||||
GimpLayerModeEffects paint_mode,
|
||||
@ -519,7 +519,7 @@ script_fu_add_script (LISP a)
|
||||
#endif
|
||||
script->arg_values[i].sfa_file.filename =
|
||||
g_strdup (script->arg_defaults[i].sfa_file.filename);
|
||||
script->arg_values[i].sfa_file.fileselection = NULL;
|
||||
script->arg_values[i].sfa_file.file_entry = NULL;
|
||||
|
||||
args[i + 1].type = GIMP_PDB_STRING;
|
||||
args[i + 1].name = (script->arg_types[i] == SF_FILENAME ?
|
||||
@ -1319,18 +1319,18 @@ script_fu_interface (SFScript *script)
|
||||
widget_leftalign = FALSE;
|
||||
|
||||
if (script->arg_types[i] == SF_FILENAME)
|
||||
widget = gimp_file_selection_new (_("Script-Fu File Selection"),
|
||||
widget = gimp_file_entry_new (_("Script-Fu File Selection"),
|
||||
script->arg_values[i].sfa_file.filename,
|
||||
FALSE, TRUE);
|
||||
else
|
||||
widget = gimp_file_selection_new (_("Script-Fu Folder Selection"),
|
||||
widget = gimp_file_entry_new (_("Script-Fu Folder Selection"),
|
||||
script->arg_values[i].sfa_file.filename,
|
||||
TRUE, TRUE);
|
||||
|
||||
script->arg_values[i].sfa_file.fileselection = widget;
|
||||
script->arg_values[i].sfa_file.file_entry = widget;
|
||||
|
||||
g_signal_connect (widget, "filename_changed",
|
||||
G_CALLBACK (script_fu_file_selection_callback),
|
||||
G_CALLBACK (script_fu_file_entry_callback),
|
||||
&script->arg_values[i].sfa_file);
|
||||
break;
|
||||
|
||||
@ -1339,20 +1339,20 @@ script_fu_interface (SFScript *script)
|
||||
|
||||
widget = gimp_font_select_widget_new (_("Script-Fu Font Selection"),
|
||||
script->arg_values[i].sfa_font,
|
||||
script_fu_font_preview,
|
||||
script_fu_font_callback,
|
||||
&script->arg_values[i].sfa_font);
|
||||
break;
|
||||
|
||||
case SF_PATTERN:
|
||||
widget = gimp_pattern_select_widget_new (_("Script-fu Pattern Selection"),
|
||||
script->arg_values[i].sfa_pattern,
|
||||
script_fu_pattern_preview,
|
||||
script_fu_pattern_callback,
|
||||
&script->arg_values[i].sfa_pattern);
|
||||
break;
|
||||
case SF_GRADIENT:
|
||||
widget = gimp_gradient_select_widget_new (_("Script-Fu Gradient Selection"),
|
||||
script->arg_values[i].sfa_gradient,
|
||||
script_fu_gradient_preview,
|
||||
script_fu_gradient_callback,
|
||||
&script->arg_values[i].sfa_gradient);
|
||||
break;
|
||||
|
||||
@ -1362,7 +1362,7 @@ script_fu_interface (SFScript *script)
|
||||
script->arg_values[i].sfa_brush.opacity,
|
||||
script->arg_values[i].sfa_brush.spacing,
|
||||
script->arg_values[i].sfa_brush.paint_mode,
|
||||
script_fu_brush_preview,
|
||||
script_fu_brush_callback,
|
||||
&script->arg_values[i].sfa_brush);
|
||||
break;
|
||||
|
||||
@ -1461,7 +1461,7 @@ script_fu_interface_quit (SFScript *script)
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_pattern_preview (const gchar *name,
|
||||
script_fu_pattern_callback (const gchar *name,
|
||||
gint width,
|
||||
gint height,
|
||||
gint bytes,
|
||||
@ -1469,44 +1469,38 @@ script_fu_pattern_preview (const gchar *name,
|
||||
gboolean closing,
|
||||
gpointer data)
|
||||
{
|
||||
gchar **pname;
|
||||
|
||||
pname = (gchar **) data;
|
||||
gchar **pname = data;
|
||||
|
||||
g_free (*pname);
|
||||
*pname = g_strdup (name);
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_gradient_preview (const gchar *name,
|
||||
script_fu_gradient_callback (const gchar *name,
|
||||
gint width,
|
||||
const gdouble *mask_data,
|
||||
gboolean closing,
|
||||
gpointer data)
|
||||
{
|
||||
gchar **gname;
|
||||
|
||||
gname = (gchar **) data;
|
||||
gchar **gname = data;
|
||||
|
||||
g_free (*gname);
|
||||
*gname = g_strdup (name);
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_font_preview (const gchar *name,
|
||||
script_fu_font_callback (const gchar *name,
|
||||
gboolean closing,
|
||||
gpointer data)
|
||||
{
|
||||
gchar **fname;
|
||||
|
||||
fname = (gchar **) data;
|
||||
gchar **fname = data;
|
||||
|
||||
g_free (*fname);
|
||||
*fname = g_strdup (name);
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_brush_preview (const gchar *name,
|
||||
script_fu_brush_callback (const gchar *name,
|
||||
gdouble opacity,
|
||||
gint spacing,
|
||||
GimpLayerModeEffects paint_mode,
|
||||
@ -1516,9 +1510,7 @@ script_fu_brush_preview (const gchar *name,
|
||||
gboolean closing,
|
||||
gpointer data)
|
||||
{
|
||||
SFBrush *brush;
|
||||
|
||||
brush = (SFBrush *) data;
|
||||
SFBrush *brush = data;
|
||||
|
||||
g_free (brush->name);
|
||||
|
||||
@ -1541,8 +1533,7 @@ script_fu_response (GtkWidget *widget,
|
||||
|
||||
case GTK_RESPONSE_OK:
|
||||
script_fu_ok (script);
|
||||
gtk_widget_destroy (sf_interface->dialog);
|
||||
break;
|
||||
/* fallthru */
|
||||
|
||||
default:
|
||||
gtk_widget_destroy (sf_interface->dialog);
|
||||
@ -1826,8 +1817,8 @@ script_fu_reset (SFScript *script)
|
||||
g_free (script->arg_values[i].sfa_file.filename);
|
||||
script->arg_values[i].sfa_file.filename =
|
||||
g_strdup (script->arg_defaults[i].sfa_file.filename);
|
||||
gimp_file_selection_set_filename
|
||||
(GIMP_FILE_SELECTION (script->arg_values[i].sfa_file.fileselection),
|
||||
gimp_file_entry_set_filename
|
||||
(GIMP_FILE_ENTRY (script->arg_values[i].sfa_file.file_entry),
|
||||
script->arg_values[i].sfa_file.filename);
|
||||
break;
|
||||
|
||||
@ -1868,7 +1859,7 @@ script_fu_reset (SFScript *script)
|
||||
|
||||
static void
|
||||
script_fu_about_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
SFScript *script)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *frame;
|
||||
@ -1879,8 +1870,6 @@ script_fu_about_callback (GtkWidget *widget,
|
||||
GtkWidget *text_view;
|
||||
GtkTextBuffer *text_buffer;
|
||||
|
||||
SFScript *script = (SFScript *) data;
|
||||
|
||||
if (sf_interface->about_dialog == NULL)
|
||||
{
|
||||
sf_interface->about_dialog = dialog =
|
||||
@ -1990,23 +1979,19 @@ script_fu_menu_callback (gint32 id,
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_file_selection_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
script_fu_file_entry_callback (GtkWidget *widget,
|
||||
SFFilename *file)
|
||||
{
|
||||
SFFilename *file;
|
||||
|
||||
file = (SFFilename *) data;
|
||||
|
||||
if (file->filename)
|
||||
g_free (file->filename);
|
||||
|
||||
file->filename =
|
||||
gimp_file_selection_get_filename (GIMP_FILE_SELECTION (file->fileselection));
|
||||
gimp_file_entry_get_filename (GIMP_FILE_ENTRY(file->file_entry));
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_error_msg (const gchar *command)
|
||||
{
|
||||
g_message (_("Script-Fu Error while executing\n %s\n%s"),
|
||||
g_message (_("Error while executing\n%s\n%s"),
|
||||
command, siod_err_msg);
|
||||
}
|
||||
|
Reference in New Issue
Block a user