2003-02-05 22:39:40 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "tools-types.h"
|
|
|
|
|
|
|
|
#include "config/gimpconfig.h"
|
2003-02-27 04:34:58 +08:00
|
|
|
#include "config/gimpconfig-deserialize.h"
|
|
|
|
#include "config/gimpconfig-serialize.h"
|
2003-02-05 22:39:40 +08:00
|
|
|
|
|
|
|
#include "core/gimptoolinfo.h"
|
|
|
|
|
|
|
|
#include "text/gimptext.h"
|
|
|
|
|
2003-02-06 02:23:58 +08:00
|
|
|
#include "widgets/gimpcolorpanel.h"
|
2003-02-05 22:39:40 +08:00
|
|
|
#include "widgets/gimpfontselection.h"
|
|
|
|
#include "widgets/gimppropwidgets.h"
|
|
|
|
#include "widgets/gimptexteditor.h"
|
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
|
|
|
|
|
|
|
#include "gimptextoptions.h"
|
|
|
|
|
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
|
|
|
|
2003-02-27 04:34:58 +08:00
|
|
|
static void gimp_text_options_init (GimpTextOptions *options);
|
|
|
|
static void gimp_text_options_class_init (GimpTextOptionsClass *options_class);
|
|
|
|
static void gimp_text_options_config_iface_init (GimpConfigInterface *config_iface);
|
2003-02-05 22:39:40 +08:00
|
|
|
|
2003-02-27 04:34:58 +08:00
|
|
|
static void gimp_text_options_reset (GimpToolOptions *tool_options);
|
|
|
|
|
|
|
|
static gboolean gimp_text_options_serialize (GObject *object,
|
|
|
|
gint fd,
|
|
|
|
gint indent_level,
|
|
|
|
gpointer data);
|
|
|
|
static gboolean gimp_text_options_deserialize (GObject *object,
|
|
|
|
GScanner *scanner,
|
|
|
|
gint nest_level,
|
|
|
|
gpointer data);
|
2003-02-05 22:39:40 +08:00
|
|
|
|
|
|
|
|
2003-02-08 01:12:21 +08:00
|
|
|
static GimpToolOptionsClass *parent_class = NULL;
|
|
|
|
|
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
GType
|
|
|
|
gimp_text_options_get_type (void)
|
|
|
|
{
|
|
|
|
static GType type = 0;
|
|
|
|
|
|
|
|
if (! type)
|
|
|
|
{
|
|
|
|
static const GTypeInfo info =
|
|
|
|
{
|
|
|
|
sizeof (GimpTextOptionsClass),
|
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_text_options_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpTextOptions),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_text_options_init,
|
|
|
|
};
|
2003-02-27 04:34:58 +08:00
|
|
|
static const GInterfaceInfo config_iface_info =
|
|
|
|
{
|
|
|
|
(GInterfaceInitFunc) gimp_text_options_config_iface_init,
|
|
|
|
NULL, /* iface_finalize */
|
|
|
|
NULL /* iface_data */
|
|
|
|
};
|
2003-02-05 22:39:40 +08:00
|
|
|
|
|
|
|
type = g_type_register_static (GIMP_TYPE_TOOL_OPTIONS,
|
|
|
|
"GimpTextOptions",
|
|
|
|
&info, 0);
|
2003-02-27 04:34:58 +08:00
|
|
|
|
|
|
|
g_type_add_interface_static (type,
|
|
|
|
GIMP_TYPE_CONFIG_INTERFACE,
|
|
|
|
&config_iface_info);
|
2003-02-05 22:39:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_text_options_class_init (GimpTextOptionsClass *klass)
|
|
|
|
{
|
2003-02-08 01:12:21 +08:00
|
|
|
GObjectClass *object_class;
|
|
|
|
GimpToolOptionsClass *options_class;
|
|
|
|
|
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
|
|
options_class = GIMP_TOOL_OPTIONS_CLASS (klass);
|
|
|
|
|
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
|
|
|
options_class->reset = gimp_text_options_reset;
|
2003-02-05 22:39:40 +08:00
|
|
|
}
|
|
|
|
|
2003-02-27 04:34:58 +08:00
|
|
|
static void
|
|
|
|
gimp_text_options_config_iface_init (GimpConfigInterface *config_iface)
|
|
|
|
{
|
|
|
|
config_iface->serialize = gimp_text_options_serialize;
|
|
|
|
config_iface->deserialize = gimp_text_options_deserialize;
|
|
|
|
}
|
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
static void
|
|
|
|
gimp_text_options_init (GimpTextOptions *options)
|
|
|
|
{
|
|
|
|
GObject *text;
|
|
|
|
|
|
|
|
text = g_object_new (GIMP_TYPE_TEXT, NULL);
|
|
|
|
|
|
|
|
options->text = GIMP_TEXT (text);
|
|
|
|
|
|
|
|
options->buffer = gimp_prop_text_buffer_new (text, "text", -1);
|
|
|
|
}
|
|
|
|
|
2003-02-27 04:34:58 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_text_options_serialize (GObject *object,
|
|
|
|
gint fd,
|
|
|
|
gint indent_level,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpTextOptions *options = GIMP_TEXT_OPTIONS (object);
|
|
|
|
|
|
|
|
return gimp_config_serialize_properties (G_OBJECT (options->text),
|
|
|
|
fd, indent_level);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_text_options_deserialize (GObject *object,
|
|
|
|
GScanner *scanner,
|
|
|
|
gint nest_level,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpTextOptions *options = GIMP_TEXT_OPTIONS (object);
|
|
|
|
|
|
|
|
return gimp_config_deserialize_properties (G_OBJECT (options->text),
|
|
|
|
scanner, nest_level, FALSE);
|
|
|
|
}
|
|
|
|
|
2003-02-08 01:12:21 +08:00
|
|
|
static void
|
|
|
|
gimp_text_options_reset (GimpToolOptions *tool_options)
|
|
|
|
{
|
|
|
|
GimpTextOptions *options = GIMP_TEXT_OPTIONS (tool_options);
|
|
|
|
|
|
|
|
gimp_config_reset (G_OBJECT (options->text));
|
|
|
|
|
|
|
|
GIMP_TOOL_OPTIONS_CLASS (parent_class)->reset (tool_options);
|
|
|
|
}
|
|
|
|
|
2003-02-10 01:32:52 +08:00
|
|
|
GtkWidget *
|
2003-02-05 22:39:40 +08:00
|
|
|
gimp_text_options_gui (GimpToolOptions *tool_options)
|
|
|
|
{
|
|
|
|
GimpTextOptions *options;
|
2003-02-21 08:42:53 +08:00
|
|
|
GObject *config;
|
2003-02-05 22:39:40 +08:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *button;
|
2003-02-21 08:42:53 +08:00
|
|
|
GtkWidget *menu;
|
2003-02-05 22:39:40 +08:00
|
|
|
GtkWidget *font_selection;
|
2003-02-06 02:23:58 +08:00
|
|
|
GtkWidget *box;
|
2003-02-05 22:39:40 +08:00
|
|
|
GtkWidget *spinbutton;
|
|
|
|
gint digits;
|
|
|
|
|
|
|
|
options = GIMP_TEXT_OPTIONS (tool_options);
|
2003-02-21 08:42:53 +08:00
|
|
|
config = G_OBJECT (options->text);
|
2003-02-05 22:39:40 +08:00
|
|
|
|
2003-02-10 01:32:52 +08:00
|
|
|
vbox = gimp_tool_options_gui (tool_options);
|
2003-02-05 22:39:40 +08:00
|
|
|
|
2003-02-21 08:42:53 +08:00
|
|
|
table = gtk_table_new (6, 3, FALSE);
|
2003-02-05 22:39:40 +08:00
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
2003-02-21 08:42:53 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
2003-02-05 22:39:40 +08:00
|
|
|
gtk_widget_show (table);
|
|
|
|
|
2003-02-21 08:42:53 +08:00
|
|
|
font_selection = gimp_prop_font_selection_new (config, "font");
|
2003-02-05 22:39:40 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
2003-02-09 08:22:42 +08:00
|
|
|
_("_Font:"), 1.0, 0.5,
|
2003-02-21 08:42:53 +08:00
|
|
|
font_selection, 2, FALSE);
|
2003-02-05 22:39:40 +08:00
|
|
|
|
|
|
|
digits = gimp_unit_get_digits (options->text->font_size_unit);
|
2003-02-21 08:42:53 +08:00
|
|
|
spinbutton = gimp_prop_spin_button_new (config, "font-size",
|
2003-02-05 22:39:40 +08:00
|
|
|
1.0, 10.0, digits);
|
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
2003-02-09 08:22:42 +08:00
|
|
|
_("_Size:"), 1.0, 0.5,
|
2003-02-21 08:42:53 +08:00
|
|
|
spinbutton, 1, FALSE);
|
2003-02-05 22:39:40 +08:00
|
|
|
|
2003-02-21 08:42:53 +08:00
|
|
|
menu = gimp_prop_unit_menu_new (config, "font-size-unit", "%a");
|
|
|
|
g_object_set_data (G_OBJECT (menu), "set_digits", spinbutton);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), menu, 2, 3, 1, 2,
|
2003-02-05 22:39:40 +08:00
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
2003-02-21 08:42:53 +08:00
|
|
|
gtk_widget_show (menu);
|
2003-02-05 22:39:40 +08:00
|
|
|
|
2003-02-21 08:42:53 +08:00
|
|
|
button = gimp_prop_color_button_new (config, "color",
|
|
|
|
_("Text Color"),
|
2003-02-06 06:15:39 +08:00
|
|
|
-1, 24, GIMP_COLOR_AREA_FLAT);
|
2003-02-06 02:23:58 +08:00
|
|
|
gimp_color_panel_set_context (GIMP_COLOR_PANEL (button),
|
|
|
|
GIMP_CONTEXT (options));
|
2003-02-05 22:39:40 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
|
2003-02-21 08:42:53 +08:00
|
|
|
_("Color:"), 1.0, 0.5,
|
|
|
|
button, 1, FALSE);
|
2003-02-05 22:39:40 +08:00
|
|
|
|
2003-02-21 08:42:53 +08:00
|
|
|
box = gimp_prop_enum_stock_box_new (config, "justify", "gtk-justify", 0, 0);
|
2003-02-06 02:23:58 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 3,
|
2003-02-21 08:42:53 +08:00
|
|
|
_("Justify:"), 1.0, 0.5,
|
|
|
|
box, 2, TRUE);
|
2003-02-06 02:23:58 +08:00
|
|
|
|
2003-02-21 08:42:53 +08:00
|
|
|
spinbutton = gimp_prop_spin_button_new (config, "indent", 1.0, 10.0, 1);
|
2003-02-05 22:39:40 +08:00
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 5);
|
2003-02-21 08:42:53 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 4,
|
|
|
|
_("Indent:"), 1.0, 0.5,
|
|
|
|
spinbutton, 1, FALSE);
|
2003-02-05 22:39:40 +08:00
|
|
|
|
2003-02-21 08:42:53 +08:00
|
|
|
spinbutton = gimp_prop_spin_button_new (config, "line-spacing", 1.0, 10.0, 1);
|
2003-02-05 22:39:40 +08:00
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 5);
|
2003-02-06 06:15:39 +08:00
|
|
|
gimp_table_attach_stock (GTK_TABLE (table), 5,
|
2003-02-21 08:42:53 +08:00
|
|
|
_("Line\nSpacing:"), 0.0,
|
|
|
|
spinbutton, 1, GIMP_STOCK_LINE_SPACING);
|
2003-02-10 01:32:52 +08:00
|
|
|
|
|
|
|
return vbox;
|
2003-02-05 22:39:40 +08:00
|
|
|
}
|