home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / plug-ins / imagemap / imap_source.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-25  |  2.3 KB  |  80 lines

  1. /*
  2.  * This is a plug-in for the GIMP.
  3.  *
  4.  * Generates clickable image maps.
  5.  *
  6.  * Copyright (C) 1998-1999 Maurits Rijk  lpeek.mrijk@consunet.nl
  7.  *
  8.  * This program is free software; you can redistribute it and/or modify
  9.  * it under the terms of the GNU General Public License as published by
  10.  * the Free Software Foundation; either version 2 of the License, or
  11.  * (at your option) any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program; if not, write to the Free Software
  20.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21.  *
  22.  */
  23.  
  24. #include <stdarg.h>
  25. #include <stdio.h>
  26.  
  27. #include "imap_default_dialog.h"
  28. #include "libgimp/stdplugins-intl.h"
  29. #include "imap_main.h"
  30. #include "imap_source.h"
  31.  
  32. static void 
  33. save_to_view(gpointer param, const char* format, ...)
  34. {
  35.    va_list ap;
  36.    char scratch[1024];
  37.  
  38.    va_start(ap, format);
  39.    vsprintf(scratch, format, ap);
  40.    va_end(ap);
  41.  
  42.    gtk_text_insert(GTK_TEXT(param), NULL, NULL, NULL, scratch, -1);
  43. }
  44.  
  45.  
  46. void 
  47. do_source_dialog(void)
  48. {
  49.    static DefaultDialog_t *dialog;
  50.    static GtkWidget *text;
  51.    if (!dialog) {
  52.       GtkWidget *window;
  53.  
  54.       dialog = make_default_dialog(_("View Source"));
  55.       default_dialog_hide_cancel_button(dialog);
  56.       default_dialog_hide_apply_button(dialog);
  57.  
  58.       text = gtk_text_new(NULL, NULL);
  59.       gtk_widget_show(text);
  60.  
  61.       window = gtk_scrolled_window_new(GTK_TEXT(text)->hadj, 
  62.                        GTK_TEXT(text)->vadj);
  63.       gtk_widget_set_usize(window, 640, 400);
  64.       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog->dialog)->vbox), window, 
  65.              TRUE, TRUE, 0);
  66.       gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(window), 
  67.                      GTK_POLICY_AUTOMATIC, 
  68.                      GTK_POLICY_AUTOMATIC);
  69.       gtk_widget_show(window);
  70.       gtk_container_add(GTK_CONTAINER(window), text);
  71.       
  72.    }
  73.    gtk_text_freeze(GTK_TEXT(text));
  74.    gtk_editable_delete_text(GTK_EDITABLE(text), 0, -1);
  75.    dump_output(text, save_to_view);
  76.    gtk_text_thaw(GTK_TEXT(text));
  77.  
  78.    default_dialog_show(dialog);
  79. }
  80.