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

added dependency on PangoFT2 (Pango compiled with FreeType2 support).

2001-08-11  Sven Neumann  <sven@gimp.org>

	* configure.in: added dependency on PangoFT2 (Pango compiled with
	FreeType2 support).

	* app/Makefile.am: link against PangoFT2.

	* app/tools/Makefile.am
	* app/tools/gimptexttool.[ch]: rudimentary new text tool. Still needs
	lots of work.

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h:
	* app/widgets/gimpfontselection-dialog.[ch]
	* app/widgets/gimpfontselection.[ch]: added font selection widgets.

	* libgimpwidgets/Makefile.am
	* libgimpwidgets/gimpwidgetstypes.h
	* libgimpwidgets/gimpfontselection.[ch]: removed font selection code
	from here since the fonts need to be selected from the core's
	PangoContext. Will add PDB-controlled font selection later.
parent 357f463d
2001-08-11 Sven Neumann <sven@gimp.org>
* configure.in: added dependency on PangoFT2 (Pango compiled with
FreeType2 support).
* app/Makefile.am: link against PangoFT2.
* app/tools/Makefile.am
* app/tools/gimptexttool.[ch]: rudimentary new text tool. Still needs
lots of work.
* app/widgets/Makefile.am
* app/widgets/widgets-types.h:
* app/widgets/gimpfontselection-dialog.[ch]
* app/widgets/gimpfontselection.[ch]: added font selection widgets.
* libgimpwidgets/Makefile.am
* libgimpwidgets/gimpwidgetstypes.h
* libgimpwidgets/gimpfontselection.[ch]: removed font selection code
from here since the fonts need to be selected from the core's
PangoContext. Will add PDB-controlled font selection later.
2001-08-11 Michael Natterer <mitch@gimp.org>
* TODO.xml: added a TODO entry about additional image/file info.
......@@ -43,13 +65,8 @@
* app/widgets/gimpdnd.[ch]: make it DND-able.
<<<<<<< ChangeLog
* app/widgets/gimppreview.c: fix preview rendering correctly this
time.
=======
* app/widgets/gimppreview.c: fix preview rendering correctly this
time.
>>>>>>> 1.3709
2001-08-10 Sven Neumann <sven@gimp.org>
......
......@@ -164,6 +164,7 @@ gimp_LDADD = @STRIP_BEGIN@ \
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
$(top_builddir)/libgimpwidgets/libgimpwidgets-$(LT_RELEASE).la \
$(GTK_LIBS) \
$(PANGOFT2_LIBS) \
$(GIMP_THREAD_LIBS) \
$(GIMP_MP_LIBS) \
$(INTLLIBS) \
......
......@@ -128,6 +128,7 @@ INCLUDES = @STRIP_BEGIN@ \
-I$(top_srcdir) \
-I$(top_srcdir)/app \
$(GTK_CFLAGS) \
$(PANGOFT2_CFLAGS) \
-I$(includedir) \
@STRIP_END@
......
......@@ -20,65 +20,41 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <pango/pangoft2.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif
#include <gdk/gdkprivate.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
#include "paint-funcs/paint-funcs.h"
#include "base/base-types.h"
#include "base/pixel-region.h"
#include "base/tile-manager.h"
#include "base/tile-manager-crop.h"
#include "base/tile.h"
#include "paint-funcs/paint-funcs.h"
#include "core/gimpchannel.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "core/gimplayer.h"
#include "widgets/gimpwidgets-utils.h"
#include "widgets/gimpfontselection.h"
#include "gimpeditselectiontool.h"
#include "gimptexttool.h"
#include "gimptool.h"
#include "tool_manager.h"
#include "tool_options.h"
#include "app_procs.h"
#include "errors.h"
#include "floating_sel.h"
#include "gdisplay.h"
#include "plug_in.h"
#include "floating_sel.h"
#include "undo_types.h"
#include "undo.h"
#include "libgimp/gimpintl.h"
#define FOUNDRY 0
#define FAMILY 1
#define WEIGHT 2
#define SLANT 3
#define SET_WIDTH 4
#define PIXEL_SIZE 6
#define POINT_SIZE 7
#define XRESOLUTION 8
#define YRESOLUTION 9
#define SPACING 10
#define REGISTRY 12
#define ENCODING 13
#define DEFAULT_FONT "sans Normal"
/* the text tool structures */
......@@ -88,25 +64,14 @@ typedef struct _TextOptions TextOptions;
struct _TextOptions
{
GimpToolOptions tool_options;
gboolean antialias;
gboolean antialias_d;
GtkWidget *antialias_w;
gint border;
gint border_d;
GtkObject *border_w;
gboolean use_dyntext;
gboolean use_dyntext_d;
GtkWidget *use_dyntext_w;
GtkWidget *font_selection;
};
static void gimp_text_tool_class_init (GimpTextToolClass *klass);
static void gimp_text_tool_init (GimpTextTool *tool);
static void gimp_text_tool_destroy (GtkObject *object);
static void gimp_text_tool_finalize (GObject *object);
static void text_tool_control (GimpTool *tool,
ToolAction tool_action,
......@@ -120,35 +85,15 @@ static void text_tool_button_release (GimpTool *tool,
static void text_tool_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp);
static void text_tool_render (GimpTextTool *text_tool);
static TextOptions * text_tool_options_new (void);
static TextOptions * text_tool_options_new (GimpTextTool *text_tool);
static void text_tool_options_reset (GimpToolOptions *tool_options);
static void text_dialog_create (void);
static void text_dialog_ok_callback (GtkWidget *widget,
gpointer data);
static void text_dialog_cancel_callback (GtkWidget *widget,
gpointer data);
static gint text_dialog_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void text_init_render (GimpTextTool *text_tool);
static void text_gdk_image_to_region (GdkImage *image,
gint ,
PixelRegion *);
static void text_size_multiply (gchar **fontname,
gint size);
static void text_set_resolution (gchar **fontname,
gdouble xres,
gdouble yres);
/* local variables */
static TextOptions *text_tool_options = NULL;
static GtkWidget *text_tool_shell = NULL;
static GimpToolClass *parent_class = NULL;
......@@ -168,26 +113,28 @@ gimp_text_tool_register (Gimp *gimp)
GIMP_STOCK_TOOL_TEXT);
}
GtkType
GType
gimp_text_tool_get_type (void)
{
static GtkType tool_type = 0;
static GType tool_type = 0;
if (! tool_type)
{
GtkTypeInfo tool_info =
static const GTypeInfo tool_info =
{
"GimpTextTool",
sizeof (GimpTextToolClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_text_tool_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpTextTool),
sizeof (GimpTextToolClass),
(GtkClassInitFunc) gimp_text_tool_class_init,
(GtkObjectInitFunc) gimp_text_tool_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
0, /* n_preallocs */
(GInstanceInitFunc) gimp_text_tool_init,
};
tool_type = gtk_type_unique (GIMP_TYPE_TOOL, &tool_info);
tool_type = g_type_register_static (GIMP_TYPE_TOOL, "GimpTextTool",
&tool_info, 0);
}
return tool_type;
......@@ -196,15 +143,17 @@ gimp_text_tool_get_type (void)
static void
gimp_text_tool_class_init (GimpTextToolClass *klass)
{
GtkObjectClass *object_class;
GimpToolClass *tool_class;
GObjectClass *object_class;
GimpToolClass *tool_class;
object_class = (GtkObjectClass *) klass;
tool_class = (GimpToolClass *) klass;
object_class = G_OBJECT_CLASS (klass);
tool_class = GIMP_TOOL_CLASS (klass);
parent_class = gtk_type_class (GIMP_TYPE_TOOL);
object_class->destroy = gimp_text_tool_destroy;
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_text_tool_finalize;
tool_class->control = text_tool_control;
tool_class->button_press = text_tool_button_press;
......@@ -219,28 +168,36 @@ gimp_text_tool_init (GimpTextTool *text_tool)
tool = GIMP_TOOL (text_tool);
text_tool->pango_context = pango_ft2_get_context ();
/* The tool options */
if (! text_tool_options)
{
text_tool_options = text_tool_options_new ();
text_tool_options = text_tool_options_new (text_tool);
tool_manager_register_tool_options (GIMP_TYPE_TEXT_TOOL,
(GimpToolOptions *) text_tool_options);
}
tool->tool_cursor = GIMP_TEXT_TOOL_CURSOR;
tool->scroll_lock = TRUE; /* Disallow scrolling */
}
static void
gimp_text_tool_destroy (GtkObject *object)
gimp_text_tool_finalize (GObject *object)
{
if (text_tool_shell)
gimp_dialog_hide (text_tool_shell);
GimpTextTool *text_tool;
text_tool = GIMP_TEXT_TOOL (object);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
if (text_tool->pango_context)
{
g_object_unref (text_tool->pango_context);
text_tool->pango_context = NULL;
}
if (G_OBJECT_CLASS (parent_class)->finalize)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
......@@ -249,127 +206,29 @@ text_tool_options_reset (GimpToolOptions *tool_options)
TextOptions *options;
options = (TextOptions *) tool_options;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->antialias_w),
options->antialias_d);
gtk_adjustment_set_value (GTK_ADJUSTMENT (options->border_w),
options->border_d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->use_dyntext_w),
options->use_dyntext_d);
}
static TextOptions *
text_tool_options_new (void)
text_tool_options_new (GimpTextTool *text_tool)
{
TextOptions *options;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *spinbutton;
GtkWidget *sep;
options = g_new0 (TextOptions, 1);
tool_options_init ((GimpToolOptions *) options,
text_tool_options_reset);
options->antialias = options->antialias_d = TRUE;
options->border = options->border_d = 0;
options->use_dyntext = options->use_dyntext_d = FALSE;
tool_options_init ((GimpToolOptions *) options, text_tool_options_reset);
/* the main vbox */
vbox = options->tool_options.main_vbox;
/* antialias toggle */
options->antialias_w =
gtk_check_button_new_with_label (_("Antialiasing"));
g_signal_connect (G_OBJECT (options->antialias_w), "toggled",
G_CALLBACK (gimp_toggle_button_update),
&options->antialias);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->antialias_w),
options->antialias_d);
gtk_box_pack_start (GTK_BOX (vbox), options->antialias_w,
FALSE, FALSE, 0);
gtk_widget_show (options->antialias_w);
/* the border spinbutton */
hbox = gtk_hbox_new (FALSE, 4);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
label = gtk_label_new (_("Border:"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
options->border_w =
gtk_adjustment_new (options->border_d, 0.0, 32767.0, 1.0, 50.0, 0.0);
g_signal_connect (G_OBJECT (options->border_w), "value_changed",
G_CALLBACK (gimp_int_adjustment_update),
&options->border);
spinbutton =
gtk_spin_button_new (GTK_ADJUSTMENT (options->border_w), 1.0, 0.0);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
gtk_widget_set_usize (spinbutton, 75, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
gtk_widget_show (spinbutton);
gtk_widget_show (hbox);
sep = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 0);
gtk_widget_show (sep);
/* the dynamic text toggle */
options->use_dyntext_w =
gtk_check_button_new_with_label (_("Use Dynamic Text"));
g_signal_connect (G_OBJECT (options->use_dyntext_w), "toggled",
G_CALLBACK (gimp_toggle_button_update),
&options->use_dyntext);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->use_dyntext_w),
options->use_dyntext_d);
gtk_box_pack_start (GTK_BOX (vbox), options->use_dyntext_w,
FALSE, FALSE, 0);
gtk_widget_show (options->use_dyntext_w);
/* let the toggle callback set the sensitive states */
gtk_widget_set_sensitive (options->antialias_w, ! options->use_dyntext_d);
gtk_widget_set_sensitive (spinbutton, ! options->use_dyntext_d);
gtk_widget_set_sensitive (label, ! options->use_dyntext_d);
g_object_set_data (G_OBJECT (options->use_dyntext_w), "inverse_sensitive",
spinbutton);
g_object_set_data (G_OBJECT (spinbutton), "inverse_sensitive", label);
g_object_set_data (G_OBJECT (label), "inverse_sensitive",
options->antialias_w);
options->font_selection = gimp_font_selection_new (text_tool->pango_context);
gimp_font_selection_set_fontname (GIMP_FONT_SELECTION (options->font_selection), DEFAULT_FONT);
gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (options->font_selection),
FALSE, FALSE, 0);
gtk_widget_show (options->font_selection);
return options;
}
static void
text_call_gdyntext (GDisplay *gdisp)
{
ProcRecord *proc_rec;
Argument *args;
/* find the gDynText PDB record */
if ((proc_rec = procedural_db_lookup (gdisp->gimage->gimp,
"plug_in_dynamic_text")) == NULL)
{
g_message ("text_call_gdyntext: gDynText procedure lookup failed");
return;
}
/* plug-in arguments as if called by <Image>/Filters/... */
args = g_new (Argument, 3);
args[0].arg_type = GIMP_PDB_INT32;
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].arg_type = GIMP_PDB_IMAGE;
args[1].value.pdb_int = (gint32) gimp_image_get_ID (gdisp->gimage);
args[2].arg_type = GIMP_PDB_DRAWABLE;
args[2].value.pdb_int = (gint32) gimp_drawable_get_ID (gimp_image_active_drawable (gdisp->gimage));
plug_in_run (proc_rec, args, 3, FALSE, TRUE, gdisp->ID);
g_free (args);
}
static void
text_tool_control (GimpTool *tool,
ToolAction action,
......@@ -384,8 +243,6 @@ text_tool_control (GimpTool *tool,
break;
case HALT:
if (text_tool_shell)
gimp_dialog_hide (text_tool_shell);
break;
default:
......@@ -399,7 +256,6 @@ text_tool_button_press (GimpTool *tool,
GDisplay *gdisp)
{
GimpTextTool *text_tool;
GimpLayer *layer;
text_tool = GIMP_TEXT_TOOL (tool);
......@@ -411,29 +267,6 @@ text_tool_button_press (GimpTool *tool,
gdisplay_untransform_coords (gdisp, bevent->x, bevent->y,
&text_tool->click_x, &text_tool->click_y,
TRUE, 0);
if ((layer = gimp_image_pick_correlate_layer (gdisp->gimage,
text_tool->click_x,
text_tool->click_y)))
/* If there is a floating selection, and this aint it, use the move tool */
if (gimp_layer_is_floating_sel (layer))
{
init_edit_selection (tool, gdisp, bevent, EDIT_LAYER_TRANSLATE);
return;
}
if (text_tool_options->use_dyntext)
{
text_call_gdyntext (gdisp);
return;
}
if (! text_tool_shell)
text_dialog_create ();
if (! GTK_WIDGET_VISIBLE (text_tool_shell))
gtk_widget_show (text_tool_shell);
}
static void
......@@ -441,6 +274,8 @@ text_tool_button_release (GimpTool *tool,
GdkEventButton *bevent,
GDisplay *gdisp)
{
text_tool_render (GIMP_TEXT_TOOL (tool));
tool->state = INACTIVE;
}
......@@ -449,23 +284,6 @@ text_tool_cursor_update (GimpTool *tool,
GdkEventMotion *mevent,
GDisplay *gdisp)
{
GimpLayer *layer;
gint x, y;
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
&x, &y, FALSE, FALSE);
if ((layer = gimp_image_pick_correlate_layer (gdisp->gimage, x, y)))
/* if there is a floating selection, and this aint it... */
if (gimp_layer_is_floating_sel (layer))
{
gdisplay_install_tool_cursor (gdisp,
GDK_FLEUR,
GIMP_MOVE_TOOL_CURSOR,
GIMP_CURSOR_MODIFIER_NONE);
return;
}
gdisplay_install_tool_cursor (gdisp,
GDK_XTERM,
GIMP_TEXT_TOOL_CURSOR,
......@@ -473,165 +291,30 @@ text_tool_cursor_update (GimpTool *tool,
}
static void
text_dialog_create (void)
{
text_tool_shell = gtk_font_selection_dialog_new (_("Text Tool"));
gtk_window_set_wmclass (GTK_WINDOW (text_tool_shell), "text_tool", "Gimp");
gtk_window_set_policy (GTK_WINDOW (text_tool_shell), FALSE, TRUE, FALSE);
gtk_window_set_position (GTK_WINDOW (text_tool_shell), GTK_WIN_POS_MOUSE);
/* handle the wm close signal */
g_signal_connect (G_OBJECT (text_tool_shell), "delete_event",
G_CALLBACK (text_dialog_delete_callback),
text_tool_shell);
/* ok and cancel buttons */
g_signal_connect (G_OBJECT (GTK_FONT_SELECTION_DIALOG
(text_tool_shell)->ok_button), "clicked",
G_CALLBACK (text_dialog_ok_callback),
text_tool_shell);
g_signal_connect (G_OBJECT (GTK_FONT_SELECTION_DIALOG
(text_tool_shell)->cancel_button), "clicked",
G_CALLBACK (text_dialog_cancel_callback),
text_tool_shell);
/* Show the shell */
gtk_widget_show (text_tool_shell);
}
static void
text_dialog_ok_callback (GtkWidget *widget,
gpointer data)
{
GimpTool *active_tool;
gimp_dialog_hide (data);
active_tool = tool_manager_get_active (the_gimp);
if (active_tool && GIMP_IS_TEXT_TOOL (active_tool))
{
text_init_render (GIMP_TEXT_TOOL (active_tool));
}
}
static gint
text_dialog_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
text_dialog_cancel_callback (widget, data);
return TRUE;
}
static void
text_dialog_cancel_callback (GtkWidget *widget,
gpointer data)
text_tool_render (GimpTextTool *text_tool)
{
gimp_dialog_hide (GTK_WIDGET (data));
}
static void
text_init_render (GimpTextTool *text_tool)
{
GDisplay *gdisp;
gchar *fontname;
gchar *text;
gboolean antialias = text_tool_options->antialias;
fontname = gtk_font_selection_dialog_get_font_name
(GTK_FONT_SELECTION_DIALOG (text_tool_shell));
if (! fontname)
return;
GDisplay *gdisp;
PangoFontDescription *font_desc;
gchar *fontname;
gchar *text;
gdisp = text_tool->gdisp;
font_desc = gimp_font_selection_get_font_desc (GIMP_FONT_SELECTION (text_tool_options->font_selection));
font_desc->size = PANGO_SCALE * 60; /* FIXME */
fontname = pango_font_description_to_string (font_desc);
pango_font_description_free (font_desc);
/* override the user's antialias setting if this is an indexed image */
if (gimp_image_base_type (gdisp->gimage) == INDEXED)
antialias = FALSE;
/* If we're anti-aliasing, request a larger font than user specified.
* This will probably produce a font which isn't available if fonts
* are not scalable on this particular X server. TODO: Ideally, should
* grey out anti-alias on these kinds of servers. */
if (antialias)
text_size_multiply (&fontname, SUPERSAMPLE);
/* If the text size is specified in points, it's size will be scaled
* correctly according to the image's resolution.
* FIXME: this currently can't be activated for the PDB, as the text has
* to be rendered in the size "text_get_extents" returns.
* TODO: add resolution parameters to "text_get_extents"
*/
text_set_resolution (&fontname,
gdisp->gimage->xresolution,
gdisp->gimage->yresolution);
text = gtk_font_selection_dialog_get_preview_text
(GTK_FONT_SELECTION_DIALOG (text_tool_shell));
/* strdup it since the render function strtok()s the text */
text = g_strdup (text);
text = "gimp"; /* FIXME */
text_render (gdisp->gimage, gimp_image_active_drawable (gdisp->gimage),
text_tool->click_x, text_tool->click_y,
fontname, text, text_tool_options->border, antialias);
gdisplays_flush ();
fontname, text, 0 /*border*/, TRUE /* antialias */);
g_free (fontname);
g_free (text);
}
static void
text_gdk_image_to_region (GdkImage *image,
gint scale,
PixelRegion *textPR)
{
GdkColor black;
gint black_pixel;
gint pixel;
gint value;
gint scalex, scaley;