Commit 787439b8 authored by Juan Pablo Ugarte's avatar Juan Pablo Ugarte
Browse files

Updated GtkAssistant support

Fixed bug #664276 "Can't add widgets to a GtkAssistant"
Make assistant update current page when a child is selected in the project.
parent f9c63cfc
......@@ -7923,7 +7923,6 @@ glade_gtk_assistant_update_page_type (GtkAssistant * assistant)
{
page = gtk_assistant_get_nth_page (assistant, i);
gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONTENT);
}
/* Now we have set page-type in every page, force button update */
......@@ -7931,8 +7930,6 @@ glade_gtk_assistant_update_page_type (GtkAssistant * assistant)
{
page = gtk_assistant_get_nth_page (assistant, i);
gtk_assistant_set_page_complete (assistant, page, TRUE);
gtk_assistant_set_current_page (assistant, i);
gtk_assistant_update_buttons_state (assistant);
}
if (current >= 0)
......@@ -7982,6 +7979,48 @@ glade_gtk_assistant_parse_finished (GladeProject * project, GObject * object)
}
}
GList *
glade_gtk_assistant_get_children (GladeWidgetAdaptor *adaptor,
GObject *container)
{
GtkAssistant *assist = GTK_ASSISTANT (container);
gint i, n_pages = gtk_assistant_get_n_pages (assist);
GList *children = NULL, *parent_children;
/* Chain up */
if (GWA_GET_CLASS (GTK_TYPE_WINDOW)->get_children)
parent_children = GWA_GET_CLASS (GTK_TYPE_WINDOW)->get_children (adaptor, container);
else
parent_children = NULL;
for (i = 0; i < n_pages; i++)
children = g_list_prepend (children, gtk_assistant_get_nth_page (assist, i));
children = g_list_reverse (children);
return glade_util_purify_list (g_list_concat (children, parent_children));
}
static void
on_assistant_project_selection_changed (GladeProject *project,
GladeWidget *gassist)
{
GList *selection = glade_project_selection_get (project);
if (selection && g_list_next (selection) == NULL)
{
GladeWidget *selected = glade_widget_get_from_gobject (selection->data);
GtkAssistant *assist = GTK_ASSISTANT (glade_widget_get_object (gassist));
gint pos;
if (!selected) return;
if (glade_widget_get_parent (selected) == gassist &&
glade_widget_property_get (selected, "position", &pos, NULL))
gtk_assistant_set_current_page (assist, pos);
}
}
void
glade_gtk_assistant_post_create (GladeWidgetAdaptor * adaptor,
GObject * object, GladeCreateReason reason)
......@@ -7994,10 +8033,8 @@ glade_gtk_assistant_post_create (GladeWidgetAdaptor * adaptor,
g_signal_connect (project, "parse-finished",
G_CALLBACK (glade_gtk_assistant_parse_finished),
object);
return;
}
if (reason == GLADE_CREATE_USER)
else if (reason == GLADE_CREATE_USER)
{
glade_gtk_assistant_append_new_page (parent, project,
_("Introduction page"),
......@@ -8015,6 +8052,10 @@ glade_gtk_assistant_post_create (GladeWidgetAdaptor * adaptor,
glade_widget_property_set (parent, "n-pages", 3);
}
g_signal_connect (project, "selection-changed",
G_CALLBACK (on_assistant_project_selection_changed),
parent);
}
void
......@@ -8027,15 +8068,31 @@ glade_gtk_assistant_add_child (GladeWidgetAdaptor * adaptor,
gtk_assistant_append_page (assistant, widget);
}
static void
assistant_remove_child (GtkAssistant *assistant, GtkWidget *child)
{
gint i, n = gtk_assistant_get_n_pages (assistant);
for (i = 0; i < n; i++)
{
if (child == gtk_assistant_get_nth_page (assistant, i))
{
gtk_assistant_remove_page (assistant, i);
return;
}
}
}
void
glade_gtk_assistant_remove_child (GladeWidgetAdaptor * adaptor,
GObject * container, GObject * child)
{
GtkAssistant *assistant = GTK_ASSISTANT (container);
GladeWidget *gassistant = glade_widget_get_from_gobject (container);
GtkAssistant *assistant = GTK_ASSISTANT (container);
assistant_remove_child (assistant, GTK_WIDGET (child));
gtk_container_remove (GTK_CONTAINER (container), GTK_WIDGET (child));
glade_widget_property_set (gassistant, "n-pages",
glade_widget_property_set (gassistant, "n-pages",
gtk_assistant_get_n_pages (assistant));
}
......@@ -8049,7 +8106,7 @@ glade_gtk_assistant_replace_child (GladeWidgetAdaptor * adaptor,
gint pos = glade_gtk_assistant_get_page (assistant, old_page);
gboolean set_current = gtk_assistant_get_current_page (assistant) == pos;
gtk_container_remove (GTK_CONTAINER (container), old_page);
assistant_remove_child (assistant, old_page);
gtk_assistant_insert_page (assistant, page, pos);
glade_gtk_assistant_update_page_type (assistant);
......@@ -8090,7 +8147,10 @@ glade_gtk_assistant_set_property (GladeWidgetAdaptor * adaptor,
for (i = gtk_assistant_get_n_pages (GTK_ASSISTANT (object)),
size = g_value_get_int (value); i < size; i++)
{
g_message ("aaaa %d %d", i,size);
gtk_assistant_append_page (assistant, glade_placeholder_new ());
}
glade_gtk_assistant_update_page_type (assistant);
......@@ -8141,7 +8201,7 @@ glade_gtk_assistant_set_child_property (GladeWidgetAdaptor * adaptor,
glade_gtk_assistant_get_page (assistant, widget);
g_object_ref (child);
gtk_container_remove (GTK_CONTAINER (container), widget);
assistant_remove_child (assistant, widget);
gtk_assistant_insert_page (assistant, widget, pos);
g_object_unref (child);
......
......@@ -2002,11 +2002,15 @@ embedded in another object</_tooltip>
<verify-function>glade_gtk_assistant_verify_property</verify-function>
<child-set-property-function>glade_gtk_assistant_set_child_property</child-set-property-function>
<child-get-property-function>glade_gtk_assistant_get_child_property</child-get-property-function>
<get-children-function>glade_gtk_assistant_get_children</get-children-function>
<internal-children>
<object name="action_area"/>
</internal-children>
<properties>
<property save="False" id="n-pages" _name="Number of Pages">
<parameter-spec>
<type>GParamInt</type>
<min>1</min>
<min>0</min>
</parameter-spec>
<_tooltip>Number of pages in this assistant</_tooltip>
</property>
......
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