[gtk+] GtkFontChooserDialog: Select when a list item is activated



commit 5c09061e0f36f6431eb16f124ee5260da63bfb6c
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Aug 24 00:49:59 2011 -0400

    GtkFontChooserDialog: Select when a list item is activated
    
    This is the expected behavior.

 gtk/gtkfontchooserdialog.c |   22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkfontchooserdialog.c b/gtk/gtkfontchooserdialog.c
index 9d11292..2fac04c 100644
--- a/gtk/gtkfontchooserdialog.c
+++ b/gtk/gtkfontchooserdialog.c
@@ -87,6 +87,16 @@ gtk_font_chooser_dialog_class_init (GtkFontChooserDialogClass *klass)
 }
 
 static void
+font_activated_cb (GtkFontChooser *fontchooser,
+                   const gchar    *fontname,
+                   gpointer        user_data)
+{
+  GtkDialog *dialog = user_data;
+
+  gtk_dialog_response (dialog, GTK_RESPONSE_OK);
+}
+
+static void
 gtk_font_chooser_dialog_init (GtkFontChooserDialog *fontchooserdiag)
 {
   GtkFontChooserDialogPrivate *priv;
@@ -117,6 +127,9 @@ gtk_font_chooser_dialog_init (GtkFontChooserDialog *fontchooserdiag)
   gtk_box_pack_start (GTK_BOX (content_area),
                       priv->fontchooser, TRUE, TRUE, 0);
 
+  g_signal_connect (priv->fontchooser, "font-activated",
+                    G_CALLBACK (font_activated_cb), dialog);
+
   /* Create the action area */
   priv->cancel_button = gtk_dialog_add_button (dialog,
                                                GTK_STOCK_CANCEL,
@@ -127,17 +140,16 @@ gtk_font_chooser_dialog_init (GtkFontChooserDialog *fontchooserdiag)
   gtk_widget_grab_default (priv->select_button);
 
   gtk_dialog_set_alternative_button_order (GTK_DIALOG (fontchooserdiag),
-             GTK_RESPONSE_OK,
-             GTK_RESPONSE_CANCEL,
-             -1);
+                                           GTK_RESPONSE_OK,
+                                           GTK_RESPONSE_CANCEL,
+                                           -1);
 
   gtk_window_set_title (GTK_WINDOW (fontchooserdiag), _("Font Selection"));
 
   gtk_widget_pop_composite_child ();
 }
 
-/**
- * gtk_font_chooser_dialog_new:
+/** gtk_font_chooser_dialog_new:
  * @title: (allow-none): Title of the dialog, or %NULL
  * @parent: (allow-none): Trasient parent of the dialog, or %NULL
  *



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