Drop GtkAssistantPage::has-padding

This is causing us some internal complications, and
it is very easy to just add padding to the pages
yourself.
This commit is contained in:
Matthias Clasen 2019-02-14 14:46:01 -05:00
parent d327d3fab2
commit e5e2bd3187
5 changed files with 14 additions and 112 deletions

View File

@ -233,8 +233,6 @@ gtk_assistant_set_page_title
gtk_assistant_get_page_title
gtk_assistant_set_page_complete
gtk_assistant_get_page_complete
gtk_assistant_set_page_has_padding
gtk_assistant_get_page_has_padding
gtk_assistant_add_action_widget
gtk_assistant_remove_action_widget
gtk_assistant_update_buttons_state

View File

@ -593,6 +593,14 @@
child properties to child meta objects.
</para>
</section>
<section>
<title>Adapt to changes in the GtkAssistant API</title>
<para>
The ::has-padding property is gone, and GtkAssistant no longer adds padding
to pages. You can easily do that yourself.
</para>
</section>
</section>
</chapter>

View File

@ -92,11 +92,9 @@ struct _GtkAssistantPage
GtkAssistantPageType type;
guint complete : 1;
guint complete_set : 1;
guint has_padding : 1;
gchar *title;
GtkWidget *box;
GtkWidget *page;
GtkWidget *regular_title;
GtkWidget *current_title;
@ -217,7 +215,6 @@ static void
gtk_assistant_page_init (GtkAssistantPage *page)
{
page->type = GTK_ASSISTANT_PAGE_CONTENT;
page->has_padding = TRUE;
}
static void
@ -281,13 +278,6 @@ gtk_assistant_page_class_init (GtkAssistantPageClass *class)
P_("Whether all required fields on the page have been filled out"),
FALSE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
g_object_class_install_property (object_class,
CHILD_PROP_HAS_PADDING,
g_param_spec_boolean ("has-padding",
P_("Has padding"),
P_("Whether the assistant adds padding around the page"),
TRUE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
g_object_class_install_property (object_class,
CHILD_PROP_CHILD,
g_param_spec_object ("child",
@ -967,7 +957,7 @@ set_current_page (GtkAssistant *assistant,
gtk_window_set_title (GTK_WINDOW (assistant), priv->current_page->title);
gtk_stack_set_visible_child (GTK_STACK (priv->content), priv->current_page->box);
gtk_stack_set_visible_child (GTK_STACK (priv->content), priv->current_page->page);
/* update buttons state, flow may have changed */
if (gtk_widget_get_mapped (GTK_WIDGET (assistant)))
@ -1280,16 +1270,6 @@ gtk_assistant_page_set_property (GObject *object,
}
break;
case CHILD_PROP_HAS_PADDING:
if (page->has_padding != g_value_get_boolean (value))
{
page->has_padding = g_value_get_boolean (value);
if (page->box)
g_object_set (page->box, "margin", page->has_padding ? 12 : 0, NULL);
g_object_notify (G_OBJECT (page), "has-padding");
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -1322,10 +1302,6 @@ gtk_assistant_page_get_property (GObject *object,
g_value_set_boolean (value, page->complete);
break;
case CHILD_PROP_HAS_PADDING:
g_value_set_boolean (value, page->has_padding);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -1401,7 +1377,7 @@ find_page (GtkAssistant *assistant,
while (child)
{
GtkAssistantPage *page_info = child->data;
if (page_info->page == page || page_info->box == page)
if (page_info->page == page)
return child;
child = child->next;
@ -1500,16 +1476,11 @@ gtk_assistant_remove (GtkContainer *container,
GtkWidget *page)
{
GtkAssistant *assistant = (GtkAssistant*) container;
GtkWidget *box;
/* Forward this removal to the content stack */
box = gtk_widget_get_parent (page);
if (GTK_IS_BOX (box) &&
assistant->priv->content != NULL &&
gtk_widget_get_parent (box) == assistant->priv->content)
if (gtk_widget_get_parent (page) == assistant->priv->content)
{
gtk_container_remove (GTK_CONTAINER (box), page);
gtk_container_remove (GTK_CONTAINER (assistant->priv->content), box);
gtk_container_remove (GTK_CONTAINER (assistant->priv->content), page);
}
else
{
@ -1791,7 +1762,6 @@ gtk_assistant_insert_page (GtkAssistant *assistant,
page_info = g_object_new (GTK_TYPE_ASSISTANT_PAGE, NULL);
page_info->page = g_object_ref (page);
page_info->has_padding = TRUE;
return gtk_assistant_add_page (assistant, page_info, position);
@ -1806,7 +1776,6 @@ gtk_assistant_add_page (GtkAssistant *assistant,
GtkAssistantPrivate *priv = assistant->priv;
gint n_pages;
GtkStyleContext *context;
GtkWidget *box;
GtkWidget *sibling;
char *name;
@ -1854,18 +1823,10 @@ gtk_assistant_add_page (GtkAssistant *assistant,
gtk_box_insert_child_after (GTK_BOX (priv->sidebar), page_info->current_title, sibling);
gtk_box_insert_child_after (GTK_BOX (priv->sidebar), page_info->regular_title, sibling);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_show (box);
gtk_container_add (GTK_CONTAINER (box), page_info->page);
g_object_set (box, "margin", 12, NULL);
g_signal_connect (box, "remove", G_CALLBACK (assistant_remove_page_cb), assistant);
name = g_strdup_printf ("page%d", position);
gtk_stack_add_named (GTK_STACK (priv->content), box, name);
name = g_strdup_printf ("%p", page_info->page);
gtk_stack_add_named (GTK_STACK (priv->content), page_info->page, name);
g_free (name);
page_info->box = box;
if (gtk_widget_get_mapped (GTK_WIDGET (assistant)))
{
update_buttons_state (assistant);
@ -2203,63 +2164,6 @@ gtk_assistant_get_page_complete (GtkAssistant *assistant,
return page_info->complete;
}
/**
* gtk_assistant_set_page_has_padding:
* @assistant: a #GtkAssistant
* @page: a page of @assistant
* @has_padding: whether this page has padding
*
* Sets whether the assistant is adding padding around
* the page.
*/
void
gtk_assistant_set_page_has_padding (GtkAssistant *assistant,
GtkWidget *page,
gboolean has_padding)
{
GtkAssistantPage *page_info;
GList *child;
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
g_return_if_fail (GTK_IS_WIDGET (page));
child = find_page (assistant, page);
g_return_if_fail (child != NULL);
page_info = (GtkAssistantPage*) child->data;
g_object_set (page_info, "has-padding", has_padding, NULL);
}
/**
* gtk_assistant_get_page_has_padding:
* @assistant: a #GtkAssistant
* @page: a page of @assistant
*
* Gets whether page has padding.
*
* Returns: %TRUE if @page has padding
*/
gboolean
gtk_assistant_get_page_has_padding (GtkAssistant *assistant,
GtkWidget *page)
{
GtkAssistantPage *page_info;
GList *child;
g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), FALSE);
g_return_val_if_fail (GTK_IS_WIDGET (page), FALSE);
child = find_page (assistant, page);
g_return_val_if_fail (child != NULL, TRUE);
page_info = (GtkAssistantPage*) child->data;
return page_info->has_padding;
}
/**
* gtk_assistant_update_buttons_state:
* @assistant: a #GtkAssistant

View File

@ -214,13 +214,6 @@ void gtk_assistant_update_buttons_state (GtkAssistant *assista
GDK_AVAILABLE_IN_ALL
void gtk_assistant_commit (GtkAssistant *assistant);
GDK_AVAILABLE_IN_ALL
void gtk_assistant_set_page_has_padding (GtkAssistant *assistant,
GtkWidget *page,
gboolean has_padding);
GDK_AVAILABLE_IN_ALL
gboolean gtk_assistant_get_page_has_padding (GtkAssistant *assistant,
GtkWidget *page);
GDK_AVAILABLE_IN_ALL
GtkAssistantPage * gtk_assistant_get_page (GtkAssistant *assistant,
GtkWidget *child);

View File

@ -570,7 +570,6 @@ create_full_featured_assistant (GtkWidget *widget)
gtk_assistant_append_page (GTK_ASSISTANT (assistant), page);
gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), page, "Filechooser");
gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), page, TRUE);
gtk_assistant_set_page_has_padding (GTK_ASSISTANT (assistant), page, FALSE);
page = get_test_page ("Page 3");
gtk_widget_show (page);