]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/surface_quake2/surfacedialog.cpp
* fixed a lot of compiler warnings (mostly const char * stuff and use of uninitialize...
[xonotic/netradiant.git] / plugins / surface_quake2 / surfacedialog.cpp
1 /*
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5 This file is part of GtkRadiant.
6
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 */
21
22 //
23 // Surface Dialog Module
24 //
25
26 //
27 // Nurail: Implemented to Module from the main Radiant Surface Dialog code
28 //
29
30
31 #include <gtk/gtk.h>
32 #include <glib/gi18n.h>
33 #include <gdk/gdkkeysyms.h>
34
35 #include "surfdlg_plugin.h"
36
37
38
39 #ifdef _DEBUG
40 //#define DBG_SI 1
41 #endif
42
43 #include "gtkr_vector.h"
44
45 std::vector<texdef_to_face_t> g_texdef_face_vector;
46
47 inline texdef_to_face_t* get_texdef_face_list()
48 {
49   return &(*g_texdef_face_vector.begin());
50 }
51
52 inline unsigned int texdef_face_list_empty()
53 {
54   return g_texdef_face_vector.empty();
55 }
56
57 inline unsigned int texdef_face_list_size()
58 {
59   return g_texdef_face_vector.size();
60 }
61
62 // For different faces having different values
63 bool is_HShift_conflicting;
64 bool is_VShift_conflicting;
65 bool is_HScale_conflicting;
66 bool is_VScale_conflicting;
67 bool is_Rotate_conflicting;
68 bool is_TextureName_conflicting;
69
70 void ShowDlg();
71 void HideDlg();
72 void SetTexMods();
73 void GetTexMods(bool b_SetUndoPoint = FALSE);
74 void BuildDialog();
75 void FitAll();
76 void InitDefaultIncrement(texdef_t *);
77 void DoSnapTToGrid(float hscale, float vscale);
78 // called to perform a fitting from the outside (shortcut key)
79 void SurfaceDialogFitAll();
80
81 // Quake2 Flags Functions
82 void SetFlagButtons_Quake2(texdef_to_face_t *texdef_face_list,  bool b_isListEmpty);
83 void SetChangeInFlags_Face_Quake2 (texdef_to_face_t *texdef_face_list);
84 GtkWidget* Create_Quake2FlagsDialog (GtkWidget* surfacedialog_widget);
85
86
87 // Dialog Data
88 int m_nHeight;
89 int m_nWidth;
90
91 // 0 is invalid, otherwise it's the Id of the last 'do' we are responsible for
92 int m_nUndoId;
93
94
95 texturewin_t *texturewin;
96 texdef_t *l_pIncrement;
97 texdef_t texdef_offset;
98 texdef_t texdef_SI_values;
99
100 // For Texture Entry, activate only on entry change
101 char old_texture_entry[128];
102
103 // the texdef to switch back to when the OnCancel is called
104 texdef_t        g_old_texdef;
105
106 // when TRUE, this thing means the surface inspector is currently being displayed
107 bool  g_surfwin = FALSE;
108 // turn on/off processing of the "changed" "value_changed" messages
109 // (need to turn off when we are feeding data in)
110 bool g_bListenChanged = true;
111 // turn on/off listening of the update messages
112 bool g_bListenUpdate = true;
113
114 GtkWidget* create_SurfaceInspector (void);
115 GtkWidget *SurfaceInspector = NULL;
116
117 GtkWidget *m_pWidget;
118 GtkWidget *GetWidget () { return SurfaceInspector; }
119 GtkWidget *Get_SI_Module_Widget () { return SurfaceInspector; }
120 void SetWidget(GtkWidget *new_widget) { m_pWidget = new_widget; }
121 GtkWidget *GetDlgWidget (const char* name)
122   { return GTK_WIDGET (g_object_get_data (G_OBJECT (SurfaceInspector), name)); }
123
124 // Spins for FitTexture
125 GtkWidget *spin_width;
126 GtkWidget *spin_height;
127
128
129 GtkWidget *texture_combo;
130 GtkWidget *texture_combo_entry;
131
132 GtkWidget *match_grid_button;
133 GtkWidget *lock_valuechange_togglebutton;
134
135 GtkObject *hshift_value_spinbutton_adj;
136 GtkWidget *hshift_value_spinbutton;
137 GtkObject *vshift_value_spinbutton_adj;
138 GtkWidget *vshift_value_spinbutton;
139 GtkObject *hscale_value_spinbutton_adj;
140 GtkWidget *hscale_value_spinbutton;
141 GtkObject *vscale_value_spinbutton_adj;
142 GtkWidget *vscale_value_spinbutton;
143 GtkObject *rotate_value_spinbutton_adj;
144 GtkWidget *rotate_value_spinbutton;
145
146 GtkObject *hshift_offset_spinbutton_adj;
147 GtkWidget *hshift_offset_spinbutton;
148 GtkObject *vshift_offset_spinbutton_adj;
149 GtkWidget *vshift_offset_spinbutton;
150 GtkObject *hscale_offset_spinbutton_adj;
151 GtkWidget *hscale_offset_spinbutton;
152 GtkObject *vscale_offset_spinbutton_adj;
153 GtkWidget *vscale_offset_spinbutton;
154 GtkObject *rotate_offset_spinbutton_adj;
155 GtkWidget *rotate_offset_spinbutton;
156
157 GtkObject *hshift_step_spinbutton_adj;
158 GtkWidget *hshift_step_spinbutton;
159 GtkObject *vshift_step_spinbutton_adj;
160 GtkWidget *vshift_step_spinbutton;
161 GtkObject *hscale_step_spinbutton_adj;
162 GtkWidget *hscale_step_spinbutton;
163 GtkObject *vscale_step_spinbutton_adj;
164 GtkWidget *vscale_step_spinbutton;
165 GtkObject *rotate_step_spinbutton_adj;
166 GtkWidget *rotate_step_spinbutton;
167
168 GtkObject *fit_width_spinbutton_adj;
169 GtkWidget *fit_width_spinbutton;
170 GtkObject *fit_height_spinbutton_adj;
171 GtkWidget *fit_height_spinbutton;
172 GtkWidget *fit_button;
173 GtkWidget *axial_button;
174
175 GtkWidget *done_button;
176 GtkWidget *apply_button;
177 GtkWidget *cancel_button;
178
179 // Callbacks
180 gboolean on_texture_combo_entry_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data);
181 void on_texture_combo_entry_activate (GtkEntry *entry, gpointer user_data);
182
183 static void on_match_grid_button_clicked (GtkButton *button, gpointer user_data);
184 static void on_lock_valuechange_togglebutton_toggled (GtkToggleButton *togglebutton, gpointer user_data);
185
186 static void on_hshift_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
187 static void on_vshift_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
188 static void on_hscale_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
189 static void on_vscale_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
190 static void on_rotate_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
191
192 static void on_hshift_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
193 static void on_vshift_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
194 static void on_hscale_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
195 static void on_vscale_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
196 static void on_rotate_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
197
198 static void on_hshift_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
199 static void on_vshift_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
200 static void on_hscale_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
201 static void on_vscale_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
202 static void on_rotate_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
203
204 static void on_fit_width_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
205 static void on_fit_height_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data);
206 static void on_fit_button_clicked (GtkButton *button, gpointer user_data);
207 static void on_axial_button_clicked (GtkButton *button, gpointer user_data);
208
209 static void on_done_button_clicked (GtkButton *button, gpointer user_data);
210 static void on_apply_button_clicked (GtkButton *button, gpointer user_data);
211 static void on_cancel_button_clicked (GtkButton *button, gpointer user_data);
212
213
214 /*
215 ===================================================
216
217   SURFACE INSPECTOR
218
219 ===================================================
220 */
221
222
223 void IsFaceConflicting()
224 {
225   texdef_t* tmp_texdef;
226   texdef_to_face_t* temp_texdef_face_list;
227   char buf[12];
228   char texture_name[128];
229
230   if (texdef_face_list_empty())
231   {
232     gtk_entry_set_text( GTK_ENTRY (hshift_value_spinbutton), "");
233     gtk_entry_set_text( GTK_ENTRY (vshift_value_spinbutton), "");
234     gtk_entry_set_text( GTK_ENTRY (hscale_value_spinbutton), "");
235     gtk_entry_set_text( GTK_ENTRY (vscale_value_spinbutton), "");
236     gtk_entry_set_text( GTK_ENTRY (rotate_value_spinbutton), "");
237     gtk_entry_set_text( GTK_ENTRY (texture_combo_entry), "");
238     return;
239   }
240
241   g_bListenChanged = FALSE;
242
243   tmp_texdef = &get_texdef_face_list()->texdef;
244
245   strcpy(texture_name, tmp_texdef->GetName() );
246
247   texdef_SI_values.shift[0] = tmp_texdef->shift[0];
248   texdef_SI_values.shift[1] = tmp_texdef->shift[1];
249   texdef_SI_values.scale[0] = tmp_texdef->scale[0];
250   texdef_SI_values.scale[1] = tmp_texdef->scale[1];
251   texdef_SI_values.rotate = tmp_texdef->rotate;
252   texdef_SI_values.SetName( texture_name );
253
254   is_HShift_conflicting = FALSE;
255   is_VShift_conflicting = FALSE;
256   is_HScale_conflicting = FALSE;
257   is_VScale_conflicting = FALSE;
258   is_Rotate_conflicting = FALSE;
259   is_TextureName_conflicting = FALSE;
260
261   if (texdef_face_list_size() > 1)
262   {
263     temp_texdef_face_list = get_texdef_face_list()->next;
264
265     for (temp_texdef_face_list; temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
266     {
267       tmp_texdef = &temp_texdef_face_list->texdef;
268       if ( texdef_SI_values.shift[0] != tmp_texdef->shift[0] )
269         is_HShift_conflicting = TRUE;
270
271       if ( texdef_SI_values.shift[1] != tmp_texdef->shift[1] )
272         is_VShift_conflicting = TRUE;
273
274       if ( texdef_SI_values.scale[0] != tmp_texdef->scale[0] )
275         is_HScale_conflicting = TRUE;
276
277       if ( texdef_SI_values.scale[1] != tmp_texdef->scale[1] )
278         is_VScale_conflicting = TRUE;
279
280       if ( texdef_SI_values.rotate != tmp_texdef->rotate )
281         is_Rotate_conflicting = TRUE;
282
283       if ( strcmp( texture_name, tmp_texdef->GetName() ) )
284         is_TextureName_conflicting = TRUE;
285     }
286   }
287
288   if(is_HShift_conflicting)
289     gtk_entry_set_text( GTK_ENTRY (hshift_value_spinbutton), "");
290   else
291     gtk_spin_button_set_value( GTK_SPIN_BUTTON(hshift_value_spinbutton) , texdef_SI_values.shift[0] );
292
293   if(is_VShift_conflicting)
294     gtk_entry_set_text( GTK_ENTRY (vshift_value_spinbutton), "");
295   else
296     gtk_spin_button_set_value( GTK_SPIN_BUTTON(vshift_value_spinbutton) , texdef_SI_values.shift[1] );
297
298   if(is_HScale_conflicting)
299     gtk_entry_set_text( GTK_ENTRY (hscale_value_spinbutton), "");
300   else
301     gtk_spin_button_set_value( GTK_SPIN_BUTTON(hscale_value_spinbutton) , texdef_SI_values.scale[0] );
302
303   if(is_VScale_conflicting)
304     gtk_entry_set_text( GTK_ENTRY (vscale_value_spinbutton), "");
305   else
306     gtk_spin_button_set_value( GTK_SPIN_BUTTON(vscale_value_spinbutton) , texdef_SI_values.scale[1] );
307
308   if(is_Rotate_conflicting)
309     gtk_entry_set_text( GTK_ENTRY (rotate_value_spinbutton), "");
310   else
311     gtk_spin_button_set_value( GTK_SPIN_BUTTON(rotate_value_spinbutton) , texdef_SI_values.rotate );
312
313   g_bListenChanged = TRUE;
314 }
315
316 #define MAX_NUM_LIST_ITEMS 15
317 static void PopulateTextureComboList()
318 {
319   texdef_t* tmp_texdef;
320   texdef_to_face_t* temp_texdef_face_list;
321   char blank[1];
322   GList *items = NULL;
323   GList *tmp_item;
324   int num_of_list_items = 0;
325
326   blank[0] = 0;
327
328   if (texdef_face_list_empty())
329   {
330     items = g_list_append (items, (gpointer) blank);
331     // For Texture Entry, activate only on entry change
332     strcpy (old_texture_entry, blank);
333   }
334   else if ( !is_TextureName_conflicting )
335   {
336     temp_texdef_face_list = get_texdef_face_list();
337     tmp_texdef = (texdef_t *) &get_texdef_face_list()->texdef;
338     items = g_list_append( items, (gpointer) tmp_texdef->GetName() );
339     // For Texture Entry, activate only on entry change
340     strcpy (old_texture_entry, tmp_texdef->GetName());
341   }
342   else
343   {
344     for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
345     {
346       tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
347       // Need to do a string compare, hence the custom search
348       if (!( g_list_find_custom (items, tmp_texdef->GetName(), (GCompareFunc) strcmp ) ))
349       {
350         items = g_list_append( items, (gpointer) tmp_texdef->GetName() );
351         num_of_list_items++;
352       }
353       // Make sure the combo list isn't too long
354       if (num_of_list_items >= MAX_NUM_LIST_ITEMS)
355         break;
356     }
357     // If this isn't added last (to the top of the list), g_list_find freaks.
358     items = g_list_prepend (items, (gpointer) blank);
359     // For Texture Entry, activate only on entry change
360     strcpy (old_texture_entry, blank);
361   }
362
363   gtk_combo_set_popdown_strings (GTK_COMBO (texture_combo), items);
364   g_list_free(items);
365
366 }
367
368 static void ZeroOffsetValues()
369 {
370   texdef_offset.shift[0] = 0.0;
371   texdef_offset.shift[1] = 0.0;
372   texdef_offset.scale[0] = 0.0;
373   texdef_offset.scale[1] = 0.0;
374   texdef_offset.rotate = 0.0;
375 }
376
377 static void GetTexdefInfo_from_Radiant()
378 {
379   g_texdef_face_vector.clear();
380
381   unsigned int count = GetSelectedFaceCountfromBrushes();
382   if(count == 0)
383     count = GetSelectedFaceCount();
384
385   g_texdef_face_vector.resize(count);
386
387   if (!texdef_face_list_empty())
388   {
389     texdef_to_face_t* p = get_texdef_face_list();
390     GetSelFacesTexdef( get_texdef_face_list() );
391   }
392
393   IsFaceConflicting();
394   PopulateTextureComboList();
395   ZeroOffsetValues();
396   if ( texdef_face_list_empty() )
397     SetFlagButtons_Quake2( get_texdef_face_list() , TRUE);
398   else
399     SetFlagButtons_Quake2( get_texdef_face_list() , FALSE);
400 }
401
402 static gint delete_event_callback(GtkWidget *widget, GdkEvent* event, gpointer data)
403 {
404   HideDlg();
405   return TRUE;
406 }
407
408 // make the shift increments match the grid settings
409 // the objective being that the shift+arrows shortcuts move the texture by the corresponding grid size
410 // this depends on a scale value if you have selected a particular texture on which you want it to work:
411 // we move the textures in pixels, not world units. (i.e. increment values are in pixel)
412 // depending on the texture scale it doesn't take the same amount of pixels to move of g_qeglobals.d_gridsize
413 // increment * scale = gridsize
414 // hscale and vscale are optional parameters, if they are zero they will be set to the default scale
415 // NOTE: the default scale depends if you are using BP mode or regular.
416 // For regular it's 0.5f (128 pixels cover 64 world units), for BP it's simply 1.0f
417 // see fenris #2810
418 void DoSnapTToGrid(float hscale, float vscale)
419 {
420   l_pIncrement = Get_SI_Inc();
421
422   if (hscale == 0.0f)
423   {
424     hscale = 0.5f;
425   }
426   if (vscale == 0.0f)
427   {
428      vscale = 0.5f;
429   }
430 #ifdef _DEBUG
431   Sys_Printf ("DoSnapTToGrid: hscale %g vscale %g\n", hscale, vscale);
432 #endif
433   l_pIncrement->shift[0] = GridSize() / hscale;
434   l_pIncrement->shift[1] = GridSize() / vscale;
435   // now some update work
436   // FIXME: doesn't look good here, seems to be called several times
437   SetTexMods();
438 }
439
440 void UpdateSurfaceDialog()
441 {
442   if (!g_bListenUpdate)
443     return;
444
445   if (!SurfaceInspector)
446     return;
447
448   // avoid long delays on slow computers
449   while (gtk_events_pending ())
450     gtk_main_iteration ();
451
452   if (g_surfwin)
453   {
454 #ifdef DBG_SI
455     Sys_Printf("UpdateSurfaceDialog\n");
456 #endif
457     GetTexdefInfo_from_Radiant();
458     SetTexMods();
459   }
460
461 }
462
463 // DoSurface will always try to show the surface inspector
464 // or update it because something new has been selected
465 void DoSurface (void)
466 {
467 #ifdef DBG_SI
468   Sys_Printf("DoSurface\n");
469 #endif
470   if (!SurfaceInspector)
471     create_SurfaceInspector ();
472
473   ShowDlg();
474   SetTexMods ();
475 }
476
477 void ToggleSurface()
478 {
479 #ifdef DBG_SI
480   Sys_Printf("ToggleSurface Module\n");
481 #endif
482   if (!g_surfwin)
483     DoSurface ();
484   else
485     on_cancel_button_clicked(NULL, NULL);
486 }
487
488 // NOTE: will raise and show the Surface inspector and exec fit for patches and brushes
489 void SurfaceDlgFitAll()
490 {
491   DoSurface();
492   FitAll();
493 }
494
495 // =============================================================================
496 // SurfaceDialog class
497
498 void ShowDlg()
499 {
500
501   if(!SurfaceInspector)
502     create_SurfaceInspector();
503   else
504     gtk_widget_show (SurfaceInspector);
505
506   GetTexdefInfo_from_Radiant();
507   GetTexMods(TRUE); // Set Initial Undo Point
508   g_surfwin = TRUE;
509 }
510
511 void HideDlg()
512 {
513   g_surfwin = FALSE;
514   gtk_widget_hide (SurfaceInspector);
515 }
516
517
518 // set default values for increments (shift scale and rot)
519 // this is called by the prefs code if can't find the values
520 void InitDefaultIncrement(texdef_t *tex)
521 {
522   tex->SetName("foo");
523   tex->shift[0] = 8;
524   tex->shift[1] = 8;
525   tex->scale[0] = 0.25;
526   tex->scale[1] = 0.25;
527   tex->rotate = 10;
528 }
529
530 void BuildDialog ()
531 {
532    if ( !SurfaceInspector )
533     create_SurfaceInspector();
534 }
535
536 /*
537 ==============
538 SetTexMods
539
540 Set the fields to the current texdef (i.e. map/texdef -> dialog widgets)
541 ===============
542 */
543
544 void SetTexMods()
545 {
546   texdef_t *pt;
547   GtkSpinButton *spin;
548   GtkAdjustment *adjust;
549
550   texturewin = Texturewin ();
551   l_pIncrement = Get_SI_Inc();
552
553 #ifdef DBG_SI
554   Sys_Printf("SurfaceDlg SetTexMods\n");
555 #endif
556
557   if (!g_surfwin)
558     return;
559
560   pt = &texturewin->texdef;
561
562   g_bListenChanged = false;
563
564   if(strncmp(pt->GetName(), "textures/", 9) != 0)
565     texdef_offset.SetName(SHADER_NOT_FOUND);
566
567
568   spin = GTK_SPIN_BUTTON (hshift_offset_spinbutton);
569   gtk_spin_button_set_value (spin, texdef_offset.shift[0]);
570   adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
571   adjust->step_increment = l_pIncrement->shift[0];
572   gtk_spin_button_set_value (GTK_SPIN_BUTTON(hshift_step_spinbutton), l_pIncrement->shift[0]);
573
574   spin = GTK_SPIN_BUTTON (hshift_value_spinbutton);
575   adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
576   adjust->step_increment = l_pIncrement->shift[0];
577
578
579   spin = GTK_SPIN_BUTTON (vshift_offset_spinbutton);
580   gtk_spin_button_set_value (spin, texdef_offset.shift[1]);
581   adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
582   adjust->step_increment = l_pIncrement->shift[1];
583   gtk_spin_button_set_value (GTK_SPIN_BUTTON(vshift_step_spinbutton), l_pIncrement->shift[1]);
584
585   spin = GTK_SPIN_BUTTON (vshift_value_spinbutton);
586   adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
587   adjust->step_increment = l_pIncrement->shift[1];
588
589
590   spin = GTK_SPIN_BUTTON (hscale_offset_spinbutton);
591   gtk_spin_button_set_value (spin, texdef_offset.scale[0]);
592   adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
593   adjust->step_increment = l_pIncrement->scale[0];
594   gtk_spin_button_set_value (GTK_SPIN_BUTTON(hscale_step_spinbutton), l_pIncrement->scale[0]);
595
596   spin = GTK_SPIN_BUTTON (hscale_value_spinbutton);
597   adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
598   adjust->step_increment = l_pIncrement->scale[0];
599
600
601   spin = GTK_SPIN_BUTTON (vscale_offset_spinbutton);
602   gtk_spin_button_set_value (spin, texdef_offset.scale[1]);
603   adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
604   adjust->step_increment = l_pIncrement->scale[1];
605   gtk_spin_button_set_value (GTK_SPIN_BUTTON(vscale_step_spinbutton), l_pIncrement->scale[1]);
606
607   spin = GTK_SPIN_BUTTON (vscale_value_spinbutton);
608   adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
609   adjust->step_increment = l_pIncrement->scale[1];
610
611
612   spin = GTK_SPIN_BUTTON (rotate_offset_spinbutton);
613   gtk_spin_button_set_value (spin, texdef_offset.rotate);
614   adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
615   adjust->step_increment = l_pIncrement->rotate;
616   gtk_spin_button_set_value (GTK_SPIN_BUTTON(rotate_step_spinbutton), l_pIncrement->rotate);
617
618   spin = GTK_SPIN_BUTTON (rotate_value_spinbutton);
619   adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin));
620   adjust->step_increment = l_pIncrement->rotate;
621
622
623   g_bListenChanged = true;
624
625   // store the current texdef as our escape route if user hits OnCancel
626   g_old_texdef = texturewin->texdef;
627 }
628
629 /*
630 ==============
631 GetTexMods
632
633 Shows any changes to the main Radiant windows
634 ===============
635 */
636 void GetTexMods(bool b_SetUndoPoint)
637 {
638
639 #ifdef DBG_SI
640   Sys_Printf("SurfaceDlg GetTexMods\n");
641 #endif
642
643   if ( !texdef_face_list_empty() )
644   {
645     g_bListenUpdate=FALSE;
646     SetChangeInFlags_Face_Quake2 ( get_texdef_face_list() );
647     SetTexdef_FaceList( get_texdef_face_list(), b_SetUndoPoint, false );
648     g_bListenUpdate=TRUE;
649
650     if (b_SetUndoPoint)
651       m_nUndoId = Undo_GetUndoId();
652   }
653 }
654
655 void FitAll()
656 {
657   on_fit_button_clicked(NULL, NULL);
658 }
659
660
661 ////////////////////////////////////////////////////////////////////
662 //
663 //  GUI Section
664 //
665 ////////////////////////////////////////////////////////////////////
666
667 GtkWidget* create_SurfaceInspector (void)
668 {
669
670   GtkWidget *label;
671   GtkWidget *hseparator;
672   GtkWidget *eventbox;
673
674   GtkWidget *viewport8;
675   GtkWidget *viewport9;
676   GtkWidget *viewport2;
677   GtkWidget *viewport7;
678   GtkWidget *viewport5;
679   GtkWidget *viewport6;
680   GtkWidget *viewport10;
681
682   GtkWidget *table1;
683   GtkWidget *table4;
684   GtkWidget *table5;
685   GtkWidget *table7;
686
687   GtkWidget *alignment1;
688   GtkWidget *alignment2;
689   GtkWidget *alignment3;
690
691   GtkWidget *vbox7;
692
693   GtkWidget *hbox1;
694   GtkWidget *hbox2;
695   GtkWidget *hbox3;
696   GtkWidget *hbox4;
697
698   GtkWidget *image1;
699   GtkWidget *image2;
700   GtkWidget *image3;
701
702   GtkWidget *hbuttonbox1;
703
704   SurfaceInspector = gtk_window_new (GTK_WINDOW_TOPLEVEL);
705   gtk_container_set_border_width (GTK_CONTAINER (SurfaceInspector), 4);
706   gtk_window_set_title (GTK_WINDOW (SurfaceInspector), "Surface Inspector");
707
708   SetWinPos_from_Prefs(SurfaceInspector);
709
710   viewport8 = gtk_viewport_new (NULL, NULL);
711   gtk_widget_show (viewport8);
712   gtk_container_add (GTK_CONTAINER (SurfaceInspector), viewport8);
713   gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport8), GTK_SHADOW_NONE);
714
715   vbox7 = gtk_vbox_new (FALSE, 0);
716   gtk_widget_show (vbox7);
717   gtk_container_add (GTK_CONTAINER (viewport8), vbox7);
718
719   viewport9 = gtk_viewport_new (NULL, NULL);
720   gtk_widget_show (viewport9);
721   gtk_box_pack_start (GTK_BOX (vbox7), viewport9, FALSE, FALSE, 0);
722   gtk_container_set_border_width (GTK_CONTAINER (viewport9), 2);
723   gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport9), GTK_SHADOW_ETCHED_IN);
724
725   hbox1 = gtk_hbox_new (FALSE, 0);
726   gtk_widget_show (hbox1);
727   gtk_container_add (GTK_CONTAINER (viewport9), hbox1);
728   gtk_container_set_border_width (GTK_CONTAINER (hbox1), 4);
729
730   label = gtk_label_new ("Texture: ");
731   gtk_widget_show (label);
732   gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
733   gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
734
735   texture_combo = gtk_combo_new ();
736   g_object_set_data (G_OBJECT (GTK_COMBO (texture_combo)->popwin),
737                      "KeepMeAround", texture_combo);
738   gtk_combo_disable_activate ( (GtkCombo*) texture_combo);
739   gtk_widget_show (texture_combo);
740   gtk_box_pack_start (GTK_BOX (hbox1), texture_combo, TRUE, TRUE, 0);
741
742   texture_combo_entry = GTK_COMBO (texture_combo)->entry;
743   gtk_widget_show (texture_combo_entry);
744   gtk_entry_set_max_length (GTK_ENTRY (texture_combo_entry), 128);
745
746   viewport2 = gtk_viewport_new (NULL, NULL);
747   gtk_widget_show (viewport2);
748   gtk_box_pack_start (GTK_BOX (vbox7), viewport2, FALSE, TRUE, 0);
749   gtk_container_set_border_width (GTK_CONTAINER (viewport2), 2);
750   gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport2), GTK_SHADOW_ETCHED_IN);
751
752   table1 = gtk_table_new (13, 4, FALSE);
753   gtk_widget_show (table1);
754   gtk_container_add (GTK_CONTAINER (viewport2), table1);
755
756   hseparator = gtk_hseparator_new ();
757   gtk_widget_show (hseparator);
758   gtk_table_attach (GTK_TABLE (table1), hseparator, 1, 2, 1, 2,
759                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
760                     (GtkAttachOptions) (GTK_FILL), 0, 0);
761
762   hseparator = gtk_hseparator_new ();
763   gtk_widget_show (hseparator);
764   gtk_table_attach (GTK_TABLE (table1), hseparator, 2, 3, 1, 2,
765                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
766                     (GtkAttachOptions) (GTK_FILL), 0, 0);
767
768   hseparator = gtk_hseparator_new ();
769   gtk_widget_show (hseparator);
770   gtk_table_attach (GTK_TABLE (table1), hseparator, 3, 4, 1, 2,
771                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
772                     (GtkAttachOptions) (GTK_FILL), 0, 0);
773
774   hseparator = gtk_hseparator_new ();
775   gtk_widget_show (hseparator);
776   gtk_table_attach (GTK_TABLE (table1), hseparator, 1, 2, 3, 4,
777                     (GtkAttachOptions) (GTK_FILL),
778                     (GtkAttachOptions) (GTK_FILL), 0, 0);
779
780   hseparator = gtk_hseparator_new ();
781   gtk_widget_show (hseparator);
782   gtk_table_attach (GTK_TABLE (table1), hseparator, 2, 3, 3, 4,
783                     (GtkAttachOptions) (GTK_FILL),
784                     (GtkAttachOptions) (GTK_FILL), 0, 0);
785
786   hseparator = gtk_hseparator_new ();
787   gtk_widget_show (hseparator);
788   gtk_table_attach (GTK_TABLE (table1), hseparator, 3, 4, 3, 4,
789                     (GtkAttachOptions) (GTK_FILL),
790                     (GtkAttachOptions) (GTK_FILL), 0, 0);
791
792   hseparator = gtk_hseparator_new ();
793   gtk_widget_show (hseparator);
794   gtk_table_attach (GTK_TABLE (table1), hseparator, 1, 2, 5, 6,
795                     (GtkAttachOptions) (GTK_FILL),
796                     (GtkAttachOptions) (GTK_FILL), 0, 0);
797
798   hseparator = gtk_hseparator_new ();
799   gtk_widget_show (hseparator);
800   gtk_table_attach (GTK_TABLE (table1), hseparator, 2, 3, 5, 6,
801                     (GtkAttachOptions) (GTK_FILL),
802                     (GtkAttachOptions) (GTK_FILL), 0, 0);
803
804   hseparator = gtk_hseparator_new ();
805   gtk_widget_show (hseparator);
806   gtk_table_attach (GTK_TABLE (table1), hseparator, 3, 4, 5, 6,
807                     (GtkAttachOptions) (GTK_FILL),
808                     (GtkAttachOptions) (GTK_FILL), 0, 0);
809
810   hseparator = gtk_hseparator_new ();
811   gtk_widget_show (hseparator);
812   gtk_table_attach (GTK_TABLE (table1), hseparator, 1, 2, 7, 8,
813                     (GtkAttachOptions) (GTK_FILL),
814                     (GtkAttachOptions) (GTK_FILL), 0, 0);
815
816   hseparator = gtk_hseparator_new ();
817   gtk_widget_show (hseparator);
818   gtk_table_attach (GTK_TABLE (table1), hseparator, 2, 3, 7, 8,
819                     (GtkAttachOptions) (GTK_FILL),
820                     (GtkAttachOptions) (GTK_FILL), 0, 0);
821
822   hseparator = gtk_hseparator_new ();
823   gtk_widget_show (hseparator);
824   gtk_table_attach (GTK_TABLE (table1), hseparator, 3, 4, 7, 8,
825                     (GtkAttachOptions) (GTK_FILL),
826                     (GtkAttachOptions) (GTK_FILL), 0, 0);
827
828   hseparator = gtk_hseparator_new ();
829   gtk_widget_show (hseparator);
830   gtk_table_attach (GTK_TABLE (table1), hseparator, 1, 2, 9, 10,
831                     (GtkAttachOptions) (GTK_FILL),
832                     (GtkAttachOptions) (GTK_FILL), 0, 0);
833
834   hseparator = gtk_hseparator_new ();
835   gtk_widget_show (hseparator);
836   gtk_table_attach (GTK_TABLE (table1), hseparator, 2, 3, 9, 10,
837                     (GtkAttachOptions) (GTK_FILL),
838                     (GtkAttachOptions) (GTK_FILL), 0, 0);
839
840   hseparator = gtk_hseparator_new ();
841   gtk_widget_show (hseparator);
842   gtk_table_attach (GTK_TABLE (table1), hseparator, 3, 4, 9, 10,
843                     (GtkAttachOptions) (GTK_FILL),
844                     (GtkAttachOptions) (GTK_FILL), 0, 0);
845
846   hseparator = gtk_hseparator_new ();
847   gtk_widget_show (hseparator);
848   gtk_table_attach (GTK_TABLE (table1), hseparator, 1, 2, 11, 12,
849                     (GtkAttachOptions) (GTK_FILL),
850                     (GtkAttachOptions) (GTK_FILL), 0, 0);
851
852   hseparator = gtk_hseparator_new ();
853   gtk_widget_show (hseparator);
854   gtk_table_attach (GTK_TABLE (table1), hseparator, 2, 3, 11, 12,
855                     (GtkAttachOptions) (GTK_FILL),
856                     (GtkAttachOptions) (GTK_FILL), 0, 0);
857
858   hseparator = gtk_hseparator_new ();
859   gtk_widget_show (hseparator);
860   gtk_table_attach (GTK_TABLE (table1), hseparator, 3, 4, 11, 12,
861                     (GtkAttachOptions) (GTK_FILL),
862                     (GtkAttachOptions) (GTK_FILL), 0, 0);
863
864   label = gtk_label_new ("Offset");
865   gtk_widget_show (label);
866   gtk_table_attach (GTK_TABLE (table1), label, 2, 3, 0, 1,
867                     (GtkAttachOptions) (GTK_FILL),
868                     (GtkAttachOptions) (0), 0, 0);
869
870   label = gtk_label_new ("Step");
871   gtk_widget_show (label);
872   gtk_table_attach (GTK_TABLE (table1), label, 3, 4, 0, 1,
873                     (GtkAttachOptions) (GTK_FILL),
874                     (GtkAttachOptions) (0), 0, 0);
875
876   eventbox = gtk_event_box_new ();
877   gtk_widget_show (eventbox);
878   gtk_table_attach (GTK_TABLE (table1), eventbox, 3, 4, 12, 13,
879                     (GtkAttachOptions) (GTK_FILL),
880                     (GtkAttachOptions) (GTK_FILL), 0, 0);
881
882   match_grid_button = gtk_button_new_with_mnemonic ("Match Grid");
883   gtk_widget_show (match_grid_button);
884   gtk_container_add (GTK_CONTAINER (eventbox), match_grid_button);
885
886   label = gtk_label_new ("Value");
887   gtk_widget_show (label);
888   gtk_table_attach (GTK_TABLE (table1), label, 1, 2, 0, 1,
889                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
890                     (GtkAttachOptions) (0), 0, 0);
891   gtk_misc_set_alignment (GTK_MISC (label), 0.5, 1);
892
893   hseparator = gtk_hseparator_new ();
894   gtk_widget_show (hseparator);
895   gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 3, 4,
896                     (GtkAttachOptions) (GTK_SHRINK | GTK_FILL),
897                     (GtkAttachOptions) (GTK_FILL), 0, 0);
898
899   hseparator = gtk_hseparator_new ();
900   gtk_widget_show (hseparator);
901   gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 5, 6,
902                     (GtkAttachOptions) (GTK_FILL),
903                     (GtkAttachOptions) (GTK_FILL), 0, 0);
904
905   hseparator = gtk_hseparator_new ();
906   gtk_widget_show (hseparator);
907   gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 7, 8,
908                     (GtkAttachOptions) (GTK_FILL),
909                     (GtkAttachOptions) (GTK_FILL), 0, 0);
910
911   hseparator = gtk_hseparator_new ();
912   gtk_widget_show (hseparator);
913   gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 9, 10,
914                     (GtkAttachOptions) (GTK_FILL),
915                     (GtkAttachOptions) (GTK_FILL), 0, 0);
916
917   hseparator = gtk_hseparator_new ();
918   gtk_widget_show (hseparator);
919   gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 11, 12,
920                     (GtkAttachOptions) (GTK_FILL),
921                     (GtkAttachOptions) (GTK_FILL), 0, 0);
922
923   eventbox = gtk_event_box_new ();
924   gtk_widget_show (eventbox);
925   gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 4, 5,
926                     (GtkAttachOptions) (GTK_FILL),
927                     (GtkAttachOptions) (GTK_FILL), 0, 0);
928
929   label = gtk_label_new ("V Shift: ");
930   gtk_widget_show (label);
931   gtk_container_add (GTK_CONTAINER (eventbox), label);
932   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
933   gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
934
935   eventbox = gtk_event_box_new ();
936   gtk_widget_show (eventbox);
937   gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 6, 7,
938                     (GtkAttachOptions) (GTK_FILL),
939                     (GtkAttachOptions) (GTK_FILL), 0, 0);
940
941   label = gtk_label_new (" H Scale: ");
942   gtk_widget_show (label);
943   gtk_container_add (GTK_CONTAINER (eventbox), label);
944   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
945   gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
946
947   eventbox = gtk_event_box_new ();
948   gtk_widget_show (eventbox);
949   gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 8, 9,
950                     (GtkAttachOptions) (GTK_FILL),
951                     (GtkAttachOptions) (GTK_FILL), 0, 0);
952
953   label = gtk_label_new ("V Scale: ");
954   gtk_widget_show (label);
955   gtk_container_add (GTK_CONTAINER (eventbox), label);
956   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
957   gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
958
959   eventbox = gtk_event_box_new ();
960   gtk_widget_show (eventbox);
961   gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 10, 11,
962                     (GtkAttachOptions) (GTK_FILL),
963                     (GtkAttachOptions) (GTK_FILL), 0, 0);
964
965   label = gtk_label_new ("Rotate: ");
966   gtk_widget_show (label);
967   gtk_container_add (GTK_CONTAINER (eventbox), label);
968   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
969   gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
970
971   eventbox = gtk_event_box_new ();
972   gtk_widget_show (eventbox);
973   gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 2, 3,
974                     (GtkAttachOptions) (GTK_FILL),
975                     (GtkAttachOptions) (GTK_FILL), 0, 0);
976
977   label = gtk_label_new ("H Shift: ");
978   gtk_widget_show (label);
979   gtk_container_add (GTK_CONTAINER (eventbox), label);
980   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
981   gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
982
983   hseparator = gtk_hseparator_new ();
984   gtk_widget_show (hseparator);
985   gtk_table_attach (GTK_TABLE (table1), hseparator, 0, 1, 1, 2,
986                     (GtkAttachOptions) (GTK_FILL),
987                     (GtkAttachOptions) (GTK_FILL), 0, 0);
988
989   eventbox = gtk_event_box_new ();
990   gtk_widget_show (eventbox);
991   gtk_table_attach (GTK_TABLE (table1), eventbox, 1, 2, 12, 13,
992                     (GtkAttachOptions) (GTK_FILL),
993                     (GtkAttachOptions) (GTK_FILL), 0, 0);
994
995   lock_valuechange_togglebutton = gtk_toggle_button_new_with_mnemonic ("UNLOCK");
996   gtk_widget_show (lock_valuechange_togglebutton);
997   gtk_container_add (GTK_CONTAINER (eventbox), lock_valuechange_togglebutton);
998
999   // Value Spins
1000   hshift_value_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1001   hshift_value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hshift_value_spinbutton_adj), 1, 2);
1002   gtk_widget_show (hshift_value_spinbutton);
1003   gtk_table_attach (GTK_TABLE (table1), hshift_value_spinbutton, 1, 2, 2, 3,
1004                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1005                     (GtkAttachOptions) (0), 0, 0);
1006   gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hshift_value_spinbutton), GTK_UPDATE_IF_VALID);
1007   gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (hshift_value_spinbutton), TRUE);
1008   gtk_widget_set_sensitive( GTK_WIDGET( hshift_value_spinbutton ), FALSE );
1009
1010   vshift_value_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1011   vshift_value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vshift_value_spinbutton_adj), 1, 2);
1012   gtk_widget_show (vshift_value_spinbutton);
1013   gtk_table_attach (GTK_TABLE (table1), vshift_value_spinbutton, 1, 2, 4, 5,
1014                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1015                     (GtkAttachOptions) (0), 0, 0);
1016   gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vshift_value_spinbutton), GTK_UPDATE_IF_VALID);
1017   gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (vshift_value_spinbutton), TRUE);
1018   gtk_widget_set_sensitive( GTK_WIDGET( vshift_value_spinbutton ), FALSE );
1019
1020   hscale_value_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1021   hscale_value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hscale_value_spinbutton_adj), 1, 4);
1022   gtk_widget_show (hscale_value_spinbutton);
1023   gtk_table_attach (GTK_TABLE (table1), hscale_value_spinbutton, 1, 2, 6, 7,
1024                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1025                     (GtkAttachOptions) (0), 0, 0);
1026   gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hscale_value_spinbutton), GTK_UPDATE_IF_VALID);
1027   gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (hscale_value_spinbutton), TRUE);
1028   gtk_widget_set_sensitive( GTK_WIDGET( hscale_value_spinbutton ), FALSE );
1029
1030   vscale_value_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1031   vscale_value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vscale_value_spinbutton_adj), 1, 4);
1032   gtk_widget_show (vscale_value_spinbutton);
1033   gtk_table_attach (GTK_TABLE (table1), vscale_value_spinbutton, 1, 2, 8, 9,
1034                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1035                     (GtkAttachOptions) (0), 0, 0);
1036   gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vscale_value_spinbutton), GTK_UPDATE_IF_VALID);
1037   gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (vscale_value_spinbutton), TRUE);
1038   gtk_widget_set_sensitive( GTK_WIDGET( vscale_value_spinbutton ), FALSE );
1039
1040   rotate_value_spinbutton_adj = gtk_adjustment_new (0.0, -360.0, 360.0, 1.0, 10.0, 10.0);
1041   rotate_value_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (rotate_value_spinbutton_adj), 1, 0);
1042   gtk_widget_show (rotate_value_spinbutton);
1043   gtk_table_attach (GTK_TABLE (table1), rotate_value_spinbutton, 1, 2, 10, 11,
1044                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1045                     (GtkAttachOptions) (0), 0, 0);
1046   gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (rotate_value_spinbutton), GTK_UPDATE_IF_VALID);
1047   gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (rotate_value_spinbutton), TRUE);
1048   gtk_widget_set_sensitive( GTK_WIDGET( rotate_value_spinbutton ), FALSE );
1049
1050   // Offset Spins
1051   hshift_offset_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1052   hshift_offset_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hshift_offset_spinbutton_adj), 0, 2);
1053   gtk_widget_show (hshift_offset_spinbutton);
1054   gtk_table_attach (GTK_TABLE (table1), hshift_offset_spinbutton, 2, 3, 2, 3,
1055                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1056                     (GtkAttachOptions) (0), 4, 0);
1057   gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (hshift_offset_spinbutton), TRUE);
1058   gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hshift_offset_spinbutton), GTK_UPDATE_IF_VALID);
1059   gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (hshift_offset_spinbutton), TRUE);
1060
1061   vshift_offset_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1062   vshift_offset_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vshift_offset_spinbutton_adj), 0, 2);
1063   gtk_widget_show (vshift_offset_spinbutton);
1064   gtk_table_attach (GTK_TABLE (table1), vshift_offset_spinbutton, 2, 3, 4, 5,
1065                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1066                     (GtkAttachOptions) (0), 4, 0);
1067   gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (vshift_offset_spinbutton), TRUE);
1068   gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vshift_offset_spinbutton), GTK_UPDATE_IF_VALID);
1069   gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (vshift_offset_spinbutton), TRUE);
1070
1071   hscale_offset_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1072   hscale_offset_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hscale_offset_spinbutton_adj), 0, 4);
1073   gtk_widget_show (hscale_offset_spinbutton);
1074   gtk_table_attach (GTK_TABLE (table1), hscale_offset_spinbutton, 2, 3, 6, 7,
1075                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1076                     (GtkAttachOptions) (0), 4, 0);
1077   gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (hscale_offset_spinbutton), TRUE);
1078   gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hscale_offset_spinbutton), GTK_UPDATE_IF_VALID);
1079   gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (hscale_offset_spinbutton), TRUE);
1080
1081   vscale_offset_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1082   vscale_offset_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vscale_offset_spinbutton_adj), 0, 4);
1083   gtk_widget_show (vscale_offset_spinbutton);
1084   gtk_table_attach (GTK_TABLE (table1), vscale_offset_spinbutton, 2, 3, 8, 9,
1085                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1086                     (GtkAttachOptions) (0), 4, 0);
1087   gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (vscale_offset_spinbutton), TRUE);
1088   gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vscale_offset_spinbutton), GTK_UPDATE_IF_VALID);
1089   gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (vscale_offset_spinbutton), TRUE);
1090
1091   rotate_offset_spinbutton_adj = gtk_adjustment_new (0.0, -360.0, 360.0, 1.0, 10.0, 10.0);
1092   rotate_offset_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (rotate_offset_spinbutton_adj), 0, 2);
1093   gtk_widget_show (rotate_offset_spinbutton);
1094   gtk_table_attach (GTK_TABLE (table1), rotate_offset_spinbutton, 2, 3, 10, 11,
1095                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1096                     (GtkAttachOptions) (0), 4, 0);
1097   gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (rotate_offset_spinbutton), TRUE);
1098   gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (rotate_offset_spinbutton), GTK_UPDATE_IF_VALID);
1099   gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (rotate_offset_spinbutton), TRUE);
1100
1101     // Step Spins
1102   hshift_step_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1103   hshift_step_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hshift_step_spinbutton_adj), 1, 2);
1104   gtk_widget_show (hshift_step_spinbutton);
1105   gtk_table_attach (GTK_TABLE (table1), hshift_step_spinbutton, 3, 4, 2, 3,
1106                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1107                     (GtkAttachOptions) (0), 0, 0);
1108   gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hshift_step_spinbutton), GTK_UPDATE_IF_VALID);
1109
1110   vshift_step_spinbutton_adj = gtk_adjustment_new (0.0, -8192.0, 8192.0, 2.0, 8.0, 8.0);
1111   vshift_step_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vshift_step_spinbutton_adj), 1, 2);
1112   gtk_widget_show (vshift_step_spinbutton);
1113   gtk_table_attach (GTK_TABLE (table1), vshift_step_spinbutton, 3, 4, 4, 5,
1114                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1115                     (GtkAttachOptions) (0), 0, 0);
1116   gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vshift_step_spinbutton), GTK_UPDATE_IF_VALID);
1117
1118   hscale_step_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1119   hscale_step_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (hscale_step_spinbutton_adj), 1, 4);
1120   gtk_widget_show (hscale_step_spinbutton);
1121   gtk_table_attach (GTK_TABLE (table1), hscale_step_spinbutton, 3, 4, 6, 7,
1122                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1123                     (GtkAttachOptions) (0), 0, 0);
1124   gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (hscale_step_spinbutton), GTK_UPDATE_IF_VALID);
1125
1126   vscale_step_spinbutton_adj = gtk_adjustment_new (0.0, -1024.0, 1024.0, 1.0, 4.0, 4.0);
1127   vscale_step_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (vscale_step_spinbutton_adj), 1, 4);
1128   gtk_widget_show (vscale_step_spinbutton);
1129   gtk_table_attach (GTK_TABLE (table1), vscale_step_spinbutton, 3, 4, 8, 9,
1130                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1131                     (GtkAttachOptions) (0), 0, 0);
1132   gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (vscale_step_spinbutton), GTK_UPDATE_IF_VALID);
1133
1134   rotate_step_spinbutton_adj = gtk_adjustment_new (0.0, -360.0, 360.0, 1.0, 10.0, 10.0);
1135   rotate_step_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (rotate_step_spinbutton_adj), 1, 2);
1136   gtk_widget_show (rotate_step_spinbutton);
1137   gtk_table_attach (GTK_TABLE (table1), rotate_step_spinbutton, 3, 4, 10, 11,
1138                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1139                     (GtkAttachOptions) (0), 0, 0);
1140   gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (rotate_step_spinbutton), GTK_UPDATE_IF_VALID);
1141
1142   eventbox = gtk_event_box_new ();
1143   gtk_widget_show (eventbox);
1144   gtk_table_attach (GTK_TABLE (table1), eventbox, 2, 3, 12, 13,
1145                     (GtkAttachOptions) (0),
1146                     (GtkAttachOptions) (0), 0, 0);
1147
1148   eventbox = gtk_event_box_new ();
1149   gtk_widget_show (eventbox);
1150   gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 12, 13,
1151                     (GtkAttachOptions) (0),
1152                     (GtkAttachOptions) (0), 0, 0);
1153
1154   eventbox = gtk_event_box_new ();
1155   gtk_widget_show (eventbox);
1156   gtk_table_attach (GTK_TABLE (table1), eventbox, 0, 1, 0, 1,
1157                     (GtkAttachOptions) (0),
1158                     (GtkAttachOptions) (0), 0, 0);
1159
1160   viewport7 = gtk_viewport_new (NULL, NULL);
1161   gtk_widget_show (viewport7);
1162   gtk_box_pack_start (GTK_BOX (vbox7), viewport7, FALSE, TRUE, 0);
1163   gtk_container_set_border_width (GTK_CONTAINER (viewport7), 2);
1164   gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport7), GTK_SHADOW_ETCHED_IN);
1165
1166   table4 = gtk_table_new (4, 7, FALSE);
1167   gtk_widget_show (table4);
1168   gtk_container_add (GTK_CONTAINER (viewport7), table4);
1169
1170   viewport5 = gtk_viewport_new (NULL, NULL);
1171   gtk_widget_show (viewport5);
1172   gtk_table_attach (GTK_TABLE (table4), viewport5, 1, 7, 0, 4,
1173                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1174                     (GtkAttachOptions) (0), 0, 0);
1175   gtk_container_set_border_width (GTK_CONTAINER (viewport5), 6);
1176   gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport5), GTK_SHADOW_ETCHED_OUT);
1177
1178   table5 = gtk_table_new (2, 3, FALSE);
1179   gtk_widget_show (table5);
1180   gtk_container_add (GTK_CONTAINER (viewport5), table5);
1181   gtk_container_set_border_width (GTK_CONTAINER (table5), 5);
1182   gtk_table_set_col_spacings (GTK_TABLE (table5), 2);
1183
1184   label = gtk_label_new ("Height");
1185   gtk_widget_show (label);
1186   gtk_table_attach (GTK_TABLE (table5), label, 2, 3, 0, 1,
1187                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1188                     (GtkAttachOptions) (GTK_FILL), 0, 0);
1189   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1190   gtk_misc_set_alignment (GTK_MISC (label), 0.5, 1);
1191
1192   label = gtk_label_new ("Width");
1193   gtk_widget_show (label);
1194   gtk_table_attach (GTK_TABLE (table5), label, 1, 2, 0, 1,
1195                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1196                     (GtkAttachOptions) (GTK_FILL), 0, 0);
1197   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1198   gtk_misc_set_alignment (GTK_MISC (label), 0.5, 1);
1199
1200   fit_width_spinbutton_adj = gtk_adjustment_new (1, 1, 32, 1, 10, 10);
1201   fit_width_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (fit_width_spinbutton_adj), 1, 0);
1202   gtk_widget_show (fit_width_spinbutton);
1203   gtk_table_attach (GTK_TABLE (table5), fit_width_spinbutton, 1, 2, 1, 2,
1204                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1205                     (GtkAttachOptions) (GTK_FILL), 0, 0);
1206   gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (fit_width_spinbutton), TRUE);
1207   gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (fit_width_spinbutton), GTK_UPDATE_IF_VALID);
1208
1209   fit_height_spinbutton_adj = gtk_adjustment_new (1, 1, 32, 1, 10, 10);
1210   fit_height_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (fit_height_spinbutton_adj), 1, 0);
1211   gtk_widget_show (fit_height_spinbutton);
1212   gtk_table_attach (GTK_TABLE (table5), fit_height_spinbutton, 2, 3, 1, 2,
1213                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1214                     (GtkAttachOptions) (GTK_FILL), 3, 0);
1215   gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (fit_height_spinbutton), TRUE);
1216   gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (fit_height_spinbutton), GTK_UPDATE_IF_VALID);
1217
1218   eventbox = gtk_event_box_new ();
1219   gtk_widget_show (eventbox);
1220   gtk_table_attach (GTK_TABLE (table5), eventbox, 0, 1, 0, 1,
1221                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1222                     (GtkAttachOptions) (GTK_FILL), 0, 0);
1223
1224   eventbox = gtk_event_box_new ();
1225   gtk_widget_show (eventbox);
1226   gtk_table_attach (GTK_TABLE (table5), eventbox, 0, 1, 1, 2,
1227                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1228                     (GtkAttachOptions) (GTK_FILL), 4, 0);
1229
1230   fit_button = gtk_button_new_with_mnemonic ("    Fit    ");
1231   gtk_widget_show (fit_button);
1232   gtk_container_add (GTK_CONTAINER (eventbox), fit_button);
1233
1234   viewport6 = gtk_viewport_new (NULL, NULL);
1235   gtk_widget_show (viewport6);
1236   gtk_table_attach (GTK_TABLE (table4), viewport6, 0, 1, 0, 4,
1237                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1238                     (GtkAttachOptions) (0), 0, 0);
1239   gtk_container_set_border_width (GTK_CONTAINER (viewport6), 4);
1240   gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport6), GTK_SHADOW_NONE);
1241
1242   table7 = gtk_table_new (2, 1, FALSE);
1243   gtk_widget_show (table7);
1244   gtk_container_add (GTK_CONTAINER (viewport6), table7);
1245
1246   eventbox = gtk_event_box_new ();
1247   gtk_widget_show (eventbox);
1248   gtk_table_attach (GTK_TABLE (table7), eventbox, 0, 1, 0, 2,
1249                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1250                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
1251
1252   axial_button = gtk_button_new_with_mnemonic ("Axial");
1253   gtk_widget_show (axial_button);
1254   gtk_container_add (GTK_CONTAINER (eventbox), axial_button);
1255   gtk_widget_set_size_request (axial_button, 56, 29);
1256   gtk_container_set_border_width (GTK_CONTAINER (axial_button), 4);
1257
1258   // Fit in Flags sub-dialog
1259   Create_Quake2FlagsDialog(vbox7);
1260
1261   viewport10 = gtk_viewport_new (NULL, NULL);
1262   gtk_widget_show (viewport10);
1263   gtk_box_pack_start (GTK_BOX (vbox7), viewport10, FALSE, TRUE, 0);
1264   gtk_container_set_border_width (GTK_CONTAINER (viewport10), 2);
1265   gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport10), GTK_SHADOW_ETCHED_IN);
1266
1267   hbuttonbox1 = gtk_hbutton_box_new ();
1268   gtk_widget_show (hbuttonbox1);
1269   gtk_container_add (GTK_CONTAINER (viewport10), hbuttonbox1);
1270   gtk_container_set_border_width (GTK_CONTAINER (hbuttonbox1), 4);
1271   gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox1), GTK_BUTTONBOX_SPREAD);
1272
1273   done_button = gtk_button_new ();
1274   gtk_widget_show (done_button);
1275   gtk_container_add (GTK_CONTAINER (hbuttonbox1), done_button);
1276   GTK_WIDGET_SET_FLAGS (done_button, GTK_CAN_DEFAULT);
1277
1278   alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0);
1279   gtk_widget_show (alignment1);
1280   gtk_container_add (GTK_CONTAINER (done_button), alignment1);
1281
1282   hbox2 = gtk_hbox_new (FALSE, 2);
1283   gtk_widget_show (hbox2);
1284   gtk_container_add (GTK_CONTAINER (alignment1), hbox2);
1285
1286   image1 = gtk_image_new_from_stock ("gtk-yes", GTK_ICON_SIZE_BUTTON);
1287   gtk_widget_show (image1);
1288   gtk_box_pack_start (GTK_BOX (hbox2), image1, FALSE, FALSE, 0);
1289
1290   label = gtk_label_new_with_mnemonic ("Done");
1291   gtk_widget_show (label);
1292   gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
1293   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1294
1295   apply_button = gtk_button_new ();
1296   gtk_widget_show (apply_button);
1297   gtk_container_add (GTK_CONTAINER (hbuttonbox1), apply_button);
1298   GTK_WIDGET_SET_FLAGS (apply_button, GTK_CAN_DEFAULT);
1299
1300   alignment3 = gtk_alignment_new (0.5, 0.5, 0, 0);
1301   gtk_widget_show (alignment3);
1302   gtk_container_add (GTK_CONTAINER (apply_button), alignment3);
1303
1304   hbox4 = gtk_hbox_new (FALSE, 2);
1305   gtk_widget_show (hbox4);
1306   gtk_container_add (GTK_CONTAINER (alignment3), hbox4);
1307
1308   image3 = gtk_image_new_from_stock ("gtk-apply", GTK_ICON_SIZE_BUTTON);
1309   gtk_widget_show (image3);
1310   gtk_box_pack_start (GTK_BOX (hbox4), image3, FALSE, FALSE, 0);
1311
1312   label = gtk_label_new_with_mnemonic ("Apply");
1313   gtk_widget_show (label);
1314   gtk_box_pack_start (GTK_BOX (hbox4), label, FALSE, FALSE, 0);
1315   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1316
1317   cancel_button = gtk_button_new ();
1318   gtk_widget_show (cancel_button);
1319   gtk_container_add (GTK_CONTAINER (hbuttonbox1), cancel_button);
1320   GTK_WIDGET_SET_FLAGS (cancel_button, GTK_CAN_DEFAULT);
1321
1322   alignment2 = gtk_alignment_new (0.5, 0.5, 0, 0);
1323   gtk_widget_show (alignment2);
1324   gtk_container_add (GTK_CONTAINER (cancel_button), alignment2);
1325
1326   hbox3 = gtk_hbox_new (FALSE, 2);
1327   gtk_widget_show (hbox3);
1328   gtk_container_add (GTK_CONTAINER (alignment2), hbox3);
1329
1330   image2 = gtk_image_new_from_stock ("gtk-no", GTK_ICON_SIZE_BUTTON);
1331   gtk_widget_show (image2);
1332   gtk_box_pack_start (GTK_BOX (hbox3), image2, FALSE, FALSE, 0);
1333
1334   label = gtk_label_new_with_mnemonic ("Cancel");
1335   gtk_widget_show (label);
1336   gtk_box_pack_start (GTK_BOX (hbox3), label, FALSE, FALSE, 0);
1337   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1338
1339
1340   g_signal_connect ( (gpointer) SurfaceInspector,
1341                       "delete_event",
1342                       G_CALLBACK (delete_event_callback),
1343                       NULL );
1344   g_signal_connect ((gpointer) SurfaceInspector, "destroy",
1345                     G_CALLBACK (gtk_widget_destroy),
1346                     NULL);
1347
1348   g_signal_connect ((gpointer) texture_combo_entry, "key_press_event",
1349                     G_CALLBACK (on_texture_combo_entry_key_press_event),
1350                     NULL);
1351   g_signal_connect ((gpointer) texture_combo_entry, "activate",
1352                     G_CALLBACK (on_texture_combo_entry_activate),
1353                     NULL);
1354
1355
1356   g_signal_connect ((gpointer) hshift_offset_spinbutton, "value_changed",
1357                     G_CALLBACK (on_hshift_offset_spinbutton_value_changed),
1358                     NULL);
1359   g_signal_connect ((gpointer) vshift_offset_spinbutton, "value_changed",
1360                     G_CALLBACK (on_vshift_offset_spinbutton_value_changed),
1361                     NULL);
1362   g_signal_connect ((gpointer) hscale_offset_spinbutton, "value_changed",
1363                     G_CALLBACK (on_hscale_offset_spinbutton_value_changed),
1364                     NULL);
1365   g_signal_connect ((gpointer) vscale_offset_spinbutton, "value_changed",
1366                     G_CALLBACK (on_vscale_offset_spinbutton_value_changed),
1367                     NULL);
1368   g_signal_connect ((gpointer) rotate_offset_spinbutton, "value_changed",
1369                     G_CALLBACK (on_rotate_offset_spinbutton_value_changed),
1370                     NULL);
1371
1372   g_signal_connect ((gpointer) hshift_value_spinbutton, "value_changed",
1373                     G_CALLBACK (on_hshift_value_spinbutton_value_changed),
1374                     NULL);
1375   g_signal_connect ((gpointer) vshift_value_spinbutton, "value_changed",
1376                     G_CALLBACK (on_vshift_value_spinbutton_value_changed),
1377                     NULL);
1378   g_signal_connect ((gpointer) hscale_value_spinbutton, "value_changed",
1379                     G_CALLBACK (on_hscale_value_spinbutton_value_changed),
1380                     NULL);
1381   g_signal_connect ((gpointer) vscale_value_spinbutton, "value_changed",
1382                     G_CALLBACK (on_vscale_value_spinbutton_value_changed),
1383                     NULL);
1384   g_signal_connect ((gpointer) rotate_value_spinbutton, "value_changed",
1385                     G_CALLBACK (on_rotate_value_spinbutton_value_changed),
1386                     NULL);
1387
1388   g_signal_connect ((gpointer) hshift_step_spinbutton, "value_changed",
1389                     G_CALLBACK (on_hshift_step_spinbutton_value_changed),
1390                     NULL);
1391   g_signal_connect ((gpointer) vshift_step_spinbutton, "value_changed",
1392                     G_CALLBACK (on_vshift_step_spinbutton_value_changed),
1393                     NULL);
1394   g_signal_connect ((gpointer) hscale_step_spinbutton, "value_changed",
1395                     G_CALLBACK (on_hscale_step_spinbutton_value_changed),
1396                     NULL);
1397   g_signal_connect ((gpointer) vscale_step_spinbutton, "value_changed",
1398                     G_CALLBACK (on_vscale_step_spinbutton_value_changed),
1399                     NULL);
1400   g_signal_connect ((gpointer) rotate_step_spinbutton, "value_changed",
1401                     G_CALLBACK (on_rotate_step_spinbutton_value_changed),
1402                     NULL);
1403
1404   g_signal_connect ((gpointer) match_grid_button, "clicked",
1405                     G_CALLBACK (on_match_grid_button_clicked),
1406                     NULL);
1407   g_signal_connect ((gpointer) lock_valuechange_togglebutton, "toggled",
1408                     G_CALLBACK (on_lock_valuechange_togglebutton_toggled),
1409                     NULL);
1410
1411   g_signal_connect ((gpointer) fit_width_spinbutton, "value_changed",
1412                     G_CALLBACK (on_fit_width_spinbutton_value_changed),
1413                     NULL);
1414   g_signal_connect ((gpointer) fit_height_spinbutton, "value_changed",
1415                     G_CALLBACK (on_fit_height_spinbutton_value_changed),
1416                     NULL);
1417   g_signal_connect ((gpointer) fit_button, "clicked",
1418                     G_CALLBACK (on_fit_button_clicked),
1419                     NULL);
1420
1421   g_signal_connect ((gpointer) axial_button, "clicked",
1422                     G_CALLBACK (on_axial_button_clicked),
1423                     NULL);
1424
1425   g_signal_connect ((gpointer) done_button, "clicked",
1426                     G_CALLBACK (on_done_button_clicked),
1427                     NULL);
1428   g_signal_connect ((gpointer) apply_button, "clicked",
1429                     G_CALLBACK (on_apply_button_clicked),
1430                     NULL);
1431   g_signal_connect ((gpointer) cancel_button, "clicked",
1432                     G_CALLBACK (on_cancel_button_clicked),
1433                     NULL);
1434
1435
1436   return SurfaceInspector;
1437 }
1438
1439
1440 // Texture Combo
1441 gboolean on_texture_combo_entry_key_press_event (GtkWidget *widget, GdkEventKey *event,
1442                                                  gpointer user_data)
1443 {
1444   // Have Tab activate selection as well as Return
1445   if (event->keyval == GDK_Tab)
1446     g_signal_emit_by_name ( texture_combo_entry, "activate" );
1447
1448   return FALSE;
1449 }
1450
1451 void on_texture_combo_entry_activate (GtkEntry *entry, gpointer user_data)
1452 {
1453   texdef_t* tmp_texdef;
1454   texdef_t* tmp_orig_texdef;
1455   texdef_to_face_t* temp_texdef_face_list;
1456   char text[128] = { 0 };
1457
1458   if (!texdef_face_list_empty() && g_bListenChanged)
1459   {
1460     // activate only on entry change
1461     strcpy( text, gtk_entry_get_text(entry));
1462     if ( strcmp( old_texture_entry, text ))
1463     {
1464       // Check for spaces in shader name
1465       if (text[0] <= ' ' || strchr(text, ' '))
1466         Sys_FPrintf(SYS_WRN, "WARNING: spaces in shader names are not allowed, ignoring '%s'\n", text);
1467       else
1468       {
1469         for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1470         {
1471           tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1472           tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1473           strcpy( old_texture_entry, text );
1474           tmp_texdef->SetName( text );
1475         }
1476         GetTexMods();
1477       }
1478     }
1479   }
1480 }
1481
1482 // Offset Spins
1483 static void on_hshift_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1484 {
1485   texdef_t* tmp_texdef;
1486   texdef_t* tmp_orig_texdef;
1487   texdef_to_face_t* temp_texdef_face_list;
1488
1489   texdef_offset.shift[0] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hshift_offset_spinbutton) );
1490
1491   if (!texdef_face_list_empty() && g_bListenChanged)
1492   {
1493     for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1494     {
1495       tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1496       tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1497       if (is_HShift_conflicting)
1498         tmp_texdef->shift[0] = tmp_orig_texdef->shift[0] + texdef_offset.shift[0];
1499       else
1500         tmp_texdef->shift[0] = texdef_SI_values.shift[0] + texdef_offset.shift[0];
1501     }
1502     GetTexMods();
1503   }
1504 }
1505
1506 static void on_vshift_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1507 {
1508   texdef_t* tmp_texdef;
1509   texdef_t* tmp_orig_texdef;
1510   texdef_to_face_t* temp_texdef_face_list;
1511
1512   texdef_offset.shift[1] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vshift_offset_spinbutton) );
1513
1514   if (!texdef_face_list_empty() && g_bListenChanged)
1515   {
1516     for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1517     {
1518       tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1519       tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1520       if (is_VShift_conflicting)
1521         tmp_texdef->shift[1] = tmp_orig_texdef->shift[1] + texdef_offset.shift[1];
1522       else
1523         tmp_texdef->shift[1] = texdef_SI_values.shift[1] + texdef_offset.shift[1];
1524     }
1525     GetTexMods();
1526   }
1527
1528 }
1529
1530 static void on_hscale_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1531 {
1532   texdef_t* tmp_texdef;
1533   texdef_t* tmp_orig_texdef;
1534   texdef_to_face_t* temp_texdef_face_list;
1535
1536   texdef_offset.scale[0] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hscale_offset_spinbutton) );
1537
1538   if (!texdef_face_list_empty() && g_bListenChanged)
1539   {
1540     for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1541     {
1542       tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1543       tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1544       if (is_HScale_conflicting)
1545         tmp_texdef->scale[0] = tmp_orig_texdef->scale[0] + texdef_offset.scale[0];
1546       else
1547         tmp_texdef->scale[0] = texdef_SI_values.scale[0] + texdef_offset.scale[0];
1548     }
1549     GetTexMods();
1550   }
1551
1552
1553 }
1554
1555 static void on_vscale_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1556 {
1557   texdef_t* tmp_texdef;
1558   texdef_t* tmp_orig_texdef;
1559   texdef_to_face_t* temp_texdef_face_list;
1560
1561   texdef_offset.scale[1] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vscale_offset_spinbutton) );
1562
1563   if (!texdef_face_list_empty() && g_bListenChanged)
1564   {
1565     for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1566     {
1567       tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1568       tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1569       if (is_VScale_conflicting)
1570         tmp_texdef->scale[1] = tmp_orig_texdef->scale[1] + texdef_offset.scale[1];
1571       else
1572         tmp_texdef->scale[1] = texdef_SI_values.scale[1] + texdef_offset.scale[1];
1573     }
1574     GetTexMods();
1575   }
1576
1577 }
1578
1579 static void on_rotate_offset_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1580 {
1581   texdef_t* tmp_texdef;
1582   texdef_t* tmp_orig_texdef;
1583   texdef_to_face_t* temp_texdef_face_list;
1584
1585   texdef_offset.rotate = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(rotate_offset_spinbutton) );
1586
1587   if (!texdef_face_list_empty() && g_bListenChanged)
1588   {
1589     for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1590     {
1591       tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1592       tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1593       if (is_Rotate_conflicting)
1594         tmp_texdef->rotate = tmp_orig_texdef->rotate + texdef_offset.rotate;
1595       else
1596         tmp_texdef->rotate = texdef_SI_values.rotate + texdef_offset.rotate;
1597     }
1598     GetTexMods();
1599   }
1600
1601 }
1602
1603
1604 // Match Grid
1605 static void on_match_grid_button_clicked (GtkButton *button, gpointer user_data)
1606 {
1607   float hscale, vscale;
1608
1609   if( !strcmp(gtk_entry_get_text (GTK_ENTRY (hscale_value_spinbutton)), "") )
1610     hscale = 0.0;
1611   else
1612     hscale = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hscale_value_spinbutton) );
1613
1614   if( !strcmp( gtk_entry_get_text (GTK_ENTRY (vscale_value_spinbutton)), "") )
1615     vscale = 0.0;
1616   else
1617     vscale = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vscale_value_spinbutton) );
1618   DoSnapTToGrid (hscale, vscale);
1619 }
1620
1621
1622 // Lock out changes to Value
1623 static void on_lock_valuechange_togglebutton_toggled (GtkToggleButton *togglebutton, gpointer user_data)
1624 {
1625   bool is_Locked;
1626
1627   is_Locked = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lock_valuechange_togglebutton));
1628
1629   gtk_widget_set_sensitive( GTK_WIDGET( hscale_value_spinbutton ), is_Locked );
1630   gtk_widget_set_sensitive( GTK_WIDGET( vscale_value_spinbutton ), is_Locked );
1631   gtk_widget_set_sensitive( GTK_WIDGET( hshift_value_spinbutton ), is_Locked );
1632   gtk_widget_set_sensitive( GTK_WIDGET( vshift_value_spinbutton ), is_Locked );
1633   gtk_widget_set_sensitive( GTK_WIDGET( rotate_value_spinbutton ), is_Locked );
1634 }
1635
1636
1637 // Value Spins
1638 static void on_hshift_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1639 {
1640   texdef_t* tmp_texdef;
1641   texdef_t* tmp_orig_texdef;
1642   texdef_to_face_t* temp_texdef_face_list;
1643
1644   texdef_SI_values.shift[0] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hshift_value_spinbutton) );
1645
1646   if (!texdef_face_list_empty() && g_bListenChanged)
1647   {
1648     for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1649     {
1650       tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1651       tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1652       tmp_texdef->shift[0] = texdef_SI_values.shift[0] + texdef_offset.shift[0];
1653       is_HShift_conflicting = FALSE;
1654     }
1655     GetTexMods();
1656   }
1657 }
1658
1659 static void on_vshift_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1660 {
1661   texdef_t* tmp_texdef;
1662   texdef_t* tmp_orig_texdef;
1663   texdef_to_face_t* temp_texdef_face_list;
1664
1665   texdef_SI_values.shift[1]  = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vshift_value_spinbutton) );
1666
1667   if (!texdef_face_list_empty() && g_bListenChanged)
1668   {
1669     for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1670     {
1671       tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1672       tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1673       tmp_texdef->shift[1] = texdef_SI_values.shift[1] + texdef_offset.shift[1];
1674       is_VShift_conflicting = FALSE;
1675     }
1676     GetTexMods();
1677   }
1678 }
1679
1680 static void on_hscale_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1681 {
1682   texdef_t* tmp_texdef;
1683   texdef_t* tmp_orig_texdef;
1684   texdef_to_face_t* temp_texdef_face_list;
1685
1686   texdef_SI_values.scale[0] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hscale_value_spinbutton) );
1687
1688   if (!texdef_face_list_empty() && g_bListenChanged)
1689   {
1690     for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1691     {
1692       tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1693       tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1694       tmp_texdef->scale[0] = texdef_SI_values.scale[0] + texdef_offset.scale[0];
1695       is_HScale_conflicting = FALSE;
1696     }
1697     GetTexMods();
1698   }
1699 }
1700
1701 static void on_vscale_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1702 {
1703   texdef_t* tmp_texdef;
1704   texdef_t* tmp_orig_texdef;
1705   texdef_to_face_t* temp_texdef_face_list;
1706
1707   texdef_SI_values.scale[1] = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vscale_value_spinbutton) );
1708
1709   if (!texdef_face_list_empty() && g_bListenChanged)
1710   {
1711     for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1712     {
1713       tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1714       tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1715       tmp_texdef->scale[1] = texdef_SI_values.scale[1] + texdef_offset.scale[1];
1716       is_VScale_conflicting = FALSE;
1717     }
1718     GetTexMods();
1719   }
1720 }
1721
1722 static void on_rotate_value_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1723 {
1724   texdef_t* tmp_texdef;
1725   texdef_t* tmp_orig_texdef;
1726   texdef_to_face_t* temp_texdef_face_list;
1727
1728   texdef_SI_values.rotate = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(rotate_value_spinbutton) );
1729
1730   if (!texdef_face_list_empty() && g_bListenChanged)
1731   {
1732     for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1733     {
1734       tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1735       tmp_orig_texdef = (texdef_t *) &temp_texdef_face_list->orig_texdef;
1736       tmp_texdef->rotate = texdef_SI_values.rotate + texdef_offset.rotate;
1737       is_Rotate_conflicting = FALSE;
1738     }
1739     GetTexMods();
1740   }
1741 }
1742
1743
1744 // Step Spins
1745 static void on_hshift_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1746 {
1747   gfloat val;
1748   GtkAdjustment * adjust;
1749
1750   if (!g_bListenChanged)
1751     return;
1752
1753   l_pIncrement = Get_SI_Inc();
1754
1755 #ifdef DBG_SI
1756   Sys_Printf("OnIncrementChanged HShift\n");
1757 #endif
1758
1759   val = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hshift_step_spinbutton) ) ;
1760   adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( hshift_offset_spinbutton ));
1761   adjust->step_increment = val;
1762   adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( hshift_value_spinbutton ));
1763   adjust->step_increment = val;
1764   l_pIncrement->shift[0] = val;
1765 }
1766
1767 static void on_vshift_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1768 {
1769   gfloat val;
1770   GtkAdjustment * adjust;
1771
1772   if (!g_bListenChanged)
1773     return;
1774
1775   l_pIncrement = Get_SI_Inc();
1776
1777 #ifdef DBG_SI
1778   Sys_Printf("OnIncrementChanged VShift\n");
1779 #endif
1780
1781   val = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vshift_step_spinbutton) ) ;
1782   adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( vshift_offset_spinbutton ));
1783   adjust->step_increment = val;
1784   adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( vshift_value_spinbutton ));
1785   adjust->step_increment = val;
1786   l_pIncrement->shift[1] = val;
1787 }
1788
1789 static void on_hscale_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1790 {
1791   gfloat val;
1792   GtkAdjustment * adjust;
1793
1794   if (!g_bListenChanged)
1795     return;
1796
1797   l_pIncrement = Get_SI_Inc();
1798
1799 #ifdef DBG_SI
1800   Sys_Printf("OnIncrementChanged HShift\n");
1801 #endif
1802
1803   val = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(hscale_step_spinbutton) ) ;
1804   adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( hscale_offset_spinbutton ));
1805   adjust->step_increment = val;
1806   adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( hscale_value_spinbutton ));
1807   adjust->step_increment = val;
1808   l_pIncrement->scale[0] = val;
1809 }
1810
1811 static void on_vscale_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1812 {
1813   gfloat val;
1814   GtkAdjustment * adjust;
1815
1816   if (!g_bListenChanged)
1817     return;
1818
1819   l_pIncrement = Get_SI_Inc();
1820
1821 #ifdef DBG_SI
1822   Sys_Printf("OnIncrementChanged HShift\n");
1823 #endif
1824
1825   val = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(vscale_step_spinbutton) ) ;
1826   adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( vscale_offset_spinbutton ));
1827   adjust->step_increment = val;
1828   adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( vscale_value_spinbutton ));
1829   adjust->step_increment = val;
1830   l_pIncrement->scale[1] = val;
1831 }
1832
1833 static void on_rotate_step_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1834 {
1835   gfloat val;
1836   GtkAdjustment * adjust;
1837
1838   if (!g_bListenChanged)
1839     return;
1840
1841   l_pIncrement = Get_SI_Inc();
1842
1843 #ifdef DBG_SI
1844   Sys_Printf("OnIncrementChanged HShift\n");
1845 #endif
1846
1847   val = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(rotate_step_spinbutton) ) ;
1848   adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( rotate_offset_spinbutton ));
1849   adjust->step_increment = val;
1850   adjust = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON ( rotate_value_spinbutton ));
1851   adjust->step_increment = val;
1852   l_pIncrement->rotate = val;
1853 }
1854
1855
1856 // Fit Texture
1857 static void on_fit_width_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1858 {
1859   m_nWidth = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(fit_width_spinbutton) );
1860 }
1861
1862 static void on_fit_height_spinbutton_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
1863 {
1864   m_nHeight = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(fit_height_spinbutton) );
1865 }
1866
1867 static void on_fit_button_clicked (GtkButton *button, gpointer user_data)
1868 {
1869   FaceList_FitTexture(get_texdef_face_list(), m_nHeight, m_nWidth);
1870   Sys_UpdateWindows(W_ALL);
1871 }
1872
1873
1874 // Axial Button
1875 static void on_axial_button_clicked (GtkButton *button, gpointer user_data)
1876 {
1877   texdef_t* tmp_texdef;
1878   texdef_t* tmp_orig_texdef;
1879   texdef_to_face_t* temp_texdef_face_list;
1880
1881   if (!texdef_face_list_empty() && g_bListenChanged)
1882   {
1883     for (temp_texdef_face_list = get_texdef_face_list(); temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
1884     {
1885       tmp_texdef = (texdef_t *) &temp_texdef_face_list->texdef;
1886       tmp_texdef->shift[0] = 0.0;
1887       tmp_texdef->shift[1] = 0.0;
1888       tmp_texdef->scale[0] = 0.5;
1889       tmp_texdef->scale[1] = 0.5;
1890       tmp_texdef->rotate = 0.0;
1891     }
1892   }
1893
1894   SetTexdef_FaceList( get_texdef_face_list(), FALSE, TRUE );
1895   Sys_UpdateWindows(W_ALL);
1896 }
1897
1898
1899 // Action Buttons
1900 static void on_done_button_clicked (GtkButton *button, gpointer user_data)
1901 {
1902   if ( !texdef_face_list_empty() )
1903     GetTexMods(TRUE);
1904   HideDlg();
1905   Sys_UpdateWindows(W_ALL);
1906 }
1907
1908 static void on_apply_button_clicked (GtkButton *button, gpointer user_data)
1909 {
1910   if (!g_bListenChanged)
1911     return;
1912
1913   if ( !texdef_face_list_empty() )
1914   {
1915     GetTexMods (TRUE);
1916     Sys_UpdateWindows(W_CAMERA);
1917     GetTexdefInfo_from_Radiant();
1918     SetTexMods();
1919   }
1920 }
1921
1922 static void on_cancel_button_clicked (GtkButton *button, gpointer user_data)
1923 {
1924   texturewin = Texturewin ();
1925   texturewin->texdef = g_old_texdef;
1926   // cancel the last do if we own it
1927   if ( (m_nUndoId == Undo_GetUndoId()) && ( m_nUndoId != 0 ))
1928   {
1929 #ifdef DBG_SI
1930     Sys_Printf("OnCancel calling Undo_Undo\n");
1931 #endif
1932     g_bListenUpdate = false;
1933     Undo_Undo(TRUE);
1934     g_bListenUpdate = true;
1935     m_nUndoId = 0;
1936   }
1937   HideDlg();
1938 }
1939
1940