[gimp] Bug 772126 - Make GimpColorFrame handle very long numbers



commit b46b9d8921071b11fd0a2bf66a2003bdb9e42127
Author: Michael Natterer <mitch gimp org>
Date:   Tue Apr 3 01:45:27 2018 +0200

    Bug 772126 - Make GimpColorFrame handle very long numbers
    
    Add "ellipsize" property to GimpColorFrame and set it to
    PANGO_ELLIPSIZE_END in the the pointer information dockable.
    
    Better cut off long numbers than make them expand the dock.

 app/display/gimpcursorview.c |    2 ++
 app/widgets/gimpcolorframe.c |   41 +++++++++++++++++++++++++++++++++++++++--
 app/widgets/gimpcolorframe.h |    5 +++++
 3 files changed, 46 insertions(+), 2 deletions(-)
---
diff --git a/app/display/gimpcursorview.c b/app/display/gimpcursorview.c
index 4b8ccfa..6ec54da 100644
--- a/app/display/gimpcursorview.c
+++ b/app/display/gimpcursorview.c
@@ -320,6 +320,8 @@ gimp_cursor_view_init (GimpCursorView *view)
   view->priv->color_frame_1 = gimp_color_frame_new ();
   gimp_color_frame_set_mode (GIMP_COLOR_FRAME (view->priv->color_frame_1),
                              GIMP_COLOR_FRAME_MODE_PIXEL);
+  gimp_color_frame_set_ellipsize (GIMP_COLOR_FRAME (view->priv->color_frame_1),
+                                  PANGO_ELLIPSIZE_END);
   gtk_box_pack_start (GTK_BOX (view->priv->color_hbox), view->priv->color_frame_1,
                       TRUE, TRUE, 0);
   gtk_widget_show (view->priv->color_frame_1);
diff --git a/app/widgets/gimpcolorframe.c b/app/widgets/gimpcolorframe.c
index ab831ae..07586e7 100644
--- a/app/widgets/gimpcolorframe.c
+++ b/app/widgets/gimpcolorframe.c
@@ -43,7 +43,8 @@ enum
   PROP_HAS_NUMBER,
   PROP_NUMBER,
   PROP_HAS_COLOR_AREA,
-  PROP_HAS_COORDS
+  PROP_HAS_COORDS,
+  PROP_ELLIPSIZE,
 };
 
 
@@ -122,6 +123,13 @@ gimp_color_frame_class_init (GimpColorFrameClass *klass)
                                                          NULL, NULL,
                                                          FALSE,
                                                          GIMP_PARAM_READWRITE));
+
+  g_object_class_install_property (object_class, PROP_ELLIPSIZE,
+                                   g_param_spec_enum ("ellipsize",
+                                                      NULL, NULL,
+                                                      PANGO_TYPE_ELLIPSIZE_MODE,
+                                                      PANGO_ELLIPSIZE_NONE,
+                                                      GIMP_PARAM_READWRITE));
 }
 
 static void
@@ -182,7 +190,7 @@ gimp_color_frame_init (GimpColorFrame *frame)
       gtk_label_set_selectable (GTK_LABEL (frame->value_labels[i]), TRUE);
       gtk_label_set_xalign (GTK_LABEL (frame->value_labels[i]), 1.0);
       gtk_box_pack_end (GTK_BOX (hbox), frame->value_labels[i],
-                        FALSE, FALSE, 0);
+                        TRUE, TRUE, 0);
       gtk_widget_show (frame->value_labels[i]);
     }
 
@@ -249,6 +257,10 @@ gimp_color_frame_get_property (GObject    *object,
       g_value_set_enum (value, frame->frame_mode);
       break;
 
+    case PROP_ELLIPSIZE:
+      g_value_set_enum (value, frame->ellipsize);
+      break;
+
     case PROP_HAS_NUMBER:
       g_value_set_boolean (value, frame->has_number);
       break;
@@ -285,6 +297,10 @@ gimp_color_frame_set_property (GObject      *object,
       gimp_color_frame_set_mode (frame, g_value_get_enum (value));
       break;
 
+    case PROP_ELLIPSIZE:
+      gimp_color_frame_set_ellipsize (frame, g_value_get_enum (value));
+      break;
+
     case PROP_HAS_NUMBER:
       gimp_color_frame_set_has_number (frame, g_value_get_boolean (value));
       break;
@@ -418,6 +434,27 @@ gimp_color_frame_set_mode (GimpColorFrame     *frame,
 }
 
 void
+gimp_color_frame_set_ellipsize (GimpColorFrame     *frame,
+                                PangoEllipsizeMode  ellipsize)
+{
+  gint i;
+
+  g_return_if_fail (GIMP_IS_COLOR_FRAME (frame));
+
+  if (ellipsize != frame->ellipsize)
+    {
+      frame->ellipsize = ellipsize;
+
+      for (i = 0; i < GIMP_COLOR_FRAME_ROWS; i++)
+        {
+          if (frame->value_labels[i])
+            gtk_label_set_ellipsize (GTK_LABEL (frame->value_labels[i]),
+                                     ellipsize);
+        }
+    }
+}
+
+void
 gimp_color_frame_set_has_number (GimpColorFrame *frame,
                                  gboolean        has_number)
 {
diff --git a/app/widgets/gimpcolorframe.h b/app/widgets/gimpcolorframe.h
index 430c054..8b3dc29 100644
--- a/app/widgets/gimpcolorframe.h
+++ b/app/widgets/gimpcolorframe.h
@@ -46,6 +46,8 @@ struct _GimpColorFrame
 
   GimpColorFrameMode  frame_mode;
 
+  PangoEllipsizeMode  ellipsize;
+
   gboolean            has_number;
   gint                number;
 
@@ -80,6 +82,9 @@ GtkWidget * gimp_color_frame_new                (void);
 void        gimp_color_frame_set_mode           (GimpColorFrame     *frame,
                                                  GimpColorFrameMode  mode);
 
+void        gimp_color_frame_set_ellipsize      (GimpColorFrame     *frame,
+                                                 PangoEllipsizeMode  ellipsize);
+
 void        gimp_color_frame_set_has_number     (GimpColorFrame     *frame,
                                                  gboolean            has_number);
 void        gimp_color_frame_set_number         (GimpColorFrame     *frame,


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