summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Borelli <pborelli@src.gnome.org>2003-10-05 11:35:53 +0000
committerPaolo Borelli <pborelli@src.gnome.org>2003-10-05 11:35:53 +0000
commitf03300bbdbb02e99c58a60f34c382bf83a56b177 (patch)
treeb3e2ef20c26bb2b7ec659143727ae53f6e1195f6
parent5ea081fd13c0445f396081095810fd2a7ffdaaa4 (diff)
downloadglade-f03300bbdbb02e99c58a60f34c382bf83a56b177.tar.gz
Introduce a fill_empty method to GladeWidgetClass that, if needed, fills a container with placeholders.
-rw-r--r--ChangeLog15
-rw-r--r--src/glade-gtk.c29
-rw-r--r--src/glade-widget-class.c49
-rw-r--r--src/glade-widget-class.h2
-rw-r--r--src/glade-widget.c36
-rw-r--r--src/glade.h1
-rw-r--r--widgets/Makefile.am2
-rw-r--r--widgets/gtk-base.xml6
-rw-r--r--widgets/gtkbox.xml3
-rw-r--r--widgets/gtkbutton.xml5
-rw-r--r--widgets/gtkdialog.xml24
11 files changed, 94 insertions, 78 deletions
diff --git a/ChangeLog b/ChangeLog
index 7a848a16..6d226322 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2003-10-05 Paolo Borelli <pborelli@katamail.com>
+
+ * src/glade.h: define GLADE_TAG_FILL_EMPTY_FUNCTION
+ * src/glade-widget-class.[ch]: add the fill_empty method.
+ * src/glade-widget.c: substitute glade_widget_fill_empty with the
+ class->fill_empty method.
+ * src/glade-gtk.c: implement the fill_empty method for GtkContainer,
+ GtkDialog and GtkPaned.
+ * widgets/gtkcontainer.xml: added.
+ * widgets/gtkpaned.xml: added.
+ * widgets/gtkdialog.xml: add fill_empty method
+ * widgets/gtkbutton.xml: ditto.
+ * widgets/gtkbox.xml: ditto.
+ * widgets/gtk-base.xml: add gtkpaned and gtkcontainer.
+
2003-10-04 Joaquin Cuenca Abela <e98cuenc@yahoo.com>
* src/glade-gtk.h: remove this file.
diff --git a/src/glade-gtk.c b/src/glade-gtk.c
index f6ca4392..09301e34 100644
--- a/src/glade-gtk.c
+++ b/src/glade-gtk.c
@@ -106,7 +106,6 @@ glade_gtk_option_menu_set_items (GObject *object, GValue *value)
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
}
-
void
glade_gtk_progress_bar_set_format (GObject *object, GValue *value)
{
@@ -566,3 +565,31 @@ glade_gtk_table_post_create (GObject *object, GValue *value)
}
}
+/* ------------------------------------ Fill Empty functions ------------------------------- */
+void
+glade_gtk_container_fill_empty (GObject *container)
+{
+ g_return_if_fail (GTK_IS_CONTAINER (container));
+
+ gtk_container_add (GTK_CONTAINER (container), glade_placeholder_new ());
+}
+
+void
+glade_gtk_dialog_fill_empty (GObject *dialog)
+{
+ g_return_if_fail (GTK_IS_DIALOG (dialog));
+
+ GtkWidget *vbox = GTK_DIALOG (dialog)->vbox;
+ gtk_box_pack_start_defaults (GTK_BOX (vbox), glade_placeholder_new ());
+}
+
+void
+glade_gtk_paned_fill_empty (GObject *paned)
+{
+ g_return_if_fail (GTK_IS_PANED (paned));
+
+ gtk_paned_add1 (GTK_PANED (paned), glade_placeholder_new ());
+ gtk_paned_add2 (GTK_PANED (paned), glade_placeholder_new ());
+}
+
+
diff --git a/src/glade-widget-class.c b/src/glade-widget-class.c
index e35af56c..4199279f 100644
--- a/src/glade-widget-class.c
+++ b/src/glade-widget-class.c
@@ -301,31 +301,41 @@ glade_widget_class_extend_with_file (GladeWidgetClass *widget_class, const char
GladeXmlNode *properties;
GladeXmlNode *node;
char *post_create_function_name;
+ char *fill_empty_function_name;
g_return_val_if_fail (filename != NULL, FALSE);
context = glade_xml_context_new_from_path (filename, NULL, GLADE_TAG_GLADE_WIDGET_CLASS);
- if (context != NULL) {
- doc = glade_xml_context_get_doc (context);
- node = glade_xml_doc_get_root (doc);
-
- post_create_function_name = glade_xml_get_value_string (node, GLADE_TAG_POST_CREATE_FUNCTION);
- if (post_create_function_name && widget_class->module) {
- if (!g_module_symbol (widget_class->module, post_create_function_name, (void **) &widget_class->post_create_function))
- g_warning ("Could not find %s\n", post_create_function_name);
- }
- g_free (post_create_function_name);
-
- properties = glade_xml_search_child (node, GLADE_TAG_PROPERTIES);
- /* if we found a <properties> tag on the xml file, we add the properties
- * that we read from the xml file to the class */
- if (properties != NULL)
- glade_property_class_list_add_from_node (properties, widget_class, &widget_class->properties);
+ if (!context)
+ return FALSE;
+
+ doc = glade_xml_context_get_doc (context);
+ node = glade_xml_doc_get_root (doc);
+ if (!doc || !node)
+ return FALSE;
+
+ post_create_function_name = glade_xml_get_value_string (node, GLADE_TAG_POST_CREATE_FUNCTION);
+ if (post_create_function_name && widget_class->module) {
+ if (!g_module_symbol (widget_class->module, post_create_function_name, (void **) &widget_class->post_create_function))
+ g_warning ("Could not find %s\n", post_create_function_name);
+ }
+ g_free (post_create_function_name);
- return TRUE;
+ fill_empty_function_name = glade_xml_get_value_string (node, GLADE_TAG_FILL_EMPTY_FUNCTION);
+ if (fill_empty_function_name && widget_class->module) {
+ if (!g_module_symbol (widget_class->module, fill_empty_function_name, (void **) &widget_class->fill_empty))
+ g_warning ("Could not find %s\n", fill_empty_function_name);
}
+ g_free (fill_empty_function_name);
- return FALSE;
+ /* if we found a <properties> tag on the xml file, we add the properties
+ * that we read from the xml file to the class.
+ */
+ properties = glade_xml_search_child (node, GLADE_TAG_PROPERTIES);
+ if (properties)
+ glade_property_class_list_add_from_node (properties, widget_class, &widget_class->properties);
+
+ return TRUE;
}
/**
@@ -393,6 +403,9 @@ glade_widget_class_merge (GladeWidgetClass *widget_class, GladeWidgetClass *pare
if (widget_class->post_create_function == NULL)
widget_class->post_create_function = parent_class->post_create_function;
+ if (widget_class->fill_empty == NULL)
+ widget_class->fill_empty = parent_class->fill_empty;
+
last_property = g_list_last (widget_class->properties);
parent_properties = parent_class->properties;
for (; parent_properties; parent_properties = parent_properties->next) {
diff --git a/src/glade-widget-class.h b/src/glade-widget-class.h
index 23d95e31..779fc068 100644
--- a/src/glade-widget-class.h
+++ b/src/glade-widget-class.h
@@ -77,6 +77,8 @@ struct _GladeWidgetClass
void (*post_create_function) (GObject *gobject);
+ void (*fill_empty) (GtkWidget *widget);
+
gboolean in_palette;
};
diff --git a/src/glade-widget.c b/src/glade-widget.c
index b02938a7..2cdaccc2 100644
--- a/src/glade-widget.c
+++ b/src/glade-widget.c
@@ -679,38 +679,6 @@ glade_widget_new_full (GladeWidgetClass *class,
return widget;
}
-static void
-glade_widget_fill_empty (GtkWidget *widget)
-{
- GList *children;
- gboolean empty = TRUE;
-
- if (!GTK_IS_CONTAINER (widget))
- return;
-
- /* fill with placeholders the containers that are inside of this container */
- children = gtk_container_get_children (GTK_CONTAINER (widget));
-
- /* loop over the children of this container, and fill them with placeholders */
- while (children != NULL) {
- glade_widget_fill_empty (GTK_WIDGET (children->data));
- children = children->next;
- empty = FALSE;
- }
-
- if (empty) {
- /* retrieve the desired number of placeholders that this widget should hold */
- int nb_children = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "glade_nb_placeholders"));
- int i;
-
- if (nb_children == 0 && GTK_IS_BIN (widget))
- nb_children = 1;
-
- for (i = nb_children; i > 0; i--)
- gtk_container_add (GTK_CONTAINER (widget), glade_placeholder_new ());
- }
-}
-
static GtkWidget *
glade_widget_append_query (GtkWidget *table,
GladePropertyClass *property_class,
@@ -904,8 +872,8 @@ glade_widget_new_from_class (GladeWidgetClass *class,
glade_widget_apply_queried_properties (widget, result);
/* If we are a container, add the placeholders */
- if (g_type_is_a (class->type, GTK_TYPE_CONTAINER))
- glade_widget_fill_empty (widget->widget);
+ if (widget->class->fill_empty)
+ widget->class->fill_empty (widget->widget);
if (result)
glade_property_query_result_destroy (result);
diff --git a/src/glade.h b/src/glade.h
index 0bee4711..67c68fff 100644
--- a/src/glade.h
+++ b/src/glade.h
@@ -93,6 +93,7 @@
#define GLADE_TAG_DEFAULT "Default"
#define GLADE_TAG_DISABLED "Disabled"
#define GLADE_TAG_POST_CREATE_FUNCTION "PostCreateFunction"
+#define GLADE_TAG_FILL_EMPTY_FUNCTION "FillEmptyFunction"
#define GLADE_TAG_IN_PALETTE "InPalette"
#define GLADE_TAG_CATALOG "GladeCatalog"
diff --git a/widgets/Makefile.am b/widgets/Makefile.am
index 7149f988..0207e8ae 100644
--- a/widgets/Makefile.am
+++ b/widgets/Makefile.am
@@ -8,6 +8,7 @@ widgets_DATA = \
gtkbox.xml \
gtkbutton.xml \
gtkcheckbutton.xml \
+ gtkcontainer.xml \
gtkdialog.xml \
gtkentry.xml \
gtkframe.xml \
@@ -16,6 +17,7 @@ widgets_DATA = \
gtkmessagedialog.xml \
gtknotebook.xml \
gtkoptionmenu.xml \
+ gtkpaned.xml \
gtkprogressbar.xml \
gtkradiobutton.xml \
gtkseparator.xml \
diff --git a/widgets/gtk-base.xml b/widgets/gtk-base.xml
index 87e24899..5a97b45c 100644
--- a/widgets/gtk-base.xml
+++ b/widgets/gtk-base.xml
@@ -1,7 +1,9 @@
<GladeCatalog Title="Gtk+ Basic" library="gtk">
<GladeWidget name="GtkWidget" filename="gtkwidget.xml"/>
+ <GladeWidget name="GtkContainer" filename="gtkcontainer.xml"/>
<GladeWidget name="GtkBox" filename="gtkbox.xml"/>
+ <GladeWidget name="GtkPaned" filename="gtkpaned.xml"/>
<GladeWidget name="GtkWindow" generic_name="window" filename="gtkwindow.xml"/>
@@ -15,7 +17,7 @@
<GladeWidget name="GtkEntry" generic_name="entry"/>
<GladeWidget name="GtkTextView" generic_name="textview"/>
- <GladeWidget name="GtkButton" generic_name="button"/>
+ <GladeWidget name="GtkButton" generic_name="button" filename="gtkbutton.xml"/>
<GladeWidget name="GtkToggleButton" generic_name="togglebutton"/>
<GladeWidget name="GtkCheckButton" generic_name="checkbutton"/>
<GladeWidget name="GtkSpinButton" generic_name="spinbutton"/>
@@ -33,7 +35,7 @@
<GladeWidget name="GtkImage" generic_name="image"/>
<GladeWidget name="GtkDrawingArea" generic_name="drawingarea"/>
- <GladeWidget name="GtkDialog" generic_name="dialog"/>
+ <GladeWidget name="GtkDialog" generic_name="dialog" filename="gtkdialog.xml"/>
<GladeWidget name="GtkMessageDialog" generic_name="messagedialog" filename="gtkmessagedialog.xml"/>
<GladeWidget name="GtkFileSelection" generic_name="fileselection"/>
<GladeWidget name="GtkColorSelectionDialog" generic_name="colorselectiondialog"/>
diff --git a/widgets/gtkbox.xml b/widgets/gtkbox.xml
index dd7dc552..e7163845 100644
--- a/widgets/gtkbox.xml
+++ b/widgets/gtkbox.xml
@@ -1,4 +1,7 @@
<GladeWidgetClass>
+
+ <FillEmptyFunction>ignore</FillEmptyFunction>
+
<Properties>
<Property Name="Size" Id="size" Default="3">
diff --git a/widgets/gtkbutton.xml b/widgets/gtkbutton.xml
index 5da32f24..6e2be253 100644
--- a/widgets/gtkbutton.xml
+++ b/widgets/gtkbutton.xml
@@ -1,7 +1,6 @@
<GladeWidgetClass>
- <Name>GtkButton</Name>
- <GenericName>button</GenericName>
- <Toplevel>False</Toplevel>
+
+ <FillEmptyFunction>ignore</FillEmptyFunction>
<Properties>
diff --git a/widgets/gtkdialog.xml b/widgets/gtkdialog.xml
index 3e654034..425d4aed 100644
--- a/widgets/gtkdialog.xml
+++ b/widgets/gtkdialog.xml
@@ -1,37 +1,21 @@
<GladeWidgetClass>
- <Name>GtkDialog</Name>
- <GenericName>dialog</GenericName>
- <Toplevel>True</Toplevel>
- <Placeholder>True</Placeholder>
<PostCreateFunction>glade_gtk_dialog_post_create</PostCreateFunction>
+ <FillEmptyFunction>glade_gtk_dialog_fill_empty</FillEmptyFunction>
<Properties>
- <Property Id="has-separator"/>
- <Property Id="border-width"/>
- <Property Id="title"/>
- <Property Id="type"/>
- <Property Id="window-position"/>
<Property Id="modal">
<SetFunction>ignore</SetFunction>
</Property>
<Property Id="default-width" Default="0" Optional="True" OptionalDefault="False"/>
<Property Id="default-height" Default="0" Optional="True" OptionalDefault="False"/>
- <Property Id="allow-grow"/>
- <Property Id="allow-shrink"/>
-
- <Property Common="True" Id="sensitive"/>
<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>
+ <SetFunction>ignore</SetFunction>
+ <GetFunction>ignore</GetFunction>
</Property>
- <Property Common="True" Id="can-default"/>
- <Property Common="True" Id="has-default"/>
- <Property Common="True" Id="can-focus"/>
- <Property Common="True" Id="extension-events"/>
</Properties>
-
+
</GladeWidgetClass>