mirror of https://github.com/GNOME/gimp.git
app/widgets/widgets-enums.c moved enum GimpAspectType to libgimpwidgets.
2007-02-08 Sven Neumann <sven@gimp.org> * app/widgets/widgets-enums.c * libgimpwidgets/gimpwidgetsenums.[ch]: moved enum GimpAspectType to libgimpwidgets. * libgimpwidgets/gimpratioentry.[ch]: added property "aspect" with getters and setters. * libgimpwidgets/gimpwidgets.def: updated. svn path=/trunk/; revision=21867
This commit is contained in:
parent
f7bfea19d9
commit
525b8bd6b5
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2007-02-08 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/widgets/widgets-enums.c
|
||||
* libgimpwidgets/gimpwidgetsenums.[ch]: moved enum GimpAspectType
|
||||
to libgimpwidgets.
|
||||
|
||||
* libgimpwidgets/gimpratioentry.[ch]: added property "aspect" with
|
||||
getters and setters.
|
||||
|
||||
* libgimpwidgets/gimpwidgets.def: updated.
|
||||
|
||||
2007-02-08 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
Unbreak rectangle select tool undo handling a bit:
|
||||
|
|
|
@ -36,36 +36,6 @@ gimp_active_color_get_type (void)
|
|||
return type;
|
||||
}
|
||||
|
||||
GType
|
||||
gimp_aspect_type_get_type (void)
|
||||
{
|
||||
static const GEnumValue values[] =
|
||||
{
|
||||
{ GIMP_ASPECT_SQUARE, "GIMP_ASPECT_SQUARE", "square" },
|
||||
{ GIMP_ASPECT_PORTRAIT, "GIMP_ASPECT_PORTRAIT", "portrait" },
|
||||
{ GIMP_ASPECT_LANDSCAPE, "GIMP_ASPECT_LANDSCAPE", "landscape" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static const GimpEnumDesc descs[] =
|
||||
{
|
||||
{ GIMP_ASPECT_SQUARE, "GIMP_ASPECT_SQUARE", NULL },
|
||||
{ GIMP_ASPECT_PORTRAIT, N_("Portrait"), NULL },
|
||||
{ GIMP_ASPECT_LANDSCAPE, N_("Landscape"), NULL },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static GType type = 0;
|
||||
|
||||
if (! type)
|
||||
{
|
||||
type = g_enum_register_static ("GimpAspectType", values);
|
||||
gimp_enum_set_value_descriptions (type, descs);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
GType
|
||||
gimp_color_dialog_state_get_type (void)
|
||||
{
|
||||
|
|
|
@ -35,18 +35,6 @@ typedef enum
|
|||
} GimpActiveColor;
|
||||
|
||||
|
||||
#define GIMP_TYPE_ASPECT_TYPE (gimp_aspect_type_get_type ())
|
||||
|
||||
GType gimp_aspect_type_get_type (void) G_GNUC_CONST;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GIMP_ASPECT_SQUARE,
|
||||
GIMP_ASPECT_PORTRAIT, /*< desc="Portrait" >*/
|
||||
GIMP_ASPECT_LANDSCAPE /*< desc="Landscape" >*/
|
||||
} GimpAspectType;
|
||||
|
||||
|
||||
#define GIMP_TYPE_COLOR_DIALOG_STATE (gimp_color_dialog_state_get_type ())
|
||||
|
||||
GType gimp_color_dialog_state_get_type (void) G_GNUC_CONST;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
*
|
||||
* gimpratioentry.c
|
||||
* Copyright (C) 2006 Simon Budig <simon@gimp.org>
|
||||
* Copyright (C) 2007 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
|
||||
|
@ -46,6 +47,7 @@ enum
|
|||
PROP_RATIO,
|
||||
PROP_NUMERATOR,
|
||||
PROP_DENOMINATOR,
|
||||
PROP_ASPECT
|
||||
};
|
||||
|
||||
enum
|
||||
|
@ -126,6 +128,13 @@ gimp_ratio_entry_class_init (GimpRatioEntryClass *klass)
|
|||
G_MINDOUBLE, G_MAXDOUBLE,
|
||||
1.0,
|
||||
GIMP_PARAM_READWRITE));
|
||||
g_object_class_install_property (object_class, PROP_ASPECT,
|
||||
g_param_spec_enum ("aspect",
|
||||
"Aspect", NULL,
|
||||
GIMP_TYPE_ASPECT_TYPE,
|
||||
GIMP_ASPECT_SQUARE,
|
||||
GIMP_PARAM_READWRITE));
|
||||
|
||||
|
||||
klass->history = gtk_list_store_new (NUM_COLUMNS,
|
||||
G_TYPE_DOUBLE, G_TYPE_DOUBLE,
|
||||
|
@ -145,16 +154,26 @@ gimp_ratio_entry_set_property (GObject *object,
|
|||
case PROP_RATIO:
|
||||
gimp_ratio_entry_set_ratio (entry, g_value_get_double (value));
|
||||
break;
|
||||
|
||||
case PROP_NUMERATOR:
|
||||
gimp_ratio_entry_set_fraction (entry,
|
||||
g_value_get_double (value),
|
||||
entry->denominator);
|
||||
break;
|
||||
|
||||
case PROP_DENOMINATOR:
|
||||
gimp_ratio_entry_set_fraction (entry,
|
||||
entry->numerator,
|
||||
g_value_get_double (value));
|
||||
break;
|
||||
|
||||
case PROP_ASPECT:
|
||||
gimp_ratio_entry_set_aspect (entry, g_value_get_enum (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,12 +190,22 @@ gimp_ratio_entry_get_property (GObject *object,
|
|||
case PROP_RATIO:
|
||||
g_value_set_double (value, gimp_ratio_entry_get_ratio (entry));
|
||||
break;
|
||||
|
||||
case PROP_NUMERATOR:
|
||||
g_value_set_double (value, entry->numerator);
|
||||
break;
|
||||
|
||||
case PROP_DENOMINATOR:
|
||||
g_value_set_double (value, entry->denominator);
|
||||
break;
|
||||
|
||||
case PROP_ASPECT:
|
||||
g_value_set_enum (value, gimp_ratio_entry_get_aspect (entry));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -314,8 +343,8 @@ gimp_ratio_entry_get_ratio (GimpRatioEntry *entry)
|
|||
**/
|
||||
void
|
||||
gimp_ratio_entry_set_fraction (GimpRatioEntry *entry,
|
||||
const gdouble numerator,
|
||||
const gdouble denominator)
|
||||
gdouble numerator,
|
||||
gdouble denominator)
|
||||
{
|
||||
gdouble old_ratio;
|
||||
|
||||
|
@ -368,6 +397,68 @@ gimp_ratio_entry_get_fraction (GimpRatioEntry *entry,
|
|||
*denominator = entry->denominator;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_ratio_entry_set_aspect:
|
||||
* @entry: a #GimpRatioEntry widget
|
||||
* @aspect: the new aspect
|
||||
*
|
||||
* Sets the aspect of the ratio by swapping the numerator and denominator
|
||||
* (or setting them to 1.0 in case that @aspect is %GIMP_ASPECT_SQUARE).
|
||||
*
|
||||
* Since: GIMP 2.4
|
||||
**/
|
||||
void
|
||||
gimp_ratio_entry_set_aspect (GimpRatioEntry *entry,
|
||||
GimpAspectType aspect)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_RATIO_ENTRY (entry));
|
||||
|
||||
if (gimp_ratio_entry_get_aspect (entry) == aspect)
|
||||
return;
|
||||
|
||||
switch (aspect)
|
||||
{
|
||||
case GIMP_ASPECT_SQUARE:
|
||||
gimp_ratio_entry_set_fraction (entry, 1.0, 1.0);
|
||||
break;
|
||||
|
||||
case GIMP_ASPECT_LANDSCAPE:
|
||||
case GIMP_ASPECT_PORTRAIT:
|
||||
gimp_ratio_entry_set_fraction (entry,
|
||||
entry->denominator, entry->numerator);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_ratio_entry_get_aspect:
|
||||
* @entry: a #GimpRatioEntry widget
|
||||
*
|
||||
* Gets the aspect of the ratio displayed by a #GimpRatioEntry.
|
||||
*
|
||||
* Returns: The entry's current aspect.
|
||||
*
|
||||
* Since: GIMP 2.4
|
||||
**/
|
||||
GimpAspectType
|
||||
gimp_ratio_entry_get_aspect (GimpRatioEntry *entry)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_RATIO_ENTRY (entry), GIMP_ASPECT_SQUARE);
|
||||
|
||||
if (entry->numerator > entry->denominator)
|
||||
{
|
||||
return GIMP_ASPECT_LANDSCAPE;
|
||||
}
|
||||
else if (entry->numerator < entry->denominator)
|
||||
{
|
||||
return GIMP_ASPECT_PORTRAIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
return GIMP_ASPECT_SQUARE;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_ratio_entry_events (GtkWidget *widget,
|
||||
GdkEvent *event)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
*
|
||||
* gimpratioentry.h
|
||||
* Copyright (C) 2006 Simon Budig <simon@gimp.org>
|
||||
* Copyright (C) 2007 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
|
||||
|
@ -75,6 +76,10 @@ void gimp_ratio_entry_set_ratio (GimpRatioEntry *entry,
|
|||
gdouble ratio);
|
||||
gdouble gimp_ratio_entry_get_ratio (GimpRatioEntry *entry);
|
||||
|
||||
void gimp_ratio_entry_set_aspect (GimpRatioEntry *entry,
|
||||
GimpAspectType aspect);
|
||||
GimpAspectType gimp_ratio_entry_get_aspect (GimpRatioEntry *entry);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
EXPORTS
|
||||
gimp_aspect_type_get_type
|
||||
gimp_browser_add_search_types
|
||||
gimp_browser_get_type
|
||||
gimp_browser_new
|
||||
|
@ -268,10 +269,12 @@ EXPORTS
|
|||
gimp_radio_group_new2
|
||||
gimp_radio_group_set_active
|
||||
gimp_random_seed_new
|
||||
gimp_ratio_entry_get_aspect
|
||||
gimp_ratio_entry_get_fraction
|
||||
gimp_ratio_entry_get_ratio
|
||||
gimp_ratio_entry_get_type
|
||||
gimp_ratio_entry_new
|
||||
gimp_ratio_entry_set_aspect
|
||||
gimp_ratio_entry_set_fraction
|
||||
gimp_ratio_entry_set_ratio
|
||||
gimp_resolution_entry_attach_label
|
||||
|
|
|
@ -8,6 +8,37 @@
|
|||
#include "libgimp/libgimp-intl.h"
|
||||
|
||||
/* enumerations from "./gimpwidgetsenums.h" */
|
||||
GType
|
||||
gimp_aspect_type_get_type (void)
|
||||
{
|
||||
static const GEnumValue values[] =
|
||||
{
|
||||
{ GIMP_ASPECT_SQUARE, "GIMP_ASPECT_SQUARE", "square" },
|
||||
{ GIMP_ASPECT_PORTRAIT, "GIMP_ASPECT_PORTRAIT", "portrait" },
|
||||
{ GIMP_ASPECT_LANDSCAPE, "GIMP_ASPECT_LANDSCAPE", "landscape" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static const GimpEnumDesc descs[] =
|
||||
{
|
||||
{ GIMP_ASPECT_SQUARE, N_("Square"), NULL },
|
||||
{ GIMP_ASPECT_PORTRAIT, N_("Portrait"), NULL },
|
||||
{ GIMP_ASPECT_LANDSCAPE, N_("Landscape"), NULL },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static GType type = 0;
|
||||
|
||||
if (! type)
|
||||
{
|
||||
type = g_enum_register_static ("GimpAspectType", values);
|
||||
gimp_type_set_translation_domain (type, GETTEXT_PACKAGE "-libgimp");
|
||||
gimp_enum_set_value_descriptions (type, descs);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
GType
|
||||
gimp_chain_position_get_type (void)
|
||||
{
|
||||
|
|
|
@ -26,6 +26,18 @@ G_BEGIN_DECLS
|
|||
/* For information look into the C source or the html documentation */
|
||||
|
||||
|
||||
#define GIMP_TYPE_ASPECT_TYPE (gimp_aspect_type_get_type ())
|
||||
|
||||
GType gimp_aspect_type_get_type (void) G_GNUC_CONST;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GIMP_ASPECT_SQUARE, /*< desc="Square" >*/
|
||||
GIMP_ASPECT_PORTRAIT, /*< desc="Portrait" >*/
|
||||
GIMP_ASPECT_LANDSCAPE /*< desc="Landscape" >*/
|
||||
} GimpAspectType;
|
||||
|
||||
|
||||
#define GIMP_TYPE_CHAIN_POSITION (gimp_chain_position_get_type ())
|
||||
|
||||
GType gimp_chain_position_get_type (void) G_GNUC_CONST;
|
||||
|
|
Loading…
Reference in New Issue