Commit e92bcf2b authored by Chema Celorio's avatar Chema Celorio Committed by Jose Maria Celorio

keep a list of all the GladeWidgetClass that we loaded

2001-12-02  Chema Celorio  <chema@celorio.com>

	* src/glade-catalog.c (glade_catalog_load): keep a list of all the
	GladeWidgetClass that we loaded

	* src/main.c (glade_init): s/catalog/catalogs
	* src/glade-project-window.h (struct _GladeProjectWindow): ditto
	* src/glade-project-window.c (glade_project_window_new): ditto

	* src/glade-placeholder.c (glade_placeholder_get_from_properties): return
	GTK_BIN (parent->widget)->child if we have a GtkWindow

	* src/glade-catalog.c (glade_catalog_load): constify
	(glade_catalog_load_all): check if we where able to open the directory
parent 1244551a
......@@ -32,12 +32,13 @@
#include "glade-catalog.h"
#include "glade-widget-class.h"
GladeCatalog *glade_catalog = NULL;
GList *glade_catalog_list = NULL; /* A list of GladeCatalog items */
GList *widget_class_list = NULL; /* A list of all the GladeWidgetClass objects loaded */
GladeCatalog *
glade_catalog_get (void)
GList *
glade_catalog_get_widgets (void)
{
return glade_catalog;
return widget_class_list;
}
static GladeCatalog *
......@@ -109,7 +110,7 @@ glade_catalog_new_from_file (const gchar *file)
}
GladeCatalog *
glade_catalog_load (gchar *file_name)
glade_catalog_load (const gchar *file_name)
{
GladeWidgetClass *class;
GladeCatalog *catalog;
......@@ -127,12 +128,16 @@ glade_catalog_load (gchar *file_name)
name = list->data;
class = glade_widget_class_new_from_name (name);
if (class == NULL) continue;
new_list = g_list_prepend (new_list, class);
new_list = g_list_prepend (new_list, class);
widget_class_list = g_list_prepend (widget_class_list, class);
/* We keep a list per catalog (group) and a general list of
* all widgets loaded
*/
}
catalog->widgets = g_list_reverse (new_list);
glade_catalog = catalog;
glade_catalog_list = g_list_prepend (glade_catalog_list, catalog);
list = catalog->widgets;
for (; list != NULL; list = list->next) {
......@@ -155,6 +160,11 @@ glade_catalog_load_all (void)
gchar *filename = NULL;
catalogsdir = opendir (CATALOG_DIR);
if (!catalogsdir) {
g_warning ("Could not open catalogs from %s\n", CATALOG_DIR);
return NULL;
}
direntry = readdir (catalogsdir);
while (direntry) {
filename = g_strdup_printf ("%s/%s", CATALOG_DIR, direntry->d_name);
......
......@@ -21,10 +21,11 @@ struct _GladeCatalog
*/
};
GladeCatalog * glade_catalog_load (gchar *file_name);
GladeCatalog * glade_catalog_load (const gchar *file_name);
GladeCatalog * glade_catalog_get (void);
GList * glade_catalog_load_all (void);
GList * glade_catalog_get_widgets (void); /* This prolly should be in glade-widget-class.c */
G_END_DECLS
......
......@@ -344,7 +344,7 @@ glade_palette_create (GladeProjectWindow *gpw)
/* FIXME: I think that I should not tell you why. This code
* do what it should do, but it sucks a lot.
*/
catalogs = gpw->catalog;
catalogs = gpw->catalogs;
/* Groups */
for (i = 0; catalogs != NULL; catalogs = g_list_next (catalogs), i++){
......@@ -362,7 +362,7 @@ glade_palette_create (GladeProjectWindow *gpw)
gtk_box_pack_start (GTK_BOX (palette->vbox), widget,
FALSE, TRUE, 3);
catalogs = gpw->catalog;
catalogs = gpw->catalogs;
/* Sections */
for (i = 0; catalogs != NULL; catalogs = g_list_next (catalogs), i++){
......
......@@ -462,7 +462,7 @@ glade_placeholder_get_from_properties (GladeWidget *parent,
}
}
} else if (glade_widget_class_is (parent->class, "GtkWindow")) {
placeholder = NULL;
placeholder = GTK_BIN (parent->widget)->child;
} else {
glade_implement_me ();
}
......
......@@ -306,7 +306,7 @@ glade_project_window_set_view (GladeProjectWindow *gpw, GladeProjectView *view)
}
GladeProjectWindow *
glade_project_window_new (GList *catalog)
glade_project_window_new (GList *catalogs)
{
GladeProjectWindow *gpw;
GladeProjectView *view;
......@@ -315,7 +315,7 @@ glade_project_window_new (GList *catalog)
gpw = g_new0 (GladeProjectWindow, 1);
glade_project_window_create (gpw, view);
gpw->catalog = catalog;
gpw->catalogs = catalogs;
gpw->views = g_list_prepend (NULL, view);
gpw->add_class = NULL;
......
......@@ -28,7 +28,7 @@ struct _GladeProjectWindow
GladePalette *palette; /* See glade-palette */
GladeEditor *editor; /* See glade-editor */
GladeProjectView *active_view; /* See glade-project-view */
GList *catalog; /* See glade-catalog */
GList *catalogs; /* See glade-catalog */
GladeWidgetClass *add_class; /* The GladeWidgetClass that we are about
* to add to a container. NULL if no
* class is to be added. This also has to
......@@ -43,7 +43,7 @@ struct _GladeProjectWindow
};
GladeProjectWindow * glade_project_window_new (GList *catalog);
GladeProjectWindow * glade_project_window_new (GList *catalogs);
GladeProjectWindow * glade_project_window_get ();
GladeProject * glade_project_window_get_project ();
void glade_project_window_show_all (GladeProjectWindow *gpw);
......
......@@ -438,15 +438,12 @@ glade_widget_class_dump_param_specs (GladeWidgetClass *class)
GladeWidgetClass *
glade_widget_class_get_by_name (const gchar *name)
{
GladeCatalog *catalog;
GladeWidgetClass *class;
GList *list;
g_return_val_if_fail (name != NULL, NULL);
catalog = glade_catalog_get ();
g_return_val_if_fail (catalog != NULL, NULL);
list = catalog->widgets;
list = glade_catalog_get_widgets ();
for (; list != NULL; list = list->next) {
class = list->data;
g_return_val_if_fail (class->name != NULL, NULL);
......
......@@ -67,7 +67,7 @@ static gint
glade_init ()
{
GladeProjectWindow *project_window;
GList *catalog;
GList *catalogs;
if (!g_module_supported ()) {
g_warning (_("gmodule support not found. gmodule support is requiered "
......@@ -84,11 +84,11 @@ glade_init ()
glade_cursor_init ();
glade_packing_init ();
catalog = glade_catalog_load_all ();
if (catalog == NULL)
catalogs = glade_catalog_load_all ();
if (catalogs == NULL)
return FALSE;
project_window = glade_project_window_new (catalog);
project_window = glade_project_window_new (catalogs);
return TRUE;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment