added some blurbs that will show up as tooltips in the text tool options.
2003-02-05 Sven Neumann <sven@gimp.org> * app/text/gimptext.c: added some blurbs that will show up as tooltips in the text tool options. Tweaked default values. * app/text/gimptextlayout.c (gimp_text_layout_position): if gravity is none (the default), position the layout according to its justification. * app/widgets/gimpenummenu.[ch]: added new functions that create a hbox of radio buttons with icons from an enum type. * app/widgets/gimppropwidgets.[ch]: added a property widget constructors for the new enum_stock_box.
This commit is contained in:

committed by
Sven Neumann

parent
e49d99afbc
commit
87b133f813
15
ChangeLog
15
ChangeLog
@ -1,3 +1,18 @@
|
||||
2003-02-05 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/text/gimptext.c: added some blurbs that will show up as
|
||||
tooltips in the text tool options. Tweaked default values.
|
||||
|
||||
* app/text/gimptextlayout.c (gimp_text_layout_position): if
|
||||
gravity is none (the default), position the layout according to its
|
||||
justification.
|
||||
|
||||
* app/widgets/gimpenummenu.[ch]: added new functions that create a
|
||||
hbox of radio buttons with icons from an enum type.
|
||||
|
||||
* app/widgets/gimppropwidgets.[ch]: added a property widget
|
||||
constructors for the new enum_stock_box.
|
||||
|
||||
2003-02-05 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/text/text-enums.[ch]
|
||||
|
@ -33,6 +33,9 @@
|
||||
|
||||
#include "gimptext.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
@ -140,21 +143,25 @@ gimp_text_class_init (GimpTextClass *klass)
|
||||
&black,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_JUSTIFICATION,
|
||||
"justify", NULL,
|
||||
"justify",
|
||||
NULL,
|
||||
GIMP_TYPE_TEXT_JUSTIFICATION,
|
||||
GIMP_TEXT_JUSTIFY_LEFT,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_INDENTATION,
|
||||
"indent", NULL,
|
||||
"indent",
|
||||
_("How many pixels the "
|
||||
"first line should be shorter."),
|
||||
-8192.0, 8192.0, 0.0,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_LINE_SPACING,
|
||||
"line-spacing", NULL,
|
||||
"line-spacing",
|
||||
_("Additional line spacing (in pixels)."),
|
||||
-8192.0, 8192.0, 0.0,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_LETTER_SPACING,
|
||||
"letter-spacing", NULL,
|
||||
0.0, 64.0, 1.0,
|
||||
-8192.0, 8192.0, 0.0,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_FIXED_WIDTH,
|
||||
"fixed-width", NULL,
|
||||
@ -166,7 +173,7 @@ gimp_text_class_init (GimpTextClass *klass)
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_GRAVITY,
|
||||
"gravity", NULL,
|
||||
GIMP_TYPE_GRAVITY_TYPE, GIMP_GRAVITY_CENTER,
|
||||
GIMP_TYPE_GRAVITY_TYPE, GIMP_GRAVITY_NONE,
|
||||
0);
|
||||
|
||||
/* border does only exist to implement the old text API */
|
||||
|
@ -289,12 +289,13 @@ gimp_text_layout_render (GimpTextLayout *layout)
|
||||
static void
|
||||
gimp_text_layout_position (GimpTextLayout *layout)
|
||||
{
|
||||
GimpText *text;
|
||||
PangoRectangle ink;
|
||||
PangoRectangle logical;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
gboolean fixed;
|
||||
GimpText *text;
|
||||
PangoRectangle ink;
|
||||
PangoRectangle logical;
|
||||
GimpGravityType gravity;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
gboolean fixed;
|
||||
|
||||
layout->extents.x = 0;
|
||||
layout->extents.x = 0;
|
||||
@ -330,12 +331,13 @@ gimp_text_layout_position (GimpTextLayout *layout)
|
||||
layout->extents.width = fixed ? text->fixed_width : x2 - x1;
|
||||
layout->extents.height = fixed ? text->fixed_height : y2 - y1;
|
||||
|
||||
/* border should only be used by the compatibility API;
|
||||
we assume that gravity is CENTER
|
||||
*/
|
||||
gravity = text->gravity;
|
||||
|
||||
/* border should only be used by the compatibility API */
|
||||
if (text->border)
|
||||
{
|
||||
fixed = TRUE;
|
||||
gravity = GIMP_GRAVITY_CENTER;
|
||||
|
||||
layout->extents.width += 2 * text->border;
|
||||
layout->extents.height += 2 * text->border;
|
||||
@ -347,14 +349,30 @@ gimp_text_layout_position (GimpTextLayout *layout)
|
||||
if (!fixed)
|
||||
return;
|
||||
|
||||
switch (text->gravity)
|
||||
if (gravity == GIMP_GRAVITY_NONE)
|
||||
{
|
||||
switch (pango_layout_get_alignment (layout->layout))
|
||||
{
|
||||
case PANGO_ALIGN_LEFT:
|
||||
gravity = GIMP_GRAVITY_NORTH_WEST;
|
||||
break;
|
||||
case PANGO_ALIGN_CENTER:
|
||||
gravity = GIMP_GRAVITY_NORTH;
|
||||
break;
|
||||
case PANGO_ALIGN_RIGHT:
|
||||
gravity = GIMP_GRAVITY_NORTH_EAST;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (gravity)
|
||||
{
|
||||
case GIMP_GRAVITY_NONE:
|
||||
case GIMP_GRAVITY_NORTH_WEST:
|
||||
case GIMP_GRAVITY_SOUTH_WEST:
|
||||
case GIMP_GRAVITY_WEST:
|
||||
break;
|
||||
|
||||
case GIMP_GRAVITY_NONE:
|
||||
case GIMP_GRAVITY_CENTER:
|
||||
case GIMP_GRAVITY_NORTH:
|
||||
case GIMP_GRAVITY_SOUTH:
|
||||
@ -370,12 +388,12 @@ gimp_text_layout_position (GimpTextLayout *layout)
|
||||
|
||||
switch (text->gravity)
|
||||
{
|
||||
case GIMP_GRAVITY_NONE:
|
||||
case GIMP_GRAVITY_NORTH:
|
||||
case GIMP_GRAVITY_NORTH_WEST:
|
||||
case GIMP_GRAVITY_NORTH_EAST:
|
||||
break;
|
||||
|
||||
case GIMP_GRAVITY_NONE:
|
||||
case GIMP_GRAVITY_CENTER:
|
||||
case GIMP_GRAVITY_WEST:
|
||||
case GIMP_GRAVITY_EAST:
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "gimpenummenu.h"
|
||||
@ -423,6 +425,7 @@ gimp_enum_radio_box_new_with_range (GType enum_type,
|
||||
return vbox;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gimp_enum_radio_frame_new:
|
||||
* @enum_type: the #GType of an enum.
|
||||
@ -509,3 +512,112 @@ gimp_enum_radio_frame_new_with_range (GType enum_type,
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gimp_enum_stock_box_new:
|
||||
* @enum_type: the #GType of an enum.
|
||||
* @stock_prefix: the prefix of the group of stock ids to use.
|
||||
* @callback: a callback to connect to the "toggled" signal of each
|
||||
* #GtkRadioButton that is created.
|
||||
* @callback_data: data to pass to the @callback.
|
||||
* @first_button: returns the first button in the created group.
|
||||
*
|
||||
* Creates a horizontal box of radio buttons with stock icons. The
|
||||
* stock_id for each icon is created by appending the enum_value's
|
||||
* nick to the given @stock_prefix.
|
||||
*
|
||||
* Return value: a new #GtkHbox holding a group of #GtkRadioButtons.
|
||||
**/
|
||||
GtkWidget *
|
||||
gimp_enum_stock_box_new (GType enum_type,
|
||||
const gchar *stock_prefix,
|
||||
GCallback callback,
|
||||
gpointer callback_data,
|
||||
GtkWidget **first_button)
|
||||
{
|
||||
GEnumClass *enum_class;
|
||||
GtkWidget *box;
|
||||
|
||||
g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
|
||||
|
||||
enum_class = g_type_class_ref (enum_type);
|
||||
|
||||
box = gimp_enum_stock_box_new_with_range (enum_type,
|
||||
enum_class->minimum,
|
||||
enum_class->maximum,
|
||||
stock_prefix,
|
||||
callback, callback_data,
|
||||
first_button);
|
||||
|
||||
g_type_class_unref (enum_class);
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_enum_stock_box_new_with_range (GType enum_type,
|
||||
gint minimum,
|
||||
gint maximum,
|
||||
const gchar *stock_prefix,
|
||||
GCallback callback,
|
||||
gpointer callback_data,
|
||||
GtkWidget **first_button)
|
||||
{
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *button;
|
||||
GtkWidget *image;
|
||||
GEnumClass *enum_class;
|
||||
GEnumValue *value;
|
||||
gchar *stock_id;
|
||||
GSList *group = NULL;
|
||||
|
||||
g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
|
||||
g_return_val_if_fail (stock_prefix != NULL, NULL);
|
||||
|
||||
enum_class = g_type_class_ref (enum_type);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 1);
|
||||
g_object_weak_ref (G_OBJECT (hbox),
|
||||
(GWeakNotify) g_type_class_unref, enum_class);
|
||||
|
||||
if (first_button)
|
||||
*first_button = NULL;
|
||||
|
||||
for (value = enum_class->values; value->value_name; value++)
|
||||
{
|
||||
if (value->value < minimum || value->value > maximum)
|
||||
continue;
|
||||
|
||||
button = gtk_radio_button_new (group);
|
||||
|
||||
if (first_button && *first_button == NULL)
|
||||
*first_button = button;
|
||||
|
||||
stock_id = g_strconcat (stock_prefix, "-", value->value_nick, NULL);
|
||||
image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
|
||||
|
||||
if (image)
|
||||
{
|
||||
gtk_container_add (GTK_CONTAINER (button), image);
|
||||
gtk_widget_show (image);
|
||||
}
|
||||
|
||||
if (value->value_name)
|
||||
gimp_help_set_help_data (button, value->value_name, NULL);
|
||||
|
||||
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
g_object_set_data (G_OBJECT (button), "gimp-item-data",
|
||||
GINT_TO_POINTER (value->value));
|
||||
|
||||
if (callback)
|
||||
g_signal_connect (button, "toggled",
|
||||
callback,
|
||||
callback_data);
|
||||
}
|
||||
|
||||
return hbox;
|
||||
}
|
||||
|
@ -115,5 +115,18 @@ GtkWidget * gimp_enum_radio_frame_new_with_range (GType enum_type,
|
||||
gpointer callback_data,
|
||||
GtkWidget **first_button);
|
||||
|
||||
GtkWidget * gimp_enum_stock_box_new (GType enum_type,
|
||||
const gchar *stock_prefix,
|
||||
GCallback callback,
|
||||
gpointer callback_data,
|
||||
GtkWidget **first_button);
|
||||
GtkWidget * gimp_enum_stock_box_new_with_range (GType enum_type,
|
||||
gint minimum,
|
||||
gint maximum,
|
||||
const gchar *stock_prefix,
|
||||
GCallback callback,
|
||||
gpointer callback_data,
|
||||
GtkWidget **first_button);
|
||||
|
||||
|
||||
#endif /* __GIMP_ENUM_MENU_H__ */
|
||||
|
@ -152,11 +152,11 @@ gimp_prop_check_button_notify (GObject *config,
|
||||
/* option menus */
|
||||
/******************/
|
||||
|
||||
static void gimp_prop_option_menu_callback (GtkWidget *widget,
|
||||
GObject *config);
|
||||
static void gimp_prop_option_menu_notify (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GtkWidget *menu);
|
||||
static void gimp_prop_option_menu_callback (GtkWidget *widget,
|
||||
GObject *config);
|
||||
static void gimp_prop_option_menu_notify (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GtkWidget *menu);
|
||||
|
||||
GtkWidget *
|
||||
gimp_prop_boolean_option_menu_new (GObject *config,
|
||||
@ -289,6 +289,103 @@ gimp_prop_option_menu_notify (GObject *config,
|
||||
}
|
||||
|
||||
|
||||
/*********************/
|
||||
/* stock radio box */
|
||||
/*********************/
|
||||
|
||||
static void gimp_prop_radio_button_callback (GtkWidget *widget,
|
||||
GObject *config);
|
||||
static void gimp_prop_radio_button_notify (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GtkWidget *button);
|
||||
|
||||
|
||||
GtkWidget *
|
||||
gimp_prop_enum_stock_box_new (GObject *config,
|
||||
const gchar *property_name,
|
||||
const gchar *stock_prefix,
|
||||
gint minimum,
|
||||
gint maximum)
|
||||
{
|
||||
GParamSpec *param_spec;
|
||||
GtkWidget *box;
|
||||
GtkWidget *button;
|
||||
gint value;
|
||||
|
||||
param_spec = check_param_spec (config, property_name,
|
||||
G_TYPE_PARAM_ENUM, G_STRLOC);
|
||||
if (! param_spec)
|
||||
return NULL;
|
||||
|
||||
g_object_get (config,
|
||||
property_name, &value,
|
||||
NULL);
|
||||
|
||||
if (minimum != maximum)
|
||||
{
|
||||
box = gimp_enum_stock_box_new_with_range (param_spec->value_type,
|
||||
minimum, maximum,
|
||||
stock_prefix,
|
||||
G_CALLBACK (gimp_prop_radio_button_callback),
|
||||
config,
|
||||
&button);
|
||||
}
|
||||
else
|
||||
{
|
||||
box = gimp_enum_stock_box_new (param_spec->value_type,
|
||||
stock_prefix,
|
||||
G_CALLBACK (gimp_prop_radio_button_callback),
|
||||
config,
|
||||
&button);
|
||||
}
|
||||
|
||||
gimp_radio_group_set_active (GTK_RADIO_BUTTON (button),
|
||||
GINT_TO_POINTER (value));
|
||||
|
||||
set_param_spec (G_OBJECT (box), NULL, param_spec);
|
||||
|
||||
connect_notify (config, property_name,
|
||||
G_CALLBACK (gimp_prop_radio_button_notify),
|
||||
button);
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_prop_radio_button_callback (GtkWidget *widget,
|
||||
GObject *config)
|
||||
{
|
||||
GParamSpec *param_spec;
|
||||
gint value;
|
||||
|
||||
param_spec = get_param_spec (G_OBJECT (widget->parent));
|
||||
if (! param_spec)
|
||||
return;
|
||||
|
||||
value = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
|
||||
"gimp-item-data"));
|
||||
|
||||
g_object_set (config,
|
||||
param_spec->name, value,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_prop_radio_button_notify (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GtkWidget *button)
|
||||
{
|
||||
gint value;
|
||||
|
||||
g_object_get (config,
|
||||
param_spec->name, &value,
|
||||
NULL);
|
||||
|
||||
gimp_radio_group_set_active (GTK_RADIO_BUTTON (button),
|
||||
GINT_TO_POINTER (value));
|
||||
}
|
||||
|
||||
|
||||
/*****************/
|
||||
/* adjustments */
|
||||
/*****************/
|
||||
|
@ -41,6 +41,12 @@ GtkWidget * gimp_prop_enum_option_menu_new (GObject *config,
|
||||
gint minimum,
|
||||
gint maximum);
|
||||
|
||||
GtkWidget * gimp_prop_enum_stock_box_new (GObject *config,
|
||||
const gchar *property_name,
|
||||
const gchar *stock_prefix,
|
||||
gint minimum,
|
||||
gint maximum);
|
||||
|
||||
|
||||
/* GParamInt, GParamUInt, GParamLong, GParamULong, GParamDouble */
|
||||
|
||||
|
@ -152,11 +152,11 @@ gimp_prop_check_button_notify (GObject *config,
|
||||
/* option menus */
|
||||
/******************/
|
||||
|
||||
static void gimp_prop_option_menu_callback (GtkWidget *widget,
|
||||
GObject *config);
|
||||
static void gimp_prop_option_menu_notify (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GtkWidget *menu);
|
||||
static void gimp_prop_option_menu_callback (GtkWidget *widget,
|
||||
GObject *config);
|
||||
static void gimp_prop_option_menu_notify (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GtkWidget *menu);
|
||||
|
||||
GtkWidget *
|
||||
gimp_prop_boolean_option_menu_new (GObject *config,
|
||||
@ -289,6 +289,103 @@ gimp_prop_option_menu_notify (GObject *config,
|
||||
}
|
||||
|
||||
|
||||
/*********************/
|
||||
/* stock radio box */
|
||||
/*********************/
|
||||
|
||||
static void gimp_prop_radio_button_callback (GtkWidget *widget,
|
||||
GObject *config);
|
||||
static void gimp_prop_radio_button_notify (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GtkWidget *button);
|
||||
|
||||
|
||||
GtkWidget *
|
||||
gimp_prop_enum_stock_box_new (GObject *config,
|
||||
const gchar *property_name,
|
||||
const gchar *stock_prefix,
|
||||
gint minimum,
|
||||
gint maximum)
|
||||
{
|
||||
GParamSpec *param_spec;
|
||||
GtkWidget *box;
|
||||
GtkWidget *button;
|
||||
gint value;
|
||||
|
||||
param_spec = check_param_spec (config, property_name,
|
||||
G_TYPE_PARAM_ENUM, G_STRLOC);
|
||||
if (! param_spec)
|
||||
return NULL;
|
||||
|
||||
g_object_get (config,
|
||||
property_name, &value,
|
||||
NULL);
|
||||
|
||||
if (minimum != maximum)
|
||||
{
|
||||
box = gimp_enum_stock_box_new_with_range (param_spec->value_type,
|
||||
minimum, maximum,
|
||||
stock_prefix,
|
||||
G_CALLBACK (gimp_prop_radio_button_callback),
|
||||
config,
|
||||
&button);
|
||||
}
|
||||
else
|
||||
{
|
||||
box = gimp_enum_stock_box_new (param_spec->value_type,
|
||||
stock_prefix,
|
||||
G_CALLBACK (gimp_prop_radio_button_callback),
|
||||
config,
|
||||
&button);
|
||||
}
|
||||
|
||||
gimp_radio_group_set_active (GTK_RADIO_BUTTON (button),
|
||||
GINT_TO_POINTER (value));
|
||||
|
||||
set_param_spec (G_OBJECT (box), NULL, param_spec);
|
||||
|
||||
connect_notify (config, property_name,
|
||||
G_CALLBACK (gimp_prop_radio_button_notify),
|
||||
button);
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_prop_radio_button_callback (GtkWidget *widget,
|
||||
GObject *config)
|
||||
{
|
||||
GParamSpec *param_spec;
|
||||
gint value;
|
||||
|
||||
param_spec = get_param_spec (G_OBJECT (widget->parent));
|
||||
if (! param_spec)
|
||||
return;
|
||||
|
||||
value = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
|
||||
"gimp-item-data"));
|
||||
|
||||
g_object_set (config,
|
||||
param_spec->name, value,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_prop_radio_button_notify (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GtkWidget *button)
|
||||
{
|
||||
gint value;
|
||||
|
||||
g_object_get (config,
|
||||
param_spec->name, &value,
|
||||
NULL);
|
||||
|
||||
gimp_radio_group_set_active (GTK_RADIO_BUTTON (button),
|
||||
GINT_TO_POINTER (value));
|
||||
}
|
||||
|
||||
|
||||
/*****************/
|
||||
/* adjustments */
|
||||
/*****************/
|
||||
|
@ -41,6 +41,12 @@ GtkWidget * gimp_prop_enum_option_menu_new (GObject *config,
|
||||
gint minimum,
|
||||
gint maximum);
|
||||
|
||||
GtkWidget * gimp_prop_enum_stock_box_new (GObject *config,
|
||||
const gchar *property_name,
|
||||
const gchar *stock_prefix,
|
||||
gint minimum,
|
||||
gint maximum);
|
||||
|
||||
|
||||
/* GParamInt, GParamUInt, GParamLong, GParamULong, GParamDouble */
|
||||
|
||||
|
@ -143,6 +143,7 @@ app/plug-in/plug-in-rc.c
|
||||
app/plug-in/plug-ins.c
|
||||
|
||||
app/text/text-enums.c
|
||||
app/text/gimptext.c
|
||||
|
||||
app/tools/gimpairbrushtool.c
|
||||
app/tools/gimpbezierselecttool.c
|
||||
|
Reference in New Issue
Block a user