gimp r27578 - in trunk: . app/widgets
- From: martinn svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r27578 - in trunk: . app/widgets
- Date: Sun, 9 Nov 2008 14:02:39 +0000 (UTC)
Author: martinn
Date: Sun Nov 9 14:02:38 2008
New Revision: 27578
URL: http://svn.gnome.org/viewvc/gimp?rev=27578&view=rev
Log:
* app/widgets/gimpcursorview.[ch]: Don't expose implementation
details, introduce internal helper functions, and make coordinates
outside the image be represented with an italic font instead of
enclosed in parenthesis.
Modified:
trunk/ChangeLog
trunk/app/widgets/gimpcursorview.c
trunk/app/widgets/gimpcursorview.h
Modified: trunk/app/widgets/gimpcursorview.c
==============================================================================
--- trunk/app/widgets/gimpcursorview.c (original)
+++ trunk/app/widgets/gimpcursorview.c Sun Nov 9 14:02:38 2008
@@ -41,6 +41,7 @@
#include "gimpcolorframe.h"
#include "gimpcursorview.h"
#include "gimpdocked.h"
+#include "gimpeditor.h"
#include "gimpmenufactory.h"
#include "gimpsessioninfo-aux.h"
@@ -54,6 +55,29 @@
};
+struct _GimpCursorView
+{
+ GimpEditor parent_instance;
+
+ GtkWidget *coord_hbox;
+ GtkWidget *color_hbox;
+
+ GtkWidget *pixel_x_label;
+ GtkWidget *pixel_y_label;
+ GtkWidget *unit_x_label;
+ GtkWidget *unit_y_label;
+ GtkWidget *color_frame_1;
+ GtkWidget *color_frame_2;
+
+ gboolean sample_merged;
+};
+
+struct _GimpCursorViewClass
+{
+ GimpEditorClass parent_class;
+};
+
+
static void gimp_cursor_view_docked_iface_init (GimpDockedInterface *iface);
static void gimp_cursor_view_set_property (GObject *object,
@@ -72,6 +96,15 @@
GList *aux_info);
static GList *gimp_cursor_view_get_aux_info (GimpDocked *docked);
+static void gimp_cursor_view_format_as_unit (GimpUnit unit,
+ Gimp *gimp,
+ gchar *output_buf,
+ gint output_buf_size,
+ gdouble pixel_value,
+ gdouble image_res);
+static void gimp_cursor_view_set_label_italic (GtkWidget *label,
+ gboolean italic);
+
G_DEFINE_TYPE_WITH_CODE (GimpCursorView, gimp_cursor_view, GIMP_TYPE_EDITOR,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_DOCKED,
@@ -312,6 +345,39 @@
}
static void
+gimp_cursor_view_format_as_unit (GimpUnit unit,
+ Gimp *gimp,
+ gchar *output_buf,
+ gint output_buf_size,
+ gdouble pixel_value,
+ gdouble image_res)
+{
+ gchar format_buf[32];
+ gdouble unit_factor;
+ gint unit_digits;
+ const gchar *unit_str;
+
+ unit_factor = _gimp_unit_get_factor (gimp, unit);
+ unit_digits = _gimp_unit_get_digits (gimp, unit);
+ unit_str = _gimp_unit_get_abbreviation (gimp, unit);
+
+ g_snprintf (format_buf, sizeof (format_buf), "%%.%df %s", unit_digits, unit_str);
+
+ g_snprintf (output_buf, output_buf_size, format_buf, pixel_value * unit_factor / image_res);
+}
+
+static void
+gimp_cursor_view_set_label_italic (GtkWidget *label,
+ gboolean italic)
+{
+ PangoAttrType attribute = italic ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL;
+
+ gimp_label_set_attributes (GTK_LABEL (label),
+ PANGO_ATTR_STYLE, attribute,
+ -1);
+}
+
+static void
gimp_cursor_view_style_set (GtkWidget *widget,
GtkStyle *prev_style)
{
@@ -375,10 +441,6 @@
gdouble y)
{
gboolean in_image;
- gdouble unit_factor;
- gint unit_digits;
- const gchar *unit_str;
- gchar format_buf[32];
gchar buf[32];
GimpImageType sample_type;
GimpRGB color;
@@ -397,26 +459,21 @@
in_image = (x >= 0.0 && x < gimp_image_get_width (image) &&
y >= 0.0 && y < gimp_image_get_height (image));
- unit_factor = _gimp_unit_get_factor (image->gimp, unit);
- unit_digits = _gimp_unit_get_digits (image->gimp, unit);
- unit_str = _gimp_unit_get_abbreviation (image->gimp, unit);
-
-#define FORMAT_STRING(s) (in_image ? (s) : "("s")")
-
- g_snprintf (buf, sizeof (buf), FORMAT_STRING ("%d"), (gint) floor (x));
+ g_snprintf (buf, sizeof (buf), "%d", (gint) floor (x));
gtk_label_set_text (GTK_LABEL (view->pixel_x_label), buf);
+ gimp_cursor_view_set_label_italic (view->pixel_x_label, ! in_image);
- g_snprintf (buf, sizeof (buf), FORMAT_STRING ("%d"), (gint) floor (y));
+ g_snprintf (buf, sizeof (buf), "%d", (gint) floor (y));
gtk_label_set_text (GTK_LABEL (view->pixel_y_label), buf);
+ gimp_cursor_view_set_label_italic (view->pixel_y_label, ! in_image);
- g_snprintf (format_buf, sizeof (format_buf),
- FORMAT_STRING ("%%.%df %s"), unit_digits, unit_str);
-
- g_snprintf (buf, sizeof (buf), format_buf, x * unit_factor / xres);
+ gimp_cursor_view_format_as_unit (unit, image->gimp, buf, sizeof (buf), x, xres);
gtk_label_set_text (GTK_LABEL (view->unit_x_label), buf);
+ gimp_cursor_view_set_label_italic (view->unit_x_label, ! in_image);
- g_snprintf (buf, sizeof (buf), format_buf, y * unit_factor / yres);
+ gimp_cursor_view_format_as_unit (unit, image->gimp, buf, sizeof (buf), y, yres);
gtk_label_set_text (GTK_LABEL (view->unit_y_label), buf);
+ gimp_cursor_view_set_label_italic (view->unit_y_label, ! in_image);
if (gimp_image_pick_color (image, NULL,
(gint) floor (x),
Modified: trunk/app/widgets/gimpcursorview.h
==============================================================================
--- trunk/app/widgets/gimpcursorview.h (original)
+++ trunk/app/widgets/gimpcursorview.h Sun Nov 9 14:02:38 2008
@@ -23,9 +23,6 @@
#define __GIMP_CURSOR_VIEW_H__
-#include "gimpeditor.h"
-
-
#define GIMP_TYPE_CURSOR_VIEW (gimp_cursor_view_get_type ())
#define GIMP_CURSOR_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CURSOR_VIEW, GimpCursorView))
#define GIMP_CURSOR_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CURSOR_VIEW, GimpCursorViewClass))
@@ -36,28 +33,6 @@
typedef struct _GimpCursorViewClass GimpCursorViewClass;
-struct _GimpCursorView
-{
- GimpEditor parent_instance;
-
- GtkWidget *coord_hbox;
- GtkWidget *color_hbox;
-
- GtkWidget *pixel_x_label;
- GtkWidget *pixel_y_label;
- GtkWidget *unit_x_label;
- GtkWidget *unit_y_label;
- GtkWidget *color_frame_1;
- GtkWidget *color_frame_2;
-
- gboolean sample_merged;
-};
-
-struct _GimpCursorViewClass
-{
- GimpEditorClass parent_class;
-};
-
GType gimp_cursor_view_get_type (void) G_GNUC_CONST;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]