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.
This commit is contained in:
Javier Jardón 2009-09-23 16:53:55 +02:00
parent 39c1da4d01
commit 127033f83d
3 changed files with 46 additions and 0 deletions

View File

@ -1126,6 +1126,7 @@ gtk_dialog_add_buttons G_GNUC_NULL_TERMINATED
gtk_dialog_get_action_area
gtk_dialog_get_content_area
gtk_dialog_get_has_separator
gtk_dialog_get_widget_for_response
gtk_dialog_get_response_for_widget
gtk_dialog_get_type G_GNUC_CONST
gtk_dialog_new

View File

@ -1120,6 +1120,49 @@ _gtk_dialog_set_ignore_separator (GtkDialog *dialog,
priv->ignore_separator = ignore_separator;
}
/**
* 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

View File

@ -148,6 +148,8 @@ void gtk_dialog_set_response_sensitive (GtkDialog *dialog,
gboolean setting);
void gtk_dialog_set_default_response (GtkDialog *dialog,
gint response_id);
GtkWidget* gtk_dialog_get_widget_for_response (GtkDialog *dialog,
gint response_id);
gint gtk_dialog_get_response_for_widget (GtkDialog *dialog,
GtkWidget *widget);