Commit 79d2bb6a authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

removed all parameters from gimp_proc_browser_dialog_new() and removed the

2005-08-03  Michael Natterer  <mitch@gimp.org>

	* libgimp/gimpprocbrowserdialog.[ch]: removed all parameters from
	gimp_proc_browser_dialog_new() and removed the "scheme_names"
	stuff.

	* plug-ins/dbbrowser/procedure-browser.c
	* plug-ins/pygimp/procbrowser.c
	* plug-ins/script-fu/script-fu-console.c: changed accordingly.

	* plug-ins/script-fu/script-fu-interface.c
	* plug-ins/script-fu/script-fu-scripts.c
	* plug-ins/script-fu/script-fu-types.h
	* plug-ins/script-fu/siod-wrapper.c: removed all sorts of
	conversions between '-' and '_' for procedure names.

	* plug-ins/script-fu/script-fu.c: use canonical names for
	script-fu's procedures.
parent 335ba076
2005-08-03 Michael Natterer <mitch@gimp.org>
* libgimp/gimpprocbrowserdialog.[ch]: removed all parameters from
gimp_proc_browser_dialog_new() and removed the "scheme_names"
stuff.
* plug-ins/dbbrowser/procedure-browser.c
* plug-ins/pygimp/procbrowser.c
* plug-ins/script-fu/script-fu-console.c: changed accordingly.
* plug-ins/script-fu/script-fu-interface.c
* plug-ins/script-fu/script-fu-scripts.c
* plug-ins/script-fu/script-fu-types.h
* plug-ins/script-fu/siod-wrapper.c: removed all sorts of
conversions between '-' and '_' for procedure names.
* plug-ins/script-fu/script-fu.c: use canonical names for
script-fu's procedures.
2005-08-03 Michael Natterer <mitch@gimp.org>
* app/actions/vectors-commands.c
......
......@@ -68,7 +68,6 @@ typedef enum
enum
{
COLUMN_LABEL,
COLUMN_PROC_NAME,
N_COLUMNS
};
......@@ -91,7 +90,6 @@ static void browser_search (GimpBrowser *browser,
const gchar *query_text,
gint search_type,
GimpProcBrowserDialog *dialog);
static void browser_convert_string (gchar *str);
static GimpDialogClass *parent_class = NULL;
......@@ -151,8 +149,6 @@ gimp_proc_browser_dialog_init (GimpProcBrowserDialog *dialog)
GtkCellRenderer *renderer;
GtkTreeSelection *selection;
dialog->scheme_names = FALSE;
dialog->browser = gimp_browser_new ();
gimp_browser_add_search_types (GIMP_BROWSER (dialog->browser),
_("by name"), SEARCH_TYPE_NAME,
......@@ -219,26 +215,12 @@ gimp_proc_browser_dialog_init (GimpProcBrowserDialog *dialog)
/* public functions */
GtkWidget *
gimp_proc_browser_dialog_new (gboolean scheme_names,
gboolean apply_button)
gimp_proc_browser_dialog_new (void)
{
GimpProcBrowserDialog *dialog;
dialog = g_object_new (GIMP_TYPE_PROC_BROWSER_DIALOG, NULL);
dialog->scheme_names = scheme_names ? TRUE : FALSE;
if (apply_button)
{
gtk_dialog_add_button (GTK_DIALOG (dialog),
GTK_STOCK_APPLY, GTK_RESPONSE_APPLY);
gtk_dialog_set_default_response (GTK_DIALOG (dialog),
GTK_RESPONSE_APPLY);
}
gtk_dialog_add_button (GTK_DIALOG (dialog),
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
/* first search (all procedures) */
browser_search (GIMP_BROWSER (dialog->browser), "", SEARCH_TYPE_ALL,
dialog);
......@@ -306,7 +288,6 @@ static void
browser_show_procedure (GimpProcBrowserDialog *dialog,
const gchar *proc_name)
{
gchar *name;
gchar *proc_blurb;
gchar *proc_help;
gchar *proc_author;
......@@ -318,11 +299,6 @@ browser_show_procedure (GimpProcBrowserDialog *dialog,
GimpParamDef *params;
GimpParamDef *return_vals;
name = g_strdup (proc_name);
if (dialog->scheme_names)
browser_convert_string (name);
gimp_procedural_db_proc_info (proc_name,
&proc_blurb,
&proc_help,
......@@ -336,7 +312,7 @@ browser_show_procedure (GimpProcBrowserDialog *dialog,
&return_vals);
gimp_browser_set_widget (GIMP_BROWSER (dialog->browser),
gimp_proc_view_new (name,
gimp_proc_view_new (proc_name,
NULL,
proc_blurb,
proc_help,
......@@ -349,7 +325,6 @@ browser_show_procedure (GimpProcBrowserDialog *dialog,
params,
return_vals));
g_free (name);
g_free (proc_blurb);
g_free (proc_help);
g_free (proc_author);
......@@ -358,7 +333,6 @@ browser_show_procedure (GimpProcBrowserDialog *dialog,
gimp_destroy_paramdefs (params, n_params);
gimp_destroy_paramdefs (return_vals, n_return_vals);
}
static void
......@@ -382,7 +356,7 @@ browser_search (GimpBrowser *browser,
while (*q)
{
if ((*q == '_') || (*q == '-'))
g_string_append (query, "[-_]");
g_string_append (query, "-");
else
g_string_append_c (query, *q);
......@@ -482,7 +456,6 @@ browser_search (GimpBrowser *browser,
gint i;
dialog->store = gtk_list_store_new (N_COLUMNS,
G_TYPE_STRING,
G_TYPE_STRING);
gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->tree_view),
GTK_TREE_MODEL (dialog->store));
......@@ -490,18 +463,11 @@ browser_search (GimpBrowser *browser,
for (i = 0; i < num_procs; i++)
{
str = g_strdup (proc_list[i]);
if (dialog->scheme_names)
browser_convert_string (str);
gtk_list_store_append (dialog->store, &iter);
gtk_list_store_set (dialog->store, &iter,
COLUMN_LABEL, str,
COLUMN_PROC_NAME, proc_list[i],
-1);
g_free (str);
g_free (proc_list[i]);
}
......@@ -510,7 +476,8 @@ browser_search (GimpBrowser *browser,
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (dialog->tree_view));
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (dialog->store),
COLUMN_LABEL, GTK_SORT_ASCENDING);
COLUMN_PROC_NAME,
GTK_SORT_ASCENDING);
gtk_tree_model_get_iter_first (GTK_TREE_MODEL (dialog->store), &iter);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->tree_view));
......@@ -524,15 +491,3 @@ browser_search (GimpBrowser *browser,
gimp_browser_show_message (browser, _("No matches"));
}
}
static void
browser_convert_string (gchar *str)
{
while (*str)
{
if (*str == '_')
*str = '-';
str++;
}
}
......@@ -44,8 +44,6 @@ struct _GimpProcBrowserDialog
{
GimpDialog parent_instance;
gboolean scheme_names;
GtkWidget *browser;
GtkListStore *store;
......@@ -66,11 +64,9 @@ struct _GimpProcBrowserDialogClass
};
GType gimp_proc_browser_dialog_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_proc_browser_dialog_new (gboolean scheme_names,
gboolean apply_button);
GType gimp_proc_browser_dialog_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_proc_browser_dialog_new (void);
gchar * gimp_proc_browser_dialog_get_selected (GimpProcBrowserDialog *dialog);
......
......@@ -117,7 +117,9 @@ run (const gchar *name,
gimp_ui_init ("dbbrowser", FALSE);
dialog = gimp_proc_browser_dialog_new (FALSE, FALSE);
dialog = gimp_proc_browser_dialog_new ();
gtk_dialog_add_button (GTK_DIALOG (dialog),
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
......
......@@ -117,7 +117,9 @@ run (const gchar *name,
gimp_ui_init ("dbbrowser", FALSE);
dialog = gimp_proc_browser_dialog_new (FALSE, FALSE);
dialog = gimp_proc_browser_dialog_new ();
gtk_dialog_add_button (GTK_DIALOG (dialog),
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
......
......@@ -162,7 +162,17 @@ proc_browser_dialog_new(PyObject *self, PyObject *args, PyObject *kwargs)
}
}
dlg = G_OBJECT(gimp_proc_browser_dialog_new(FALSE, has_apply));
dlg = G_OBJECT(gimp_proc_browser_dialog_new());
if (has_apply) {
gtk_dialog_add_button(GTK_DIALOG(dlg),
GTK_STOCK_APPLY, GTK_RESPONSE_APPLY);
gtk_dialog_set_default_response(GTK_DIALOG(dlg),
GTK_RESPONSE_APPLY);
}
gtk_dialog_add_button(GTK_DIALOG(dlg),
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
g_signal_connect_data(dlg, "response",
G_CALLBACK(proxy_apply_callback), proxy_data,
......
......@@ -232,7 +232,6 @@ init_procedures (void)
{
LISP args = NIL;
LISP code = NIL;
gchar *proc_name;
gint j;
/* create a new scheme func that calls gimp-proc-db-call */
......@@ -250,13 +249,8 @@ init_procedures (void)
args = nreverse (args);
code = nreverse (code);
/* convert the procedure name to scheme-like naming conventions */
proc_name = g_strdup (proc_list[i]);
convert_string (proc_name);
/* set the scheme-based procedure name */
args = cons (rintern (proc_name), args);
g_free (proc_name);
/* set the procedure name */
args = cons (rintern (proc_list[i]), args);
/* set the actual pdb procedure name */
code = cons (cons (cintern ("quote"),
......@@ -556,7 +550,6 @@ marshall_proc_db_call (LISP a)
&nparams, &nreturn_vals,
&params, &return_vals))
{
convert_string (proc_name);
g_snprintf (error_str, sizeof (error_str),
"Invalid procedure name %s specified", proc_name);
return my_err (error_str, NIL);
......@@ -577,7 +570,6 @@ marshall_proc_db_call (LISP a)
/* Check the supplied number of arguments */
if ((nlength (a) - 1) != nparams)
{
convert_string (proc_name);
g_snprintf (error_str, sizeof (error_str),
"Invalid arguments supplied to %s -- "
"(# args: %ld, expecting: %d)",
......@@ -656,7 +648,6 @@ marshall_proc_db_call (LISP a)
if ((n_elements < 0) || (n_elements > nlength (list)))
{
convert_string (proc_name);
g_snprintf (error_str, sizeof (error_str),
"INT32 array (argument %d) for function %s has "
"incorrect length (got %ld, expected %d)",
......@@ -680,7 +671,6 @@ marshall_proc_db_call (LISP a)
if ((n_elements < 0) || (n_elements > nlength (list)))
{
convert_string (proc_name);
g_snprintf (error_str, sizeof (error_str),
"INT16 array (argument %d) for function %s has "
"incorrect length (got %ld, expected %d)",
......@@ -704,7 +694,6 @@ marshall_proc_db_call (LISP a)
if ((n_elements < 0) || (n_elements > nlength (list)))
{
convert_string (proc_name);
g_snprintf (error_str, sizeof (error_str),
"INT8 array (argument %d) for function %s has "
"incorrect length (got %ld, expected %d)",
......@@ -727,7 +716,6 @@ marshall_proc_db_call (LISP a)
if ((n_elements < 0) || (n_elements > nlength (list)))
{
convert_string (proc_name);
g_snprintf (error_str, sizeof (error_str),
"FLOAT array (argument %d) for function %s has "
"incorrect length (got %ld, expected %d)",
......@@ -750,7 +738,6 @@ marshall_proc_db_call (LISP a)
if ((n_elements < 0) || (n_elements > nlength (list)))
{
convert_string (proc_name);
g_snprintf (error_str, sizeof (error_str),
"STRING array (argument %d) for function %s has "
"incorrect length (got %ld, expected %d)",
......@@ -918,7 +905,6 @@ marshall_proc_db_call (LISP a)
break;
default:
convert_string (proc_name);
g_snprintf (error_str, sizeof (error_str),
"Argument %d for %s is an unknown type",
i + 1, proc_name);
......
......@@ -289,7 +289,14 @@ script_fu_browse_callback (GtkWidget *widget,
{
if (! console->proc_browser)
{
console->proc_browser = gimp_proc_browser_dialog_new (TRUE, TRUE);
console->proc_browser = gimp_proc_browser_dialog_new ();
gtk_dialog_add_buttons (GTK_DIALOG (console->proc_browser),
GTK_STOCK_APPLY, GTK_RESPONSE_APPLY,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (console->proc_browser),
GTK_RESPONSE_APPLY);
g_object_add_weak_pointer (G_OBJECT (console->proc_browser),
(gpointer) &console->proc_browser);
......
......@@ -215,11 +215,7 @@ script_fu_interface (SFScript *script)
sf_interface->title = g_strdup_printf (_("Script-Fu: %s"),
sf_interface->short_title);
sf_interface->help_id = g_strdup (script->pdb_name);
for (tmp = sf_interface->help_id; tmp && *tmp; tmp++)
if (*tmp == '_')
*tmp = '-';
sf_interface->help_id = g_strdup (script->script_name);
sf_interface->dialog = dlg =
gimp_dialog_new (sf_interface->title, "script-fu",
......
......@@ -160,7 +160,6 @@ script_fu_add_script (LISP a)
LISP adj_list;
LISP brush_list;
LISP option_list;
gchar *s;
/* Check the length of a */
if (nlength (a) < 7)
......@@ -174,14 +173,6 @@ script_fu_add_script (LISP a)
script->script_name = g_strdup (val);
a = cdr (a);
/* transform the function name into a name containing "_" for each "-".
* this does not hurt anybody, yet improves the life of many... ;)
*/
script->pdb_name = g_strdup (val);
for (s = script->pdb_name; *s; s++)
if (*s == '-')
*s = '_';
/* Find the script menu_path */
val = get_c_string (car (a));
script->menu_path = g_strdup (val);
......@@ -615,10 +606,9 @@ script_fu_add_script (LISP a)
LISP
script_fu_add_menu (LISP a)
{
SFScript *script;
SFMenu *menu;
gchar *val;
gchar *s;
SFScript *script;
SFMenu *menu;
const gchar *name;
/* Check the length of a */
if (nlength (a) != 2)
......@@ -626,15 +616,10 @@ script_fu_add_menu (LISP a)
NIL);
/* Find the script PDB entry name */
val = g_strdup (get_c_string (car (a)));
for (s = val; *s; s++)
if (*s == '-')
*s = '_';
name = get_c_string (car (a));
a = cdr (a);
script = script_fu_find_script (val);
g_free (val);
script = script_fu_find_script (name);
if (! script)
return my_err ("Nonexisting procedure name in script-fu-menu-register",
......@@ -646,8 +631,7 @@ script_fu_add_menu (LISP a)
menu->script = script;
/* Find the script menu path */
val = get_c_string (car (a));
menu->menu_path = g_strdup (val);
menu->menu_path = g_strdup (get_c_string (car (a)));
script_menu_list = g_list_prepend (script_menu_list, menu);
......@@ -710,7 +694,7 @@ script_fu_install_script (gpointer foo,
if (strncmp (script->menu_path, "<None>", 6) != 0)
menu_path = script->menu_path;
gimp_install_temp_proc (script->pdb_name,
gimp_install_temp_proc (script->script_name,
script->help,
"",
script->author,
......@@ -737,7 +721,7 @@ static void
script_fu_install_menu (SFMenu *menu,
gpointer foo)
{
gimp_plugin_menu_register (menu->script->pdb_name, menu->menu_path);
gimp_plugin_menu_register (menu->script->script_name, menu->menu_path);
g_free (menu->menu_path);
g_free (menu);
......@@ -937,7 +921,7 @@ script_fu_lookup_script (gpointer *foo,
{
SFScript *script = list->data;
if (strcmp (script->pdb_name, *name) == 0)
if (strcmp (script->script_name, *name) == 0)
{
/* store the script in the name pointer and stop the traversal */
*name = script;
......@@ -949,15 +933,15 @@ script_fu_lookup_script (gpointer *foo,
}
static SFScript *
script_fu_find_script (const gchar *pdb_name)
script_fu_find_script (const gchar *script_name)
{
gconstpointer script = pdb_name;
gconstpointer script = script_name;
g_tree_foreach (script_tree,
(GTraverseFunc) script_fu_lookup_script,
&script);
if (script == pdb_name)
if (script == script_name)
return NULL;
return (SFScript *) script;
......@@ -971,9 +955,8 @@ script_fu_free_script (SFScript *script)
g_return_if_fail (script != NULL);
/* Uninstall the temporary procedure for this script */
gimp_uninstall_temp_proc (script->pdb_name);
gimp_uninstall_temp_proc (script->script_name);
g_free (script->pdb_name);
g_free (script->script_name);
g_free (script->menu_path);
g_free (script->help);
......
......@@ -84,7 +84,6 @@ typedef union
typedef struct
{
gchar *script_name;
gchar *pdb_name;
gchar *menu_path;
gchar *help;
gchar *author;
......
......@@ -95,7 +95,7 @@ script_fu_query (void)
gimp_plugin_domain_register (GETTEXT_PACKAGE "-script-fu", NULL);
gimp_install_procedure ("extension_script_fu",
gimp_install_procedure ("extension-script-fu",
"A scheme interpreter for scripting GIMP operations",
"More help here later",
"Spencer Kimball & Peter Mattis",
......@@ -106,7 +106,7 @@ script_fu_query (void)
GIMP_EXTENSION,
0, 0, NULL, NULL);
gimp_install_procedure ("plug_in_script_fu_console",
gimp_install_procedure ("plug-in-script-fu-console",
"Provides a console mode for script-fu development",
"Provides an interface which allows interactive "
"scheme development.",
......@@ -119,10 +119,10 @@ script_fu_query (void)
G_N_ELEMENTS (console_args), 0,
console_args, NULL);
gimp_plugin_menu_register ("plug_in_script_fu_console",
gimp_plugin_menu_register ("plug-in-script-fu-console",
N_("<Toolbox>/Xtns/Script-Fu"));
gimp_install_procedure ("plug_in_script_fu_text_console",
gimp_install_procedure ("plug-in-script-fu-text-console",
"Provides a text console mode for script-fu "
"development",
"Provides an interface which allows interactive "
......@@ -136,7 +136,7 @@ script_fu_query (void)
G_N_ELEMENTS (textconsole_args), 0,
textconsole_args, NULL);
gimp_install_procedure ("plug_in_script_fu_server",
gimp_install_procedure ("plug-in-script-fu-server",
"Provides a server for remote script-fu operation",
"Provides a server for remote script-fu operation",
"Spencer Kimball & Peter Mattis",
......@@ -148,10 +148,10 @@ script_fu_query (void)
G_N_ELEMENTS (server_args), 0,
server_args, NULL);
gimp_plugin_menu_register ("plug_in_script_fu_server",
gimp_plugin_menu_register ("plug-in-script-fu-server",
N_("<Toolbox>/Xtns/Script-Fu"));
gimp_install_procedure ("plug_in_script_fu_eval",
gimp_install_procedure ("plug-in-script-fu-eval",
"Evaluate scheme code",
"Evaluate the code under the scheme interpreter "
"(primarily for batch mode)",
......@@ -180,7 +180,7 @@ script_fu_run (const gchar *name,
/* Determine before we allow scripts to register themselves
* whether this is the base, automatically installed script-fu extension
*/
if (strcmp (name, "extension_script_fu") == 0)
if (strcmp (name, "extension-script-fu") == 0)
{
/* Setup auxillary temporary procedures for the base extension */
script_fu_extension_init ();
......@@ -197,7 +197,7 @@ script_fu_run (const gchar *name,
/* Load all of the available scripts */
script_fu_find_scripts ();
if (strcmp (name, "extension_script_fu") == 0)
if (strcmp (name, "extension-script-fu") == 0)
{
/*
* The main, automatically installed script fu extension. For
......@@ -220,7 +220,7 @@ script_fu_run (const gchar *name,
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = status;
}
else if (strcmp (name, "plug_in_script_fu_text_console") == 0)
else if (strcmp (name, "plug-in-script-fu-text-console") == 0)
{
/*
* The script-fu text console for interactive SIOD development
......@@ -229,7 +229,7 @@ script_fu_run (const gchar *name,
script_fu_text_console_run (name, nparams, param,
nreturn_vals, return_vals);
}
else if (strcmp (name, "plug_in_script_fu_console") == 0)
else if (strcmp (name, "plug-in-script-fu-console") == 0)
{
/*
* The script-fu console for interactive SIOD development
......@@ -238,7 +238,7 @@ script_fu_run (const gchar *name,
script_fu_console_run (name, nparams, param,
nreturn_vals, return_vals);
}
else if (strcmp (name, "plug_in_script_fu_server") == 0)
else if (strcmp (name, "plug-in-script-fu-server") == 0)
{
/*
* The script-fu server for remote operation
......@@ -247,7 +247,7 @@ script_fu_run (const gchar *name,
script_fu_server_run (name, nparams, param,
nreturn_vals, return_vals);
}
else if (strcmp (name, "plug_in_script_fu_eval") == 0)
else if (strcmp (name, "plug-in-script-fu-eval") == 0)
{
/*
* A non-interactive "console" (for batch mode)
......@@ -304,7 +304,7 @@ script_fu_extension_init (void)
gimp_plugin_menu_branch_register ("<Image>/Filters/Decor",
N_("Stencil _Ops"));
gimp_install_temp_proc ("script_fu_refresh",
gimp_install_temp_proc ("script-fu-refresh",
"Re-read all available scripts",
"Re-read all available scripts",
"Spencer Kimball & Peter Mattis",
......
......@@ -232,7 +232,6 @@ init_procedures (void)
{
LISP args = NIL;
LISP code = NIL;
gchar *proc_name;
gint j;
/* create a new scheme func that calls gimp-proc-db-call */
......@@ -250,13 +249,8 @@ init_procedures (void)
args = nreverse (args);
code = nreverse (code);
/* convert the procedure name to scheme-like naming conventions */
proc_name = g_strdup (proc_list[i]);
convert_string (proc_name);
/* set the scheme-based procedure name */
args = cons (rintern (proc_name), args);
g_free (proc_name);
/* set the procedure name */
args = cons (rintern (proc_list[i]), args);
/* set the actual pdb procedure name */
code = cons (cons (cintern ("quote"),
......@@ -556,7 +550,6 @@ marshall_proc_db_call (LISP a)
&nparams, &nreturn_vals,
&params, &return_vals))
{
convert_string (proc_name);