Commit 633fd1cd authored by Carlos Perell Marn's avatar Carlos Perell Marn Committed by Carlos Perelló Marín

Added CATALOG_DIR to store catalogs Added to load several catalogs from

2001-12-02  Carlos Perell Marn <carlos@gnome-db.org>

	* acconfig.h, configure.in: Added CATALOG_DIR to store catalogs
	* src/glade-catalog.* (glade_catalog_load_all): Added to load
	several catalogs from $prefix/share/glade/catalog/*.xml. It calls
	the old glade_catalog_load with a new arg which is the catalog
	file name.
	* src/glade-catalog.h: Added the title gchar* to store the title
	for this catalog.
	* src/glade-palette.h: Added a notebook at GladePalette object.
	* src/glade-palette.c (glade_palette_init): We create a notebook
	to store several catalogs.
	* src/glade-palette.c (glade_palette_create): Really ugly hack that
	needs to be FIXED when we finish glade2 functionality. Sorry, it's a
	fast hack that works.
	* src/glade-palette.c (on_palette_button_toggled): Implemented, we
	change the notebook page.
	* src/glade-project-window.*:
	* src/main.c: Instead of GladeCatalog we have now a list (GList) of
	GladeCatalog.
	* widgets/gtkmenubar.xml: Added some default values.
	* widgets/gtk-base.xml: Added. It has the catalog for gtk2 base.
	* widgets/gtk-additional.xml: Added. It has the catalog for gtk2
	additional.
	* widgets/catalog.xml: Removed, now we have several catalogs.
parent a9f1711c
2001-12-02 Carlos Perell Marn <carlos@gnome-db.org>
* acconfig.h, configure.in: Added CATALOG_DIR to store catalogs
* src/glade-catalog.* (glade_catalog_load_all): Added to load
several catalogs from $prefix/share/glade/catalog/*.xml. It calls
the old glade_catalog_load with a new arg which is the catalog
file name.
* src/glade-catalog.h: Added the title gchar* to store the title
for this catalog.
* src/glade-palette.h: Added a notebook at GladePalette object.
* src/glade-palette.c (glade_palette_init): We create a notebook
to store several catalogs.
* src/glade-palette.c (glade_palette_create): Really ugly hack that
needs to be FIXED when we finish glade2 functionality. Sorry, it's a
fast hack that works.
* src/glade-palette.c (on_palette_button_toggled): Implemented, we
change the notebook page.
* src/glade-project-window.*:
* src/main.c: Instead of GladeCatalog we have now a list (GList) of
GladeCatalog.
* widgets/gtkmenubar.xml: Added some default values.
* widgets/gtk-base.xml: Added. It has the catalog for gtk2 base.
* widgets/gtk-additional.xml: Added. It has the catalog for gtk2
additional.
* widgets/catalog.xml: Removed, now we have several catalogs.
2001-12-02 Carlos Perell Marn <carlos@gnome-db.org>
* widgets/gtkinputdialog.xml: It does not need placeholder.
......
......@@ -14,4 +14,5 @@
#undef USING_OAF
#undef PIXMAPS_DIR
#undef WIDGETS_DIR
#undef CATALOG_DIR
#undef GETTEXT_PACKAGE
......@@ -66,15 +66,20 @@ if test "x${prefix}" = "xNONE"; then
pixmapsdir="${ac_default_prefix}/${DATADIRNAME}/${PACKAGE}/pixmaps"
AC_DEFINE_UNQUOTED(WIDGETS_DIR, "${ac_default_prefix}/${DATADIRNAME}/${PACKAGE}/widgets")
widgetsdir="${ac_default_prefix}/${DATADIRNAME}/${PACKAGE}/widgets"
AC_DEFINE_UNQUOTED(CATALOG_DIR, "${ac_default_prefix}/${DATADIRNAME}/${PACKAGE}/catalog")
catalogdir="${ac_default_prefix}/${DATADIRNAME}/${PACKAGE}/catalog"
else
AC_DEFINE_UNQUOTED(PIXMAPS_DIR, "${prefix}/${DATADIRNAME}/${PACKAGE}/pixmaps")
pixmapsdir="${prefix}/${DATADIRNAME}/${PACKAGE}/pixmaps"
AC_DEFINE_UNQUOTED(WIDGETS_DIR, "${prefix}/${DATADIRNAME}/${PACKAGE}/widgets")
widgetsdir="${prefix}/${DATADIRNAME}/${PACKAGE}/widgets"
AC_DEFINE_UNQUOTED(CATALOG_DIR, "${prefix}/${DATADIRNAME}/${PACKAGE}/catalog")
catalogdir="${prefix}/${DATADIRNAME}/${PACKAGE}/catalog"
fi
AC_SUBST(pixmapsdir)
AC_SUBST(widgetsdir)
AC_SUBST(catalogdir)
AC_OUTPUT([
Makefile
......
......@@ -23,6 +23,10 @@
#include <string.h>
#include <config.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <unistd.h>
#include "glade.h"
#include "glade-catalog.h"
......@@ -87,6 +91,7 @@ glade_catalog_load_names_from_file (GladeCatalog *catalog, const gchar *file_nam
return;
doc = glade_xml_context_get_doc (context);
root = glade_xml_doc_get_root (doc);
catalog->title = glade_xml_get_property_string_required (root, "Title", NULL);
catalog->names = glade_catalog_load_names_from_node (context, root);
glade_xml_context_free (context);
}
......@@ -104,7 +109,7 @@ glade_catalog_new_from_file (const gchar *file)
}
GladeCatalog *
glade_catalog_load (void)
glade_catalog_load (gchar *file_name)
{
GladeWidgetClass *class;
GladeCatalog *catalog;
......@@ -112,7 +117,7 @@ glade_catalog_load (void)
GList *new_list;
gchar *name;
catalog = glade_catalog_new_from_file (WIDGETS_DIR "/catalog.xml");
catalog = glade_catalog_new_from_file (file_name);
if (catalog == NULL)
return NULL;
......@@ -139,3 +144,30 @@ glade_catalog_load (void)
return catalog;
}
GList *
glade_catalog_load_all (void)
{
DIR *catalogsdir = NULL;
struct dirent *direntry = NULL;
struct stat statinfo;
GList *catalogs = NULL;
GladeCatalog *gcatalog = NULL;
gchar *filename = NULL;
catalogsdir = opendir (CATALOG_DIR);
direntry = readdir (catalogsdir);
while (direntry) {
filename = g_strdup_printf ("%s/%s", CATALOG_DIR, direntry->d_name);
stat (filename, &statinfo);
if (S_ISREG (statinfo.st_mode)) {
gcatalog = glade_catalog_load (filename);
if (gcatalog)
catalogs = g_list_append (catalogs, gcatalog);
}
g_free (filename);
direntry = readdir (catalogsdir);
}
closedir (catalogsdir);
return catalogs;
}
......@@ -11,6 +11,7 @@ G_BEGIN_DECLS
struct _GladeCatalog
{
gchar *title; /* Title for this catalog */
GList *names; /* Contains the list of names that we are going
* to try to load. This is basically a memory
* representation of catalog.xml
......@@ -20,9 +21,11 @@ struct _GladeCatalog
*/
};
GladeCatalog * glade_catalog_load (void);
GladeCatalog * glade_catalog_load (gchar *file_name);
GladeCatalog * glade_catalog_get (void);
GList * glade_catalog_load_all (void);
G_END_DECLS
#endif /* __GLADE_CATALOG_H__ */
......@@ -197,9 +197,8 @@ glade_palette_attach_pixmap (GladePalette *palette, GtkWidget *table, GList *lis
}
static GtkWidget *
glade_palette_widget_table_create (GladePalette *palette)
glade_palette_widget_table_create (GladePalette *palette, GladeCatalog *catalog)
{
GladeProjectWindow *gpw;
GtkWidget *table;
GtkWidget *dummy;
GList *list;
......@@ -208,8 +207,7 @@ glade_palette_widget_table_create (GladePalette *palette)
gint cols = 4;
gint i;
gpw = palette->project_window;
list = gpw->catalog->widgets;
list = catalog->widgets;
num = g_list_length (list);
rows = (gint)((num - 1)/ cols) + 1;
......@@ -234,21 +232,26 @@ glade_palette_widget_table_create (GladePalette *palette)
static gint
on_palette_button_toggled (GtkWidget *button, GladePalette *palette)
{
gint *page;
page = g_object_get_data (G_OBJECT (button), "page");
gtk_notebook_set_page (GTK_NOTEBOOK (palette->notebook), *page);
return TRUE;
}
static GtkWidget *
glade_palette_button_group_create (GladePalette *palette)
glade_palette_button_group_create (GladePalette *palette, gchar *name, gint *page)
{
GtkWidget *button;
GtkWidget *hbox;
hbox = gtk_hbox_new (TRUE, 0);
button = gtk_radio_button_new_with_label (palette->sections_button_group, "GTK + Basic");
button = gtk_radio_button_new_with_label (palette->sections_button_group, name);
palette->sections_button_group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
g_object_set_data (G_OBJECT (button), "page", page);
gtk_signal_connect (GTK_OBJECT (button), "toggled",
(GtkSignalFunc) on_palette_button_toggled, palette);
......@@ -291,13 +294,9 @@ glade_palette_init (GladePalette * palette)
widget = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (palette->vbox), widget, FALSE, TRUE, 3);
/* Groups */
widget = glade_palette_button_group_create (palette);
gtk_box_pack_start (GTK_BOX (palette->vbox), widget, FALSE, TRUE, 3);
/* Separator */
widget = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (palette->vbox), widget, FALSE, TRUE, 3);
/* Notebook */
palette->notebook = gtk_notebook_new ();
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (palette->notebook), FALSE);
/* Delete event, don't destroy it */
gtk_signal_connect (GTK_OBJECT (palette), "delete_event",
......@@ -326,6 +325,8 @@ void
glade_palette_create (GladeProjectWindow *gpw)
{
GtkWidget *widget;
GList *catalogs;
gint i;
if (gpw->palette == NULL) {
GladePalette *palette;
......@@ -339,8 +340,41 @@ glade_palette_create (GladeProjectWindow *gpw)
* cause we don't have a pointer to palette->project_window when
* we are in glade_palette_init ()
*/
widget = glade_palette_widget_table_create (gpw->palette);
gtk_box_pack_start (GTK_BOX (gpw->palette->vbox), widget, FALSE, TRUE, 3);
/* 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;
/* Groups */
for (i = 0; catalogs != NULL; catalogs = g_list_next (catalogs), i++){
gint *page = g_malloc (sizeof (int));
*page = i;
widget = glade_palette_button_group_create (palette,
((GladeCatalog *)catalogs->data)->title,
page);
gtk_box_pack_start (GTK_BOX (palette->vbox), widget,
FALSE, TRUE, 3);
}
/* Separator */
widget = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (palette->vbox), widget,
FALSE, TRUE, 3);
catalogs = gpw->catalog;
/* Sections */
for (i = 0; catalogs != NULL; catalogs = g_list_next (catalogs), i++){
widget = glade_palette_widget_table_create (gpw->palette,
catalogs->data);
gtk_notebook_append_page (GTK_NOTEBOOK (palette->notebook),
widget, NULL);
}
gtk_box_pack_end (GTK_BOX (palette->vbox), palette->notebook,
FALSE, TRUE, 3);
gtk_widget_show (palette->notebook);
}
}
......
......@@ -42,6 +42,7 @@ struct _GladePalette
* it contains the text "Selector" when we are
* in select widget mode
*/
GtkWidget *notebook; /* Where we store the different catalogs */
GSList *sections_button_group; /* Each section of the palette has
* a button. This is the button_group_list
......
......@@ -306,7 +306,7 @@ glade_project_window_set_view (GladeProjectWindow *gpw, GladeProjectView *view)
}
GladeProjectWindow *
glade_project_window_new (GladeCatalog *catalog)
glade_project_window_new (GList *catalog)
{
GladeProjectWindow *gpw;
GladeProjectView *view;
......
......@@ -28,7 +28,7 @@ struct _GladeProjectWindow
GladePalette *palette; /* See glade-palette */
GladeEditor *editor; /* See glade-editor */
GladeProjectView *active_view; /* See glade-project-view */
GladeCatalog *catalog; /* See glade-catalog */
GList *catalog; /* 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 (GladeCatalog *catalog);
GladeProjectWindow * glade_project_window_new (GList *catalog);
GladeProjectWindow * glade_project_window_get ();
GladeProject * glade_project_window_get_project ();
void glade_project_window_show_all (GladeProjectWindow *gpw);
......
......@@ -67,7 +67,7 @@ static gint
glade_init ()
{
GladeProjectWindow *project_window;
GladeCatalog *catalog;
GList *catalog;
if (!g_module_supported ()) {
g_warning (_("gmodule support not found. gmodule support is requiered "
......@@ -84,7 +84,7 @@ glade_init ()
glade_cursor_init ();
glade_packing_init ();
catalog = glade_catalog_load ();
catalog = glade_catalog_load_all ();
if (catalog == NULL)
return FALSE;
......
catalog_DATA = \
gtk-base.xml \
gtk-additional.xml
widgets_DATA = \
catalog.xml \
gtkaccellabel.xml \
gtkalignment.xml \
gtkarrow.xml \
......@@ -60,4 +63,6 @@ widgets_DATA = \
gtkvseparator.xml \
gtkwindow.xml
EXTRA_DIST = $(widgets_DATA)
EXTRA_DIST = \
$(catalog_DATA) \
$(widgets_DATA)
<GladeCatalog Title="GTK + Additional">
<GladeWidget>gtkhscale</GladeWidget>
<GladeWidget>gtkvscale</GladeWidget>
<GladeWidget>gtkhruler</GladeWidget>
<GladeWidget>gtkvruler</GladeWidget>
<GladeWidget>gtkalignment</GladeWidget>
<GladeWidget>gtkeventbox</GladeWidget>
<GladeWidget>gtkcalendar</GladeWidget>
<GladeWidget>gtkaspectframe</GladeWidget>
<GladeWidget>gtkmenu</GladeWidget>
<GladeWidget>gtkcurve</GladeWidget>
<GladeWidget>gtkgammacurve</GladeWidget>
<GladeWidget>gtkhscrollbar</GladeWidget>
<GladeWidget>gtkvscrollbar</GladeWidget>
<GladeWidget>gtkcolorselection</GladeWidget>
<GladeWidget>gtkfontselection</GladeWidget>
<GladeWidget>gtkinputdialog</GladeWidget>
<GladeWidget>gtkarrow</GladeWidget>
<GladeWidget>gtklayout</GladeWidget>
<GladeWidget>gtkplug</GladeWidget>
<GladeWidget>gtksocket</GladeWidget>
</GladeCatalog>
<GladeCatalog>
<GladeCatalog Title="GTK + Basic">
<GladeWidget>gtkwindow</GladeWidget>
......@@ -52,31 +52,4 @@
<GladeWidget>gtkscrolledwindow</GladeWidget>
<GladeWidget>gtkviewport</GladeWidget>
<GladeWidget>gtkhscale</GladeWidget>
<GladeWidget>gtkvscale</GladeWidget>
<GladeWidget>gtkhruler</GladeWidget>
<GladeWidget>gtkvruler</GladeWidget>
<GladeWidget>gtkalignment</GladeWidget>
<GladeWidget>gtkeventbox</GladeWidget>
<GladeWidget>gtkcalendar</GladeWidget>
<GladeWidget>gtkaspectframe</GladeWidget>
<GladeWidget>gtkmenu</GladeWidget>
<GladeWidget>gtkcurve</GladeWidget>
<GladeWidget>gtkgammacurve</GladeWidget>
<GladeWidget>gtkhscrollbar</GladeWidget>
<GladeWidget>gtkvscrollbar</GladeWidget>
<GladeWidget>gtkcolorselection</GladeWidget>
<GladeWidget>gtkfontselection</GladeWidget>
<GladeWidget>gtkinputdialog</GladeWidget>
<GladeWidget>gtkarrow</GladeWidget>
<GladeWidget>gtklayout</GladeWidget>
<GladeWidget>gtkplug</GladeWidget>
<GladeWidget>gtksocket</GladeWidget>
</GladeCatalog>
......@@ -6,6 +6,17 @@
<Properties>
<Property Common="True" Optional="True" OptioanlDefault="False" Default="0" Id="width-request"/>
<Property Common="True" Optional="True" OptioanlDefault="False" Default="0" Id="height-request"/>
<Property Common="True" Id="visible" Default="True">
<SetFunction>ignore</SetFunction>
</Property>
<Property Common="True" Id="tooltip" ParamSpec="False" Name="Tooltip">
<Type>String</Type>
<SetFunction>glade_gtk_widget_set_tooltip</SetFunction>
<GetFunction>glade_gtk_widget_get_tooltip</GetFunction>
</Property>
</Properties>
</GladeWidgetClass>
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