home *** CD-ROM | disk | FTP | other *** search
/ ftp.sunet.sepub/pictures / 2014.11.ftp.sunet.se-pictures.tar / ftp.sunet.se / pub / pictures / ACiD-artpacks / programs / unix / editors / gimp-plugins-unstable-0_99_23_tar.gz / gimp-plugins-unstable-0_99_23_tar / gimp-plugins-unstable-0.99.23 / ascii / ascii.txt < prev    next >
Text File  |  1998-02-24  |  6KB  |  207 lines

  1.  
  2. ASCII file plugin V1.12 for the GIMP     Peter Kirchgessner, 10-Jan-98
  3. ====================================     e-mail: pkirchg@aol.com
  4.                                          WWW   : http://members.aol.com/pkirchg
  5.  
  6. Here is the ASCII file plugin for the GIMP V 0.99.17 and up.
  7. It reads text-files (.asc, .txt) and creates an image.
  8. It uses a fontselect widget based on the text-tool.
  9. The widget can also be used separately.
  10. In the directory
  11.  
  12.     ftp://members.aol.com/pkirchg/pub/gimp
  13.  
  14. you will find the following files:
  15.  
  16.     ascii.txt                  : this document
  17.     ascii.tgz                  : gzipped tarfile with sources and documentation
  18.     ascii.linux.386.elf.tgz    : gzipped tarfile with Linux exectuable
  19.  
  20. News:
  21.   V 1.12, 10-Jan-98:
  22.     Update for Gimp V 0.99.17, gtk+-0.99.2
  23.   V 1.11, 13-Dec-97:
  24.     first release
  25.  
  26. Installation of executable
  27. --------------------------
  28.   To tell the GIMP about the ASCII-file-plugin, copy the executable
  29.   to /usr/local/lib/gimp/0.99.x/plug-ins .
  30.  
  31. Installation from source
  32. ------------------------
  33.   Add ascii to the configure script of gimp like any other plug-in
  34.   and run configure to create the makefile.
  35.  
  36. Suggestions
  37. -----------
  38.   Suggestions about the plug-in should be mailed to pkirchg@aol.com
  39.  
  40. Separate use of the fontselect-widget
  41. -------------------------------------
  42. The fontselect widget can also be used separately. You only need the
  43. files fontsel.c and fontsel.h. For an example of how to use it,
  44. see below. fontsel.c and fontsel.h are based on text_tools.c,
  45. build_menu.c and linked.c. Differences to the text-tool dialog:
  46.  
  47. - Text disappears if an invalid size is entered
  48. - Additional menus for registry and encoding
  49. - registry/encoding/border-entries can be hidden
  50.  
  51. A simple makefile for the example below (assumed to be placed
  52. in the plug-in directory, creates program fsel):
  53.  
  54. fsel: fselmain.o fontsel.o
  55.     gcc -g -o fsel fselmain.o fontsel.o -I/usr/local/include -I.. \
  56.     -I/usr/X11R6/include \
  57.     -I../app  -L/usr/local/lib -lgtk -lgdk -lglib -lm
  58.  
  59. fselmain.o: fselmain.c fontsel.h
  60.     gcc -c -g -Wall fselmain.c -I/usr/local/include -I.. \
  61.     -I/usr/X11R6/include -I../app
  62.  
  63. fontsel.o: fontsel.c fontsel.h
  64.     gcc -c -g -Wall fontsel.c -I/usr/local/include -I.. \
  65.     -I/usr/X11R6/include -I../app
  66.  
  67. The example fselmain.c, how to use the fontselect widget
  68. (Note the parts marked FONTSELECT):
  69.  
  70.  
  71. #include <stdlib.h>
  72. #include <stdio.h>
  73. #include "gtk/gtk.h"
  74. #include "fontsel.h"
  75.  
  76. static void
  77. select_close_callback (GtkWidget *widget,
  78.                      gpointer   data)
  79.  
  80. {int *ok = (int *)data;
  81.  
  82.   *ok = 0;
  83.   gtk_main_quit ();
  84. }
  85.  
  86. static void
  87. select_ok_callback (GtkWidget *widget,
  88.                   gpointer   data)
  89.  
  90. {int *ok = (int *)data;
  91.  
  92.   *ok = 1;
  93.   gtk_main_quit ();
  94. }
  95.  
  96.  
  97. int main (int argc, char *argv[])
  98.  
  99. {GtkWidget *dlg;
  100.  GtkWidget *button;
  101.  GtkWidget *frame;
  102.  GtkWidget *vbox;
  103.  FontSelectDialog *fontselectdialog;
  104.  FontProperties *fprop;
  105.  FontProperties fpset;
  106.  int ok = 0;
  107.  
  108.   argc = 1;
  109.   argv = g_new (gchar *, 1);
  110.   argv[0] = g_strdup ("load");
  111.  
  112.   gtk_init (&argc, &argv);
  113.  
  114.   dlg = gtk_dialog_new ();
  115.   gtk_window_set_title (GTK_WINDOW (dlg), "Select Font");
  116.   gtk_window_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
  117.   gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
  118.                       (GtkSignalFunc) select_close_callback,
  119.                       (gpointer)&ok);
  120.  
  121.   /*  Action area  */
  122.   button = gtk_button_new_with_label ("OK");
  123.   GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
  124.   gtk_signal_connect (GTK_OBJECT (button), "clicked",
  125.                       (GtkSignalFunc) select_ok_callback,
  126.                       (gpointer)&ok);
  127.   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button,
  128.                       TRUE, TRUE, 0);
  129.   gtk_widget_grab_default (button);
  130.   gtk_widget_show (button);
  131.  
  132.   button = gtk_button_new_with_label ("Cancel");
  133.   GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
  134.   gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
  135.                              (GtkSignalFunc) gtk_widget_destroy,
  136.                              GTK_OBJECT (dlg));
  137.   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button,
  138.                       TRUE, TRUE, 0);
  139.   gtk_widget_show (button);
  140.  
  141.   /* Font */
  142.   frame = gtk_frame_new ("Font");
  143.   gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
  144.   gtk_container_border_width (GTK_CONTAINER (frame), 10);
  145.   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame,
  146.                       FALSE, TRUE, 0);
  147.   vbox = gtk_vbox_new (FALSE, 5);
  148.   gtk_container_border_width (GTK_CONTAINER (vbox), 5);
  149.   gtk_container_add (GTK_CONTAINER (frame), vbox);
  150.  
  151.   
  152.   /* FONTSELECT: Reset widget options to defaults */
  153.   fontselect_properties_reset (&fpset);
  154.  
  155.   /* FONTSELECT: Assign your own defaults */
  156.   fpset.foundry = NULL;
  157.   fpset.family = "courier";
  158.   fpset.weight = NULL;
  159.   fpset.slant = "r";
  160.   fpset.set_width = NULL;
  161.   fpset.spacing = NULL;
  162.   fpset.registry = NULL;
  163.   fpset.encoding = NULL;
  164.   fpset.size = 24;
  165.   fpset.use_pixel = 1;
  166.   fpset.border = 5;
  167.   fpset.antialias = 0;
  168.   fpset.text = "ABCabc123";
  169.  
  170.   fpset.hide_registry = 0;
  171.   fpset.hide_encoding = 0;
  172.   fpset.hide_border = 0;
  173.  
  174.   /* FONTSELECT: create widget in a box (!) with default values */
  175.   fontselectdialog = fontselect_dialog_new (vbox, &fpset);
  176.  
  177.   /* FONTSELECT: show widget */
  178.   gtk_widget_show (fontselectdialog->widget);
  179.   gtk_widget_show (vbox);
  180.   gtk_widget_show (frame);
  181.   gtk_widget_show (dlg);
  182.   gtk_main ();
  183.  
  184.   if (ok)
  185.   { /* FONTSELECT: inquire assigned values */
  186.     fprop = fontselect_properties_get (fontselectdialog);
  187.  
  188.     printf ("Font Selected:\n");
  189.     printf ("-%s-%s-%s-%s-%s-*-%f-%f-75-75-%s-*-%s-%s\n",
  190.             fprop->foundry, fprop->family, fprop->weight, fprop->slant,
  191.             fprop->set_width, fprop->size, fprop->size, fprop->spacing,
  192.             fprop->registry, fprop->encoding);
  193.     printf ("use_pixel=%d, border=%d, antialias=%d, text=%s\n",
  194.             fprop->use_pixel, fprop->border, fprop->antialias, fprop->text);
  195.  
  196.     /* FONTSELECT: free memory used for assigned values */
  197.     fontselect_properties_free (fprop);
  198.   }
  199.  
  200.   /* FONTSELECT: free memory used by fontselect widget */
  201.   fontselect_dialog_free (fontselectdialog);
  202.  
  203.   return (0);
  204. }
  205.  
  206.  
  207.