Commit 3eaf6e9a authored by GMT 1999 Andy Thomas's avatar GMT 1999 Andy Thomas Committed by Andy Thomas

Changed:-

Sat Jan 30 23:51:04 GMT 1999 Andy Thomas <alt@picnic.demon.co.uk>

	Changed:-

	* app/dialog_handler.c
	* app/dialog_handler.h
	* app/gimage.c
	* app/gimprc.c
	* app/plug_in.c
	* app/plug_in.h

	Fixed problem with TAB key hiding all dialogs. With some WM
	you could hide all the windows with TAB then close the last image
	down... opps how do you get back to the main dialog. Main
	dialog is now poped up when last image is closed and we had
	used TAB key to hide it.

	New PDB functions to query plugin info. Plugin to follow...
parent 07686fcd
Sat Jan 30 23:51:04 GMT 1999 Andy Thomas <alt@picnic.demon.co.uk>
Changed:-
* app/dialog_handler.c
* app/dialog_handler.h
* app/gimage.c
* app/gimprc.c
* app/plug_in.c
* app/plug_in.h
Fixed problem with TAB key hiding all dialogs. With some WM
you could hide all the windows with TAB then close the last image
down... opps how do you get back to the main dialog. Main
dialog is now poped up when last image is closed and we had
used TAB key to hide it.
New PDB functions to query plugin info. Plugin to follow...
Sat Jan 30 23:47:37 1999 Tor Lillqvist <tml@iki.fi>
* app/menus.c (menus_init_mru): Don't g_snprintf into a NULL pointer.
......
......@@ -28,6 +28,7 @@
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#include "regex.h"
#include "libgimp/parasite.h"
#include "libgimp/parasiteP.h" /* ick */
......@@ -136,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
static Argument* plugins_query_invoker (Argument *args);
static GSList *plug_in_defs = NULL;
......@@ -304,6 +307,92 @@ static ProcRecord plugin_temp_PDB_name_proc =
{ { plugin_temp_PDB_name_invoker } },
};
/* The number keeps getting repeated here because in is required
* by the PDB interface for *ARRAY types.
*/
static ProcArg plugins_query_out_args[] =
{
{ PDB_INT32,
"num_plugins",
"the number of plugins"
},
{ PDB_STRINGARRAY,
"menu_path",
"the menu path of the plugin"
},
{ PDB_INT32,
"num_plugins",
"the number of plugins"
},
{ PDB_STRINGARRAY,
"plugin_accelerator",
"String representing keyboard accelerator (could be empty string)"
},
{ PDB_INT32,
"num_plugins",
"the number of plugins"
},
{ PDB_STRINGARRAY,
"plugin_location",
"Location of the plugin program"
},
{ PDB_INT32,
"num_plugins",
"the number of plugins"
},
{ PDB_STRINGARRAY,
"plugin_image_type",
"Type of image that this plugin will work on"
},
{ PDB_INT32,
"num_plugins",
"the number of plugins"
},
{ PDB_INT32ARRAY,
"plugin_install_time",
"Time that the plugin was installed"
},
{ PDB_INT32,
"num_plugins",
"the number of plugins"
},
{ PDB_STRINGARRAY,
"plugin_real_name",
"The internal name of the plugin"
}
};
static ProcArg plugins_query_in_args[] =
{
{ PDB_STRING,
"search_string",
"If not an empty string then use this as a search pattern"
}
};
ProcRecord plugin_query_proc =
{
"gimp_plugins_query",
"Queries the plugin database for its contents",
"This procedure queries the contents of the plugin database",
"Andy Thomas",
"Andy Thomas",
"1999",
PDB_INTERNAL,
/* Input arguments */
sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]),
plugins_query_in_args,
/* Output arguments */
sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]),
plugins_query_out_args,
/* Exec method */
{ { plugins_query_invoker } },
};
void
plug_in_init ()
......@@ -324,9 +413,13 @@ plug_in_init ()
procedural_db_register (&message_handler_get_proc);
procedural_db_register (&message_handler_set_proc);
/* initialize the message box procedural db calls */
/* initialize the temp name PDB interafce */
procedural_db_register (&plugin_temp_PDB_name_proc);
/* initialize the plugin browser */
procedural_db_register (&plugin_query_proc);
/* initialize the gimp protocol library and set the read and
* write handlers.
*/
......@@ -423,6 +516,7 @@ plug_in_init ()
proc_def = tmp2->data;
tmp2 = tmp2->next;
proc_def->mtime = plug_in_def->mtime;
plug_in_proc_def_insert (proc_def);
}
}
......@@ -1723,6 +1817,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc_def->magics = NULL;
proc_def->image_types = g_strdup (proc_install->image_types);
proc_def->image_types_val = plug_in_image_types_parse (proc_def->image_types);
/* Install temp one use todays time */
proc_def->mtime = time(NULL);
proc = &proc_def->db_info;
......@@ -3173,3 +3269,133 @@ plugin_temp_PDB_name_invoker (Argument *args)
return return_args;
}
static int
match_strings (regex_t * preg,
char * a)
{
int ret = regexec (preg, a, 0, NULL, 0);
return ret;
}
static Argument*
plugins_query_invoker (Argument *args)
{
Argument *return_args;
PlugInProcDef *proc_def;
gchar * search_str;
GSList *tmp;
gint i = 0;
guint num_plugins = 0;
gchar * *menu_strs;
gchar * *accel_strs;
gchar * *prog_strs;
gchar * *types_strs;
gchar * *realname_strs;
gint *time_ints;
regex_t sregex;
/* Get the search string */
search_str = args[0].value.pdb_pointer;
if(search_str && strlen(search_str) > 0)
{
regcomp(&sregex,search_str,REG_ICASE);
}
else
search_str = NULL;
/* count number of plugin entries */
/* then allocate 4 arrays of correct size where we can store the
* strings.
*/
tmp = proc_defs;
while (tmp)
{
proc_def = tmp->data;
tmp = tmp->next;
if (proc_def->prog && proc_def->menu_path)
{
gchar * name = strrchr (proc_def->menu_path, '/');
if (name)
name = name + 1;
else
name = proc_def->menu_path;
if(search_str && match_strings(&sregex,name))
continue;
num_plugins++;
}
}
return_args = procedural_db_return_args (&plugin_query_proc, TRUE);
menu_strs = g_new(gchar *,num_plugins);
accel_strs = g_new(gchar *,num_plugins);
prog_strs = g_new(gchar *,num_plugins);
types_strs = g_new(gchar *,num_plugins);
realname_strs = g_new(gchar *,num_plugins);
time_ints = g_new(gint ,num_plugins);
return_args[1].value.pdb_int = num_plugins;
return_args[2].value.pdb_pointer = menu_strs;
return_args[3].value.pdb_int = num_plugins;
return_args[4].value.pdb_pointer = accel_strs;
return_args[5].value.pdb_int = num_plugins;
return_args[6].value.pdb_pointer = prog_strs;
return_args[7].value.pdb_int = num_plugins;
return_args[8].value.pdb_pointer = types_strs;
return_args[9].value.pdb_int = num_plugins;
return_args[10].value.pdb_pointer = time_ints;
return_args[11].value.pdb_int = num_plugins;
return_args[12].value.pdb_pointer = realname_strs;
tmp = proc_defs;
while (tmp)
{
if(i > num_plugins)
g_error (_("Internal error counting plugins"));
proc_def = tmp->data;
tmp = tmp->next;
if (proc_def->prog && proc_def->menu_path);
{
ProcRecord *pr = &proc_def->db_info;
gchar * name = strrchr (proc_def->menu_path, '/');
if (name)
name = name + 1;
else
name = proc_def->menu_path;
if(search_str && match_strings(&sregex,name))
continue;
menu_strs[i] = g_strdup(proc_def->menu_path);
accel_strs[i] = g_strdup(proc_def->accelerator);
prog_strs[i] = g_strdup(proc_def->prog);
types_strs[i] = g_strdup(proc_def->image_types);
time_ints[i] = proc_def->mtime;
realname_strs[i] = g_strdup(pr->name);
i++;
}
}
/* This I hope frees up internal stuff */
if(search_str)
free (sregex.buffer);
return return_args;
}
......@@ -117,16 +117,6 @@ dialog_show_all()
/* Handle the tool box in a special way */
static void
dialog_show_toolbox()
{
if(toolbox_shell &&
toolbox_shell->state == WAS_SHOWING &&
!GTK_WIDGET_VISIBLE (toolbox_shell->d))
{
gtk_widget_show(toolbox_shell->d);
}
}
static void
dialog_hide_toolbox()
......@@ -140,6 +130,18 @@ dialog_hide_toolbox()
/* public */
void
dialog_show_toolbox()
{
if(toolbox_shell &&
toolbox_shell->state == WAS_SHOWING &&
!GTK_WIDGET_VISIBLE (toolbox_shell->d))
{
gtk_widget_show(toolbox_shell->d);
}
}
/* Set hourglass cursor on all currently registered dialogs */
void
......
......@@ -26,6 +26,7 @@ void dialog_unregister (GtkWidget *dialog);
void dialog_toggle (void);
void dialog_idle_all (void);
void dialog_unidle_all (void);
void dialog_show_toolbox (void);
#endif /* __DIALOG_HANDLER_H_ */
......@@ -18,6 +18,7 @@
#include "general.h"
#include "appenv.h"
#include "gimpset.h"
#include "dialog_handler.h"
/* gimage.c: Junk (ugly dependencies) from gimpimage.c on its way
to proper places. That is, the handlers should be moved to
......@@ -102,6 +103,26 @@ gimage_dirty_handler (GimpImage* gimage){
}
}
static void
gimlist_cb(gpointer im, gpointer data){
GSList** l=(GSList**)data;
*l=g_slist_prepend(*l, im);
}
gint
gimage_image_count()
{
GSList *list=NULL;
gint num_images = 0;
gimage_foreach(gimlist_cb, &list);
num_images = g_slist_length (list);
g_slist_free(list);
return (num_images);
}
static void
gimage_destroy_handler (GimpImage* gimage)
{
......@@ -110,6 +131,11 @@ gimage_destroy_handler (GimpImage* gimage)
undo_free (gimage);
palette_import_image_destroyed(gimage);
if(gimage_image_count() == 1) /* This is the last image */
{
dialog_show_toolbox();
}
}
static void gimage_cmap_change_handler (GimpImage* gimage, gint ncol,
......
......@@ -1147,6 +1147,7 @@ parse_plug_in_def (gpointer val1p,
while (parse_proc_def (&proc_def))
{
proc_def->mtime = plug_in_def->mtime;
proc_def->prog = g_strdup (plug_in_def->prog);
plug_in_def->proc_defs = g_slist_append (plug_in_def->proc_defs, proc_def);
}
......
......@@ -28,6 +28,7 @@
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#include "regex.h"
#include "libgimp/parasite.h"
#include "libgimp/parasiteP.h" /* ick */
......@@ -136,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
static Argument* plugins_query_invoker (Argument *args);
static GSList *plug_in_defs = NULL;
......@@ -304,6 +307,92 @@ static ProcRecord plugin_temp_PDB_name_proc =
{ { plugin_temp_PDB_name_invoker } },
};
/* The number keeps getting repeated here because in is required
* by the PDB interface for *ARRAY types.
*/
static ProcArg plugins_query_out_args[] =
{
{ PDB_INT32,
"num_plugins",
"the number of plugins"
},
{ PDB_STRINGARRAY,
"menu_path",
"the menu path of the plugin"
},
{ PDB_INT32,
"num_plugins",
"the number of plugins"
},
{ PDB_STRINGARRAY,
"plugin_accelerator",
"String representing keyboard accelerator (could be empty string)"
},
{ PDB_INT32,
"num_plugins",
"the number of plugins"
},
{ PDB_STRINGARRAY,
"plugin_location",
"Location of the plugin program"
},
{ PDB_INT32,
"num_plugins",
"the number of plugins"
},
{ PDB_STRINGARRAY,
"plugin_image_type",
"Type of image that this plugin will work on"
},
{ PDB_INT32,
"num_plugins",
"the number of plugins"
},
{ PDB_INT32ARRAY,
"plugin_install_time",
"Time that the plugin was installed"
},
{ PDB_INT32,
"num_plugins",
"the number of plugins"
},
{ PDB_STRINGARRAY,
"plugin_real_name",
"The internal name of the plugin"
}
};
static ProcArg plugins_query_in_args[] =
{
{ PDB_STRING,
"search_string",
"If not an empty string then use this as a search pattern"
}
};
ProcRecord plugin_query_proc =
{
"gimp_plugins_query",
"Queries the plugin database for its contents",
"This procedure queries the contents of the plugin database",
"Andy Thomas",
"Andy Thomas",
"1999",
PDB_INTERNAL,
/* Input arguments */
sizeof(plugins_query_in_args) / sizeof(plugins_query_in_args[0]),
plugins_query_in_args,
/* Output arguments */
sizeof(plugins_query_out_args) / sizeof(plugins_query_out_args[0]),
plugins_query_out_args,
/* Exec method */
{ { plugins_query_invoker } },
};
void
plug_in_init ()
......@@ -324,9 +413,13 @@ plug_in_init ()
procedural_db_register (&message_handler_get_proc);
procedural_db_register (&message_handler_set_proc);
/* initialize the message box procedural db calls */
/* initialize the temp name PDB interafce */
procedural_db_register (&plugin_temp_PDB_name_proc);
/* initialize the plugin browser */
procedural_db_register (&plugin_query_proc);
/* initialize the gimp protocol library and set the read and
* write handlers.
*/
......@@ -423,6 +516,7 @@ plug_in_init ()
proc_def = tmp2->data;
tmp2 = tmp2->next;
proc_def->mtime = plug_in_def->mtime;
plug_in_proc_def_insert (proc_def);
}
}
......@@ -1723,6 +1817,8 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
proc_def->magics = NULL;
proc_def->image_types = g_strdup (proc_install->image_types);
proc_def->image_types_val = plug_in_image_types_parse (proc_def->image_types);
/* Install temp one use todays time */
proc_def->mtime = time(NULL);
proc = &proc_def->db_info;
......@@ -3173,3 +3269,133 @@ plugin_temp_PDB_name_invoker (Argument *args)
return return_args;
}
static int
match_strings (regex_t * preg,
char * a)
{
int ret = regexec (preg, a, 0, NULL, 0);
return ret;
}
static Argument*
plugins_query_invoker (Argument *args)
{
Argument *return_args;
PlugInProcDef *proc_def;
gchar * search_str;
GSList *tmp;
gint i = 0;
guint num_plugins = 0;
gchar * *menu_strs;
gchar * *accel_strs;
gchar * *prog_strs;
gchar * *types_strs;
gchar * *realname_strs;
gint *time_ints;
regex_t sregex;
/* Get the search string */
search_str = args[0].value.pdb_pointer;
if(search_str && strlen(search_str) > 0)
{
regcomp(&sregex,search_str,REG_ICASE);
}
else
search_str = NULL;
/* count number of plugin entries */
/* then allocate 4 arrays of correct size where we can store the
* strings.
*/
tmp = proc_defs;
while (tmp)
{
proc_def = tmp->data;
tmp = tmp->next;
if (proc_def->prog && proc_def->menu_path)
{
gchar * name = strrchr (proc_def->menu_path, '/');
if (name)
name = name + 1;
else
name = proc_def->menu_path;
if(search_str && match_strings(&sregex,name))
continue;
num_plugins++;
}
}
return_args = procedural_db_return_args (&plugin_query_proc, TRUE);
menu_strs = g_new(gchar *,num_plugins);
accel_strs = g_new(gchar *,num_plugins);
prog_strs = g_new(gchar *,num_plugins);
types_strs = g_new(gchar *,num_plugins);
realname_strs = g_new(gchar *,num_plugins);
time_ints = g_new(gint ,num_plugins);
return_args[1].value.pdb_int = num_plugins;
return_args[2].value.pdb_pointer = menu_strs;
return_args[3].value.pdb_int = num_plugins;
return_args[4].value.pdb_pointer = accel_strs;
return_args[5].value.pdb_int = num_plugins;
return_args[6].value.pdb_pointer = prog_strs;
return_args[7].value.pdb_int = num_plugins;
return_args[8].value.pdb_pointer = types_strs;
return_args[9].value.pdb_int = num_plugins;
return_args[10].value.pdb_pointer = time_ints;
return_args[11].value.pdb_int = num_plugins;
return_args[12].value.pdb_pointer = realname_strs;
tmp = proc_defs;
while (tmp)
{
if(i > num_plugins)
g_error (_("Internal error counting plugins"));
proc_def = tmp->data;
tmp = tmp->next;
if (proc_def->prog && proc_def->menu_path);
{
ProcRecord *pr = &proc_def->db_info;
gchar * name = strrchr (proc_def->menu_path, '/');
if (name)
name = name + 1;