ASCII file plugin V1.12 for the GIMP Peter Kirchgessner, 10-Jan-98 ==================================== e-mail: pkirchg@aol.com WWW : http://members.aol.com/pkirchg Here is the ASCII file plugin for the GIMP V 0.99.17 and up. It reads text-files (.asc, .txt) and creates an image. It uses a fontselect widget based on the text-tool. The widget can also be used separately. In the directory ftp://members.aol.com/pkirchg/pub/gimp you will find the following files: ascii.txt : this document ascii.tgz : gzipped tarfile with sources and documentation ascii.linux.386.elf.tgz : gzipped tarfile with Linux exectuable News: V 1.12, 10-Jan-98: Update for Gimp V 0.99.17, gtk+-0.99.2 V 1.11, 13-Dec-97: first release Installation of executable -------------------------- To tell the GIMP about the ASCII-file-plugin, copy the executable to /usr/local/lib/gimp/0.99.x/plug-ins . Installation from source ------------------------ Add ascii to the configure script of gimp like any other plug-in and run configure to create the makefile. Suggestions ----------- Suggestions about the plug-in should be mailed to pkirchg@aol.com Separate use of the fontselect-widget ------------------------------------- The fontselect widget can also be used separately. You only need the files fontsel.c and fontsel.h. For an example of how to use it, see below. fontsel.c and fontsel.h are based on text_tools.c, build_menu.c and linked.c. Differences to the text-tool dialog: - Text disappears if an invalid size is entered - Additional menus for registry and encoding - registry/encoding/border-entries can be hidden A simple makefile for the example below (assumed to be placed in the plug-in directory, creates program fsel): fsel: fselmain.o fontsel.o gcc -g -o fsel fselmain.o fontsel.o -I/usr/local/include -I.. \ -I/usr/X11R6/include \ -I../app -L/usr/local/lib -lgtk -lgdk -lglib -lm fselmain.o: fselmain.c fontsel.h gcc -c -g -Wall fselmain.c -I/usr/local/include -I.. \ -I/usr/X11R6/include -I../app fontsel.o: fontsel.c fontsel.h gcc -c -g -Wall fontsel.c -I/usr/local/include -I.. \ -I/usr/X11R6/include -I../app The example fselmain.c, how to use the fontselect widget (Note the parts marked FONTSELECT): #include #include #include "gtk/gtk.h" #include "fontsel.h" static void select_close_callback (GtkWidget *widget, gpointer data) {int *ok = (int *)data; *ok = 0; gtk_main_quit (); } static void select_ok_callback (GtkWidget *widget, gpointer data) {int *ok = (int *)data; *ok = 1; gtk_main_quit (); } int main (int argc, char *argv[]) {GtkWidget *dlg; GtkWidget *button; GtkWidget *frame; GtkWidget *vbox; FontSelectDialog *fontselectdialog; FontProperties *fprop; FontProperties fpset; int ok = 0; argc = 1; argv = g_new (gchar *, 1); argv[0] = g_strdup ("load"); gtk_init (&argc, &argv); dlg = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dlg), "Select Font"); gtk_window_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE); gtk_signal_connect (GTK_OBJECT (dlg), "destroy", (GtkSignalFunc) select_close_callback, (gpointer)&ok); /* Action area */ button = gtk_button_new_with_label ("OK"); GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); gtk_signal_connect (GTK_OBJECT (button), "clicked", (GtkSignalFunc) select_ok_callback, (gpointer)&ok); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button, TRUE, TRUE, 0); gtk_widget_grab_default (button); gtk_widget_show (button); button = gtk_button_new_with_label ("Cancel"); GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); gtk_signal_connect_object (GTK_OBJECT (button), "clicked", (GtkSignalFunc) gtk_widget_destroy, GTK_OBJECT (dlg)); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button, TRUE, TRUE, 0); gtk_widget_show (button); /* Font */ frame = gtk_frame_new ("Font"); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); gtk_container_border_width (GTK_CONTAINER (frame), 10); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, FALSE, TRUE, 0); vbox = gtk_vbox_new (FALSE, 5); gtk_container_border_width (GTK_CONTAINER (vbox), 5); gtk_container_add (GTK_CONTAINER (frame), vbox); /* FONTSELECT: Reset widget options to defaults */ fontselect_properties_reset (&fpset); /* FONTSELECT: Assign your own defaults */ fpset.foundry = NULL; fpset.family = "courier"; fpset.weight = NULL; fpset.slant = "r"; fpset.set_width = NULL; fpset.spacing = NULL; fpset.registry = NULL; fpset.encoding = NULL; fpset.size = 24; fpset.use_pixel = 1; fpset.border = 5; fpset.antialias = 0; fpset.text = "ABCabc123"; fpset.hide_registry = 0; fpset.hide_encoding = 0; fpset.hide_border = 0; /* FONTSELECT: create widget in a box (!) with default values */ fontselectdialog = fontselect_dialog_new (vbox, &fpset); /* FONTSELECT: show widget */ gtk_widget_show (fontselectdialog->widget); gtk_widget_show (vbox); gtk_widget_show (frame); gtk_widget_show (dlg); gtk_main (); if (ok) { /* FONTSELECT: inquire assigned values */ fprop = fontselect_properties_get (fontselectdialog); printf ("Font Selected:\n"); printf ("-%s-%s-%s-%s-%s-*-%f-%f-75-75-%s-*-%s-%s\n", fprop->foundry, fprop->family, fprop->weight, fprop->slant, fprop->set_width, fprop->size, fprop->size, fprop->spacing, fprop->registry, fprop->encoding); printf ("use_pixel=%d, border=%d, antialias=%d, text=%s\n", fprop->use_pixel, fprop->border, fprop->antialias, fprop->text); /* FONTSELECT: free memory used for assigned values */ fontselect_properties_free (fprop); } /* FONTSELECT: free memory used by fontselect widget */ fontselect_dialog_free (fontselectdialog); return (0); }