handle the case where the property is queried from the gtkwidget v.s.

2001-08-06  Chema Celorio  <chema@celorio.com>

	* src/glade-widget.c (glade_widget_set_default_options_real): handle the case
	where the property is queried from the gtkwidget v.s. setting a default one.
	(glade_widget_free): implement.
	(glade_widget_delete): add content.
	(glade_widget_write): when saving a widget, add the packing properties too.

	* src/glade-signal.c (glade_signal_free): impl.

	* src/glade-signal-editor.c (glade_signal_editor_load_widget): handle a
	widget->class = NULL for clearing the signal editor.

	* src/glade-property.c (glade_property_new_from_class): handle properties
	that the default is fetched from the gtkwidget itself, not set.
	(glade_property_free): implement.

	* src/glade-project.c (glade_project_selection_changed): implement.
	(glade_project_remove_widget_real): impl.
	(glade_project_remove_widget): impl.

	* src/glade-project-window.c (gpw_delete_cb): implement.

	* src/glade-project-view.h (struct _GladeProjectView): add the remove
	signal id to the struct.

	* src/glade-project-view.c (glade_project_view_remove_item): implement
	for "Delete"
	(glade_project_view_remove_widget_cb): ditto
	(glade_project_view_set_project): connect and disconnect ->remove_item

	* src/glade-placeholder.c (glade_placeholder_replace_$x): where
	x are all the containers. Modify this functions so that we can
	use them to replace a placeholder with a widget and the other
	way arround. We need this when we delete a widget and want to
	put a placeholder where the widget was.

	* src/glade-packing.c (glade_packing_container_set_flag): impl.
	(glade_packing_container_set_integer): impl.
	(glade_packing_container_set_boolean): impl.
	(glade_packing_table_set_flag): impl.
	(glade_packing_table_set_integer): impl.
	(glade_packing_box_set_boolean): impl.
	(glade_packing_box_set_integer): impl.
	(glade_packing_box_position_get): impl.
	(glade_packing_box_position_set): when setting the pos of a child update the
	property->value of the rest, cause it has (most likely) changed.
	(table_props): add the rest of the properties
	(box_props): ditto

	* src/glade-editor.c (glade_editor_load_widget_page): handle a NULL class to
	clear the page
	(glade_editor_load_common_page): ditto
	(glade_editor_load_item): ditto
	(glade_editor_select_item_real): ditto
This commit is contained in:
Chema Celorio 2001-08-06 17:12:14 +00:00 committed by Jose Maria Celorio
parent 37e38612d9
commit ca932a90f7
25 changed files with 856 additions and 226 deletions

View File

@ -1,4 +1,5 @@
## Process this file with automake to produce Makefile.in
SUBDIRS=tests
bin_PROGRAMS = glade2

View File

@ -372,7 +372,7 @@ glade_editor_property_changed_boolean (GtkWidget *button,
gboolean state;
g_return_if_fail (property != NULL);
if (property->loading)
return;
@ -755,12 +755,6 @@ glade_editor_load_widget_page (GladeEditor *editor, GladeWidgetClass *class)
GtkContainer *container;
GList *list;
table = glade_editor_get_table_from_class (editor, class, FALSE);
if (table == NULL)
table = glade_editor_table_create (editor, class, FALSE);
g_return_if_fail (table != NULL);
/* Remove the old table that was in this container */
container = GTK_CONTAINER (editor->vbox_widget);
list = gtk_container_children (container);
@ -771,6 +765,15 @@ glade_editor_load_widget_page (GladeEditor *editor, GladeWidgetClass *class)
gtk_container_remove (container, widget);
}
if (!class)
return;
table = glade_editor_get_table_from_class (editor, class, FALSE);
if (table == NULL)
table = glade_editor_table_create (editor, class, FALSE);
g_return_if_fail (table != NULL);
/* Attach the new table */
gtk_box_pack_start (GTK_BOX (editor->vbox_widget), table->table_widget,
TRUE, TRUE, 0);
@ -783,12 +786,6 @@ glade_editor_load_common_page (GladeEditor *editor, GladeWidgetClass *class)
GtkContainer *container;
GList *list;
table = glade_editor_get_table_from_class (editor, class, TRUE);
if (table == NULL)
table = glade_editor_table_create (editor, class, TRUE);
g_return_if_fail (table != NULL);
/* Remove the old table that was in this container */
container = GTK_CONTAINER (editor->vbox_common);
list = gtk_container_children (container);
@ -799,6 +796,16 @@ glade_editor_load_common_page (GladeEditor *editor, GladeWidgetClass *class)
gtk_container_remove (container, widget);
}
if (!class)
return;
table = glade_editor_get_table_from_class (editor, class, TRUE);
if (table == NULL)
table = glade_editor_table_create (editor, class, TRUE);
g_return_if_fail (table != NULL);
/* Attach the new table */
gtk_box_pack_start (GTK_BOX (editor->vbox_common), table->table_widget,
TRUE, TRUE, 0);
@ -1139,6 +1146,10 @@ glade_editor_load_packing_page (GladeEditor *editor, GladeWidget *widget)
for (; list; list = list->next)
g_free (list->data);
old_props = NULL;
old = NULL;
if (!widget)
return;
/* Now add the new properties */
table = glade_editor_table_new (widget->class);
@ -1171,12 +1182,19 @@ glade_editor_load_item (GladeEditor *editor, GladeWidget *item)
GList *list;
/* Load the GladeWidgetClass */
class = item->class;
class = item ? item->class : NULL;
if (editor->loaded_class != class)
glade_editor_load_class (editor, class);
editor->loaded_widget = item;
glade_editor_load_packing_page (editor, item);
glade_signal_editor_load_widget (editor->signal_editor, item);
if (!item)
return;
/* Load each GladeEditorProperty */
table = glade_editor_get_table_from_class (editor, class, FALSE);
list = table->properties;
@ -1184,7 +1202,7 @@ glade_editor_load_item (GladeEditor *editor, GladeWidget *item)
property = list->data;
glade_editor_property_load (property, item);
}
/* Load each GladeEditorProperty for the common tab*/
table = glade_editor_get_table_from_class (editor, class, TRUE);
list = table->properties;
@ -1193,10 +1211,6 @@ glade_editor_load_item (GladeEditor *editor, GladeWidget *item)
glade_editor_property_load (property, item);
}
/* Load the Packin tab */
glade_editor_load_packing_page (editor, item);
glade_signal_editor_load_widget (editor->signal_editor, item);
}
@ -1212,6 +1226,14 @@ glade_editor_load_item (GladeEditor *editor, GladeWidget *item)
/**
* glade_editor_select_item_real:
* @editor:
* @widget: the widget to load into the editor. Can be NULL if we want
* to clear the editor.
*
* Select an item and load it into the editor
**/
static void
glade_editor_select_item_real (GladeEditor *editor, GladeWidget *widget)
{
@ -1222,6 +1244,9 @@ glade_editor_select_item_real (GladeEditor *editor, GladeWidget *widget)
glade_editor_load_item (editor, widget);
if (!widget)
return;
editor->loading = TRUE;
table = glade_editor_get_table_from_class (editor, widget->class, FALSE);
g_return_if_fail (table != NULL);
@ -1233,9 +1258,7 @@ void
glade_editor_select_widget (GladeEditor *editor, GladeWidget *widget)
{
g_return_if_fail (GLADE_IS_EDITOR (editor));
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget->widget));
gtk_signal_emit (GTK_OBJECT (editor),
glade_editor_signals [SELECT_ITEM], widget);
}

View File

@ -39,7 +39,7 @@ glade_gtk_entry_set_text (GObject *object, const gchar *text)
static void
glade_gtk_entry_get_text (GObject *object)
{
g_print ("IMplement get text functikon\n");
glade_implement_me ();
}
static void
@ -160,16 +160,20 @@ glade_gtk_adjustment_set_page_size (GObject *object, const gchar *string)
static void
glade_gtk_vbox_get_size (GObject *object, const gchar *string)
{
g_print ("Get size\n");
glade_implement_me ();
}
static void
glade_gtk_vbox_set_size (GObject *object, const gchar *string)
{
g_print ("Set size\n");
glade_implement_me ();
}
/* ================ Temp hack =================== */
/* We have this table, but what we should do is use gmodule for this,
* however this requires that we link with libtool cause right now
* we are loosing the symbols. Chema
*/
typedef struct _GladeGtkFunction GladeGtkFunction;
struct _GladeGtkFunction {
@ -182,13 +186,14 @@ GladeGtkFunction functions [] = {
{"glade_gtk_entry_get_text", &glade_gtk_entry_get_text},
{"glade_gtk_option_menu_set_items", &glade_gtk_option_menu_set_items},
{"glade_gtk_progress_bar_set_format", &glade_gtk_progress_bar_set_format},
{"glade_gtk_vbox_set_size", &glade_gtk_vbox_set_size},
{"glade_gtk_vbox_get_size", &glade_gtk_vbox_get_size},
{"glade_gtk_adjustment_set_max", &glade_gtk_adjustment_set_max},
{"glade_gtk_adjustment_set_min", &glade_gtk_adjustment_set_min},
{"glade_gtk_adjustment_set_step_increment", &glade_gtk_adjustment_set_step_increment},
{"glade_gtk_adjustment_set_page_increment", &glade_gtk_adjustment_set_page_increment},
{"glade_gtk_adjustment_set_page_size", &glade_gtk_adjustment_set_page_size},
{"glade_gtk_vbox_set_size", &glade_gtk_vbox_set_size},
{"glade_gtk_vbox_get_size", &glade_gtk_vbox_get_size},
};
static gpointer

View File

@ -7,6 +7,9 @@ G_BEGIN_DECLS
gboolean glade_gtk_get_set_function_hack (GladePropertyClass *class, const gchar *name);
gboolean glade_gtk_get_get_function_hack (GladePropertyClass *class, const gchar *name);
/* Remove !! */
gpointer glade_gtk_get_function (const gchar *name);
G_END_DECLS
#endif /* __GLADE_GTK_H__ */

View File

@ -21,6 +21,7 @@
*/
#include <string.h>
#include <stdlib.h>
#include "glade.h"
#include "glade-packing.h"
@ -32,51 +33,223 @@
GList *table_properties = NULL;
GList *box_properties = NULL;
/* ---------------------------------- container child properties ------------------------------ */
static void
glade_packing_x_expand_set (GObject *object, const gchar *value)
glade_packing_container_set_flag (GtkContainer *container,
GtkWidget *widget,
gboolean value,
const gchar *prop,
guint flag)
{
g_print ("X expand set %s\n", value);
}
static void
glade_packing_y_expand_set (GObject *object, const gchar *value)
{
g_print ("Y expand set %s\n", value);
GValue gvalue = { 0, };
guint old;
guint new;
g_value_init (&gvalue, G_TYPE_UINT);
gtk_container_child_get_property (container,
widget,
prop,
&gvalue);
old = g_value_get_uint (&gvalue);
/* Clear the old flag */
new = old & (~flag);
/* Set it */
new |= (value ? flag : 0);
g_value_set_uint (&gvalue, new);
gtk_container_child_set_property (container,
widget,
prop,
&gvalue);
}
static void
glade_packing_x_shrink_set (GObject *object, const gchar *value)
glade_packing_container_set_integer (GtkContainer *container,
GtkWidget *widget,
gboolean value,
const gchar *property)
{
g_print ("X shrink set %s\n", value);
}
static void
glade_packing_y_shrink_set (GObject *object, const gchar *value)
{
g_print ("Y shrink set %s\n", value);
GValue gvalue = { 0, };
g_value_init (&gvalue, G_TYPE_UINT);
g_value_set_uint (&gvalue, value);
gtk_container_child_set_property (container,
widget,
property,
&gvalue);
}
static void
glade_packing_x_fill_set (GObject *object, const gchar *value)
glade_packing_container_set_boolean (GtkContainer *container,
GtkWidget *widget,
gboolean value,
const gchar *property)
{
g_print ("X fill set %s\n", value);
GValue gvalue = { 0, };
g_value_init (&gvalue, G_TYPE_BOOLEAN);
g_value_set_boolean (&gvalue, value);
gtk_container_child_set_property (container,
widget,
property,
&gvalue);
}
/* ---------------------------------------- Table ---------------------------*/
static void
glade_packing_y_fill_set (GObject *object, const gchar *value)
glade_packing_table_set_flag (GObject *object, const gchar *value, const gchar *prop, guint flag)
{
g_print ("Y fill set %s\n", value);
GladeWidget *glade_widget;
GtkWidget *widget;
GtkTable *table;
gboolean val;
g_return_if_fail (value != NULL);
widget = GTK_WIDGET (object);
g_return_if_fail (GTK_IS_WIDGET (widget));
glade_widget = glade_widget_get_from_gtk_widget (widget);
g_return_if_fail (GLADE_IS_WIDGET (glade_widget));
table = GTK_TABLE (glade_widget->parent->widget);
g_return_if_fail (GTK_IS_TABLE (table));
val = (strcmp (value, GLADE_TAG_TRUE) == 0) ? TRUE : FALSE;
glade_packing_container_set_flag (GTK_CONTAINER (table), widget,
val, prop, flag);
}
static void
glade_packing_expand_set (GObject *object, const gchar *value)
glade_packing_table_set_integer (GObject *object, const gchar *value, const gchar *prop)
{
GladeWidget *glade_widget;
GtkWidget *widget;
GtkTable *table;
gboolean val;
g_return_if_fail (value != NULL);
widget = GTK_WIDGET (object);
g_return_if_fail (GTK_IS_WIDGET (widget));
glade_widget = glade_widget_get_from_gtk_widget (widget);
g_return_if_fail (GLADE_IS_WIDGET (glade_widget));
table = GTK_TABLE (glade_widget->parent->widget);
g_return_if_fail (GTK_IS_TABLE (table));
val = atoi (value);
glade_packing_container_set_integer (GTK_CONTAINER (table), widget,
val, prop);
}
static void
glade_packing_table_x_expand_set (GObject *object, const gchar *value)
{
glade_packing_table_set_flag (object, value, "x_options", GTK_EXPAND);
}
static void
glade_packing_table_y_expand_set (GObject *object, const gchar *value)
{
glade_packing_table_set_flag (object, value, "y_options", GTK_EXPAND);
}
static void
glade_packing_table_x_shrink_set (GObject *object, const gchar *value)
{
glade_packing_table_set_flag (object, value, "x_options", GTK_SHRINK);
}
static void
glade_packing_table_y_shrink_set (GObject *object, const gchar *value)
{
glade_packing_table_set_flag (object, value, "y_options", GTK_SHRINK);
}
static void
glade_packing_table_x_fill_set (GObject *object, const gchar *value)
{
glade_packing_table_set_flag (object, value, "x_options", GTK_FILL);
}
static void
glade_packing_table_y_fill_set (GObject *object, const gchar *value)
{
glade_packing_table_set_flag (object, value, "y_options", GTK_FILL);
}
static void
glade_packing_table_padding_h_set (GObject *object, const gchar *value)
{
glade_packing_table_set_integer (object, value, "x_padding");
}
static void
glade_packing_table_padding_v_set (GObject *object, const gchar *value)
{
glade_packing_table_set_integer (object, value, "y_padding");
}
static void
glade_packing_table_cell_x_set (GObject *object, const gchar *value)
{
glade_implement_me ();
}
static void
glade_packing_table_cell_y_set (GObject *object, const gchar *value)
{
glade_implement_me ();
}
static void
glade_packing_table_span_x_set (GObject *object, const gchar *value)
{
glade_implement_me ();
}
static void
glade_packing_table_span_y_set (GObject *object, const gchar *value)
{
glade_implement_me ();
}
/* --------------------- box ----------------------------------- */
static void
glade_packing_box_set_boolean (GObject *object, const gchar *value, const gchar *property)
{
GladeWidget *glade_widget;
GtkWidget *widget;
GtkBox *box;
gboolean val;
widget = GTK_WIDGET (object);
g_return_if_fail (GTK_IS_WIDGET (widget));
glade_widget = glade_widget_get_from_gtk_widget (widget);
g_return_if_fail (GLADE_IS_WIDGET (glade_widget));
box = GTK_BOX (glade_widget->parent->widget);
g_return_if_fail (GTK_IS_BOX (box));
val = (strcmp (value, GLADE_TAG_TRUE) == 0) ? TRUE : FALSE;
glade_packing_container_set_boolean (GTK_CONTAINER (box),
widget,
val,
property);
}
static void
glade_packing_box_set_integer (GObject *object, const gchar *value,
const gchar *property)
{
GladeWidget *glade_widget;
GtkBox *box;
GtkWidget *widget;
gboolean expand, fill;
gint padding;
GtkPackType pack_type;
gint val;
widget = GTK_WIDGET (object);
g_return_if_fail (GTK_IS_WIDGET (widget));
@ -86,24 +259,119 @@ glade_packing_expand_set (GObject *object, const gchar *value)
g_return_if_fail (GTK_IS_BOX (box));
gtk_box_query_child_packing (box, widget,
&expand, &fill, &padding, &pack_type);
val = atoi (value);
glade_packing_container_set_integer (GTK_CONTAINER (box),
widget,
val,
property);
}
expand = (strcmp (value, GLADE_TAG_TRUE) == 0);
/**
* glade_packing_expand_set:
* @object:
* @value:
*
* Sets the expand property of a widget inside a Gtk[HV]Box
**/
static void
glade_packing_box_expand_set (GObject *object, const gchar *value)
{
glade_packing_box_set_boolean (object, value, "expand");
}
gtk_box_set_child_packing (box, widget,
expand, fill, padding, pack_type);
/**
* glade_packing_fill_set:
* @object:
* @value:
*
* Sets the fill property of a widget inside a Gtk[VH]Box
**/
static void
glade_packing_box_fill_set (GObject *object, const gchar *value)
{
glade_packing_box_set_boolean (object, value, "fill");
}
/**
* glade_packing_pack_start_set:
* @object:
* @value:
*
* Sets the pack_start property for a widget inside a Gtk[HV]Box
**/
static void
glade_packing_box_pack_start_set (GObject *object, const gchar *value)
{
gchar *temp;
/* Reverse value, because pack start is an enum, not a boolean.
* Chema
*/
if (strcmp (value, GLADE_TAG_TRUE) == 0)
temp = g_strdup (GLADE_TAG_FALSE);
else
temp = g_strdup (GLADE_TAG_TRUE);
glade_packing_box_set_boolean (object, temp, "pack_type");
g_free (temp);
}
/**
* glade_packing_padding_set:
* @object:
* @value:
*
* Sets the padding for widgets inside a GtkVBox or GtkHBox
**/
static void
glade_packing_box_padding_set (GObject *object, const gchar *value)
{
glade_packing_box_set_integer (object, value, "padding");
}
static gchar *
glade_packing_box_position_get (GObject *object)
{
GladeWidget *glade_widget;
GtkBoxChild *box_child = NULL;
GtkWidget *widget;
GtkBox *box;
GList *list;
gint i;
widget = GTK_WIDGET (object);
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
glade_widget = glade_widget_get_from_gtk_widget (widget);
g_return_val_if_fail (GLADE_IS_WIDGET (glade_widget), NULL);
box = GTK_BOX (glade_widget->parent->widget);
g_return_val_if_fail (GTK_IS_BOX (box), NULL);
list = box->children;
for (; list; list = list->next) {
box_child = list->data;
if (box_child->widget == widget)
break;
}
if (list == NULL) {
g_warning ("Could not find the position in the GtkBox");
return g_strdup ("Error");
}
i = g_list_index (box->children, box_child);
return g_strdup_printf ("%d", i);
}
static void
glade_packing_fill_set (GObject *object, const gchar *value)
glade_packing_box_position_set (GObject *object, const gchar *value)
{
GladeWidget *glade_widget;
GtkBox *box;
GladeWidget *glade_widget_child;
GtkWidget *widget;
gboolean expand, fill;
gint padding;
GtkPackType pack_type;
GList *list;
GtkBox *box;
widget = GTK_WIDGET (object);
g_return_if_fail (GTK_IS_WIDGET (widget));
@ -111,55 +379,87 @@ glade_packing_fill_set (GObject *object, const gchar *value)
g_return_if_fail (GLADE_IS_WIDGET (glade_widget));
box = GTK_BOX (glade_widget->parent->widget);
g_return_if_fail (GTK_IS_BOX (box));
gtk_box_reorder_child (box, widget, atoi (value));
gtk_box_query_child_packing (box, widget,
&expand, &fill, &padding, &pack_type);
/* This all works fine, but we need to update the position property
* of the other children in this box since it has changed.
*/
list = box->children;
for (; list; list = list->next) {
GladeProperty *property;
GtkBoxChild *box_child;
GtkWidget *child;
fill = (strcmp (value, GLADE_TAG_TRUE) == 0);
box_child = list->data;
child = box_child->widget;
glade_widget_child = glade_widget_get_from_gtk_widget (child);
gtk_box_set_child_packing (box, widget,
expand, fill, padding, pack_type);
if (!glade_widget_child) {
g_warning ("Could not get the GladeWidget to set packing position");
continue;
}
property = glade_property_get_from_id (glade_widget_child->properties,
"position");
/* If we have a placeholder in the Box the property will not be found */
if (property) {
g_free (property->value);
property->value = glade_packing_box_position_get (G_OBJECT (child));
}
/* We should pass a FALSE argument so that this property is not added to the
* undo stack
* Also we should have a generic way to update a property, here we know is interger
* but it shuold be done with a generic fuction
*/
}
}
static void
glade_packing_pack_start_set (GObject *object, const gchar *value)
{
GladeWidget *glade_widget;
GtkBox *box;
GtkWidget *widget;
gboolean expand, fill;
gint padding;
GtkPackType pack_type;
widget = GTK_WIDGET (object);
g_return_if_fail (GTK_IS_WIDGET (widget));
glade_widget = glade_widget_get_from_gtk_widget (widget);
g_return_if_fail (GLADE_IS_WIDGET (glade_widget));
box = GTK_BOX (glade_widget->parent->widget);
g_return_if_fail (GTK_IS_BOX (box));
gtk_box_query_child_packing (box, widget,
&expand, &fill, &padding, &pack_type);
pack_type = (strcmp (value, GLADE_TAG_TRUE) == 0) ? GTK_PACK_START : GTK_PACK_END;
gtk_box_set_child_packing (box, widget,
expand, fill, padding, pack_type);
}
typedef struct _GladePackingProperty GladePackingProperty;
struct _GladePackingProperty
{
const gchar *name;
const gchar *id;
void (*set_function) (GObject *object, const gchar *value);
gchar * (*get_function) (GObject *object);
GladePropertyType type;
const gchar *def;
};
GladePackingProperty table_props[] =
{
{"Cell X", "cell_x", glade_packing_table_cell_x_set, NULL, GLADE_PROPERTY_TYPE_INTEGER, "0"},
{"Cell Y", "cell_y", glade_packing_table_cell_y_set, NULL, GLADE_PROPERTY_TYPE_INTEGER, "0"},
{"Col Span", "col_span", glade_packing_table_span_x_set, NULL, GLADE_PROPERTY_TYPE_INTEGER, "0"},
{"Row Span", "row_span", glade_packing_table_span_y_set, NULL, GLADE_PROPERTY_TYPE_INTEGER, "0"},
{"H Padding", "h_padding", glade_packing_table_padding_h_set, NULL, GLADE_PROPERTY_TYPE_INTEGER, "0"},
{"V Padding", "v_padding", glade_packing_table_padding_v_set, NULL, GLADE_PROPERTY_TYPE_INTEGER, "0"},
{"X Expand", "xexpand", glade_packing_table_x_expand_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, NULL},
{"Y Expand", "yexpand", glade_packing_table_y_expand_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, NULL},
{"X Shrink", "xshrink", glade_packing_table_x_shrink_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, NULL},
{"Y Shrink", "yshrink", glade_packing_table_y_shrink_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, NULL},
{"X Fill", "xfill", glade_packing_table_x_fill_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, NULL},
{"Y Fill", "yfill", glade_packing_table_y_fill_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, NULL},
};
GladePackingProperty box_props[] =
{
{"Position", "position", glade_packing_box_position_set, glade_packing_box_position_get, GLADE_PROPERTY_TYPE_INTEGER, GLADE_GET_DEFAULT_FROM_WIDGET},
{"Padding", "padding", glade_packing_box_padding_set, NULL, GLADE_PROPERTY_TYPE_INTEGER, "0"},
{"Expand", "expand", glade_packing_box_expand_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, GLADE_TAG_TRUE},
{"Fill", "fill", glade_packing_box_fill_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, GLADE_TAG_TRUE},
{"Pack Start", "packstart", glade_packing_box_pack_start_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, GLADE_TAG_TRUE},
};
/**
* glade_packing_add_property:
* @list: The list of GladePropertyClass items that we are adding to
* @prop: a structure containing the data for the GladePropertyClass we are adding
*
* Addss a property class to the list
**/
static void
glade_packing_add_property (GList **list, GladePackingProperty prop)
{
@ -172,29 +472,22 @@ glade_packing_add_property (GList **list, GladePackingProperty prop)
class->tooltip = g_strdup ("Implement me");
class->type = prop.type;
class->set_function = prop.set_function;
class->get_function = prop.get_function;
if (prop.def)
class->def = g_strdup (prop.def);
*list = g_list_prepend (*list, class);
}
GladePackingProperty table_props[] =
{
{"X Expand", "xexpand", glade_packing_x_expand_set, GLADE_PROPERTY_TYPE_BOOLEAN, NULL},
{"Y Expand", "yexpand", glade_packing_y_expand_set, GLADE_PROPERTY_TYPE_BOOLEAN, NULL},
{"X Shrink", "xshrink", glade_packing_x_shrink_set, GLADE_PROPERTY_TYPE_BOOLEAN, NULL},
{"Y Shrink", "yshrink", glade_packing_y_shrink_set, GLADE_PROPERTY_TYPE_BOOLEAN, NULL},
{"X Fill", "xfill", glade_packing_x_fill_set, GLADE_PROPERTY_TYPE_BOOLEAN, NULL},
{"Y Fill", "yfill", glade_packing_y_fill_set, GLADE_PROPERTY_TYPE_BOOLEAN, NULL},
};
GladePackingProperty box_props[] =
{
{"Expand", "expand", glade_packing_expand_set, GLADE_PROPERTY_TYPE_BOOLEAN, GLADE_TAG_FALSE},
{"Fill", "fill", glade_packing_fill_set, GLADE_PROPERTY_TYPE_BOOLEAN, GLADE_TAG_FALSE},
{"Pack Start", "packstart", glade_packing_pack_start_set, GLADE_PROPERTY_TYPE_BOOLEAN, GLADE_TAG_TRUE},
};
/**
* glade_packing_init:
* @void:
*
* Initializes the property clases for the different containers. A widget has different packing
* properties depending on the container it is beeing added to. This function initializes the
* lists of property classes that we are later going to add (when a widget i created).
**/
void
glade_packing_init (void)
{
@ -213,13 +506,21 @@ glade_packing_init (void)
}
/**
* glade_packing_add_properties_from_list:
* @widget: The widget that we are adding the properites to
* @list: The list of GladePropertyClass that we want to add to @widget
*
* Adds a set of properites to a widget based on a list of GladePropertyClass.
**/
/* Should this be in glade_widget ??. Chema */
static void
glade_packing_add_properties_from_list (GladeWidget *widget,
GList *list)
{
GladePropertyClass *class;
GladeProperty *property;
for (; list != NULL; list = list->next) {
class = list->data;
property = glade_property_new_from_class (class, widget);
@ -229,10 +530,19 @@ glade_packing_add_properties_from_list (GladeWidget *widget,
}
/**
* glade_packing_add_properties:
* @widget: The widget that we want to add the properties to
*
* Adds the packing properties to a GladeWidget depending on it's container.
* the packing properties change depending on the container a widget is using.
* so we can only add them after we container_add it.
**/
void
glade_packing_add_properties (GladeWidget *widget)
{
gchar *class;
if (widget->parent == NULL)
return;
@ -244,4 +554,5 @@ glade_packing_add_properties (GladeWidget *widget)
if ((strcmp (class, "GtkHBox") == 0) ||
(strcmp (class, "GtkVBox") == 0))
glade_packing_add_properties_from_list (widget, box_properties);
}

View File

@ -7,6 +7,7 @@ G_BEGIN_DECLS
void glade_packing_init (void);
void glade_packing_add_properties (GladeWidget *widget);
G_END_DECLS
#endif /* __GLADE_PACKING_H__ */

View File

@ -36,9 +36,9 @@
#define GLADE_PLACEHOLDER_COL_STRING "GladePlaceholderColumn"
void
glade_placeholder_replace_box (GladePlaceholder *placeholder,
GladeWidget *widget,
GladeWidget *parent)
glade_placeholder_replace_box (GtkWidget *current,
GtkWidget *new,
GtkWidget *container)
{
/* Some Gtk Hackery. Not beautifull but needed. */
GtkBoxChild *child_info = NULL;
@ -46,12 +46,12 @@ glade_placeholder_replace_box (GladePlaceholder *placeholder,
GtkBox *box;
GList *list;
box = GTK_BOX (parent->widget);
box = GTK_BOX (container);
list = box->children;
for (; list != NULL; list = list->next) {
child_info = list->data;
if (child_info->widget == placeholder)
if (child_info->widget == current)
break;
}
if (list == NULL) {
@ -59,11 +59,11 @@ glade_placeholder_replace_box (GladePlaceholder *placeholder,
return;
}
gtk_widget_unparent (child_info->widget);
child_info->widget = widget->widget;
child_info->widget = new;
gtk_widget_set_parent (child_info->widget, GTK_WIDGET (box));
/* */
child = widget->widget;
child = new;
if (GTK_WIDGET_REALIZED (box))
gtk_widget_realize (child);
if (GTK_WIDGET_VISIBLE (box) && GTK_WIDGET_VISIBLE (child)) {
@ -75,9 +75,9 @@ glade_placeholder_replace_box (GladePlaceholder *placeholder,
}
void
glade_placeholder_replace_table (GladePlaceholder *placeholder,
GladeWidget *widget,
GladeWidget *parent)
glade_placeholder_replace_table (GtkWidget *current,
GtkWidget *new,
GtkWidget *container)
{
/* Some Gtk Hackery. Not beautifull, but needed */
GtkTableChild *table_child = NULL;
@ -85,12 +85,12 @@ glade_placeholder_replace_table (GladePlaceholder *placeholder,
GtkTable *table;
GList *list;
table = GTK_TABLE (parent->widget);
table = GTK_TABLE (container);
list = table->children;
for (; list != NULL; list = list->next) {
table_child = list->data;
if (table_child->widget == placeholder)
if (table_child->widget == current)
break;
}
if (list == NULL) {
@ -99,11 +99,11 @@ glade_placeholder_replace_table (GladePlaceholder *placeholder,
}
gtk_widget_unparent (table_child->widget);
table_child->widget = widget->widget;
table_child->widget = new;
gtk_widget_set_parent (table_child->widget, GTK_WIDGET (table));
/* */
child = widget->widget;
child = new;
if (GTK_WIDGET_REALIZED (child->parent))
gtk_widget_realize (child);
if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child)) {
@ -115,42 +115,50 @@ glade_placeholder_replace_table (GladePlaceholder *placeholder,
}
void
glade_placeholder_replace_container (GladePlaceholder *placeholder,
GladeWidget *widget,
GladeWidget *parent)
glade_placeholder_replace_container (GtkWidget *current,
GtkWidget *new,
GtkWidget *container)
{
gtk_container_remove (GTK_CONTAINER (parent->widget), placeholder);
gtk_container_add (GTK_CONTAINER (parent->widget), widget->widget);
gtk_container_remove (GTK_CONTAINER (container), current);
gtk_container_add (GTK_CONTAINER (container), new);
}
/**
* glade_placeholder_replace_notebook:
* @current: the current widget that is going to be replaced
* @new: the new widget that is going to replace
* @container: the container
*
* Replaces a widget inside a notebook with a new widget.
**/
void
glade_placeholder_replace_notebook (GladePlaceholder *placeholder,
GladeWidget *widget,
GladeWidget *parent)
glade_placeholder_replace_notebook (GtkWidget *current,
GtkWidget *new,
GtkWidget *container)
{
GtkNotebook *notebook;
GtkWidget *page;
GtkWidget *label;
gint page_num;
notebook = GTK_NOTEBOOK (parent->widget);
page_num = gtk_notebook_page_num (notebook, GTK_WIDGET (placeholder));
notebook = GTK_NOTEBOOK (container);
page_num = gtk_notebook_page_num (notebook, current);
if (page_num == -1) {
g_warning ("GtkNotebookPage not found\n");
return;
}
page = gtk_notebook_get_nth_page (notebook, page_num);
label = gtk_notebook_get_tab_label (notebook, GTK_WIDGET (placeholder));
label = gtk_notebook_get_tab_label (notebook, current);
gtk_widget_ref (page);
gtk_widget_ref (label);
gtk_notebook_remove_page (notebook, page_num);
gtk_notebook_insert_page (notebook, widget->widget,
gtk_notebook_insert_page (notebook, new,
label, page_num);
gtk_notebook_set_tab_label (notebook,
widget->widget,
new,
label);
gtk_widget_unref (label);
@ -173,7 +181,7 @@ glade_placeholder_replace_widget (GladePlaceholder *placeholder, GladeWidgetClas
return;
if (parent->class->placeholder_replace != NULL)
parent->class->placeholder_replace (placeholder, widget, parent);
parent->class->placeholder_replace (GTK_WIDGET (placeholder), widget->widget, parent->widget);
else
g_warning ("A widget was added to a placeholder, but the placeholder_replace "
"function has not been implemented for this class (%s)\n",
@ -279,13 +287,13 @@ glade_placeholder_on_destroy (GladePlaceholder *widget, gpointer not_used)
{
}
static GladePlaceholder *
glade_placeholder_new (GladeWidget *glade_widget)
GladePlaceholder *
glade_placeholder_new (GladeWidget *parent)
{
GladePlaceholder *placeholder;
placeholder = gtk_drawing_area_new ();
gtk_object_set_user_data (GTK_OBJECT (placeholder), glade_widget);
gtk_object_set_user_data (GTK_OBJECT (placeholder), parent);
gtk_widget_set_events (GTK_WIDGET (placeholder),
gtk_widget_get_events (GTK_WIDGET (placeholder))
@ -296,7 +304,7 @@ glade_placeholder_new (GladeWidget *glade_widget)
gtk_widget_show (GTK_WIDGET (placeholder));
glade_placeholder_connect_draw_signals (placeholder);
glade_placeholder_connect_mouse_signals (placeholder, glade_widget->project);
glade_placeholder_connect_mouse_signals (placeholder, parent->project);
gtk_signal_connect (GTK_OBJECT (placeholder), "destroy",
GTK_SIGNAL_FUNC (glade_placeholder_on_destroy), NULL);

View File

@ -8,22 +8,24 @@ void glade_placeholder_add (GladeWidgetClass *class,
GladeWidget *widget,
GladePropertyQueryResult *result);
GladePlaceholder * glade_placeholder_new (GladeWidget *parent);
GladeWidget * glade_placeholder_get_parent (GladePlaceholder *placeholder);
/* Hacks */
void glade_placeholder_replace_box (GladePlaceholder *place_holder,
GladeWidget *widget,
GladeWidget *parent);
void glade_placeholder_replace_table (GladePlaceholder *placeholder,
GladeWidget *widget,
GladeWidget *parent);
void glade_placeholder_replace_container (GladePlaceholder *placeholder,
GladeWidget *widget,
GladeWidget *parent);
void glade_placeholder_replace_notebook (GladePlaceholder *placeholder,
GladeWidget *widget,
GladeWidget *parent);
void glade_placeholder_replace_box (GtkWidget *current,
GtkWidget *new,
GtkWidget *container);
void glade_placeholder_replace_table (GtkWidget *current,
GtkWidget *new,
GtkWidget *container);
void glade_placeholder_replace_container (GtkWidget *current,
GtkWidget *new,
GtkWidget *container);
void glade_placeholder_replace_notebook (GtkWidget *current,
GtkWidget *new,
GtkWidget *container);
G_END_DECLS

View File

@ -30,12 +30,9 @@ static void
glade_popup_menu_detach (GtkWidget *attach_widget,
GtkMenu *menu)
{
/* We don't need a detach function. do we ? Chema. */
#if 0
GladeWidget *widget;
#endif
/* Dunno what this is for */
g_print ("Detaching ************************************\n");
#if 0
gtk_widget_destroy (GTK_WIDGET (menu));
widget = glade_widget_get_from_gtk_widget (attach_widget);

View File

@ -157,7 +157,7 @@ glade_project_view_populate_model_real (GtkTreeStore *model,
GList *list;
GtkTreeIter iter;
GtkTreeIter *copy = NULL;
list = g_list_copy (widgets);
list = g_list_reverse (list);
for (; list != NULL; list = list->next) {
@ -234,6 +234,34 @@ glade_project_view_add_item (GladeProjectView *view,
glade_project_selection_set (widget, TRUE);
}
static void
glade_project_view_remove_item (GladeProjectView *view,
GladeWidget *widget)
{
GladeWidgetClass *class;
GtkTreeModel *model;
GtkTreeIter *iter;
class = glade_widget_get_class (widget);
if (view->is_list && !GLADE_WIDGET_CLASS_TOPLEVEL (class))
return;
model = GTK_TREE_MODEL (view->model);
iter = glade_project_view_find_iter_by_widget (model,
widget);
if (iter) {
static gboolean warned = FALSE;
if (!warned)
g_print ("Update the cell. BUT HOW ??\n");
warned = TRUE;
}
gtk_tree_store_remove (view->model, iter);
}
static void
glade_project_view_class_init (GladeProjectViewClass * gpv_class)
@ -245,6 +273,7 @@ glade_project_view_class_init (GladeProjectViewClass * gpv_class)
parent_class = gtk_type_class (gtk_object_get_type ());
gpv_class->add_item = glade_project_view_add_item;
gpv_class->remove_item = glade_project_view_remove_item;
gpv_class->set_project = glade_project_view_set_project;
gpv_class->widget_name_changed = glade_project_view_widget_name_changed;
}
@ -263,6 +292,16 @@ glade_project_view_cell_function (GtkTreeViewColumn *tree_column,
/* The cell exists, but not widget has been asociated with it */
if (widget == NULL)
return;
g_return_if_fail (widget->name != NULL);
g_return_if_fail (widget->class != NULL);
g_return_if_fail (GPOINTER_TO_INT (widget->class) > 5000);
g_return_if_fail (widget->class->name != NULL);
g_return_if_fail (widget->class->pixbuf != NULL);
g_return_if_fail ((widget->selected == TRUE) ||
(widget->selected == FALSE));
g_return_if_fail (GDK_IS_PIXBUF (widget->class->pixbuf));
g_object_set (G_OBJECT (cell),
"text", widget->name,
@ -359,7 +398,7 @@ glade_project_view_selection_changed (GladeProjectView *view, GladeWidget *item)
{
glade_project_selection_clear (view->project, FALSE);
g_print ("Do something\n");
glade_implement_me ();
#if 0
if (view->selected_widget == item)
return;
@ -380,6 +419,14 @@ glade_project_view_add_widget_cb (GladeProject *project,
GLADE_PROJECT_VIEW_CLASS (GTK_OBJECT_GET_CLASS(view))->add_item (view, widget);
}
static void
glade_project_view_remove_widget_cb (GladeProject *project,
GladeWidget *widget,
GladeProjectView *view)
{
GLADE_PROJECT_VIEW_CLASS (GTK_OBJECT_GET_CLASS(view))->remove_item (view, widget);
}
static void
glade_project_view_widget_name_changed_cb (GladeProject *project,
GladeWidget *widget,
@ -433,6 +480,7 @@ glade_project_view_set_project (GladeProjectView *view,
/* This view stops listening to the old project (if there was one) */
if (view->project != NULL) {
gtk_signal_disconnect (GTK_OBJECT (view->project), view->add_widget_signal_id);
gtk_signal_disconnect (GTK_OBJECT (view->project), view->remove_widget_signal_id);
gtk_signal_disconnect (GTK_OBJECT (view->project), view->widget_name_changed_signal_id);
}
@ -450,6 +498,10 @@ glade_project_view_set_project (GladeProjectView *view,
gtk_signal_connect (GTK_OBJECT (project), "add_widget",
GTK_SIGNAL_FUNC (glade_project_view_add_widget_cb),
view);
view->remove_widget_signal_id =
gtk_signal_connect (GTK_OBJECT (project), "remove_widget",
GTK_SIGNAL_FUNC (glade_project_view_remove_widget_cb),
view);
view->widget_name_changed_signal_id =
gtk_signal_connect (GTK_OBJECT (project), "widget_name_changed",
GTK_SIGNAL_FUNC (glade_project_view_widget_name_changed_cb),

View File

@ -36,8 +36,11 @@ struct _GladeProjectView
* connected to so that when the project changes
* we stop listening to the old project
*/
gulong remove_widget_signal_id;
gulong widget_name_changed_signal_id;
GtkTreeStore *model; /* Model */
gboolean is_list; /* If true the view is a list, if false the view
@ -57,6 +60,8 @@ struct _GladeProjectViewClass
void (*add_item) (GladeProjectView *view,
GladeWidget *widget);
void (*remove_item) (GladeProjectView *view,
GladeWidget *widget);
void (*widget_name_changed) (GladeProjectView *view,
GladeWidget *widget);

View File

@ -46,13 +46,48 @@ static void gpw_show_clipboard_cb (void) {};
static void gpw_undo_cb (void);
static void gpw_redo_cb (void);
static void gpw_delete_cb (void) {};
static void gpw_about_cb (void) {};
static void
gpw_open_cb (void)
{
g_print ("Implement me !\n");
glade_implement_me ();
}
static void
gpw_delete_cb (void)
{
GladeProject *project;
GList *selection;
GList *free_me;
GList *list;
project = glade_project_window_get_project ();
if (!project) {
g_warning ("Why is delete sensitive ? it shouldn't not be because "
"we don't have a project");
return;
}
selection = glade_project_selection_get (project);
/* We have to be carefull when deleting widgets from the selection
* because when we delete each widget, the ->selection pointer changes
* by the g_list_remove. Copy the list and freee it after we are done
*/
list = g_list_copy (selection);
free_me = list;
for (; list; list = list->next)
glade_widget_delete (list->data);
g_list_free (free_me);
/* Right now deleting widgets like this is not a problem, cause we
* don't support multiple selection. When we do, it would be nice
* to have glade_project_selction_freeze the remove all the widgets
* and then call glade_project_selection_thaw. This will trigger
* only one selection changed signal rather than multiple ones
* Chema
*/
}
static void
@ -78,7 +113,7 @@ gpw_save_cb (void)
static void
gpw_save_as_cb (void)
{
g_print ("Implement me !\n");
glade_implement_me ();
}
static void
@ -90,31 +125,31 @@ gpw_quit_cb (void)
static void
gpw_copy_cb (void)
{
g_print ("Copy !\n");
glade_implement_me ();
}
static void
gpw_cut_cb (void)
{
g_print ("Cut !\n");
glade_implement_me ();
}
static void
gpw_paste_cb (void)
{
g_print ("Paste !\n");
glade_implement_me ();
}
static void
gpw_undo_cb (void)
{
g_print ("Undo\n");
glade_implement_me ();
}
static void
gpw_redo_cb (void)
{
g_print ("Redo\n");
glade_implement_me ();
}
static void
@ -168,7 +203,7 @@ glade_project_window_construct_menu (GladeProjectWindow *gpw)
/* Accelerators */
accel_group = gtk_accel_group_new ();
gtk_accel_group_attach (accel_group, GTK_OBJECT (gpw->window));
gtk_accel_group_attach (accel_group, G_OBJECT (gpw->window));
gtk_accel_group_unref (accel_group);
/* Item factory */
@ -507,6 +542,8 @@ glade_project_window_query_properties_set (gpointer key_,
* @result:
*
* Queries the user for some property values before a GladeWidget creation
* for example before creating a GtkVBox we want to ask the user the number
* of columns he wants.
*
* Return Value: FALSE if the query was canceled
**/

View File

@ -155,6 +155,13 @@ glade_project_set_changed (GladeProject *project, gboolean changed)
project->changed = changed;
}
void
glade_project_selection_changed (GladeProject *project)
{
gtk_signal_emit (GTK_OBJECT (project),
glade_project_signals [SELECTION_CHANGED]);
}
void
glade_project_add_widget (GladeProject *project,
@ -171,6 +178,42 @@ glade_project_add_widget (GladeProject *project,
glade_project_set_changed (project, TRUE);
}
static void
glade_project_remove_widget_real (GladeProject *project,
GladeWidget *widget)
{
GladeWidget *child;
GList *list;
list = widget->children;
for (; list; list = list->next) {
child = list->data;
glade_project_remove_widget_real (project,
child);
}
project->selection = g_list_remove (project->selection, widget);
project->widgets = g_list_remove (project->widgets, widget);
gtk_signal_emit (GTK_OBJECT (project),
glade_project_signals [REMOVE_WIDGET], widget);
}
void
glade_project_remove_widget (GladeWidget *widget)
{
GladeProject *project;
g_return_if_fail (widget != NULL);
project = widget->project;
glade_project_remove_widget_real (project, widget);
glade_project_selection_changed (project);
glade_project_set_changed (project, TRUE);
}
void
glade_project_widget_name_changed (GladeProject *project,
GladeWidget *widget)
@ -242,13 +285,6 @@ glade_project_get_widget_by_name (GladeProject *project, const gchar *name)
void
glade_project_selection_changed (GladeProject *project)
{
gtk_signal_emit (GTK_OBJECT (project),
glade_project_signals [SELECTION_CHANGED]);
}
void
glade_project_selection_clear (GladeProject *project, gboolean emit_signal)
{
@ -334,6 +370,12 @@ glade_project_selection_set (GladeWidget *widget,
glade_project_selection_add (widget, emit_signal);
}
GList *
glade_project_selection_get (GladeProject *project)
{
return project->selection;
}
/**
* glade_project_write_widgets:

View File

@ -32,7 +32,8 @@ struct _GladeProject
GList *selection; /* We need to keep the selection in the project
* because we have multiple projects and when the
* user switchs between them, he will probably
* not want to loose the selection
* not want to loose the selection. This is a list
* of GladeWidget items.
*/
};
@ -60,6 +61,7 @@ GladeProject * glade_project_new (void);
gboolean glade_project_save (GladeProject *project);
/* Widget related stuff */
void glade_project_remove_widget (GladeWidget *widget);
void glade_project_add_widget (GladeProject *project,
GladeWidget *glade_widget);
@ -74,6 +76,8 @@ void glade_project_selection_add (GladeWidget *widget, gboolean emit_signal);
void glade_project_selection_remove (GladeWidget *widget, gboolean emit_signal);
void glade_project_selection_clear (GladeProject *project, gboolean emit_signal);
GList * glade_project_selection_get (GladeProject *project);
G_END_DECLS
#endif /* __GLADE_PROJECT_H__ */

View File

@ -167,7 +167,7 @@ struct _GladePropertyClass {
* to the function that can set this property. The functions
* to work arround this problems are inside glade-gtk.c
*/
void (*get_function) (GObject *object);
gchar * (*get_function) (GObject *object);
/* If this property can't be get with g_object_get then
* we need to implement it inside glade. This is a pointer
* to the function that can set this property. The functions

View File

@ -62,10 +62,20 @@ glade_property_new_from_class (GladePropertyClass *class, GladeWidget *widget)
GladeChoice *choice;
GList *list;
property = glade_property_new ();
property->class = class;
/* For some properties, we don't know its value utill we add the widget and
* pack it in a container. For example for a "pos" packing property we need
* to pack the property first, the query the property to know the value
*/
if (string && strcmp (string, GLADE_GET_DEFAULT_FROM_WIDGET) == 0) {
property->value = g_strdup (string);
return property;
}
switch (class->type) {
case GLADE_PROPERTY_TYPE_BOOLEAN:
if (string == NULL)
@ -270,7 +280,6 @@ glade_property_changed_integer (GladeProperty *property, gint val)
else
(*property->class->set_function) (G_OBJECT (property->widget->widget),
property->value);
}
void
@ -504,3 +513,17 @@ glade_property_write (GladeXmlContext *context, GladeProperty *property)
return node;
}
void
glade_property_free (GladeProperty *property)
{
property->class = NULL;
property->widget = NULL;
if (property->value)
g_free (property->value);
property->value = NULL;
if (property->child)
g_warning ("Implmenet free property->child\n");
g_free (property);
}

View File

@ -54,6 +54,7 @@ struct _GladePropertyQueryResult {
GList * glade_property_list_new_from_widget_class (GladeWidgetClass *class,
GladeWidget *widget);
GladeProperty * glade_property_new_from_class (GladePropertyClass *class, GladeWidget *widget);
void glade_property_free (GladeProperty *property);
void glade_property_changed_text (GladeProperty *property, const gchar *text);
void glade_property_changed_integer (GladeProperty *property, gint val);
@ -71,8 +72,6 @@ GladeChoice * glade_property_get_choice (GladeProperty *property);
/* Get a GladeProperty */
GladeProperty * glade_property_get_from_name (GList *property_list,
const gchar *name);
GladeProperty * glade_property_get_from_id (GList *settings_list,
const gchar *id);

View File

@ -342,7 +342,7 @@ glade_signal_editor_clear_entries (GladeSignalEditor *editor)
gtk_entry_set_text (GTK_ENTRY (editor->signal_name_entry), "");
gtk_entry_set_text (GTK_ENTRY (editor->signal_handler_entry), "");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
(editor->signal_after_button), FALSE);
(editor->signal_after_button), FALSE);
}
static GladeSignal *
@ -702,9 +702,12 @@ glade_signal_editor_load_widget (GladeSignalEditor *editor, GladeWidget *widget)
gtk_tree_store_clear (model);
editor->widget = widget;
editor->class = widget->class;
editor->class = widget ? widget->class : NULL;
glade_signal_editor_clear_entries (editor);
if (!widget)
return;
list = widget->signals;
for (; list != NULL; list = list->next) {

View File

@ -41,3 +41,11 @@ glade_signal_write (GladeXmlContext *context, GladeSignal *signal)
return node;
}
void
glade_signal_free (GladeSignal *signal)
{
g_free (signal->name);
g_free (signal->handler);
g_free (signal);
}

View File

@ -14,6 +14,7 @@ struct _GladeSignal {
};
GladeXmlNode * glade_signal_write (GladeXmlContext *context, GladeSignal *signal);
void glade_signal_free (GladeSignal *signal);
G_END_DECLS

View File

@ -185,7 +185,7 @@ glade_widget_class_set_type (GladeWidgetClass *class, const gchar *init_function
return FALSE;
}
/* Disabled for GtkAdjustment, but i'd like to check for this somehow */
/* Disabled for GtkAdjustment, but i'd like to check for this somehow. Chema */
#if 0
if (!g_type_is_a (type, gtk_widget_get_type ())) {
g_warning (_("The loaded type is not a GtkWidget, while trying to load \"%s\""),
@ -409,7 +409,7 @@ glade_widget_class_find_spec (GladeWidgetClass *class, const gchar *name)
*
* Dump to the console the properties of the Widget as specified
* by gtk+. You can also run glade2 with : "glade2 --dump GtkWindow" to
* get the widget properties.
* get dump a widget class properties.
*
* Return Value:
**/
@ -424,24 +424,32 @@ glade_widget_class_dump_param_specs (GladeWidgetClass *class)
glade_widget_class_get_specs (class, &specs, &n_specs);
g_print ("\nDumping ParamSpec for %s\n", class->name);
g_ok_print ("\nDumping ParamSpec for %s\n", class->name);
last = 0;
for (i = 0; i < n_specs; i++) {
spec = specs[i];
if (last != spec->owner_type)
g_print ("\n -- %s -- \n",
g_ok_print ("\n -- %s -- \n",
g_type_name (spec->owner_type));
g_print ("%02d - %-25s %s\n",
g_ok_print ("%02d - %-25s %s\n",
i,
spec->name,
g_type_name (spec->value_type));
last = spec->owner_type;
}
g_print ("\n");
g_ok_print ("\n");
}
/**
* glade_widget_class_get_by_name:
* @name:
*
* Find a GladeWidgetClass with the name @name.
*
* Return Value:
**/
GladeWidgetClass *
glade_widget_class_get_by_name (const gchar *name)
{

View File

@ -54,9 +54,9 @@ struct _GladeWidgetClass {
GList *signals; /* List of GladeWidgetClassSignal objects */
void (*placeholder_replace) (GladePlaceholder *placeholder,
GladeWidget *widget,
GladeWidget *parent);
void (*placeholder_replace) (GtkWidget *current,
GtkWidget *new,
GtkWidget *container);
};
/* GladeWidgetClassSignal contains all the info we need for a given signal, such as

View File

@ -158,7 +158,7 @@ glade_widget_find_inside_container (GtkWidget *widget, gpointer data_in)
*
* Returns the real widget that was "clicked over" for a given event (cooridantes) and a widget
* For example, when a label is clicked the button press event is triggered for its parent, this
* function takes the event and the widget that got the event and returns the real widget that was
* function takes the event and the widget that got the event and returns the real GladeWidget that was
* clicked
*
* Return Value:
@ -192,6 +192,7 @@ glade_widget_get_from_event_widget (GtkWidget *event_widget, GdkEventButton *eve
parent_window = event_widget->parent ? event_widget->parent->window : event_widget->window;
while (window && window != parent_window) {
gdk_window_get_position (window, &win_x, &win_y);
#ifdef DEBUG
g_debug (" adding X:%d Y:%d - We now have : %d %d\n",
@ -308,7 +309,6 @@ glade_widget_button_release (GtkWidget *widget, GdkEventButton *event, gpointer
return FALSE;
}
/**
* glade_widget_set_default_options:
* @widget:
@ -327,6 +327,22 @@ glade_widget_set_default_options_real (GladeWidget *widget, gboolean packing)
if (property->class->packing != packing)
continue;
/* For some properties, we get the value from the GtkWidget, for example the
* "position" packing property
*/
if (property->value && (strcmp (property->value, GLADE_GET_DEFAULT_FROM_WIDGET) == 0)) {
gchar *temp;
if (!property->class->get_function) {
g_warning ("Class %s is get_default_from_widget but no get function specified",
property->class->name);
temp = g_strdup ("Error");
} else
temp = (*property->class->get_function) (G_OBJECT (widget->widget));
g_free (property->value);
property->value = temp;
continue;
}
switch (property->class->type) {
case GLADE_PROPERTY_TYPE_BOOLEAN:
@ -607,7 +623,6 @@ glade_widget_create_gtk_widget (GladeProject *project,
GtkWidget *widget;
gchar *name;
name = glade_widget_new_name (project, class);
type = g_type_from_name (class->name);
if (! g_type_is_a (type, G_TYPE_OBJECT)) {
@ -623,13 +638,15 @@ glade_widget_create_gtk_widget (GladeProject *project,
widget = g_object_new (type, NULL);
}
name = glade_widget_new_name (project, class);
glade_widget = glade_widget_register (project, class, widget, name, parent);
g_free (name);
gtk_object_set_data (GTK_OBJECT (glade_widget->widget), GLADE_WIDGET_DATA_TAG, glade_widget);
glade_project_add_widget (project, glade_widget);
g_free (name);
/* We can be a GtkObject for example, like an adjustment */
if (!g_type_is_a (type, GTK_TYPE_WIDGET))
return glade_widget;
@ -638,7 +655,6 @@ glade_widget_create_gtk_widget (GladeProject *project,
glade_widget_connect_draw_signals (glade_widget);
glade_widget_connect_edit_signals (glade_widget);
return glade_widget;
}
@ -650,7 +666,7 @@ glade_widget_create_gtk_widget (GladeProject *project,
*
* Creates a new GladeWidget from a given class. Takes care of registering
* the widget in the project, adding it to the views and quering the user
* if necesary.
* if needed.
*
* Return Value: A newly creatred GladeWidget, NULL on user cancel or error
**/
@ -671,6 +687,7 @@ glade_widget_new_from_class_full (GladeWidgetClass *class, GladeProject *project
glade_widget = glade_widget_create_gtk_widget (project, class, parent);
/* IF we are a container, add the placeholders */
if (GLADE_WIDGET_CLASS_ADD_PLACEHOLDER (class))
glade_placeholder_add (class, glade_widget, result);
@ -681,9 +698,6 @@ glade_widget_new_from_class_full (GladeWidgetClass *class, GladeProject *project
if (result)
glade_property_query_result_destroy (result);
/* We need to set the default options after adding it to the placeholder cause
* there are packing options too
*/
glade_widget_set_default_options (glade_widget);
return glade_widget;
@ -728,7 +742,7 @@ glade_widget_get_class (GladeWidget *widget)
static GladeProperty *
glade_widget_get_property_from_list (GList *list, GladePropertyClass *class)
glade_widget_get_property_from_list (GList *list, GladePropertyClass *class, gboolean silent)
{
GladeProperty *property = NULL;
@ -741,13 +755,16 @@ glade_widget_get_property_from_list (GList *list, GladePropertyClass *class)
break;
if (property->child != NULL) {
property = glade_widget_get_property_from_list (property->child->properties,
class);
class, TRUE);
if (property != NULL)
break;
}
}
if (list == NULL) {
g_warning ("Could not find the GladeProperty to load.\n");
if (!silent)
g_warning ("Could not find the GladeProperty to load from -%s-",
class->name);
return NULL;
}
@ -768,11 +785,18 @@ GladeProperty *
glade_widget_get_property_from_class (GladeWidget *widget,
GladePropertyClass *property_class)
{
GladeProperty *property;
GList *list;
list = widget->properties;
return glade_widget_get_property_from_list (list, property_class);
property = glade_widget_get_property_from_list (list, property_class, FALSE);
if (!property)
g_warning ("Could not get property for widget %s of %s class\n",
widget->name, widget->class->name);
return property;
}
/**
@ -834,32 +858,80 @@ glade_widget_flag_selected (GladeWidget *widget)
gtk_widget_queue_draw (widget->widget);
}
static void
glade_widget_free (GladeWidget *widget)
{
GList *list;
widget->class = NULL;
widget->project = NULL;
widget->name = NULL;
widget->widget = NULL;
widget->parent = NULL;
list = widget->properties;
for (; list; list = list->next)
glade_property_free (list->data);
widget->properties = NULL;
list = widget->signals;
for (; list; list = list->next)
glade_signal_free (list->data);
widget->signals = NULL;
list = widget->children;
for (; list; list = list->next)
glade_widget_free (list->data);
widget->children = NULL;
g_free (widget);
}
void
glade_widget_delete (GladeWidget *widget)
{
g_print ("Implement delete. Widget : %s\n",
glade_widget_get_name (widget));
GladeWidget *parent;
g_return_if_fail (widget != NULL);
glade_project_remove_widget (widget);
parent = widget->parent;
if (parent) {
GladePlaceholder *placeholder;
/* Replace the slot it was occuping with a placeholder */
placeholder = glade_placeholder_new (widget->parent);
if (widget->parent->class->placeholder_replace)
widget->parent->class->placeholder_replace (widget->widget, GTK_WIDGET (placeholder), widget->parent->widget);
/* Remove it from the parent's child list */
parent->children = g_list_remove (parent->children,
widget);
} else {
gtk_widget_destroy (widget->widget);
}
glade_widget_free (widget);
}
void
glade_widget_cut (GladeWidget *widget)
{
g_print ("Implement cut. Widget : %s\n",
glade_widget_get_name (widget));
glade_implement_me ();
}
void
glade_widget_copy (GladeWidget *widget)
{
g_print ("Implement copy. Widget : %s\n",
glade_widget_get_name (widget));
glade_implement_me ();
}
void
glade_widget_paste (GladeWidget *widget)
{
g_print ("Implement paste. Widget : %s\n",
glade_widget_get_name (widget));
glade_implement_me ();
}
/**
@ -899,9 +971,11 @@ glade_widget_write (GladeXmlContext *context, GladeWidget *widget)
GladeXmlNode *node;
GladeXmlNode *child; /* This is the <widget name="foo" ..> tag */
GladeXmlNode *child_tag; /* This is the <child> tag */
GladeXmlNode *packing;
GladeWidget *child_widget;
GladeSignal *signal;
GList *list;
GList *list2;
g_return_val_if_fail (GLADE_XML_IS_CONTEXT (context), NULL);
g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
@ -910,16 +984,20 @@ glade_widget_write (GladeXmlContext *context, GladeWidget *widget)
glade_xml_node_set_property_string (node, GLADE_XML_TAG_CLASS, widget->class->name);
glade_xml_node_set_property_string (node, GLADE_XML_TAG_ID, widget->name);
/* Write the properties */
list = widget->properties;
for (; list != NULL; list = list->next) {
property = list->data;
if (property->class->packing)
continue;
child = glade_property_write (context, property);
if (child == NULL)
return NULL;
glade_xml_append_child (node, child);
}
/* Signals */
list = widget->signals;
for (; list != NULL; list = list->next) {
signal = list->data;
@ -929,7 +1007,7 @@ glade_widget_write (GladeXmlContext *context, GladeWidget *widget)
glade_xml_append_child (node, child);
}
/* Children */
list = widget->children;
for (; list != NULL; list = list->next) {
child_widget = list->data;
@ -939,6 +1017,22 @@ glade_widget_write (GladeXmlContext *context, GladeWidget *widget)
child_tag = glade_xml_node_new (context, GLADE_XML_TAG_CHILD);
glade_xml_append_child (node, child_tag);
glade_xml_append_child (child_tag, child);
/* Append the packing properties */
packing = glade_xml_node_new (context, GLADE_XML_TAG_PACKING);
list2 = child_widget->properties;
for (; list2 != NULL; list2 = list2->next) {
GladeXmlNode *packing_property;
property = list2->data;
if (!property->class->packing)
continue;
packing_property = glade_property_write (context, property);
if (packing_property == NULL)
return NULL;
glade_xml_append_child (packing, packing_property);
}
glade_xml_append_child (child_tag, packing);
/* */
}
return node;

View File

@ -6,6 +6,11 @@
gchar * _ (gchar * name);
#endif
#define g_ok_print g_print
/* I always grep for g_print to find left over debuging print's
* so for now, use g_ok_print on the code that is ment to do a g_print
* (like --dump GtkWindow). Later rename to g_print. Chema
*/
#include "glade-types.h"
#include "glade-utils.h"
#include "glade-xml-utils.h"
@ -61,6 +66,8 @@ gchar * _ (gchar * name);
#define GLADE_WIDGET_DATA_TAG "GladeWidgetDataTag"
#define GLADE_GET_DEFAULT_FROM_WIDGET "GladeGetDefaultFromWidget"
#define GLADE_XML_TAG_PROJECT "glade-interface"
#define GLADE_XML_TAG_WIDGET "widget"
#define GLADE_XML_TAG_PROPERTY "property"
@ -72,3 +79,6 @@ gchar * _ (gchar * name);
#define GLADE_XML_TAG_CHILD "child"
#define GLADE_XML_TAG_SIGNAL "signal"
#define GLADE_XML_TAG_AFTER "after"
#define GLADE_XML_TAG_PACKING "packing"

View File

@ -159,12 +159,5 @@ parse_command_line (poptContext pctx)
}
void
g_scanner_stat_mode (void)
{
g_print ("foo\n");
}
gchar * _ (gchar * name) { return name;};