[gtk+] GtkFontChooser: Add callbacks and improve test to take deprecated widgets into account



commit 4b92872a970908b3adf112ca61133a3d0bd82262
Author: Alberto Ruiz <aruiz gnome org>
Date:   Fri Apr 29 12:14:30 2011 +0100

    GtkFontChooser: Add callbacks and improve test to take deprecated widgets into account

 gtk/gtkfontchooser.c      |   28 ++++++++++++++++++++++++++--
 tests/testfontselection.c |   28 ++++++++++++++++------------
 2 files changed, 42 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkfontchooser.c b/gtk/gtkfontchooser.c
index b9a2289..b6af8be 100644
--- a/gtk/gtkfontchooser.c
+++ b/gtk/gtkfontchooser.c
@@ -900,7 +900,6 @@ gtk_font_selection_bootstrap_fontlist (GtkFontSelection* fontsel)
                                                   "markup", PREVIEW_TEXT_COLUMN,
                                                   NULL);
                                                   
-
   g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
 
   gtk_tree_view_append_column (treeview, col);
@@ -926,7 +925,6 @@ gtk_font_selection_finalize (GObject *object)
     }
 #endif
 
-
   G_OBJECT_CLASS (gtk_font_selection_parent_class)->finalize (object);
 }
 
@@ -1034,6 +1032,23 @@ update_face_model (GtkFontSelection *fontsel)
 }
 
 static void
+size_list_cursor_changed_cb (GtkTreeView *treeview, gpointer data)
+{
+
+}
+
+static void
+family_list_cursor_changed_cb (GtkTreeView *treeview, gpointer data)
+{
+
+}
+
+face_list_cursor_changed_cb (GtkTreeView *treeview, gpointer data)
+{
+
+}
+
+static void
 initialize_deprecated_widgets (GtkFontSelection *fontsel)
 {
   GtkTreeViewColumn       *col;
@@ -1083,6 +1098,15 @@ initialize_deprecated_widgets (GtkFontSelection *fontsel)
   gtk_container_add (GTK_CONTAINER (priv->face_list), face_list);
   gtk_container_add (GTK_CONTAINER (priv->size_list), size_list);
 
+  g_signal_connect (G_OBJECT (font_list), "cursor-changed",
+                    G_CALLBACK (family_list_cursor_changed_cb), fontsel);
+
+  g_signal_connect (G_OBJECT (face_list), "cursor-changed",
+                    G_CALLBACK (face_list_cursor_changed_cb), fontsel);
+
+  g_signal_connect (G_OBJECT (size_list), "cursor-changed",
+                    G_CALLBACK (size_list_cursor_changed_cb), fontsel);
+
   populate_font_model (fontsel);
   cursor_changed_cb (priv->family_face_list, priv);
 }
diff --git a/tests/testfontselection.c b/tests/testfontselection.c
index 42efdc1..5606a9c 100644
--- a/tests/testfontselection.c
+++ b/tests/testfontselection.c
@@ -26,28 +26,32 @@ int
 main (int argc, char *argv[])
 {
   GtkWidget *window;
-  GtkWidget *vbox;
-  GtkWidget *dialog;
+  GtkWidget *hbox;
   GtkWidget *fontsel;
   
   gtk_init (NULL, NULL);
     
-  dialog = gtk_font_selection_dialog_new (NULL);
+  fontsel = gtk_font_selection_new ();
 
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-  gtk_widget_set_size_request (window, 300, 300);
-  vbox = gtk_vbox_new (TRUE, 6);
-  gtk_container_add (GTK_CONTAINER (window), vbox);
+  gtk_widget_set_size_request (window, 600, 600);
+  hbox = gtk_hbox_new (FALSE, 6);
+  gtk_container_add (GTK_CONTAINER (window), hbox);
 
-  fontsel = gtk_font_selection_dialog_get_font_selection (GTK_FONT_SELECTION_DIALOG (dialog));
-  gtk_container_add (GTK_CONTAINER (vbox), gtk_font_selection_get_size_list (GTK_FONT_SELECTION (fontsel)));
-  gtk_container_add (GTK_CONTAINER (vbox), gtk_font_selection_get_family_list (GTK_FONT_SELECTION (fontsel)));
-  gtk_container_add (GTK_CONTAINER (vbox), gtk_font_selection_get_face_list (GTK_FONT_SELECTION (fontsel)));
+  g_object_ref (gtk_font_selection_get_size_list (GTK_FONT_SELECTION (fontsel)));
+  g_object_ref (gtk_font_selection_get_family_list (GTK_FONT_SELECTION (fontsel)));
+  g_object_ref (gtk_font_selection_get_face_list (GTK_FONT_SELECTION (fontsel)));
+
+  gtk_container_add (GTK_CONTAINER (hbox), gtk_font_selection_get_size_list (GTK_FONT_SELECTION (fontsel)));
+  gtk_container_add (GTK_CONTAINER (hbox), gtk_font_selection_get_family_list (GTK_FONT_SELECTION (fontsel)));
+  gtk_container_add (GTK_CONTAINER (hbox), gtk_font_selection_get_face_list (GTK_FONT_SELECTION (fontsel)));
+  gtk_container_add (GTK_CONTAINER (hbox), fontsel);
 
   gtk_widget_show_all (window);
 
-  gtk_dialog_run (GTK_DIALOG (dialog));
+  gtk_main ();
+
+  gtk_widget_destroy (window);
 
-  gtk_widget_destroy (dialog);
   return 0;
 }



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