[gtk/wip/otte/listview] font chooser: Add back row activation



commit 09cbb5154f3f8e6b0efb393bd5859061399c267b
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jan 5 14:53:27 2019 -0500

    font chooser: Add back row activation
    
    This one is easy and doesn't need any list view features.

 gtk/gtkfontchooserwidget.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
---
diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c
index 98193aa3f2..27949c1072 100644
--- a/gtk/gtkfontchooserwidget.c
+++ b/gtk/gtkfontchooserwidget.c
@@ -787,15 +787,40 @@ bind_row (GtkListItem *list_item,
   pango_attr_list_unref (attrs);
 }
 
+static void
+row_activated_cb (GtkGestureMultiPress *gesture,
+                  int n_press,
+                  double x,
+                  double y,
+                  GtkFontChooserWidget *fontchooser)
+{
+  gchar *fontname;
+
+  if (n_press == 1)
+    return;
+
+  fontname = gtk_font_chooser_widget_get_font (fontchooser);
+  _gtk_font_chooser_font_activated (GTK_FONT_CHOOSER (fontchooser), fontname);
+  g_free (fontname);
+}
+
 static void
 setup_row (GtkListItem *list_item,
            gpointer     data)
 {
+  GtkFontChooserWidget *fontchooser = data;
   GtkWidget *row;
+  GtkEventController *double_click;
 
   row = gtk_label_new ("");
   gtk_label_set_xalign (GTK_LABEL (row), 0.0);
   g_object_set (row, "margin", 10, NULL);
+
+  double_click = gtk_gesture_multi_press_new ();
+  g_signal_connect (double_click, "pressed",
+                    G_CALLBACK (row_activated_cb), fontchooser);
+  gtk_widget_add_controller (row, double_click);
+
   gtk_container_add (GTK_CONTAINER (list_item), row);
 }
 


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