Commit cd584d7f authored by Ivan Wong Yat Cheung's avatar Ivan Wong Yat Cheung
Browse files

2005-04-10 Ivan, Wong Yat Cheung <email@ivanwong.info

	* configure.in: Version number should start from 0:0:0 before
	a public release.

	* src/glade-clipboard-view.c (glade_clipboard_view_button_press_cb):
	* src/glade-editor.c (glade_editor_table_append_items):
	* src/glade-signal-editor.c (glade_signal_editor_load_widget):
	* src/glade-project-view.c:
	* src/glade-widget.c:
	* src/main.c: Get rid of some compilation warnings, correct some
	inconsistent coding style, plus some silly things.

	* src/glade-project.c: Correct some project loading behaviours. Use
	glade_widget_class_container_get_all_children instead of
	glade_widget_class_container_get_children.

	* src/glade-utils.c (glade_util_container_get_all_children):
	glade_widget_class_container_get_all_children should use
	gtk_container_forall instead of gtk_container_foreach.

	* src/glade-widget-class.c: Fix some class inhertance bugs.

	* src/glade-widget.[ch] (glade_widget_get_pack_property): New.

	* widgets/gtk+.xml:
	* src/glade-gtk.c: Add some custom add-functons that know how to
	handle placeholder. Handlers for "special child type" are there,
	we just need to wait and re-enable them once placeholder has
	GladeWidget.
parent c467d57b
2005-04-10 Ivan, Wong Yat Cheung <email@ivanwong.info
* configure.in: Version number should start from 0:0:0 before
a public release.
* src/glade-clipboard-view.c (glade_clipboard_view_button_press_cb):
* src/glade-editor.c (glade_editor_table_append_items):
* src/glade-signal-editor.c (glade_signal_editor_load_widget):
* src/glade-project-view.c:
* src/glade-widget.c:
* src/main.c: Get rid of some compilation warnings, correct some
inconsistent coding style, plus some silly things.
* src/glade-project.c: Correct some project loading behaviours. Use
glade_widget_class_container_get_all_children instead of
glade_widget_class_container_get_children.
* src/glade-utils.c (glade_util_container_get_all_children):
glade_widget_class_container_get_all_children should use
gtk_container_forall instead of gtk_container_foreach.
* src/glade-widget-class.c: Fix some class inhertance bugs.
* src/glade-widget.[ch] (glade_widget_get_pack_property): New.
* widgets/gtk+.xml:
* src/glade-gtk.c: Add some custom add-functons that know how to
handle placeholder. Handlers for "special child type" are there,
we just need to wait and re-enable them once placeholder has
GladeWidget.
2005-04-03 Tristan Van Berkom <tvb@gnome.org>
* src/glade-project-window.c: Fixed radio project menu
......
......@@ -27,9 +27,10 @@ AM_PROG_LIBTOOL
# If any interfaces have been added, removed, or changed, increment GLADE_CURRENT, and set GLADE_REVISION to 0.
# If any interfaces have been added since the last public release, then increment GLADE_AGE.
# If any interfaces have been removed since the last public release, then set GLADE_AGE to 0.
# Reference: http://www.gnu.org/software/libtool/manual.html#Versioning
GLADE_REVISION=0
GLADE_CURRENT=1
GLADE_AGE=1
GLADE_CURRENT=0
GLADE_AGE=0
AC_SUBST(GLADE_REVISION)
AC_SUBST(GLADE_CURRENT)
AC_SUBST(GLADE_AGE)
......@@ -38,7 +39,7 @@ AC_SUBST(GLADE_AGE)
dnl ================================================================
dnl Gettext stuff.
dnl ================================================================
GETTEXT_PACKAGE=glade-3
GETTEXT_PACKAGE=AC_PACKAGE_NAME
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Name of the gettext package.])
ALL_LINGUAS="az es ms nn no pl pt ru sv ta tr uk"
......
......@@ -162,7 +162,8 @@ glade_clipboard_view_button_press_cb (GtkWidget *widget,
gboolean handled = FALSE;
if (event->window == gtk_tree_view_get_bin_window (tree_view) &&
gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y,
gtk_tree_view_get_path_at_pos (tree_view,
(gint) event->x, (gint) event->y,
&path, NULL,
NULL, NULL) && path != NULL)
{
......
......@@ -1208,17 +1208,14 @@ glade_editor_table_append_items (GladeEditorTable *table,
if (!glade_property_class_is_visible (property_class, class))
continue;
if (type == TABLE_TYPE_QUERY && property_class->query == FALSE)
if (type == TABLE_TYPE_QUERY && !property_class->query)
continue;
else if (type == TABLE_TYPE_COMMON && property_class->common == FALSE)
else if (type == TABLE_TYPE_COMMON && !property_class->common)
continue;
else if (type == TABLE_TYPE_GENERAL && property_class->common == TRUE)
else if (type == TABLE_TYPE_GENERAL && property_class->common)
continue;
if (type == TABLE_TYPE_QUERY)
property = glade_editor_table_append_item (table, property_class, TRUE);
else
property = glade_editor_table_append_item (table, property_class, FALSE);
property = glade_editor_table_append_item (table, property_class, type == TABLE_TYPE_QUERY);
if (property != NULL)
new_list = g_list_prepend (new_list, property);
......
......@@ -383,7 +383,7 @@ glade_gtk_box_get_first_blank (GtkBox *box)
glade_widget_get_property (gwidget, "position");
gwidget_position = g_value_get_int (property->value);
if ((gwidget_position - position) > 0)
if (gwidget_position > position)
return position;
}
}
......@@ -409,6 +409,9 @@ glade_gtk_box_set_size (GObject *object, GValue *value)
old_size = g_list_length (box->children);
new_size = g_value_get_int (value);
if (old_size == new_size)
return;
/* Ensure placeholders first...
*/
......@@ -907,6 +910,8 @@ glade_gtk_button_set_stock (GObject *object, GValue *value)
gint val;
val = g_value_get_enum (value);
if (val == GPOINTER_TO_INT (g_object_get_data (object, "stock")))
return;
button = GTK_WIDGET (object);
g_return_if_fail (GTK_IS_BUTTON (button));
......@@ -928,9 +933,8 @@ glade_gtk_button_set_stock (GObject *object, GValue *value)
g_return_if_fail (i < eclass->n_values);
if (GTK_BIN (button)->child)
gtk_container_remove (GTK_CONTAINER (button),
GTK_BIN (button)->child);
gtk_container_remove (GTK_CONTAINER (button),
GTK_BIN (button)->child);
if (!gtk_stock_lookup (eclass->values[i].value_nick, &item))
{
......@@ -967,6 +971,7 @@ glade_gtk_button_set_stock (GObject *object, GValue *value)
}
g_type_class_unref (eclass);
g_object_set_data (object, "stock", GINT_TO_POINTER (val));
}
/**
......@@ -1069,12 +1074,12 @@ glade_gtk_fixed_button_press (GtkWidget *widget,
property = glade_widget_get_property (gwidget, "x");
property->enabled = TRUE;
g_value_set_int (&value, event->x);
g_value_set_int (&value, (gint) event->x);
glade_property_set (property, &value);
property = glade_widget_get_property (gwidget, "y");
property->enabled = TRUE;
g_value_set_int (&value, event->y);
g_value_set_int (&value, (gint) event->y);
glade_property_set (property, &value);
property = glade_widget_get_property
......@@ -1360,17 +1365,34 @@ glade_gtk_notebook_replace_child (GtkWidget *container,
GtkWidget *page;
GtkWidget *label;
gint page_num;
gchar *special_child_type;
notebook = GTK_NOTEBOOK (container);
/* FIXME: until placeholder has GladeWidget
special_child_type =
g_object_get_data (G_OBJECT (current), "special-child-type"); */
special_child_type = NULL;
if (special_child_type && !strcmp (special_child_type, "tab"))
{
page_num = (gint) g_object_get_data (G_OBJECT (current),
"page-num");
g_object_set_data (G_OBJECT (new), "page-num",
GINT_TO_POINTER (page_num));
g_object_set_data (G_OBJECT (new), "special-child-type",
"tab");
page = gtk_notebook_get_nth_page (notebook, page_num);
gtk_notebook_set_tab_label (notebook, page, new);
return;
}
page_num = gtk_notebook_page_num (notebook, current);
if (page_num == -1) {
if (page_num == -1)
{
g_warning ("GtkNotebookPage not found\n");
return;
}
page = gtk_notebook_get_nth_page (notebook, page_num);
gtk_widget_ref (page);
label = gtk_notebook_get_tab_label (notebook, current);
/* label may be NULL if the label was not set explicitely;
......@@ -1383,7 +1405,6 @@ glade_gtk_notebook_replace_child (GtkWidget *container,
gtk_notebook_remove_page (notebook, page_num);
gtk_notebook_insert_page (notebook, new, label, page_num);
gtk_widget_unref (page);
if (label)
gtk_widget_unref (label);
......@@ -1541,3 +1562,134 @@ glade_gtk_radio_button_set_group (GObject *object, GValue *value)
/* FIXME: now what? */
}
GLADEGTK_API void
glade_gtk_box_add_child (GObject *object, GObject *child)
{
gint num_children;
GladeProperty *prop;
gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child));
num_children = g_list_length (GTK_BOX (object)->children);
prop = glade_widget_get_property (glade_widget_get_from_gobject (object),
"size");
g_value_set_int (prop->value, num_children);
if (GLADE_IS_PLACEHOLDER (child))
return;
prop = glade_widget_get_pack_property (glade_widget_get_from_gobject (child),
"position");
g_value_set_int (prop->value, num_children - 1);
}
GLADEGTK_API void
glade_gtk_notebook_add_child (GObject *object, GObject *child)
{
GtkNotebook *notebook;
guint num_page;
GtkWidget *last_page;
GladeWidget *gwidget;
gchar *special_child_type;
notebook = GTK_NOTEBOOK (object);
num_page = gtk_notebook_get_n_pages (notebook);
/* last_page = gtk_notebook_get_nth_page (notebook, -1);
in glade-2 we never use tab-label, we generate a GtkLabel
and set it as the label widget (and in fact the tab-label internal
is doing more or less the same thing). If the last page has a NULL
label, _child_ is a label widget
if (last_page && !gtk_notebook_get_tab_label (notebook, last_page)) */
/* FIXME: until placeholder has GladeWidget
special_child_type = g_object_get_data (child, "special-child-type"); */
special_child_type = NULL;
if (special_child_type &&
!strcmp (special_child_type, "tab"))
{
last_page = gtk_notebook_get_nth_page (notebook, num_page - 1);
g_object_set_data (child, "page-num",
GINT_TO_POINTER (num_page - 1));
gtk_notebook_set_tab_label (notebook, last_page,
GTK_WIDGET (child));
}
else
{
GladeProperty *prop;
gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child));
prop = glade_widget_get_property (
glade_widget_get_from_gobject (object), "pages");
g_value_set_int (prop->value, num_page + 1);
gwidget = glade_widget_get_from_gobject (child);
if (gwidget)
{
prop = glade_widget_get_pack_property (gwidget,
"position");
g_value_set_int (prop->value, num_page);
}
}
}
GLADEGTK_API void
glade_gtk_button_add_child (GObject *object, GObject *child)
{
GtkWidget *old;
old = GTK_BIN (object)->child;
if (old)
gtk_container_remove (GTK_CONTAINER (object), old);
gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child));
}
GLADEGTK_API void
glade_gtk_image_set_pixbuf (GObject *object, GValue *value)
{
gchar *filename;
GdkPixbuf *pixbuf;
GError *error = NULL;
filename = (gchar*) g_value_get_string (value);
if (filename && strlen (filename))
{
gchar *pathname;
GladeProject *project =
glade_widget_get_project (
glade_widget_get_from_gobject (object));
pathname = g_path_get_dirname (project->path);
filename = g_build_filename (pathname, filename, NULL);
pixbuf = gdk_pixbuf_new_from_file (filename, &error);
g_free (filename);
if (pixbuf)
gtk_image_set_from_pixbuf (GTK_IMAGE (object), pixbuf);
}
}
GLADEGTK_API void
glade_gtk_frame_add_child (GObject *object, GObject *child)
{
gchar *special_child_type;
/* FIXME: until placeholder has GladeWidget
special_child_type = g_object_get_data (child, "special-child-type"); */
special_child_type = NULL;
if (special_child_type &&
!strcmp (special_child_type, "label_item"))
{
gtk_frame_set_label_widget (GTK_FRAME (object),
GTK_WIDGET (child));
}
else
{
gtk_container_add (GTK_CONTAINER (object),
GTK_WIDGET (child));
}
}
......@@ -143,9 +143,7 @@ glade_project_view_populate_model_real (GtkTreeStore *model,
GList *children, *list;
GtkTreeIter iter;
list = g_list_copy (widgets);
list = g_list_reverse (list);
for (; list; list = list->next)
for (list = widgets; list; list = list->next)
{
GladeWidget *widget;
......@@ -169,7 +167,6 @@ glade_project_view_populate_model_real (GtkTreeStore *model,
}
}
}
g_list_free (list);
}
static void
......@@ -483,7 +480,7 @@ glade_project_view_button_press_cb (GtkWidget *widget,
gboolean handled = FALSE;
if (event->window == gtk_tree_view_get_bin_window (tree_view) &&
gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y,
gtk_tree_view_get_path_at_pos (tree_view, (gint) event->x, (gint) event->y,
&path, NULL,
NULL, NULL) && path != NULL)
{
......@@ -600,12 +597,14 @@ glade_project_view_init (GladeProjectView *view)
view->model = gtk_tree_store_new (N_COLUMNS, G_TYPE_POINTER);
glade_project_view_populate_model (view);
#if 0
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (view->model),
0, GTK_SORT_ASCENDING);
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (view->model), 0,
glade_project_view_sort_func,
NULL, NULL);
#endif
view->tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (view->model));
......
......@@ -298,7 +298,7 @@ glade_project_add_object (GladeProject *project, GObject *object)
if ((gwidget = glade_widget_get_from_gobject (object)) == NULL)
return;
if ((children = glade_widget_class_container_get_children
if ((children = glade_widget_class_container_get_all_children
(gwidget->widget_class, gwidget->object)) != NULL)
{
for (list = children; list && list->data; list = list->next)
......@@ -726,14 +726,16 @@ glade_project_write (const GladeProject *project)
}
static GladeProject *
glade_project_new_from_interface (GladeInterface *interface)
glade_project_new_from_interface (GladeInterface *interface, const gchar *path)
{
GladeProject *project;
GladeWidget *widget;
guint i;
project = glade_project_new (FALSE);
project->changed = FALSE;
project->path = g_strdup (path);
g_free (project->name);
project->name = g_path_get_basename (path);
project->selection = NULL;
project->objects = NULL;
......@@ -750,11 +752,15 @@ glade_project_new_from_interface (GladeInterface *interface)
}
glade_project_add_object (project, widget->object);
/* project->objects = g_list_prepend (project->objects, */
/* glade_widget_get_object(widget)); */
/* g_object_ref (glade_widget_get_object(widget)); */
#if 0
project->objects = g_list_prepend (project->objects,
glade_widget_get_object(widget));
g_object_ref (glade_widget_get_object(widget));
#endif
}
project->changed = FALSE;
return project;
}
......@@ -777,18 +783,10 @@ glade_project_open (const gchar *path)
if (!interface)
return NULL;
project = glade_project_new_from_interface (interface);
project = glade_project_new_from_interface (interface, path);
glade_interface_destroy (interface);
if (project)
{
project->path = g_strdup_printf ("%s", path);
g_free (project->name);
project->name = g_path_get_basename (project->path);
project->changed = FALSE;
}
return project;
}
......
......@@ -716,7 +716,7 @@ glade_signal_editor_load_widget (GladeSignalEditor *editor,
}
else
{
gint i;
guint i;
GtkTreePath *path_parent_class;
GladeSignal *widget_signal =
(GladeSignal*) g_ptr_array_index (signals, 0);
......
......@@ -853,9 +853,9 @@ glade_util_container_get_all_children (GtkContainer *container)
g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
gtk_container_foreach (container,
gtk_container_children_callback,
&children);
gtk_container_forall (container,
gtk_container_children_callback,
&children);
return g_list_reverse (children);
}
......
......@@ -249,15 +249,18 @@ glade_widget_class_list_children (GladeWidgetClass *class)
child->type = GTK_TYPE_WIDGET;
child->properties = glade_widget_class_list_child_properties (class);
child->add = (GladeAddChildFunc) gtk_container_add;
child->remove = (GladeRemoveChildFunc) gtk_container_remove;
child->get_children = (GladeGetChildrenFunc) gtk_container_get_children;
child->get_all_children =
(GladeGetChildrenFunc) glade_util_container_get_all_children;
child->set_property =
(GladeChildSetPropertyFunc) gtk_container_child_set_property;
child->get_property =
(GladeChildGetPropertyFunc) gtk_container_child_get_property;
if (class->type == GTK_TYPE_CONTAINER)
{
child->add = (GladeAddChildFunc) gtk_container_add;
child->remove = (GladeRemoveChildFunc) gtk_container_remove;
child->get_children = (GladeGetChildrenFunc) gtk_container_get_children;
child->get_all_children =
(GladeGetChildrenFunc) glade_util_container_get_all_children;
child->set_property =
(GladeChildSetPropertyFunc) gtk_container_child_set_property;
child->get_property =
(GladeChildGetPropertyFunc) gtk_container_child_get_property;
}
children = g_list_append (children, child);
}
......@@ -686,14 +689,13 @@ accum_class_by_type (gchar *name,
}
GList *
glade_widget_class_get_derived_types (GType type)
glade_widget_class_get_derived_types (GType type)
{
GladeClassAccumPair pair = { type, NULL };
if (widget_classes != NULL)
{
g_hash_table_foreach (widget_classes, (GHFunc)accum_class_by_type, &pair);
}
if (widget_classes)
g_hash_table_foreach (widget_classes, (GHFunc) accum_class_by_type, &pair);
return pair.list;
}
......@@ -747,30 +749,26 @@ glade_widget_class_merge_properties (GList **widget_properties, GList *parent_pr
}
static GladeSupportedChild *
glade_widget_class_clone_child (GladeSupportedChild *child)
glade_widget_class_clone_child (GladeSupportedChild *child,
GladeWidgetClass *parent_class)
{
GladeSupportedChild *clone;
GList *props;
clone = g_new0 (GladeSupportedChild, 1);
clone->type = child->type;
clone->add = child->add;
clone->remove = child->remove;
clone->get_children = child->get_children;
clone->get_all_children = child->get_all_children;
clone->set_property = child->set_property;
clone->get_property = child->get_property;
clone->fill_empty = child->fill_empty;
clone->replace_child = child->replace_child;
for (props = child->properties;
props && props->data;
props = props->next)
{
clone->properties =
g_list_prepend (clone->properties,
glade_property_class_clone (props->data));
}
clone->properties = g_list_reverse (clone->properties);
clone->properties = glade_widget_class_list_child_properties (parent_class);
glade_widget_class_merge_properties
(&clone->properties, child->properties);
return clone;
}
......@@ -802,7 +800,8 @@ glade_widget_class_merge_child (GladeSupportedChild *widgets_child,
static void
glade_widget_class_merge_children (GList **widget_children,
GList *parent_children)
GList *parent_children,
GladeWidgetClass *widget_class)
{
GList *list;
GList *list2;
......@@ -827,7 +826,8 @@ glade_widget_class_merge_children (GList **widget_children,
{
*widget_children =
g_list_prepend (*widget_children,
glade_widget_class_clone_child (parents_child));
glade_widget_class_clone_child (parents_child,
widget_class));
}
else
{
......@@ -868,7 +868,7 @@ glade_widget_class_merge (GladeWidgetClass *widget_class,
/* merge the parent's supported children */
glade_widget_class_merge_children
(&widget_class->children, parent_class->children);
(&widget_class->children, parent_class->children, widget_class);
}
/**
......
......@@ -414,22 +414,25 @@ glade_widget_build_object (GladeWidgetClass *klass, GladeWidget *widget)
/* As a slight optimization, we never unref the class
*/
oclass = g_type_class_ref(klass->type);
oclass = g_type_class_ref (klass->type);
pspec = g_object_class_list_properties (oclass, &n_props);
params = g_array_new(FALSE, FALSE, sizeof(GParameter));
params = g_array_new (FALSE, FALSE, sizeof (GParameter));
for (i = 0; i < n_props; i++)
{
GParameter parameter = { 0, };
if (glade_widget_class_get_property_class (klass, pspec[i]->name) == NULL)
glade_property_class =
glade_widget_class_get_property_class (klass,
pspec[i]->name);
if (!glade_property_class)
/* Ignore properties that are not accounted for
* by the GladeWidgetClass
*/
continue;
parameter.name = pspec[i]->name; /* No need to dup this */
g_value_init(&parameter.value, pspec[i]->value_type);
parameter.name = pspec[i]->name; /* No need to dup this */
g_value_init (&parameter.value, pspec[i]->value_type);
/* If a widget is specified and has a value set for that
* property, then that value will be used (otherwise, we
......@@ -437,55 +440,53 @@ glade_widget_build_object (GladeWidgetClass *klass, GladeWidget *widget)
*/
if (widget &&
(glade_property =
glade_widget_get_property(widget, parameter.name)) != NULL)
glade_widget_get_property (widget, parameter.name)) != NULL)
{
if (g_value_type_compatible(G_VALUE_TYPE(glade_property->value),
G_VALUE_TYPE(&parameter.value)))
g_value_copy(glade_property->value, &parameter.value);
if (g_value_type_compatible (G_VALUE_TYPE (glade_property->value),
G_VALUE_TYPE (&parameter.value)))
g_value_copy (glade_property->value, &parameter.value);
else
{
g_critical("Type mismatch on %s property of %s",
parameter.name, klass->name);