Commit c3a0880c authored by Matthias Clasen's avatar Matthias Clasen

GtkAssistant: Add a way to have pages without padding

This can be useful when embedding complex widgets like
a file chooser as a page.

https://bugzilla.gnome.org/show_bug.cgi?id=750631
parent 43fcae91
......@@ -381,6 +381,8 @@ gtk_assistant_set_page_side_image
gtk_assistant_get_page_side_image
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
......
......@@ -84,6 +84,7 @@ struct _GtkAssistantPage
GtkAssistantPageType type;
guint complete : 1;
guint complete_set : 1;
guint has_padding : 1;
gchar *title;
......@@ -196,7 +197,8 @@ enum
CHILD_PROP_PAGE_TITLE,
CHILD_PROP_PAGE_HEADER_IMAGE,
CHILD_PROP_PAGE_SIDEBAR_IMAGE,
CHILD_PROP_PAGE_COMPLETE
CHILD_PROP_PAGE_COMPLETE,
CHILD_PROP_HAS_PADDING
};
enum
......@@ -622,6 +624,10 @@ gtk_assistant_class_init (GtkAssistantClass *class)
FALSE,
G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_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));
/* Bind class to template
*/
gtk_widget_class_set_template_from_resource (widget_class,
......@@ -1245,6 +1251,10 @@ gtk_assistant_set_child_property (GtkContainer *container,
gtk_assistant_set_page_complete (GTK_ASSISTANT (container), child,
g_value_get_boolean (value));
break;
case CHILD_PROP_HAS_PADDING:
gtk_assistant_set_page_has_padding (GTK_ASSISTANT (container), child,
g_value_get_boolean (value));
break;
default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
......@@ -1286,6 +1296,10 @@ G_GNUC_END_IGNORE_DEPRECATIONS
g_value_set_boolean (value,
gtk_assistant_get_page_complete (assistant, child));
break;
case CHILD_PROP_HAS_PADDING:
g_value_set_boolean (value,
gtk_assistant_get_page_has_padding (assistant, child));
break;
default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
......@@ -1766,6 +1780,7 @@ gtk_assistant_insert_page (GtkAssistant *assistant,
page_info = g_slice_new0 (GtkAssistantPage);
page_info->page = page;
page_info->regular_title = gtk_label_new (NULL);
page_info->has_padding = TRUE;
gtk_widget_set_no_show_all (page_info->regular_title, TRUE);
page_info->current_title = gtk_label_new (NULL);
gtk_widget_set_no_show_all (page_info->current_title, TRUE);
......@@ -2369,6 +2384,75 @@ 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.
*
* Since: 3.18
*/
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;
if (page_info->has_padding != has_padding)
{
page_info->has_padding = has_padding;
g_object_set (gtk_widget_get_parent (page),
"margin", has_padding ? 12 : 0,
NULL);
gtk_container_child_notify (GTK_CONTAINER (assistant), page, "has-padding");
}
}
/**
* 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
* Since: 3.18
*/
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
......
......@@ -217,6 +217,14 @@ void gtk_assistant_update_buttons_state (GtkAssistant *assista
GDK_AVAILABLE_IN_ALL
void gtk_assistant_commit (GtkAssistant *assistant);
GDK_AVAILABLE_IN_3_18
void gtk_assistant_set_page_has_padding (GtkAssistant *assistant,
GtkWidget *page,
gboolean has_padding);
GDK_AVAILABLE_IN_3_18
gboolean gtk_assistant_get_page_has_padding (GtkAssistant *assistant,
GtkWidget *page);
G_END_DECLS
#endif /* __GTK_ASSISTANT_H__ */
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