[nautilus] Conditionally depend on Pango 1.44.4



commit a9cd85a7bc045ae4b4661f0e6f9ece362a26c0c3
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Wed Nov 27 14:08:27 2019 +0000

    Conditionally depend on Pango 1.44.4
    
    We're using newly introduced Pango API, but we're not doing a version
    check on it. One option is to force a Pango ≥ 1.44.4 dependency; another
    is to do a compile time check and only use the new API if we're building
    against a new enough Pango.

 src/nautilus-canvas-item.c       | 14 +++++++++-----
 src/nautilus-view-icon-item-ui.c | 16 ++++++++++------
 2 files changed, 19 insertions(+), 11 deletions(-)
---
diff --git a/src/nautilus-canvas-item.c b/src/nautilus-canvas-item.c
index 4d33d119b..5b5d3312f 100644
--- a/src/nautilus-canvas-item.c
+++ b/src/nautilus-canvas-item.c
@@ -1381,14 +1381,12 @@ create_label_layout (NautilusCanvasItem *item,
     GString *str;
     char *zeroified_text;
     const char *p;
-    PangoAttrList *attr_list;
 
     canvas_item = EEL_CANVAS_ITEM (item);
 
     container = NAUTILUS_CANVAS_CONTAINER (canvas_item->canvas);
     context = gtk_widget_get_pango_context (GTK_WIDGET (canvas_item->canvas));
     layout = pango_layout_new (context);
-    attr_list = pango_attr_list_new ();
 
     zeroified_text = NULL;
 
@@ -1417,8 +1415,15 @@ create_label_layout (NautilusCanvasItem *item,
     pango_layout_set_spacing (layout, LABEL_LINE_SPACING);
     pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR);
 
-    pango_attr_list_insert (attr_list, pango_attr_insert_hyphens_new (FALSE));
-    pango_layout_set_attributes (layout, attr_list);
+#if PANGO_VERSION_CHECK (1, 44, 4)
+    {
+        PangoAttrList *attr_list = pango_attr_list_new ();
+
+        pango_attr_list_insert (attr_list, pango_attr_insert_hyphens_new (FALSE));
+        pango_layout_set_attributes (layout, attr_list);
+        pango_attr_list_unref (attr_list);
+    }
+#endif
 
     /* Create a font description */
     if (container->details->font)
@@ -1432,7 +1437,6 @@ create_label_layout (NautilusCanvasItem *item,
     pango_layout_set_font_description (layout, desc);
     pango_font_description_free (desc);
     g_free (zeroified_text);
-    pango_attr_list_unref (attr_list);
 
     return layout;
 }
diff --git a/src/nautilus-view-icon-item-ui.c b/src/nautilus-view-icon-item-ui.c
index d192e28fa..837dc54a9 100644
--- a/src/nautilus-view-icon-item-ui.c
+++ b/src/nautilus-view-icon-item-ui.c
@@ -128,7 +128,6 @@ constructed (GObject *object)
     GtkBox *container;
     GtkBox *item_selection_background;
     GtkLabel *label;
-    PangoAttrList *attr_list;
     GtkStyleContext *style_context;
     NautilusFile *file;
     guint icon_size;
@@ -150,9 +149,16 @@ constructed (GObject *object)
 
     label = GTK_LABEL (gtk_label_new (nautilus_file_get_display_name (file)));
     gtk_widget_show (GTK_WIDGET (label));
-    attr_list = pango_attr_list_new ();
-    pango_attr_list_insert (attr_list, pango_attr_insert_hyphens_new (FALSE));
-    gtk_label_set_attributes (label, attr_list);
+
+#if PANGO_VERSION_CHECK (1, 44, 4)
+    {
+        PangoAttrList *attr_list = pango_attr_list_new ();
+        pango_attr_list_insert (attr_list, pango_attr_insert_hyphens_new (FALSE));
+        gtk_label_set_attributes (label, attr_list);
+        pango_attr_list_unref (attr_list);
+    }
+#endif
+
     gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_MIDDLE);
     gtk_label_set_line_wrap (label, TRUE);
     gtk_label_set_line_wrap_mode (label, PANGO_WRAP_WORD_CHAR);
@@ -182,8 +188,6 @@ constructed (GObject *object)
                       (GCallback) on_view_item_size_changed, self);
     g_signal_connect (self->model, "notify::file",
                       (GCallback) on_view_item_file_changed, self);
-
-    pango_attr_list_unref (attr_list);
 }
 
 static void


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