GtkDialog: Be more careful in handling the headerbar

Just because an action widget has a parent thats a headerbar,
it is not guaranteed that it is 'our' headerbar. Add some
assertions to enforce this.
This commit is contained in:
Matthias Clasen 2014-07-17 12:53:54 -04:00
parent 7b40714541
commit 24e707315f

View File

@ -356,6 +356,8 @@ apply_response_for_header_bar (GtkDialog *dialog,
GtkDialogPrivate *priv = dialog->priv; GtkDialogPrivate *priv = dialog->priv;
GtkPackType pack; GtkPackType pack;
g_assert (gtk_widget_get_parent (child) == priv->headerbar);
if (response_id == GTK_RESPONSE_CANCEL || response_id == GTK_RESPONSE_HELP) if (response_id == GTK_RESPONSE_CANCEL || response_id == GTK_RESPONSE_HELP)
pack = GTK_PACK_START; pack = GTK_PACK_START;
else else
@ -390,6 +392,8 @@ apply_response_for_action_area (GtkDialog *dialog,
{ {
GtkDialogPrivate *priv = dialog->priv; GtkDialogPrivate *priv = dialog->priv;
g_assert (gtk_widget_get_parent (child) == priv->action_area);
if (response_id == GTK_RESPONSE_HELP) if (response_id == GTK_RESPONSE_HELP)
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (priv->action_area), child, TRUE); gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (priv->action_area), child, TRUE);
} }
@ -1786,6 +1790,7 @@ gtk_dialog_buildable_custom_finished (GtkBuildable *buildable,
gpointer user_data) gpointer user_data)
{ {
GtkDialog *dialog = GTK_DIALOG (buildable); GtkDialog *dialog = GTK_DIALOG (buildable);
GtkDialogPrivate *priv = dialog->priv;
GSList *l; GSList *l;
ActionWidgetsSubParserData *parser_data; ActionWidgetsSubParserData *parser_data;
GObject *object; GObject *object;
@ -1843,9 +1848,9 @@ gtk_dialog_buildable_custom_finished (GtkBuildable *buildable,
if (is_action) if (is_action)
{ {
if (GTK_IS_HEADER_BAR (gtk_widget_get_parent (GTK_WIDGET (object)))) if (gtk_widget_get_parent (GTK_WIDGET (object)) == priv->headerbar)
apply_response_for_header_bar (dialog, GTK_WIDGET (object), ad->response_id); apply_response_for_header_bar (dialog, GTK_WIDGET (object), ad->response_id);
else else if (gtk_widget_get_parent (GTK_WIDGET (object)) == priv->action_area)
apply_response_for_action_area (dialog, GTK_WIDGET (object), ad->response_id); apply_response_for_action_area (dialog, GTK_WIDGET (object), ad->response_id);
} }