[gtk+/gtk-2.90] Bug 596019 - No accessors for GtkDialog buttons



commit 88c417f2db317b40fcb8d2ef9eb3fbb332cc0e9a
Author: Javier Jardón <javierjc1982 gmail com>
Date:   Wed Sep 23 16:53:55 2009 +0200

    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.

 gtk/gtk.symbols |    1 +
 gtk/gtkdialog.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 gtk/gtkdialog.h |    2 ++
 3 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 4fc9ca8..a6ac397 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -905,6 +905,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
diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c
index d463306..eb25f52 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
diff --git a/gtk/gtkdialog.h b/gtk/gtkdialog.h
index 69d2c00..18a1896 100644
--- a/gtk/gtkdialog.h
+++ b/gtk/gtkdialog.h
@@ -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);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]