~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina5/tina-tools/tinatool/wdgts/gtk/wdgtsGtk_tw_init.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**********
  2  * 
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  * 
  6  * Redistribution and use in source and binary forms, with or without modification, 
  7  * are permitted provided that the following conditions are met:
  8  * 
  9  *   . Redistributions of source code must retain the above copyright notice, 
 10  *     this list of conditions and the following disclaimer.
 11  *    
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation 
 14  *     and/or other materials provided with the distribution.
 15  * 
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this 
 18  *     software without specific prior written permission.
 19  * 
 20  * 
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  * 
 35  * Program :  TINA
 36  * File    :  $Source: /home/tina/cvs/tina-tools/tinatool/wdgts/gtk/wdgtsGtk_tw_init.c,v $
 37  * Date    :  $Date: 2005/01/09 02:21:01 $
 38  * Version :  $Revision: 1.3 $
 39  * CVS Id  :  $Id: wdgtsGtk_tw_init.c,v 1.3 2005/01/09 02:21:01 paul Exp $
 40  *
 41  * Author  :  a.lacey@man.ac.uk, giob@man.ac.uk
 42  *
 43  */
 44 /** 
 45  *  @file  wdgtsGtk_tw_init.c
 46  *  @brief Initialisation for Gtk UI.
 47  *
 48  *  Code to initialise Gtk and set up global parameters to control TINA's macro 
 49  *  record/replay handling.
 50  *  Uses static data so could be better but this is how it's done for now.
 51  *
 52  */
 53 
 54 #include "wdgtsGtk_tw_init.h"
 55 
 56 #if HAVE_CONFIG_H
 57 #   include <config.h>
 58 #endif
 59 
 60 #include <stdio.h>
 61 #include <gtk/gtk.h>
 62 #include <tinatool/draw/drawPro.h>
 63 #include <tinatool/wdgts/gtk/wdgts_GtkDef.h>
 64 
 65 
 66 /**
 67  * Global variables for macro record/replay (with setters/getters).
 68  */
 69 static Bool  save    = false;    /** Flag for macro recording. */
 70 static Bool  recover = false;    /** Flag for macro replaying. */
 71 static char *progname;           /** Macro file name or "tinaTool". */
 72                                  /* static data! */
 73 
 74 /** 
 75  *  @brief  Getter for macro recording flag.
 76  *  @return  Bool  Current value of macro recording flag.
 77  */
 78 Bool tw_save(void)
 79 {
 80   return (save);
 81 }
 82 
 83 /** 
 84  *  @brief  Setter for macro recording flag.
 85  *  @param  newsave  New value of macro recording flag.
 86  *
 87  *  Provided to allow setting from external files.
 88  */
 89 void tw_set_save(Bool newsave)
 90 {
 91   save =  newsave;
 92 }
 93 
 94 /** 
 95  *  @brief  Getter for macro replaying flag.
 96  *  @return  Bool  Current value of macro replaying flag.
 97  */
 98 Bool tw_recover(void)
 99 {
100   return (recover);
101 }
102 
103 /** 
104  *  @brief  Getter for replay macro file name.
105  *  @return  Bool  Current value of replay macro file name.
106  */
107 char *tw_get_progname(void)
108 {
109   return (progname);
110 }
111 
112 /** 
113  *  @brief  Initialise for GTK/GDK.
114  */
115 void tina_init_gtk_rgb(void)
116 {
117   /** GdkRGB set-up stuff */
118   gdk_rgb_init();
119   gtk_widget_set_default_colormap (gdk_rgb_get_cmap());
120   gtk_widget_set_default_visual (gdk_rgb_get_visual());
121 
122   /** Don't need default colours with GdkRGB */
123   (void) ndefault_colors_set(0);
124 }
125 
126 /**
127  * @brief Initialise Gtk and macro record/replay flags.  
128  * @param argc Number of command line arguments.
129  * @param argv List of command line arguments.
130  * 
131  * Initialise Gtk.  Any Gtk-specific command-line args are stripped off
132  * and the tinaTool ones left for handling here.  These are used to set
133  * up the macro record/replay handling.
134  *
135  * Also initialises the gdk RGB functions.
136  */
137 void tw_init(int *argc, char **argv)
138 {
139   int     i;
140 
141   gtk_init(argc, &argv);
142   tina_init_gtk_rgb();
143 
144   progname = argv[0];
145   for (i = 1; i < *argc; i++)
146   {
147     if (argv[i][0] != '-')
148       continue;
149     switch (argv[i][1])
150     {
151       case 's':
152         save = true;
153         break;
154       case 'r':
155         recover = true;
156         break;
157       case 'f':
158         recover = true;
159         progname =  argv[i+1];
160         break;
161       case 'e':
162         toggle_bigtolittle();
163         break;
164     }
165   }
166 
167 /*
168  * Interrupt handling goes here.
169  * Duplicate the X set-up - GAB 13 Nov 2003
170  */
171 }
172 
173 /** 
174  *  @brief Quit when called.
175  *  @param dummy What it says on the tin ...
176  *
177  *  Don't think this is ever called - GAB TODO 8 Nov 2003
178  */
179 void tw_quit(int dummy)
180 {
181   extern void exit(int);
182 
183   exit(0);
184 }
185 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.