app/libgimpwidgets: move GimpUnitStore and GimpUnitComboBox to libgimpwidgets

This commit is contained in:
Michael Natterer
2010-10-14 22:15:25 +02:00
parent af518f9e84
commit 74458f46ee
10 changed files with 72 additions and 55 deletions

View File

@ -160,8 +160,12 @@ libgimpwidgets_2_0_la_sources = \
gimpstock.h \
gimpstringcombobox.c \
gimpstringcombobox.h \
gimpunitcombobox.c \
gimpunitcombobox.h \
gimpunitmenu.c \
gimpunitmenu.h \
gimpunitstore.c \
gimpunitstore.h \
gimpwidgets-error.c \
gimpwidgets-error.h \
gimpwidgets-private.c \
@ -235,7 +239,9 @@ libgimpwidgetsinclude_HEADERS = \
gimpsizeentry.h \
gimpstock.h \
gimpstringcombobox.h \
gimpunitcombobox.h \
gimpunitmenu.h \
gimpunitstore.h \
gimpwidgets-error.h \
gimpwidgets.h \
gimpwidgetsenums.h \

View File

@ -0,0 +1,146 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1999 Peter Mattis and Spencer Kimball
*
* gimpunitcombobox.c
* Copyright (C) 2004, 2008 Sven Neumann <sven@gimp.org>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "gimpwidgetstypes.h"
#include "gimpunitcombobox.h"
#include "gimpunitstore.h"
static void gimp_unit_combo_box_style_set (GtkWidget *widget,
GtkStyle *prev_style);
G_DEFINE_TYPE (GimpUnitComboBox, gimp_unit_combo_box, GTK_TYPE_COMBO_BOX)
#define parent_class gimp_unit_combo_box_parent_class
static void
gimp_unit_combo_box_class_init (GimpUnitComboBoxClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
widget_class->style_set = gimp_unit_combo_box_style_set;
gtk_widget_class_install_style_property (widget_class,
g_param_spec_double ("label-scale",
NULL, NULL,
0.0,
G_MAXDOUBLE,
1.0,
GIMP_PARAM_READABLE));
}
static void
gimp_unit_combo_box_init (GimpUnitComboBox *combo)
{
GtkCellLayout *layout = GTK_CELL_LAYOUT (combo);
GtkCellRenderer *cell;
cell = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (layout, cell, TRUE);
gtk_cell_layout_set_attributes (layout, cell,
"text", GIMP_UNIT_STORE_UNIT_PLURAL,
NULL);
}
static void
gimp_unit_combo_box_style_set (GtkWidget *widget,
GtkStyle *prev_style)
{
GtkCellLayout *layout;
GtkCellRenderer *cell;
gdouble scale;
GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
gtk_widget_style_get (widget, "label-scale", &scale, NULL);
/* hackedehack ... */
layout = GTK_CELL_LAYOUT (gtk_bin_get_child (GTK_BIN (widget)));
gtk_cell_layout_clear (layout);
cell = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT,
"scale", scale,
NULL);
gtk_cell_layout_pack_start (layout, cell, TRUE);
gtk_cell_layout_set_attributes (layout, cell,
"text", GIMP_UNIT_STORE_UNIT_ABBREVIATION,
NULL);
}
/**
* gimp_unit_combo_box_new:
*
* Return value: a new #GimpUnitComboBox.
**/
GtkWidget *
gimp_unit_combo_box_new (void)
{
GtkWidget *combo_box;
GimpUnitStore *store;
store = gimp_unit_store_new (0);
combo_box = g_object_new (GIMP_TYPE_UNIT_COMBO_BOX,
"model", store,
NULL);
g_object_unref (store);
return combo_box;
}
/**
* gimp_unit_combo_box_new_with_model:
* @model: a GimpUnitStore
*
* Return value: a new #GimpUnitComboBox.
**/
GtkWidget *
gimp_unit_combo_box_new_with_model (GimpUnitStore *model)
{
return g_object_new (GIMP_TYPE_UNIT_COMBO_BOX,
"model", model,
NULL);
}
GimpUnit
gimp_unit_combo_box_get_active (GimpUnitComboBox *combo)
{
g_return_val_if_fail (GIMP_IS_UNIT_COMBO_BOX (combo), -1);
return gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
}
void
gimp_unit_combo_box_set_active (GimpUnitComboBox *combo,
GimpUnit unit)
{
g_return_if_fail (GIMP_IS_UNIT_COMBO_BOX (combo));
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), unit);
}

View File

@ -0,0 +1,63 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1999 Peter Mattis and Spencer Kimball
*
* gimpunitcombobox.h
* Copyright (C) 2004 Sven Neumann <sven@gimp.org>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_UNIT_COMBO_BOX_H__
#define __GIMP_UNIT_COMBO_BOX_H__
#define GIMP_TYPE_UNIT_COMBO_BOX (gimp_unit_combo_box_get_type ())
#define GIMP_UNIT_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_UNIT_COMBO_BOX, GimpUnitComboBox))
#define GIMP_UNIT_COMBO_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_UNIT_COMBO_BOX, GimpUnitComboBoxClass))
#define GIMP_IS_UNIT_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_UNIT_COMBO_BOX))
#define GIMP_IS_UNIT_COMBO_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_UNIT_COMBO_BOX))
#define GIMP_UNIT_COMBO_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_UNIT_COMBO_BOX, GimpUnitComboBoxClass))
typedef struct _GimpUnitComboBoxClass GimpUnitComboBoxClass;
struct _GimpUnitComboBoxClass
{
GtkComboBoxClass parent_instance;
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
struct _GimpUnitComboBox
{
GtkComboBox parent_instance;
};
GType gimp_unit_combo_box_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_unit_combo_box_new (void);
GtkWidget * gimp_unit_combo_box_new_with_model (GimpUnitStore *model);
GimpUnit gimp_unit_combo_box_get_active (GimpUnitComboBox *combo);
void gimp_unit_combo_box_set_active (GimpUnitComboBox *combo,
GimpUnit unit);
#endif /* __GIMP_UNIT_COMBO_BOX_H__ */

View File

@ -0,0 +1,525 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpunitstore.c
* Copyright (C) 2004 Sven Neumann <sven@gimp.org>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "gimpwidgetstypes.h"
#include "gimpunitstore.h"
enum
{
PROP_0,
PROP_NUM_VALUES
};
static void gimp_unit_store_tree_model_init (GtkTreeModelIface *iface);
static void gimp_unit_store_finalize (GObject *object);
static void gimp_unit_store_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_unit_store_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static GtkTreeModelFlags gimp_unit_store_get_flags (GtkTreeModel *tree_model);
static gint gimp_unit_store_get_n_columns (GtkTreeModel *tree_model);
static GType gimp_unit_store_get_column_type (GtkTreeModel *tree_model,
gint index);
static gboolean gimp_unit_store_get_iter (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreePath *path);
static GtkTreePath *gimp_unit_store_get_path (GtkTreeModel *tree_model,
GtkTreeIter *iter);
static void gimp_unit_store_tree_model_get_value (GtkTreeModel *tree_model,
GtkTreeIter *iter,
gint column,
GValue *value);
static gboolean gimp_unit_store_iter_next (GtkTreeModel *tree_model,
GtkTreeIter *iter);
static gboolean gimp_unit_store_iter_children (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *parent);
static gboolean gimp_unit_store_iter_has_child (GtkTreeModel *tree_model,
GtkTreeIter *iter);
static gint gimp_unit_store_iter_n_children (GtkTreeModel *tree_model,
GtkTreeIter *iter);
static gboolean gimp_unit_store_iter_nth_child (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *parent,
gint n);
static gboolean gimp_unit_store_iter_parent (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *child);
G_DEFINE_TYPE_WITH_CODE (GimpUnitStore, gimp_unit_store, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL,
gimp_unit_store_tree_model_init))
#define parent_class gimp_unit_store_parent_class
static GType column_types[GIMP_UNIT_STORE_UNIT_COLUMNS] =
{
G_TYPE_INVALID,
G_TYPE_DOUBLE,
G_TYPE_INT,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING
};
static void
gimp_unit_store_class_init (GimpUnitStoreClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
column_types[GIMP_UNIT_STORE_UNIT] = GIMP_TYPE_UNIT;
object_class->finalize = gimp_unit_store_finalize;
object_class->set_property = gimp_unit_store_set_property;
object_class->get_property = gimp_unit_store_get_property;
g_object_class_install_property (object_class, PROP_NUM_VALUES,
g_param_spec_int ("num-values",
NULL, NULL,
0, G_MAXINT, 0,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
}
static void
gimp_unit_store_init (GimpUnitStore *store)
{
}
static void
gimp_unit_store_tree_model_init (GtkTreeModelIface *iface)
{
iface->get_flags = gimp_unit_store_get_flags;
iface->get_n_columns = gimp_unit_store_get_n_columns;
iface->get_column_type = gimp_unit_store_get_column_type;
iface->get_iter = gimp_unit_store_get_iter;
iface->get_path = gimp_unit_store_get_path;
iface->get_value = gimp_unit_store_tree_model_get_value;
iface->iter_next = gimp_unit_store_iter_next;
iface->iter_children = gimp_unit_store_iter_children;
iface->iter_has_child = gimp_unit_store_iter_has_child;
iface->iter_n_children = gimp_unit_store_iter_n_children;
iface->iter_nth_child = gimp_unit_store_iter_nth_child;
iface->iter_parent = gimp_unit_store_iter_parent;
}
static void
gimp_unit_store_finalize (GObject *object)
{
GimpUnitStore *store = GIMP_UNIT_STORE (object);
if (store->num_values > 0)
{
g_free (store->values);
g_free (store->resolutions);
store->num_values = 0;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_unit_store_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpUnitStore *store = GIMP_UNIT_STORE (object);
switch (property_id)
{
case PROP_NUM_VALUES:
g_return_if_fail (store->num_values == 0);
store->num_values = g_value_get_int (value);
if (store->num_values)
{
store->values = g_new0 (gdouble, store->num_values);
store->resolutions = g_new0 (gdouble, store->num_values);
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_unit_store_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpUnitStore *store = GIMP_UNIT_STORE (object);
switch (property_id)
{
case PROP_NUM_VALUES:
g_value_set_int (value, store->num_values);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static GtkTreeModelFlags
gimp_unit_store_get_flags (GtkTreeModel *tree_model)
{
return GTK_TREE_MODEL_ITERS_PERSIST | GTK_TREE_MODEL_LIST_ONLY;
}
static gint
gimp_unit_store_get_n_columns (GtkTreeModel *tree_model)
{
GimpUnitStore *store = GIMP_UNIT_STORE (tree_model);
return GIMP_UNIT_STORE_UNIT_COLUMNS + store->num_values;
}
static GType
gimp_unit_store_get_column_type (GtkTreeModel *tree_model,
gint index)
{
g_return_val_if_fail (index >= 0, G_TYPE_INVALID);
if (index < GIMP_UNIT_STORE_UNIT_COLUMNS)
return column_types[index];
return G_TYPE_DOUBLE;
}
static gboolean
gimp_unit_store_get_iter (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreePath *path)
{
gint unit;
g_return_val_if_fail (gtk_tree_path_get_depth (path) > 0, FALSE);
unit = gtk_tree_path_get_indices (path)[0];
if (unit >= 0 && unit < gimp_unit_get_number_of_units ())
{
iter->user_data = GINT_TO_POINTER (unit);
return TRUE;
}
return FALSE;
}
static GtkTreePath *
gimp_unit_store_get_path (GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
GtkTreePath *path = gtk_tree_path_new ();
gtk_tree_path_append_index (path, GPOINTER_TO_INT (iter->user_data));
return path;
}
static void
gimp_unit_store_tree_model_get_value (GtkTreeModel *tree_model,
GtkTreeIter *iter,
gint column,
GValue *value)
{
GimpUnitStore *store = GIMP_UNIT_STORE (tree_model);
GimpUnit unit;
g_return_if_fail (column >= 0 &&
column < GIMP_UNIT_STORE_UNIT_COLUMNS + store->num_values);
g_value_init (value,
column < GIMP_UNIT_STORE_UNIT_COLUMNS ?
column_types[column] :
G_TYPE_DOUBLE);
unit = GPOINTER_TO_INT (iter->user_data);
if (unit >= 0 && unit < gimp_unit_get_number_of_units ())
{
switch (column)
{
case GIMP_UNIT_STORE_UNIT:
g_value_set_int (value, unit);
break;
case GIMP_UNIT_STORE_UNIT_FACTOR:
g_value_set_double (value, gimp_unit_get_factor (unit));
break;
case GIMP_UNIT_STORE_UNIT_DIGITS:
g_value_set_int (value, gimp_unit_get_digits (unit));
break;
case GIMP_UNIT_STORE_UNIT_IDENTIFIER:
g_value_set_static_string (value, gimp_unit_get_identifier (unit));
break;
case GIMP_UNIT_STORE_UNIT_SYMBOL:
g_value_set_static_string (value, gimp_unit_get_symbol (unit));
break;
case GIMP_UNIT_STORE_UNIT_ABBREVIATION:
g_value_set_static_string (value, gimp_unit_get_abbreviation (unit));
break;
case GIMP_UNIT_STORE_UNIT_SINGULAR:
g_value_set_static_string (value, gimp_unit_get_singular (unit));
break;
case GIMP_UNIT_STORE_UNIT_PLURAL:
g_value_set_static_string (value, gimp_unit_get_plural (unit));
break;
default:
column -= GIMP_UNIT_STORE_UNIT_COLUMNS;
if (unit == GIMP_UNIT_PIXEL)
{
g_value_set_double (value, store->values[column]);
}
else if (store->resolutions[column])
{
g_value_set_double (value,
store->values[column] *
gimp_unit_get_factor (unit) /
store->resolutions[column]);
}
break;
}
}
}
static gboolean
gimp_unit_store_iter_next (GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
gint unit = GPOINTER_TO_INT (iter->user_data);
unit++;
if (unit > 0 && unit < gimp_unit_get_number_of_units ())
{
iter->user_data = GINT_TO_POINTER (unit);
return TRUE;
}
return FALSE;
}
static gboolean
gimp_unit_store_iter_children (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *parent)
{
/* this is a list, nodes have no children */
if (parent)
return FALSE;
iter->user_data = GINT_TO_POINTER (0);
return TRUE;
}
static gboolean
gimp_unit_store_iter_has_child (GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
return FALSE;
}
static gint
gimp_unit_store_iter_n_children (GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
if (iter)
return 0;
return gimp_unit_get_number_of_units ();
}
static gboolean
gimp_unit_store_iter_nth_child (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *parent,
gint n)
{
GimpUnitStore *store;
if (parent)
return FALSE;
store = GIMP_UNIT_STORE (tree_model);
if (n >= 0 && n < gimp_unit_get_number_of_units ())
{
iter->user_data = GINT_TO_POINTER (n);
return TRUE;
}
return FALSE;
}
static gboolean
gimp_unit_store_iter_parent (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *child)
{
return FALSE;
}
GimpUnitStore *
gimp_unit_store_new (gint num_values)
{
return g_object_new (GIMP_TYPE_UNIT_STORE,
"num-values", num_values,
NULL);
}
void
gimp_unit_store_set_pixel_value (GimpUnitStore *store,
gint index,
gdouble value)
{
g_return_if_fail (GIMP_IS_UNIT_STORE (store));
g_return_if_fail (index > 0 && index < store->num_values);
store->values[index] = value;
}
void
gimp_unit_store_set_pixel_values (GimpUnitStore *store,
gdouble first_value,
...)
{
va_list args;
gint i;
g_return_if_fail (GIMP_IS_UNIT_STORE (store));
va_start (args, first_value);
for (i = 0; i < store->num_values; )
{
store->values[i] = first_value;
if (++i < store->num_values)
first_value = va_arg (args, gdouble);
}
va_end (args);
}
void
gimp_unit_store_set_resolution (GimpUnitStore *store,
gint index,
gdouble resolution)
{
g_return_if_fail (GIMP_IS_UNIT_STORE (store));
g_return_if_fail (index > 0 && index < store->num_values);
store->resolutions[index] = resolution;
}
void
gimp_unit_store_set_resolutions (GimpUnitStore *store,
gdouble first_resolution,
...)
{
va_list args;
gint i;
g_return_if_fail (GIMP_IS_UNIT_STORE (store));
va_start (args, first_resolution);
for (i = 0; i < store->num_values; )
{
store->resolutions[i] = first_resolution;
if (++i < store->num_values)
first_resolution = va_arg (args, gdouble);
}
va_end (args);
}
gdouble
gimp_unit_store_get_value (GimpUnitStore *store,
GimpUnit unit,
gint index)
{
GtkTreeIter iter;
GValue value = { 0, };
g_return_val_if_fail (GIMP_IS_UNIT_STORE (store), 0.0);
g_return_val_if_fail (index >= 0 && index < store->num_values, 0.0);
iter.user_data = GINT_TO_POINTER (unit);
gimp_unit_store_tree_model_get_value (GTK_TREE_MODEL (store),
&iter,
GIMP_UNIT_STORE_FIRST_VALUE + index,
&value);
return g_value_get_double (&value);
}
void
gimp_unit_store_get_values (GimpUnitStore *store,
GimpUnit unit,
gdouble *first_value,
...)
{
va_list args;
gint i;
g_return_if_fail (GIMP_IS_UNIT_STORE (store));
va_start (args, first_value);
for (i = 0; i < store->num_values; )
{
if (first_value)
*first_value = gimp_unit_store_get_value (store, unit, i);
if (++i < store->num_values)
first_value = va_arg (args, gdouble *);
}
va_end (args);
}

View File

@ -0,0 +1,97 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpunitstore.h
* Copyright (C) 2004 Sven Neumann <sven@gimp.org>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_UNIT_STORE_H__
#define __GIMP_UNIT_STORE_H__
enum
{
GIMP_UNIT_STORE_UNIT,
GIMP_UNIT_STORE_UNIT_FACTOR,
GIMP_UNIT_STORE_UNIT_DIGITS,
GIMP_UNIT_STORE_UNIT_IDENTIFIER,
GIMP_UNIT_STORE_UNIT_SYMBOL,
GIMP_UNIT_STORE_UNIT_ABBREVIATION,
GIMP_UNIT_STORE_UNIT_SINGULAR,
GIMP_UNIT_STORE_UNIT_PLURAL,
GIMP_UNIT_STORE_UNIT_COLUMNS,
GIMP_UNIT_STORE_FIRST_VALUE = GIMP_UNIT_STORE_UNIT_COLUMNS
};
#define GIMP_TYPE_UNIT_STORE (gimp_unit_store_get_type ())
#define GIMP_UNIT_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_UNIT_STORE, GimpUnitStore))
#define GIMP_UNIT_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_UNIT_STORE, GimpUnitStoreClass))
#define GIMP_IS_UNIT_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_UNIT_STORE))
#define GIMP_IS_UNIT_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_UNIT_STORE))
#define GIMP_UNIT_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_UNIT_STORE, GimpUnitStoreClass))
typedef struct _GimpUnitStoreClass GimpUnitStoreClass;
struct _GimpUnitStoreClass
{
GObjectClass parent_class;
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
struct _GimpUnitStore
{
GObject parent_instance;
gint num_values;
gdouble *values;
gdouble *resolutions;
};
GType gimp_unit_store_get_type (void) G_GNUC_CONST;
GimpUnitStore * gimp_unit_store_new (gint num_values);
void gimp_unit_store_set_pixel_value (GimpUnitStore *store,
gint index,
gdouble value);
void gimp_unit_store_set_pixel_values (GimpUnitStore *store,
gdouble first_value,
...);
void gimp_unit_store_set_resolution (GimpUnitStore *store,
gint index,
gdouble resolution);
void gimp_unit_store_set_resolutions (GimpUnitStore *store,
gdouble first_resolution,
...);
gdouble gimp_unit_store_get_value (GimpUnitStore *store,
GimpUnit unit,
gint index);
void gimp_unit_store_get_values (GimpUnitStore *store,
GimpUnit unit,
gdouble *first_value,
...);
#endif /* __GIMP_UNIT_STORE_H__ */

View File

@ -72,7 +72,9 @@
#include <libgimpwidgets/gimpsizeentry.h>
#include <libgimpwidgets/gimpstock.h>
#include <libgimpwidgets/gimpstringcombobox.h>
#include <libgimpwidgets/gimpunitcombobox.h>
#include <libgimpwidgets/gimpunitmenu.h>
#include <libgimpwidgets/gimpunitstore.h>
#include <libgimpwidgets/gimpwidgets-error.h>
#include <libgimpwidgets/gimpzoommodel.h>

View File

@ -70,7 +70,9 @@ typedef struct _GimpRuler GimpRuler;
typedef struct _GimpScrolledPreview GimpScrolledPreview;
typedef struct _GimpSizeEntry GimpSizeEntry;
typedef struct _GimpStringComboBox GimpStringComboBox;
typedef struct _GimpUnitComboBox GimpUnitComboBox;
typedef struct _GimpUnitMenu GimpUnitMenu;
typedef struct _GimpUnitStore GimpUnitStore;
typedef struct _GimpZoomModel GimpZoomModel;