set the window title for file selection dialogs as we do for directory

2001-11-21  Sven Neumann  <sven@gimp.org>

	* libgimpwidgets/gimpfileselection.c: set the window title for file
	selection dialogs as we do for directory selection dialogs. Provide
	fallbacks if gimp_file_selection_new() is called with a NULL title.

	* plug-ins/script-fu/script-fu-enums.h
	* plug-ins/script-fu/script-fu-scripts.c
	* plug-ins/script-fu/siod-wrapper.c: applied a modified version of a
	patch from Matteo Nastasi <nastasi@tiscalinet.it> that adds the new
	Script-Fu parameter type SF-DIRNAME.

	* plug-ins/script-fu/scripts/test-sphere.scm: use SF-DIRNAME.
This commit is contained in:
Sven Neumann 2001-11-21 18:50:50 +00:00 committed by Sven Neumann
parent c8a6809605
commit d2f566a95a
9 changed files with 103 additions and 43 deletions

View File

@ -1,3 +1,17 @@
2001-11-21 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimpfileselection.c: set the window title for file
selection dialogs as we do for directory selection dialogs. Provide
fallbacks if gimp_file_selection_new() is called with a NULL title.
* plug-ins/script-fu/script-fu-enums.h
* plug-ins/script-fu/script-fu-scripts.c
* plug-ins/script-fu/siod-wrapper.c: applied a modified version of a
patch from Matteo Nastasi <nastasi@tiscalinet.it> that adds the new
Script-Fu parameter type SF-DIRNAME.
* plug-ins/script-fu/scripts/test-sphere.scm: use SF-DIRNAME.
2001-11-21 Michael Natterer <mitch@gimp.org>
* RELEASE-TO-CVS.patch: regenerated with the stuff below included.

View File

@ -347,7 +347,9 @@ gimp_file_selection_browse_callback (GtkWidget *widget,
{
if (gfs->dir_only)
{
gfs->file_selection = gtk_file_selection_new (gfs->title);
gfs->file_selection =
gtk_file_selection_new (gfs->title ?
gfs->title : _("Select Directory"));
/* hiding these widgets uses internal gtk+ knowledge, but it's
* easier than creating my own directory browser -- michael
@ -358,9 +360,11 @@ gimp_file_selection_browse_callback (GtkWidget *widget,
(GTK_FILE_SELECTION (gfs->file_selection)->file_list->parent);
}
else
{
gfs->file_selection = gtk_file_selection_new (_("Select File"));
}
{
gfs->file_selection =
gtk_file_selection_new (gfs->title ?
gfs->title : _("Select File"));
}
gtk_window_set_position (GTK_WINDOW (gfs->file_selection),
GTK_WIN_POS_MOUSE);

View File

@ -347,7 +347,9 @@ gimp_file_selection_browse_callback (GtkWidget *widget,
{
if (gfs->dir_only)
{
gfs->file_selection = gtk_file_selection_new (gfs->title);
gfs->file_selection =
gtk_file_selection_new (gfs->title ?
gfs->title : _("Select Directory"));
/* hiding these widgets uses internal gtk+ knowledge, but it's
* easier than creating my own directory browser -- michael
@ -358,9 +360,11 @@ gimp_file_selection_browse_callback (GtkWidget *widget,
(GTK_FILE_SELECTION (gfs->file_selection)->file_list->parent);
}
else
{
gfs->file_selection = gtk_file_selection_new (_("Select File"));
}
{
gfs->file_selection =
gtk_file_selection_new (gfs->title ?
gfs->title : _("Select File"));
}
gtk_window_set_position (GTK_WINDOW (gfs->file_selection),
GTK_WIN_POS_MOUSE);

View File

@ -288,6 +288,7 @@ init_constants (void)
setvar (cintern ("SF-VALUE"), flocons (SF_VALUE), NIL);
setvar (cintern ("SF-STRING"), flocons (SF_STRING), NIL);
setvar (cintern ("SF-FILENAME"), flocons (SF_FILENAME), NIL);
setvar (cintern ("SF-DIRNAME"), flocons (SF_DIRNAME), NIL);
setvar (cintern ("SF-ADJUSTMENT"), flocons (SF_ADJUSTMENT), NIL);
setvar (cintern ("SF-FONT"), flocons (SF_FONT), NIL);
setvar (cintern ("SF-PATTERN"), flocons (SF_PATTERN), NIL);

View File

@ -37,6 +37,7 @@ typedef enum
SF_BRUSH,
SF_GRADIENT,
SF_FILENAME,
SF_DIRNAME,
SF_OPTION
} SFArgType;
@ -47,9 +48,3 @@ typedef enum
} SFAdjustmentType;
#endif /* __SCRIPT_FU_ENUMS__ */

View File

@ -624,6 +624,10 @@ script_fu_add_script (LISP a)
case SF_FILENAME:
if (!TYPEP (car (a), tc_string))
return my_err ("script-fu-register: filename defaults must be string values", NIL);
/* fallthrough */
case SF_DIRNAME:
if (!TYPEP (car (a), tc_string))
return my_err ("script-fu-register: dirname defaults must be string values", NIL);
script->arg_defaults[i].sfa_file.filename =
g_strdup (get_c_string (car (a)));
@ -645,7 +649,8 @@ script_fu_add_script (LISP a)
script->arg_values[i].sfa_file.fileselection = NULL;
args[i + 1].type = GIMP_PDB_STRING;
args[i + 1].name = "filename";
args[i + 1].name = (script->arg_types[i] == SF_FILENAME ?
"filename" : "dirname");
args[i + 1].description = script->arg_labels[i];
break;
@ -921,6 +926,7 @@ script_fu_script_proc (gchar *name,
case SF_STRING:
case SF_FILENAME:
case SF_DIRNAME:
escaped = ESCAPE (params[i + 1].data.d_string);
length += strlen (escaped) + 3;
g_free (escaped);
@ -986,6 +992,7 @@ script_fu_script_proc (gchar *name,
case SF_STRING:
case SF_FILENAME:
case SF_DIRNAME:
escaped = ESCAPE (params[i + 1].data.d_string);
g_snprintf (buffer, sizeof (buffer), "\"%s\"",
escaped);
@ -1119,6 +1126,7 @@ script_fu_free_script (SFScript *script)
break;
case SF_FILENAME:
case SF_DIRNAME:
g_free (script->arg_defaults[i].sfa_file.filename);
g_free (script->arg_values[i].sfa_file.filename);
break;
@ -1381,12 +1389,20 @@ script_fu_interface (SFScript *script)
break;
case SF_FILENAME:
widget_leftalign = FALSE
;
sf_interface->args_widgets[i] =
gimp_file_selection_new (_("Script-Fu File Selection"),
script->arg_values[i].sfa_file.filename,
FALSE, TRUE);
case SF_DIRNAME:
widget_leftalign = FALSE;
if (script->arg_types[i] == SF_FILENAME)
sf_interface->args_widgets[i] =
gimp_file_selection_new (_("Script-Fu File Selection"),
script->arg_values[i].sfa_file.filename,
FALSE, TRUE);
else
sf_interface->args_widgets[i] =
gimp_file_selection_new (_("Script-Fu Directory Selection"),
script->arg_values[i].sfa_file.filename,
TRUE, TRUE);
script->arg_values[i].sfa_file.fileselection =
sf_interface->args_widgets[i];
@ -1770,6 +1786,7 @@ script_fu_ok_callback (GtkWidget *widget,
break;
case SF_FILENAME:
case SF_DIRNAME:
escaped = ESCAPE (script->arg_values[i].sfa_file.filename);
length += strlen (escaped) + 3;
g_free (escaped);
@ -1872,6 +1889,7 @@ script_fu_ok_callback (GtkWidget *widget,
break;
case SF_FILENAME:
case SF_DIRNAME:
escaped = ESCAPE (script->arg_values[i].sfa_file.filename);
g_snprintf (buffer, sizeof (buffer), "\"%s\"", escaped);
g_free (escaped);
@ -2099,6 +2117,7 @@ script_fu_reset_callback (GtkWidget *widget,
break;
case SF_FILENAME:
case SF_DIRNAME:
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);

View File

@ -624,6 +624,10 @@ script_fu_add_script (LISP a)
case SF_FILENAME:
if (!TYPEP (car (a), tc_string))
return my_err ("script-fu-register: filename defaults must be string values", NIL);
/* fallthrough */
case SF_DIRNAME:
if (!TYPEP (car (a), tc_string))
return my_err ("script-fu-register: dirname defaults must be string values", NIL);
script->arg_defaults[i].sfa_file.filename =
g_strdup (get_c_string (car (a)));
@ -645,7 +649,8 @@ script_fu_add_script (LISP a)
script->arg_values[i].sfa_file.fileselection = NULL;
args[i + 1].type = GIMP_PDB_STRING;
args[i + 1].name = "filename";
args[i + 1].name = (script->arg_types[i] == SF_FILENAME ?
"filename" : "dirname");
args[i + 1].description = script->arg_labels[i];
break;
@ -921,6 +926,7 @@ script_fu_script_proc (gchar *name,
case SF_STRING:
case SF_FILENAME:
case SF_DIRNAME:
escaped = ESCAPE (params[i + 1].data.d_string);
length += strlen (escaped) + 3;
g_free (escaped);
@ -986,6 +992,7 @@ script_fu_script_proc (gchar *name,
case SF_STRING:
case SF_FILENAME:
case SF_DIRNAME:
escaped = ESCAPE (params[i + 1].data.d_string);
g_snprintf (buffer, sizeof (buffer), "\"%s\"",
escaped);
@ -1119,6 +1126,7 @@ script_fu_free_script (SFScript *script)
break;
case SF_FILENAME:
case SF_DIRNAME:
g_free (script->arg_defaults[i].sfa_file.filename);
g_free (script->arg_values[i].sfa_file.filename);
break;
@ -1381,12 +1389,20 @@ script_fu_interface (SFScript *script)
break;
case SF_FILENAME:
widget_leftalign = FALSE
;
sf_interface->args_widgets[i] =
gimp_file_selection_new (_("Script-Fu File Selection"),
script->arg_values[i].sfa_file.filename,
FALSE, TRUE);
case SF_DIRNAME:
widget_leftalign = FALSE;
if (script->arg_types[i] == SF_FILENAME)
sf_interface->args_widgets[i] =
gimp_file_selection_new (_("Script-Fu File Selection"),
script->arg_values[i].sfa_file.filename,
FALSE, TRUE);
else
sf_interface->args_widgets[i] =
gimp_file_selection_new (_("Script-Fu Directory Selection"),
script->arg_values[i].sfa_file.filename,
TRUE, TRUE);
script->arg_values[i].sfa_file.fileselection =
sf_interface->args_widgets[i];
@ -1770,6 +1786,7 @@ script_fu_ok_callback (GtkWidget *widget,
break;
case SF_FILENAME:
case SF_DIRNAME:
escaped = ESCAPE (script->arg_values[i].sfa_file.filename);
length += strlen (escaped) + 3;
g_free (escaped);
@ -1872,6 +1889,7 @@ script_fu_ok_callback (GtkWidget *widget,
break;
case SF_FILENAME:
case SF_DIRNAME:
escaped = ESCAPE (script->arg_values[i].sfa_file.filename);
g_snprintf (buffer, sizeof (buffer), "\"%s\"", escaped);
g_free (escaped);
@ -2099,6 +2117,7 @@ script_fu_reset_callback (GtkWidget *widget,
break;
case SF_FILENAME:
case SF_DIRNAME:
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);

View File

@ -27,7 +27,6 @@
; Usage:
; SF-FONT "label" "fontname"
; ----------------------------------------------------------------------
;
; SF-BRUSH
; is only useful in interactive mode. It will create a widget in the control
; dialog. The widget consists of a preview area (which when pressed will
@ -39,7 +38,7 @@
; consisting of Brush name, opacity, spacing and brush mode in the same
; units as passed in as the default value.
;
; Usage:-
; Usage:
; SF_BRUSH "Brush" '("Circle (03)" 1.0 44 0)
;
; Here the brush dialog will be popped up with a default brush of Circle (03)
@ -49,63 +48,65 @@
; is generally available in the libgimpui library for any plugin that
; wishes to select a brush.
; ----------------------------------------------------------------------
;
; SF-PATTERN
; Only useful in interactive mode. It will create a widget in the control
; dialog. The widget consists of a preview area (which when pressed will
; produce a popup preview ) and a button with the "..." label. The button will
; popup a dialog where patterns can be selected.
;
; Usage:-
; Usage:
; SF-PATTERN "Pattern" "Maple Leaves"
;
; The value returned when the script is invoked is a string containing the
; pattern name. If the above selection was not altered the string would
; contain "Maple Leaves"
; ----------------------------------------------------------------------
;
; SF-GRADIENT
; Only useful in interactive mode. It will create a widget in the control
; dialog. The widget consists of a button containing a preview of the selected
; gradient. If the button is pressed a gradient selection dialog will popup.
;
;
; Usage:-
; Usage:
; SF-GRADIENT "Gradient" "Deep_Sea"
;
; The value returned when the script is invoked is a string containing the
; gradient name. If the above selection was not altered the string would
; contain "Deep_Sea"
;
; ----------------------------------------------------------------------
;
; SF-FILENAME
; Only useful in interactive mode. It will create a widget in the control
; dialog. The widget consists of a button containing the name of a file.
; If the button is pressed a file selection dialog will popup.
;
; Usage:-
; Usage:
; SF-FILENAME "Environment Map" (string-append "" gimp-data-dir "/scripts/beavis.jpg")
;
; The value returned when the script is invoked is a string containing the
; filename.
; ----------------------------------------------------------------------
; SF-DIRNAME
; Only useful in interactive mode. Very similar to SF-FILENAME, but the
; created widget allows to choose a directory instead of a file.
;
; Usage:
; SF-DIRNAME "Image Directory" "/var/tmp/images"
;
; The value returned when the script is invoked is a string containing the
; dirname.
; ----------------------------------------------------------------------
; SF-OPTION
; Only useful in interactive mode. It will create a widget in the control
; dialog. The widget is an option_menu showing the options that are passed
; as a list. The first option is the default choice.
;
; Usage:-
; Usage:
; SF-OPTION "Orientation" '("Horzontal" "Vertical")
;
; The value returned when the script is invoked is the number of the
; choosen option, where the option first is counted as 0.
; ----------------------------------------------------------------------
;
;
(define (script-fu-test-sphere radius
light
shadow
@ -118,7 +119,8 @@
font
size
filename
orientation)
orientation
dirname)
(let* ((width (* radius 3.75))
(height (* radius 2.5))
(img (car (gimp-image-new width height RGB)))
@ -202,6 +204,7 @@
SF-FONT "Font" "-freefont-agate-normal-r-normal-*-24-*-*-*-p-*-*-*"
SF-ADJUSTMENT "Font Size (pixels)" '(50 1 1000 1 10 0 1)
SF-FILENAME "Environment Map" (string-append "" gimp-data-dir "/scripts/beavis.jpg")
SF-OPTION "Orientation" '("Horzontal" "Vertical"))
SF-OPTION "Orientation" '("Horzontal" "Vertical")
SF-DIRNAME "Output Directory" "/var/tmp/")

View File

@ -288,6 +288,7 @@ init_constants (void)
setvar (cintern ("SF-VALUE"), flocons (SF_VALUE), NIL);
setvar (cintern ("SF-STRING"), flocons (SF_STRING), NIL);
setvar (cintern ("SF-FILENAME"), flocons (SF_FILENAME), NIL);
setvar (cintern ("SF-DIRNAME"), flocons (SF_DIRNAME), NIL);
setvar (cintern ("SF-ADJUSTMENT"), flocons (SF_ADJUSTMENT), NIL);
setvar (cintern ("SF-FONT"), flocons (SF_FONT), NIL);
setvar (cintern ("SF-PATTERN"), flocons (SF_PATTERN), NIL);