gtk+ r19727 - in trunk: . gtk
- From: federico svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk+ r19727 - in trunk: . gtk
- Date: Fri, 7 Mar 2008 03:53:58 +0000 (GMT)
Author: federico
Date: Fri Mar 7 03:53:58 2008
New Revision: 19727
URL: http://svn.gnome.org/viewvc/gtk+?rev=19727&view=rev
Log:
bgo505857 - GtkFileChooserDialog ensures its default response
Signed-off-by: Federico Mena Quintero <federico gnu org>
Modified:
trunk/ChangeLog
trunk/gtk/gtkfilechooserdialog.c
Modified: trunk/gtk/gtkfilechooserdialog.c
==============================================================================
--- trunk/gtk/gtkfilechooserdialog.c (original)
+++ trunk/gtk/gtkfilechooserdialog.c Fri Mar 7 03:53:58 2008
@@ -112,6 +112,15 @@
G_OBJECT_CLASS (gtk_file_chooser_dialog_parent_class)->finalize (object);
}
+static gboolean
+is_stock_accept_response_id (int response_id)
+{
+ return (response_id == GTK_RESPONSE_ACCEPT
+ || response_id == GTK_RESPONSE_OK
+ || response_id == GTK_RESPONSE_YES
+ || response_id == GTK_RESPONSE_APPLY);
+}
+
/* Callback used when the user activates a file in the file chooser widget */
static void
file_chooser_widget_file_activated (GtkFileChooser *chooser,
@@ -135,10 +144,7 @@
widget = GTK_WIDGET (l->data);
response_id = gtk_dialog_get_response_for_widget (GTK_DIALOG (dialog), widget);
- if (response_id == GTK_RESPONSE_ACCEPT
- || response_id == GTK_RESPONSE_OK
- || response_id == GTK_RESPONSE_YES
- || response_id == GTK_RESPONSE_APPLY)
+ if (is_stock_accept_response_id (response_id))
{
gtk_widget_activate (widget); /* Should we gtk_dialog_response (dialog, response_id) instead? */
break;
@@ -244,10 +250,7 @@
widget = GTK_WIDGET (l->data);
response_id = gtk_dialog_get_response_for_widget (GTK_DIALOG (dialog), widget);
- if (response_id == GTK_RESPONSE_ACCEPT
- || response_id == GTK_RESPONSE_OK
- || response_id == GTK_RESPONSE_YES
- || response_id == GTK_RESPONSE_APPLY)
+ if (is_stock_accept_response_id (response_id))
{
dialog->priv->response_requested = TRUE;
gtk_widget_activate (widget); /* Should we gtk_dialog_response (dialog, response_id) instead? */
@@ -383,6 +386,26 @@
}
#endif
+static void
+foreach_ensure_default_response_cb (GtkWidget *widget,
+ gpointer data)
+{
+ GtkFileChooserDialog *dialog = GTK_FILE_CHOOSER_DIALOG (data);
+ int response_id;
+
+ response_id = gtk_dialog_get_response_for_widget (GTK_DIALOG (dialog), widget);
+ if (is_stock_accept_response_id (response_id))
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), response_id);
+}
+
+static void
+ensure_default_response (GtkFileChooserDialog *dialog)
+{
+ gtk_container_foreach (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area),
+ foreach_ensure_default_response_cb,
+ dialog);
+}
+
/* GtkWidget::map handler */
static void
gtk_file_chooser_dialog_map (GtkWidget *widget)
@@ -390,6 +413,8 @@
GtkFileChooserDialog *dialog = GTK_FILE_CHOOSER_DIALOG (widget);
GtkFileChooserDialogPrivate *priv = GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE (dialog);
+ ensure_default_response (dialog);
+
if (!GTK_WIDGET_MAPPED (priv->widget))
gtk_widget_map (priv->widget);
@@ -427,12 +452,9 @@
priv = GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE (dialog);
/* Act only on response IDs we recognize */
- if ((response_id == GTK_RESPONSE_ACCEPT ||
- response_id == GTK_RESPONSE_OK ||
- response_id == GTK_RESPONSE_YES ||
- response_id == GTK_RESPONSE_APPLY) &&
- !priv->response_requested &&
- !_gtk_file_chooser_embed_should_respond (GTK_FILE_CHOOSER_EMBED (priv->widget)))
+ if (is_stock_accept_response_id (response_id)
+ && !priv->response_requested
+ && !_gtk_file_chooser_embed_should_respond (GTK_FILE_CHOOSER_EMBED (priv->widget)))
{
g_signal_stop_emission_by_name (dialog, "response");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]