diff options
author | Javier Jardón <javierjc1982@gmail.com> | 2009-09-23 16:53:55 +0200 |
---|---|---|
committer | Javier Jardón <javierjc1982@gmail.com> | 2009-10-12 17:20:02 +0200 |
commit | 127033f83d309612bc3a386e2519c4d93ff882c1 (patch) | |
tree | 63af4bff4cfa8f04e995f370c60ef88a18ee4501 /gtk/gtkdialog.c | |
parent | 39c1da4d0106ea5c63f4b38836aa65881f9dc0e1 (diff) | |
download | gtk+-127033f83d309612bc3a386e2519c4d93ff882c1.tar.gz |
Bug 596019 - No accessors for GtkDialog buttons
Add API for GtkDialog to return widgets by response ID.
Added gtk_dialog_get_widget_for_response() to access to all kinds
of buttons with all kinds of responses.
Diffstat (limited to 'gtk/gtkdialog.c')
-rw-r--r-- | gtk/gtkdialog.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c index d463306844..eb25f5224b 100644 --- a/gtk/gtkdialog.c +++ b/gtk/gtkdialog.c @@ -1121,6 +1121,49 @@ _gtk_dialog_set_ignore_separator (GtkDialog *dialog, } /** + * gtk_dialog_get_widget_for_response: + * @dialog: a #GtkDialog + * @response_id: the response ID used by the @dialog widget + * + * Gets the widget button that uses the given response ID in the action area + * of a dialog. + * + * Returns: the @widget button that uses the given @response_id, or %NULL. + * + * Since: 2.20 + */ +GtkWidget* +gtk_dialog_get_widget_for_response (GtkDialog *dialog, + gint response_id) +{ + GList *children; + GList *tmp_list; + + g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL); + + children = gtk_container_get_children (GTK_CONTAINER (dialog->action_area)); + + tmp_list = children; + while (tmp_list != NULL) + { + GtkWidget *widget = tmp_list->data; + ResponseData *rd = get_response_data (widget, FALSE); + + if (rd && rd->response_id == response_id) + { + g_list_free (children); + return widget; + } + + tmp_list = g_list_next (tmp_list); + } + + g_list_free (children); + + return NULL; +} + +/** * gtk_dialog_get_response_for_widget: * @dialog: a #GtkDialog * @widget: a widget in the action area of @dialog |