[gnome-commander] Moves get_string_pixel_size() function into utils.cc



commit 8c71476d10564c223c84462eda5749dd12504f9a
Author: Uwe Scholz <uwescholz src gnome org>
Date:   Sun Oct 30 21:04:06 2016 +0100

    Moves get_string_pixel_size() function into utils.cc

 src/gnome-cmd-dir-indicator.cc |   25 -------------------------
 src/utils.cc                   |   25 +++++++++++++++++++++++++
 src/utils.h                    |    2 ++
 3 files changed, 27 insertions(+), 25 deletions(-)
---
diff --git a/src/gnome-cmd-dir-indicator.cc b/src/gnome-cmd-dir-indicator.cc
index e219a36..fa60df9 100644
--- a/src/gnome-cmd-dir-indicator.cc
+++ b/src/gnome-cmd-dir-indicator.cc
@@ -218,31 +218,6 @@ static gint on_dir_indicator_leave (GnomeCmdDirIndicator *indicator, GdkEventMot
 }
 
 
-inline int get_string_pixel_size (const char *s, int len)
-{
-    // find the size, in pixels, of the given string
-    gint xSize, ySize;
-
-    gchar *buf = g_strndup(s, len);
-    gchar *utf8buf = get_utf8 (buf);
-
-    GtkLabel *label = GTK_LABEL (gtk_label_new (utf8buf));
-    gchar *ms = get_mono_text (utf8buf);
-    gtk_label_set_markup (label, ms);
-    g_free (ms);
-    g_object_ref_sink(G_OBJECT(label));
-
-    PangoLayout *layout = gtk_label_get_layout (label);
-    pango_layout_get_pixel_size (layout, &xSize, &ySize);
-
-    g_object_unref(GTK_OBJECT (label));
-    g_free (utf8buf);
-    g_free (buf);
-
-    return xSize;
-}
-
-
 static gboolean on_bookmark_button_clicked (GtkWidget *button, GnomeCmdDirIndicator *indicator)
 {
     if (indicator->priv->bookmark_is_popped)
diff --git a/src/utils.cc b/src/utils.cc
index 0bf5881..835efff 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -1451,3 +1451,28 @@ int split(const string &s, vector<string> &coll, const char *sep)
 
   return n;
 }
+
+
+gint get_string_pixel_size (const char *s, int len)
+{
+    // find the size, in pixels, of the given string
+    gint xSize, ySize;
+
+    gchar *buf = g_strndup(s, len);
+    gchar *utf8buf = get_utf8 (buf);
+
+    GtkLabel *label = GTK_LABEL (gtk_label_new (utf8buf));
+    gchar *ms = get_mono_text (utf8buf);
+    gtk_label_set_markup (label, ms);
+    g_free (ms);
+    g_object_ref_sink(G_OBJECT(label));
+
+    PangoLayout *layout = gtk_label_get_layout (label);
+    pango_layout_get_pixel_size (layout, &xSize, &ySize);
+
+    g_object_unref(GTK_OBJECT (label));
+    g_free (utf8buf);
+    g_free (buf);
+
+    return xSize;
+}
diff --git a/src/utils.h b/src/utils.h
index 3708396..af9415c 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -429,4 +429,6 @@ inline std::string join(const COLL<T, Compare, Allocator> &coll, const std::stri
     return join(s,coll.begin(),coll.end(),sep);
 }
 
+gint get_string_pixel_size (const char *s, int len);
+
 #endif // __UTILS_H__


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