Commit 1dc4b14f authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

app/gimprc.c app/plug_in.[ch] app/pdb/plug_in_cmds.c started to clean

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

	* app/gimprc.c
	* app/plug_in.[ch]
	* app/pdb/plug_in_cmds.c
	* tools/pdbgen/pdb/plug_in.pdb: started to clean plug_in code a little.
	Still a long way to go...

	* app/gui/splash.c: simplified
parent 8533a2d3
2001-11-24 Sven Neumann <sven@gimp.org>
* app/gimprc.c
* app/plug_in.[ch]
* app/pdb/plug_in_cmds.c
* tools/pdbgen/pdb/plug_in.pdb: started to clean plug_in code a little.
Still a long way to go...
* app/gui/splash.c: simplified
2001-11-24 Simon Budig <simon@gimp.org>
* app/base/base-types.h
......
......@@ -113,6 +113,18 @@
#include "libgimp/gimpintl.h"
struct _PlugInDef
{
gchar *prog;
GSList *proc_defs;
gchar *locale_domain;
gchar *locale_path;
gchar *help_path;
time_t mtime;
gboolean query;
};
typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked
......@@ -306,6 +318,7 @@ plug_in_init (Gimp *gimp,
extern gboolean use_shm;
gchar *filename;
gchar *basename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def;
......@@ -374,8 +387,10 @@ plug_in_init (Gimp *gimp,
plug_in_query (plug_in_def);
}
(* status_callback) (NULL, plug_in_def->prog, nth / nplugins);
basename = g_path_get_basename (plug_in_def->prog);
(* status_callback) (NULL, basename, nth / nplugins);
nth++;
g_free (basename);
}
/* insert the proc defs */
......@@ -743,6 +758,16 @@ plug_in_def_free (PlugInDef *plug_in_def,
g_free (plug_in_def);
}
void
plug_in_def_add_proc_def (PlugInDef *plug_in_def,
PlugInProcDef *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);
}
void
plug_in_def_add (PlugInDef *plug_in_def)
......@@ -1472,6 +1497,40 @@ plug_in_set_menu_sensitivity (GimpImageType type)
}
}
void
plug_in_def_set_mtime (PlugInDef *plug_in_def,
time_t mtime)
{
plug_in_def->mtime = mtime;
}
void
plug_in_def_set_locale_domain_name (PlugInDef *plug_in_def,
const gchar *domain_name)
{
if (plug_in_def->locale_domain)
g_free (plug_in_def->locale_domain);
plug_in_def->locale_domain = g_strdup (domain_name);
}
void
plug_in_def_set_locale_domain_path (PlugInDef *plug_in_def,
const gchar *domain_path)
{
if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
plug_in_def->locale_path = g_strdup (domain_path);
}
void
plug_in_def_set_help_path (PlugInDef *plug_in_def,
const gchar *help_path)
{
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
plug_in_def->help_path = g_strdup (help_path);
}
static gboolean
plug_in_recv_message (GIOChannel *channel,
GIOCondition cond,
......@@ -2474,7 +2533,7 @@ plug_in_init_file (const gchar *filename,
g_free (basename);
plug_in_def = plug_in_def_new (filename);
plug_in_def = plug_in_def_new (filename);
plug_in_def->mtime = gimp_datafile_mtime ();
plug_in_def->query = TRUE;
......
......@@ -1461,19 +1461,14 @@ parse_plug_in_def (gpointer val1p,
goto error;
token = get_next_token ();
plug_in_def->mtime = token_int;
plug_in_def_set_mtime (plug_in_def, token_int);
success = OK;
while (success == OK)
{
success = parse_proc_def (&proc_def);
if (success == OK)
{
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);
}
plug_in_def_add_proc_def (plug_in_def, proc_def);
else if (success == LOCALE_DEF)
success = parse_locale_def (plug_in_def);
else if (success == HELP_DEF)
......@@ -1504,20 +1499,15 @@ parse_locale_def (PlugInDef *plug_in_def)
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
return ERROR;
token = get_next_token ();
plug_in_def_set_locale_domain_name (plug_in_def, token_str);
if (plug_in_def->locale_domain)
g_free (plug_in_def->locale_domain);
plug_in_def->locale_domain = g_strdup (token_str);
token = peek_next_token ();
if (token && token == TOKEN_STRING)
{
token = get_next_token ();
if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
plug_in_def->locale_path = g_strdup (token_str);
plug_in_def_set_locale_domain_path (plug_in_def, token_str);
token = peek_next_token ();
}
......@@ -1528,11 +1518,8 @@ parse_locale_def (PlugInDef *plug_in_def)
return OK;
error:
g_free (plug_in_def->locale_domain);
plug_in_def->locale_domain = NULL;
g_free (plug_in_def->locale_path);
plug_in_def->locale_path = NULL;
plug_in_def_set_locale_domain_name (plug_in_def, NULL);
plug_in_def_set_locale_domain_path (plug_in_def, NULL);
return ERROR;
}
......@@ -1546,9 +1533,7 @@ parse_help_def (PlugInDef *plug_in_def)
return ERROR;
token = get_next_token ();
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
plug_in_def->help_path = g_strdup (token_str);
plug_in_def_set_help_path (plug_in_def, token_str);
token = peek_next_token ();
if (!token || token != TOKEN_RIGHT_PAREN)
......@@ -1558,9 +1543,7 @@ parse_help_def (PlugInDef *plug_in_def)
return OK;
error:
g_free (plug_in_def->help_path);
plug_in_def->help_path = NULL;
plug_in_def_set_help_path (plug_in_def, NULL);
return ERROR;
}
......
......@@ -113,6 +113,18 @@
#include "libgimp/gimpintl.h"
struct _PlugInDef
{
gchar *prog;
GSList *proc_defs;
gchar *locale_domain;
gchar *locale_path;
gchar *help_path;
time_t mtime;
gboolean query;
};
typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked
......@@ -306,6 +318,7 @@ plug_in_init (Gimp *gimp,
extern gboolean use_shm;
gchar *filename;
gchar *basename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def;
......@@ -374,8 +387,10 @@ plug_in_init (Gimp *gimp,
plug_in_query (plug_in_def);
}
(* status_callback) (NULL, plug_in_def->prog, nth / nplugins);
basename = g_path_get_basename (plug_in_def->prog);
(* status_callback) (NULL, basename, nth / nplugins);
nth++;
g_free (basename);
}
/* insert the proc defs */
......@@ -743,6 +758,16 @@ plug_in_def_free (PlugInDef *plug_in_def,
g_free (plug_in_def);
}
void
plug_in_def_add_proc_def (PlugInDef *plug_in_def,
PlugInProcDef *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);
}
void
plug_in_def_add (PlugInDef *plug_in_def)
......@@ -1472,6 +1497,40 @@ plug_in_set_menu_sensitivity (GimpImageType type)
}
}
void
plug_in_def_set_mtime (PlugInDef *plug_in_def,
time_t mtime)
{
plug_in_def->mtime = mtime;
}
void
plug_in_def_set_locale_domain_name (PlugInDef *plug_in_def,
const gchar *domain_name)
{
if (plug_in_def->locale_domain)
g_free (plug_in_def->locale_domain);
plug_in_def->locale_domain = g_strdup (domain_name);
}
void
plug_in_def_set_locale_domain_path (PlugInDef *plug_in_def,
const gchar *domain_path)
{
if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
plug_in_def->locale_path = g_strdup (domain_path);
}
void
plug_in_def_set_help_path (PlugInDef *plug_in_def,
const gchar *help_path)
{
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
plug_in_def->help_path = g_strdup (help_path);
}
static gboolean
plug_in_recv_message (GIOChannel *channel,
GIOCondition cond,
......@@ -2474,7 +2533,7 @@ plug_in_init_file (const gchar *filename,
g_free (basename);
plug_in_def = plug_in_def_new (filename);
plug_in_def = plug_in_def_new (filename);
plug_in_def->mtime = gimp_datafile_mtime ();
plug_in_def->query = TRUE;
......
......@@ -113,6 +113,18 @@
#include "libgimp/gimpintl.h"
struct _PlugInDef
{
gchar *prog;
GSList *proc_defs;
gchar *locale_domain;
gchar *locale_path;
gchar *help_path;
time_t mtime;
gboolean query;
};
typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked
......@@ -306,6 +318,7 @@ plug_in_init (Gimp *gimp,
extern gboolean use_shm;
gchar *filename;
gchar *basename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def;
......@@ -374,8 +387,10 @@ plug_in_init (Gimp *gimp,
plug_in_query (plug_in_def);
}
(* status_callback) (NULL, plug_in_def->prog, nth / nplugins);
basename = g_path_get_basename (plug_in_def->prog);
(* status_callback) (NULL, basename, nth / nplugins);
nth++;
g_free (basename);
}
/* insert the proc defs */
......@@ -743,6 +758,16 @@ plug_in_def_free (PlugInDef *plug_in_def,
g_free (plug_in_def);
}
void
plug_in_def_add_proc_def (PlugInDef *plug_in_def,
PlugInProcDef *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);
}
void
plug_in_def_add (PlugInDef *plug_in_def)
......@@ -1472,6 +1497,40 @@ plug_in_set_menu_sensitivity (GimpImageType type)
}
}
void
plug_in_def_set_mtime (PlugInDef *plug_in_def,
time_t mtime)
{
plug_in_def->mtime = mtime;
}
void
plug_in_def_set_locale_domain_name (PlugInDef *plug_in_def,
const gchar *domain_name)
{
if (plug_in_def->locale_domain)
g_free (plug_in_def->locale_domain);
plug_in_def->locale_domain = g_strdup (domain_name);
}
void
plug_in_def_set_locale_domain_path (PlugInDef *plug_in_def,
const gchar *domain_path)
{
if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
plug_in_def->locale_path = g_strdup (domain_path);
}
void
plug_in_def_set_help_path (PlugInDef *plug_in_def,
const gchar *help_path)
{
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
plug_in_def->help_path = g_strdup (help_path);
}
static gboolean
plug_in_recv_message (GIOChannel *channel,
GIOCondition cond,
......@@ -2474,7 +2533,7 @@ plug_in_init_file (const gchar *filename,
g_free (basename);
plug_in_def = plug_in_def_new (filename);
plug_in_def = plug_in_def_new (filename);
plug_in_def->mtime = gimp_datafile_mtime ();
plug_in_def->query = TRUE;
......
......@@ -18,7 +18,6 @@
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <gtk/gtk.h>
......@@ -35,7 +34,6 @@
#define DEFAULT_WIDTH 300
static gint max_label_length = 1024;
static GtkWidget *win_initstatus = NULL;
static GtkWidget *label1 = NULL;
static GtkWidget *label2 = NULL;
......@@ -47,12 +45,8 @@ static GtkWidget *progress = NULL;
void
splash_create (gboolean show_image)
{
GtkWidget *vbox;
GdkPixbuf *pixbuf = NULL;
PangoFontMetrics *metrics;
PangoContext *context;
gint width;
gint char_width;
GtkWidget *vbox;
GdkPixbuf *pixbuf = NULL;
win_initstatus = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_type_hint (GTK_WINDOW (win_initstatus),
......@@ -124,29 +118,8 @@ splash_create (gboolean show_image)
gtk_box_pack_start_defaults (GTK_BOX (vbox), progress);
gtk_widget_show (progress);
/* This is a hack: we try to compute a good guess for the maximum
* number of charcters that will fit into the splash-screen using
* the default_font
*/
context = gtk_widget_get_pango_context (label2);
metrics = pango_context_get_metrics (context,
label2->style->font_desc,
pango_context_get_language (context));
char_width = pango_font_metrics_get_approximate_char_width (metrics);
pango_font_metrics_unref (metrics);
if (pixbuf)
{
width = gdk_pixbuf_get_width (pixbuf);
}
else
{
width = DEFAULT_WIDTH;
gtk_widget_set_size_request (win_initstatus, width, -1);
}
max_label_length =
0.9 * (gdouble) width / (gdouble) PANGO_PIXELS (char_width);
if (!pixbuf)
gtk_widget_set_size_request (win_initstatus, DEFAULT_WIDTH, -1);
gtk_widget_show (win_initstatus);
}
......@@ -166,32 +139,18 @@ splash_update (const gchar *text1,
const gchar *text2,
gdouble percentage)
{
gchar *temp;
if (win_initstatus)
{
if (text1)
gtk_label_set_text (GTK_LABEL (label1), text1);
if (text2)
{
while (strlen (text2) > max_label_length)
{
temp = strchr (text2, G_DIR_SEPARATOR);
if (temp == NULL) /* for sanity */
break;
temp++;
text2 = temp;
}
gtk_label_set_text (GTK_LABEL (label2), text2);
}
percentage = CLAMP (percentage, 0.0, 1.0);
gtk_progress_bar_update (GTK_PROGRESS_BAR (progress), percentage);
while (gtk_events_pending ())
gtk_main_iteration ();
}
if (!win_initstatus)
return;
if (text1)
gtk_label_set_text (GTK_LABEL (label1), text1);
if (text2)
gtk_label_set_text (GTK_LABEL (label2), text2);
gtk_progress_bar_update (GTK_PROGRESS_BAR (progress),
CLAMP (percentage, 0.0, 1.0));
while (gtk_events_pending ())
gtk_main_iteration ();
}
......@@ -113,6 +113,18 @@
#include "libgimp/gimpintl.h"
struct _PlugInDef
{
gchar *prog;
GSList *proc_defs;
gchar *locale_domain;
gchar *locale_path;
gchar *help_path;
time_t mtime;
gboolean query;
};
typedef struct _PlugInBlocked PlugInBlocked;
struct _PlugInBlocked
......@@ -306,6 +318,7 @@ plug_in_init (Gimp *gimp,
extern gboolean use_shm;
gchar *filename;
gchar *basename;
GSList *tmp;
GSList *tmp2;
PlugInDef *plug_in_def;
......@@ -374,8 +387,10 @@ plug_in_init (Gimp *gimp,
plug_in_query (plug_in_def);
}
(* status_callback) (NULL, plug_in_def->prog, nth / nplugins);
basename = g_path_get_basename (plug_in_def->prog);
(* status_callback) (NULL, basename, nth / nplugins);
nth++;
g_free (basename);
}
/* insert the proc defs */
......@@ -743,6 +758,16 @@ plug_in_def_free (PlugInDef *plug_in_def,
g_free (plug_in_def);
}
void
plug_in_def_add_proc_def (PlugInDef *plug_in_def,
PlugInProcDef *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);
}
void
plug_in_def_add (PlugInDef *plug_in_def)
......@@ -1472,6 +1497,40 @@ plug_in_set_menu_sensitivity (GimpImageType type)
}
}
void
plug_in_def_set_mtime (PlugInDef *plug_in_def,
time_t mtime)
{
plug_in_def->mtime = mtime;
}
void
plug_in_def_set_locale_domain_name (PlugInDef *plug_in_def,
const gchar *domain_name)
{
if (plug_in_def->locale_domain)
g_free (plug_in_def->locale_domain);
plug_in_def->locale_domain = g_strdup (domain_name);
}
void
plug_in_def_set_locale_domain_path (PlugInDef *plug_in_def,
const gchar *domain_path)
{
if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
plug_in_def->locale_path = g_strdup (domain_path);
}
void
plug_in_def_set_help_path (PlugInDef *plug_in_def,
const gchar *help_path)
{
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
plug_in_def->help_path = g_strdup (help_path);
}
static gboolean
plug_in_recv_message (GIOChannel *channel,
GIOCondition cond,
......@@ -2474,7 +2533,7 @@ plug_in_init_file (const gchar *filename,
g_free (basename);
plug_in_def = plug_in_def_new (filename);
plug_in_def = plug_in_def_new (filename);
plug_in_def->mtime = gimp_datafile_mtime ();
plug_in_def->query = TRUE;
......
......@@ -426,15 +426,10 @@ plugin_domain_register_invoker (Gimp *gimp,
{
if (current_plug_in && current_plug_in->query)
{
plug_in_def = current_plug_in->user_data;
if (plug_in_def->locale_domain)
g_free (plug_in_def->locale_domain);
plug_in_def->locale_domain = g_strdup (domain_name);
if (plug_in_def->locale_path);