Commit dde381c1 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

tools/Makefile.am added a very basic GimpUnit implementation.

2005-04-28  Sven Neumann  <sven@gimp.org>

	* tools/Makefile.am
	* tools/units.[ch]: added a very basic GimpUnit implementation.

	* tools/shooter.c
	* tools/widgets.c: initialize the units and enable GimpUnitMenu.
parent 998ea546
2005-04-28 Sven Neumann <sven@gimp.org>
* tools/Makefile.am
* tools/units.[ch]: added a very basic GimpUnit implementation.
* tools/shooter.c
* tools/widgets.c: initialize the units and enable GimpUnitMenu.
2005-04-23 Sven Neumann <sven@gimp.org>
* tools/shooter.c: read the GIMP gtkrc file.
......
......@@ -27,6 +27,8 @@ doc_shooter_SOURCES = \
shadow.c \
shadow.h \
shooter.c \
units.c \
units.h \
widgets.c \
widgets.h
......
......@@ -18,8 +18,9 @@
#include "libgimpwidgets/gimpwidgets.h"
#include "libgimpwidgets/gimpwidgets-private.h"
#include "widgets.h"
#include "shadow.h"
#include "units.h"
#include "widgets.h"
static Window
......@@ -245,12 +246,13 @@ main (int argc, char **argv)
gtk_rc_add_default_file (gimp_gtkrc ());
units_init ();
gimp_widgets_init (shooter_standard_help,
shooter_get_foreground,
shooter_get_background,
shooter_ensure_modules);
toplevels = get_all_widgets ();
for (node = toplevels; node; node = g_list_next (node))
......
#include "config.h"
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpbase/gimpbase-private.h"
#include "units.h"
typedef struct
{
gdouble factor;
gint digits;
const gchar *identifier;
const gchar *symbol;
const gchar *abbreviation;
const gchar *singular;
const gchar *plural;
} GimpUnitDef;
static const GimpUnitDef unit_defs[] =
{
{ 0.0, 0, "pixels", "px", "px", "pixel", "pixels" },
{ 1.0, 2, "inches", "''", "in", "inch", "inches" },
{ 25.4, 1, "millimeters", "mm", "mm", "millimeter", "millimeters" }
};
static gint
units_get_number_of_units (void)
{
return G_N_ELEMENTS (unit_defs);
}
static gint
units_get_number_of_built_in_units (void)
{
return G_N_ELEMENTS (unit_defs);
}
static gdouble
units_unit_get_factor (GimpUnit unit)
{
return unit_defs[unit].factor;
}
static gint
units_unit_get_digits (GimpUnit unit)
{
return unit_defs[unit].digits;
}
static const gchar *
units_unit_get_identifier (GimpUnit unit)
{
return unit_defs[unit].identifier;
}
static const gchar *
units_unit_get_symbol (GimpUnit unit)
{
return unit_defs[unit].symbol;
}
static const gchar *
units_unit_get_abbreviation (GimpUnit unit)
{
return unit_defs[unit].abbreviation;
}
static const gchar *
units_unit_get_singular (GimpUnit unit)
{
return unit_defs[unit].singular;
}
static const gchar *
units_unit_get_plural (GimpUnit unit)
{
return unit_defs[unit].plural;
}
void
units_init (void)
{
GimpUnitVTable vtable;
vtable.unit_get_number_of_units = units_get_number_of_units;
vtable.unit_get_number_of_built_in_units = units_get_number_of_built_in_units;
vtable.unit_new = NULL;
vtable.unit_get_factor = units_unit_get_factor;
vtable.unit_get_digits = units_unit_get_digits;
vtable.unit_get_identifier = units_unit_get_identifier;
vtable.unit_get_symbol = units_unit_get_symbol;
vtable.unit_get_abbreviation = units_unit_get_abbreviation;
vtable.unit_get_singular = units_unit_get_singular;
vtable.unit_get_plural = units_unit_get_plural;
gimp_base_init (&vtable);
}
#ifndef __UNITS_H__
#define __UNITS_H__
void units_init (void);
#endif /* __UNITS_H__ */
......@@ -567,8 +567,7 @@ create_unit_menu (void)
vbox = gtk_vbox_new (FALSE, 6);
align = gtk_alignment_new (0.5, 0.5, 0.5, 0.0);
menu = gimp_unit_menu_new ("%a - %y (%f\"", GIMP_UNIT_POINT,
TRUE, TRUE, TRUE);
menu = gimp_unit_menu_new ("%p", GIMP_UNIT_MM, TRUE, FALSE, FALSE);
gtk_container_add (GTK_CONTAINER (align), menu);
gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox),
......@@ -600,11 +599,7 @@ get_all_widgets (void)
retval = g_list_append (retval, create_path_editor ());
retval = g_list_append (retval, create_pick_button ());
retval = g_list_append (retval, create_preview_area ());
/*
* The following doesn't work, we should init the unit system before.
* retval = g_list_append (retval, create_unit_menu ());
*/
retval = g_list_append (retval, create_unit_menu ());
return retval;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment