File: main.c

package info (click to toggle)
xmorph 1%3A20011220
  • links: PTS
  • area: main
  • in suites: woody
  • size: 3,468 kB
  • ctags: 1,534
  • sloc: ansic: 16,401; sh: 2,651; makefile: 556; tcl: 516
file content (235 lines) | stat: -rw-r--r-- 5,475 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
/*
 * Initial main.c file generated by Glade. Edit as required.
 * Glade will not overwrite this file.
 */

#include "stdio.h"
#include <string.h>

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <gtk/gtk.h>

#ifdef USE_IMLIB
#include <gdk_imlib.h>
#else
#include <gdk-pixbuf/gdk-pixbuf.h>
#endif

#ifdef HAVE_X
#include <gdk/gdkx.h>
#endif
#include <gdk/gdkrgb.h>


#include <gdk/gdk.h>

#include "interface.h"
#include "support.h"
#include "callbacks.h"
#include "gtktopdata.h"
//#include "pixmaps.h"
#include "main.h"
#include "utils.h"
#include "settings.h"
// no we use g_assert
//#include "assert.h"
#include "../libmorph/mesh.h"



GtkWidget *menuFile_g=NULL;
GtkWidget *menuEdit_g=NULL;
GtkWidget *menuMorph_g=NULL;
GtkWidget *menuSettings_g=NULL;
GtkWidget *menuHelp_g=NULL;
//GtkWidget
 GtkFileSelection  *imageselection1_g=NULL; 
GtkWidget *dialogwarning_g=NULL; 






/*************** warning code*/



/* this variable stores the number of the window that we are loading for 
   if this is MAX_WINS+1 then it refers to the window 
   containing the resulting image
   
   and the element 0 is not used
*/

guint fileselection1_for_image_num_g=0;


/********** the current settings are
  in a "structure of arrays " (see main.h)

  why not an "array of structures"?
  because many subroutines work on the
  arrays, and they would become unnecessarily complicated

  on the other end, a  "array of structures"
  may be easily modified to add new images... this
  way, the program will have to be recompiled to add new images;
  but hopefully MAX_WINS may be set to a value that is sufficient 
  in 99.9% of cases

  */

/* we will implement UNDO by copying this structure and its substructures */
extern gtkmorph_status_t    *sp;





int
main (int argc, char *argv[])
{
  
  //Window xwindow1 ;
  GtkWidget *window_main=NULL;

#ifdef ENABLE_NLS
  bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
  textdomain (PACKAGE);
#endif



  gtk_set_locale ();
  gtk_init (&argc, &argv);



    /* Inititalise GDK : done by gtk_init
       gdk_init(&argc,&argv);
       */

  gdk_rgb_init();

#ifdef HAVE_X
  //FIXME I think that I need to do something more...
  gdk_set_sm_client_id (PACKAGE);
#endif


#ifdef USE_IMLIB
  {
    /* Immediately after initialising GDK, Initialise Imlib */
    gdk_imlib_init();
    /* Get gdk to use imlib's visual and colormap */
    gtk_widget_push_visual(gdk_imlib_get_visual());
    gtk_widget_push_colormap(gdk_imlib_get_colormap());
  }
#else
  
#endif

  add_pixmap_directory (PACKAGE_DATA_DIR "/pixmaps");
  add_pixmap_directory (PACKAGE_SOURCE_DIR "/pixmaps");

  /*
   * The following code was added by Glade to create one of each component
   * (except popup menus), just so that you see something after building
   * the project. Delete any components that you don't want shown initially.
   */

  menuFile_g=create_menuFile();
  /*never do this! gtk_widget_show (menuFile_g);*/
  menuEdit_g=create_menuEdit();
  menuMorph_g=create_menuMorph(); 
  menuHelp_g=create_menuHelp();
  menuSettings_g=create_gtkmorph_menuSettings();
  /* Create a new file selection widget */
  imageselection1_g =     GTK_FILE_SELECTION(create_imageselection1() );
  gtk_file_selection_set_filename (imageselection1_g, "imagefile.png");

    
  sp->resulting_width =  sp->resulting_width_sp = 768;
  sp->resulting_height = sp->resulting_height_sp = 576;
  sp->meshes_x=40;
  sp->meshes_y=30;
  
  /* create images */

  // this is honored in the following
  sp->max_wins=1;
  
  {
    int lp;
    for(lp=1 ; lp <= sp->max_wins;  lp ++)
      {
	create_and_show_image_win(lp);
      }
  }

  setup_handlebox_factors();


  window_main = create_window_main ();
  // FIXME I am undecided
  // 1) the resulting image is in a  window, and there is the main window
  // 2) the resulting image is in detachable handlebox in  ' '     ' '
  // Actually we can switch from one to the other:
  //  we detach the content and we attach it in the other.
  // It looks complicated but the fact is, I would like
  // the possibility that the user may set with a preference 1) or 2)
  if (0) {
    // case 1) NOW DONT WORK
    //we create the MAX_WINS+1 to hold the resulting image
    create_and_show_image_win(MAX_WINS+1);    
    {
      GtkWidget* hb= lookup_widget  (window_main ,
				     "resultingimage_frame"),
	* vb=lookup_widget  (sp->im_widget[MAX_WINS+1] ,  "vbox3");
      g_assert(hb); 
      g_assert(vb);
      gtk_container_remove(GTK_CONTAINER (sp->im_widget[MAX_WINS+1]),
			   vb);
      gtk_container_add (GTK_CONTAINER (hb), vb);   
      gtk_widget_destroy(sp->im_widget[MAX_WINS+1]);
      sp->im_widget[MAX_WINS+1]=vb;
    }
  }
  else //case 2)
    {
      sp->im_widget[MAX_WINS+1]=window_main;
      init_image_win_data_and_set_all(MAX_WINS+1, window_main,"gtkmorph");
    }

  //FIXME is this really used?
  //gtk_widget_set_data_top(window_main,"imagenum",
  //			  GUINT_TO_POINTER(MAX_WINS+2));
  //now it needs to be set to MA_WINS+1 since it contains the resulting image
  gtk_widget_set_data_top(window_main,"imagenum",
			  GUINT_TO_POINTER(MAX_WINS+1));

  /* fix things as prescribed by the current settings */
  gtkmorph_settings_callback();

  gtk_widget_show (window_main);
 
  //xwindow_main = GDK_WINDOW_XWINDOW (GTK_WIDGET (window_main)->window);

  allocate_colors( window_main );

  /* this will crash if some problems are encountered */
  fileselection1_for_image_num_g=-1;


  gtk_main ();


  return 0;
}