Commit c6009943 authored by Manish Singh's avatar Manish Singh
Browse files

New plugin, gdyntext

-Yosh
parent 3477483c
Thu Apr 15 14:08:51 PDT 1999 Manish Singh <yosh@gimp.org>
* configure.in
* plug-ins/gdyntext: new plugin
Thu Apr 15 21:20:45 BST 1999 Andy Thomas <alt@gimp.org>
Changed:-
......
......@@ -733,6 +733,7 @@ plug-ins/gap/iter_ALT/old/Makefile
plug-ins/gauss_iir/Makefile
plug-ins/gauss_rle/Makefile
plug-ins/gbr/Makefile
plug-ins/gdyntext/Makefile
plug-ins/gee/Makefile
plug-ins/gfig/Makefile
plug-ins/gfig/gfig-examples/Makefile
......
Apr 14 1999
* MADE 1.4.0 RELEASE
* Added customizable line spacing.
Mar 17 1999
* MADE 1.3.1 RELEASE
* With GIMP 1.1 now uses only one parasite called "gdyntext-parasite".
Feb 20 1999
* MADE 1.3.0 RELEASE
* With GIMP 1.1 now uses parasites. You can force layer renaming for
compatibility with GIMP 1.0 (that hasn't parasites) by holding the
Shift key while pressing the "Ok" button.
* Some changes into the UI code.
* Triggered strings for NLS support (libgimp/gimpintl.h).
* If you use GTK+ 1.1 you may need GTK+ 1.1.16 or better for correct button
resizing in the CharMap window.
* Updated sample scripts:
gdyntext_test.scm -> for GIMP 1.0
gdyntext_test11.scm -> for GIMP 1.1
Jan 21 1999
* MADE 1.2.1 RELEASE
* Fixed the problem with removed leading spaces.
Jan 16 1999
* MADE 1.2 RELEASE
* Text loading from file.
* Ui code reorganization.
* Some internal changes for better and cleaner support for gimp 1.1 and
gtk 1.1 (changed GIMP11 ifdef to GTK_HAVE_FEATURES_1_1_12 and
GIMP_HAVE_PARASITES).
Jan 12 1999
* MADE 1.1 RELEASE
* Applied some changes for working with gimp 1.1 and gtk+ 1.1.
* New charmap window.
Jan 08 1999
* MADE 1.0 RELEASE
* Now the plug-in is undoable (except the modified layer name, GIMP fault).
* Corrected a bug that always create a new GRAYA_IMAGE layer if called on
a layer mask.
* PDB support is ok, now also returns the layer_id.
* Sample Script-Fu script added to the archive.
* Now restores the font preview state from the previous call.
Jan 07 1999
* MADE 0.9 RELEASE
* Extended the font preview to the text area widget.
* The vertical scrollbar for the text area widget now works.
* Added some new error checks and a message window.
* Gui source code cleanup and re-organization.
Dec 29 1998
* MADE 0.8 RELEASE
* Allows changing text font weight, slant and spacing.
* Fixed a bug that made gdyntext crash while rendering if the last line
isn't \n terminated.
* Fixed the plug-in RUN_WITH_LAST_VALS behaviour, now it re-apply on the
current layer (or a new one if the current hasn't alpha channel).
* Updated the PDB support, however it's still buggy ...
Dec 27 1998
* MADE 0.7 RELEASE
* Text font preview.
* Text rotation.
* A button for creating a new layer instead of modifying the current one.
* About window.
* Removed the debug output.
Dec 25 1998
* MADE 0.6 XMAS RELEASE
* Allows text alignment.
Dec 21 1998
* MADE 0.5 RELEASE
/* vim: set ts=2 sw=2 tw=79 ai expandtab: */
GIMP Dynamic Text -- image filter plug-in for The GIMP program
==============================================================
GDynText 1.4.0
Copyright (C) 1998,1999 Marco Lamberto
E-mail: lm@geocities.com
Web page: http://www.geocities.com/Tokyo/1474/gimp/
Legal stuff
===========
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 (see "COPYING" file); if not, write to the Free Software Foundation
Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Intro
=====
GIMP Dynamic Text is a GIMP plug-in that works like the text tool but
allows you writing multi-line text and made you able of modifying it later
as you want (text/font/font size/color/...).
However I hope that a feature like this will be available on GIMP 1.2 as a
standard tool.
GIMP version required: 1.0 or 1.1 (see compiling for GIMP 1.1 below)
Plug-in menu path: <Image>/Filters/Render/Dynamic Text
PDB function: plug-in-dynamic-text
Suggested hotkey: Alt+T
This is my second plug-in, the first was an xvpict loader now embedded into
the Guash plug-in of Shuji Narazaki.
It's rather far from being a complete work and I've just starded in playing
with GTK+ ... it's a really powerful but also a complex toolkit for a
programmer that had used only Java AWT for opening windows on X11!
Compiling for GIMP 1.0
======================
Simply run 'make install'. Optionally if something goes wrong you could edit
the shipped Makefile.
Compiling for GIMP 1.1
======================
You must edit the Makefile and change GIMP11BIN in order to reflect the path
where the GIMP 1.1 binary and gimptool are installed then you could run
'make install11'.
Thanks
======
* Glade, the GTK+ gui builder, was a good starting point for learning how to
write GTK+ applications.
* The "Writing a GIMP plug-in" tutorial written by Kevin Turner help me in
figuring better how the GIMP plug-in system works.
* I've taken few lines of code for the preview initialization from the bumpmap
plug-in written by Federico Mena Quintero and Jens Lautenbacher.
* The GIMP Team ;)
/* vim: set ts=2 sw=2 tw=79 ai expandtab: */
The GIMP Dynamic Text plug-in "todo"-list:
==========================================
* fix the problem with the ascent value while rendering text
* allow only valid sizes for non scalable fonts (use gtkfontselection)
* add customizable tab expansion
* disable antialias for non scalable fonts
* text save
* charmap window must handle fonts with more than 256 chars.
* behave more like an editor with font, color and justifcation applied on a
selected area only
* a list of customizable pre-sets (useful for logos)
* internal text rendering routine
* transformation window: text path, perspective, color gradients, 3d
* special effects, like customizable shadow or auto-call of scripts after the
text rendered
* autoconf stuff
If there's anything you would like to add, feel free
to send me any suggestions for new stuff or improvements.
Marco Lamberto <lm@geocities.com>
/* vim: set ts=2 sw=2 tw=79 ai expandtab: */
/*
* GIMP Dynamic Text -- This is a plug-in for The GIMP 1.0
* Copyright (C) 1998,1999 Marco Lamberto <lm@geocities.com>
* Web page: http://www.geocities.com/Tokyo/1474/gimp/
*
* 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.
*
* $Id$
*/
#include <stdio.h>
#include <gtk/gtk.h>
#include "libgimp/gimpintl.h"
#include "charmap.h"
static void charmap_class_init(CharMapClass *class);
static void charmap_init(CharMap *cm);
void on_charmap_char_toggled(GtkWidget *widget, gpointer data);
enum {
CHAR_SELECTED,
LAST_SIGNAL
};
static gint charmap_signals[LAST_SIGNAL] = { 0 };
guint charmap_get_type(void)
{
static guint cm_type = 0;
if (!cm_type) {
GtkTypeInfo cm_info = {
"CharMap",
sizeof(CharMap),
sizeof(CharMapClass),
(GtkClassInitFunc)charmap_class_init,
(GtkObjectInitFunc)charmap_init,
(GtkArgSetFunc)NULL,
(GtkArgGetFunc)NULL,
#ifdef GTK_HAVE_FEATURES_1_1_12
(GtkClassInitFunc)NULL,
#endif
};
cm_type = gtk_type_unique(gtk_vbox_get_type(), &cm_info);
}
return cm_type;
}
static void charmap_class_init(CharMapClass *klass)
{
GtkObjectClass *object_class;
object_class = (GtkObjectClass *)klass;
charmap_signals[CHAR_SELECTED] = gtk_signal_new("char_selected",
GTK_RUN_FIRST, object_class->type,
GTK_SIGNAL_OFFSET(CharMapClass, char_selected),
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0);
gtk_object_class_add_signals(object_class, charmap_signals, LAST_SIGNAL);
klass->char_selected = NULL;
}
static void charmap_init(CharMap *cm)
{
GtkWidget *table;
GtkWidget *button;
guint x, y, i;
gchar clabel[2];
gchar tip[20];
GtkTooltips *tooltips;
cm->width = 8;
cm->height = 32;
cm->current_char = -1;
table = gtk_table_new(32, 8, TRUE);
gtk_container_add(GTK_CONTAINER(cm), table);
gtk_table_set_row_spacings(GTK_TABLE(table), 0);
gtk_table_set_col_spacings(GTK_TABLE(table), 0);
gtk_widget_show(table);
tooltips = gtk_tooltips_new();
clabel[1] = 0;
for (y = 0, i = 0; y < cm->height; y++)
for (x = 0; x < cm->width; x++, i++) {
clabel[0] = i < 32 ? ' ' : i; /* skips control chars 0 < c < 32 */
button = cm->buttons[x + y * cm->width] = gtk_toggle_button_new_with_label(clabel);
if (i == 32)
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), TRUE);
gtk_table_attach(GTK_TABLE(table), button, x, x + 1, y, y + 1,
(GtkAttachOptions)GTK_EXPAND | GTK_SHRINK | GTK_FILL,
(GtkAttachOptions)GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_signal_connect_after(GTK_OBJECT(button), "toggled",
GTK_SIGNAL_FUNC(on_charmap_char_toggled), cm);
gtk_widget_show(button);
sprintf(tip, _("Char: %c, %d, 0x%02x"), i < 32 ? ' ' : i, i, i);
gtk_tooltips_set_tip(tooltips, button, tip, NULL);
}
}
GtkWidget* charmap_new(void)
{
return GTK_WIDGET(gtk_type_new(charmap_get_type()));
}
void on_charmap_char_toggled(GtkWidget *widget, gpointer data)
{
static gboolean in = FALSE; /* flag for avoiding recursive calls in signal */
if (!in) {
CharMap *cm;
gint i;
in = TRUE;
cm = (CharMap *)data;
for (i = 0; i < 256; i++)
if (cm->buttons[i] != widget && GTK_TOGGLE_BUTTON(cm->buttons[i])->active)
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(cm->buttons[i]), FALSE);
if (!GTK_TOGGLE_BUTTON(widget)->active)
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(widget), TRUE);
cm->current_char = GTK_LABEL(GTK_BUTTON(widget)->child)->label[0];
gtk_signal_emit(GTK_OBJECT(data), charmap_signals[CHAR_SELECTED]);
in = FALSE;
}
}
void charmap_set_font(CharMap *cm, GdkFont *font)
{
GtkStyle *style;
gint i;
if (font == NULL)
return;
style = gtk_style_new();
gdk_font_unref(style->font);
style->font = font;
gdk_font_ref(style->font);
for (i = 0; i < 256; i++)
gtk_widget_set_style(GTK_BUTTON(cm->buttons[i])->child, style);
gtk_widget_queue_resize(GTK_WIDGET(cm)->parent);
}
/* vim: set ts=2 sw=2 tw=79 ai nowrap: */
/*
* GIMP Dynamic Text -- This is a plug-in for The GIMP 1.0
* Copyright (C) 1998,1999 Marco Lamberto <lm@geocities.com>
* Web page: http://www.geocities.com/Tokyo/1474/gimp/
*
* 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.
*
* $Id$
*/
#ifndef _CHARMAP_H_
#define _CHARMAP_H_
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define CHARMAP(obj) GTK_CHECK_CAST(obj, charmap_get_type(), CharMap)
#define CHARMAP_CLASS(klass) GTK_CHECK_CLASS_CAST(klass, charmap_get_type(), CharMapClass)
#define IS_CHARMAP(obj) GTK_CHECK_TYPE(obj, charmap_get_type())
typedef struct _CharMap CharMap;
typedef struct _CharMapClass CharMapClass;
struct _CharMap
{
GtkVBox vbox;
GtkWidget *buttons[256];
gint width;
gint height;
gint32 current_char;
};
struct _CharMapClass
{
GtkVBoxClass parent_class;
void (* char_selected)(CharMap *cm);
};
guint charmap_get_type(void);
GtkWidget* charmap_new(void);
void charmap_set_font(CharMap *cm, GdkFont *font);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _CHARMAP_H_ */
/* vim: set ts=2 sw=2 tw=79 ai nowrap: */
/*
* GIMP Dynamic Text -- This is a plug-in for The GIMP 1.0
* Copyright (C) 1998,1999 Marco Lamberto <lm@geocities.com>
* Web page: http://www.geocities.com/Tokyo/1474/gimp/
*
* 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.
*
* $Id$
*/
#include <stdio.h>
#include <gtk/gtk.h>
#include "libgimp/gimpintl.h"
#include "charmap.h"
#include "charmap_window.h"
static void charmap_window_class_init(CharMapWindowClass *class);
static void charmap_window_init(CharMapWindow *mw);
void on_charmap_char_selected(GtkWidget *widget, gpointer data);
static GtkWindowClass *charmap_window_parent_class = NULL;
guint charmap_window_get_type(void)
{
static guint cmw_type = 0;
if (!cmw_type) {
GtkTypeInfo cmw_info = {
"CharMapWindow",
sizeof(CharMapWindow),
sizeof(CharMapWindowClass),
(GtkClassInitFunc)charmap_window_class_init,
(GtkObjectInitFunc)charmap_window_init,
(GtkArgSetFunc)NULL,
(GtkArgGetFunc)NULL,
#ifdef GTK_HAVE_FEATURES_1_1_12
(GtkClassInitFunc)NULL,
#endif
};
cmw_type = gtk_type_unique(gtk_window_get_type(), &cmw_info);
}
return cmw_type;
}
static void charmap_window_class_init(CharMapWindowClass *klass)
{
GtkObjectClass *object_class;
object_class = (GtkObjectClass *)klass;
charmap_window_parent_class = gtk_type_class(gtk_window_get_type());
}
static void charmap_window_init(CharMapWindow *cmw)
{
GtkWidget *vbox;
GtkWidget *hbox1;
GtkWidget *hbox2;
GtkWidget *hbbox1;
GtkWidget *hseparator;
GtkWidget *frame;
GtkWidget *label;
GtkTooltips *tooltips;
tooltips = gtk_tooltips_new();
vbox = gtk_vbox_new(FALSE, 5);
gtk_container_add(GTK_CONTAINER(cmw), vbox);
gtk_widget_show(vbox);
cmw->scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
gtk_box_pack_start(GTK_BOX(vbox), cmw->scrolledwindow, TRUE, TRUE, 0);
gtk_container_border_width(GTK_CONTAINER(cmw->scrolledwindow), 2);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(cmw->scrolledwindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_widget_show(cmw->scrolledwindow);
cmw->charmap = charmap_new();
#ifdef GTK_HAVE_FEATURES_1_1_12
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(cmw->scrolledwindow), cmw->charmap);
#else
gtk_container_add(GTK_CONTAINER(cmw->scrolledwindow), cmw->charmap);
#endif
gtk_signal_connect(GTK_OBJECT(cmw->charmap), "char_selected",
GTK_SIGNAL_FUNC(on_charmap_char_selected), cmw);
gtk_widget_show(cmw->charmap);
hseparator = gtk_hseparator_new();
gtk_box_pack_start(GTK_BOX(vbox), hseparator, FALSE, TRUE, 0);
gtk_widget_show(hseparator);
hbox1 = gtk_hbox_new(FALSE, 5);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, FALSE, TRUE, 0);
gtk_widget_show(hbox1);
frame = gtk_frame_new(NULL);
gtk_box_pack_start(GTK_BOX(hbox1), frame, FALSE, FALSE, 0);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
gtk_widget_show(frame);
hbox2 = gtk_hbox_new(FALSE, 5);
gtk_container_add(GTK_CONTAINER(frame), hbox2);
gtk_widget_show(hbox2);
label = gtk_label_new(_("Selected char:"));
gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 4);
gtk_widget_show(label);
cmw->label = gtk_label_new(" ");
gtk_box_pack_start(GTK_BOX(hbox2), cmw->label, FALSE, TRUE, 5);
gtk_widget_show(cmw->label);
hbbox1 = gtk_hbutton_box_new();
gtk_box_pack_end(GTK_BOX(hbox1), hbbox1, FALSE, FALSE, 0);
gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox1), GTK_BUTTONBOX_END);
gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox1), 4);
gtk_widget_show(hbbox1);
cmw->insert_button = gtk_button_new_with_label(_("Insert"));
gtk_box_pack_start(GTK_BOX(hbbox1), cmw->insert_button, FALSE, FALSE, 0);
GTK_WIDGET_SET_FLAGS(cmw->insert_button, GTK_CAN_DEFAULT);
gtk_tooltips_set_tip(tooltips, cmw->insert_button, _("Insert the selected char at the cursor position"), NULL);
gtk_widget_show(cmw->insert_button);
cmw->close_button = gtk_button_new_with_label(_("Close"));
gtk_box_pack_start(GTK_BOX(hbbox1), cmw->close_button, FALSE, FALSE, 0);
GTK_WIDGET_SET_FLAGS(cmw->close_button, GTK_CAN_DEFAULT);
gtk_widget_grab_default(cmw->close_button);
gtk_widget_show(cmw->close_button);
}
GtkWidget* charmap_window_new(const gchar *title)
{
CharMapWindow *cmw;
cmw = gtk_type_new(charmap_window_get_type());
gtk_window_set_title(GTK_WINDOW(cmw), title);
gtk_container_border_width(GTK_CONTAINER(cmw), 4);
gtk_window_set_policy(GTK_WINDOW(cmw), TRUE, TRUE, FALSE);
return GTK_WIDGET(cmw);
}
void on_charmap_char_selected(GtkWidget *widget, gpointer data)
{
CharMapWindow *cmw;
gchar lab[2];
cmw = (CharMapWindow *)data;
lab[0] = CHARMAP(cmw->charmap)->current_char;
lab[1] = 0;
gtk_label_set(GTK_LABEL(cmw->label), lab);
}
/* vim: set ts=2 sw=2 tw=79 ai nowrap: */
/*
* GIMP Dynamic Text -- This is a plug-in for The GIMP 1.0
* Copyright (C) 1998,1999 Marco Lamberto <lm@geocities.com>
* Web page: http://www.geocities.com/Tokyo/1474/gimp/
*
* 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.
*
* $Id$
*/
#ifndef _CHARMAP_WINDOW_H_
#define _CHARMAP_WINDOW_H_
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define CHARMAP_WINDOW(obj) GTK_CHECK_CAST(obj, charmap_window_get_type(), CharMapWindow)
#define CHARMAP_WINDOW_CLASS(klass) GTK_CHECK_CLASS_CAST(klass, charmap_window_get_type(), CharMapWindowClass)