OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
window.c
Go to the documentation of this file.
1 /*
2  * mape - C4 Landscape.txt editor
3  *
4  * Copyright (c) 2005-2009, Armin Burgmeier
5  *
6  * Distributed under the terms of the ISC license; see accompanying file
7  * "COPYING" for details.
8  *
9  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
10  * See accompanying file "TRADEMARK" for details.
11  *
12  * To redistribute this file separately, substitute the full license texts
13  * for the above references.
14  */
15 
16 #include <stdlib.h>
17 #include <gtksourceview/gtksourcebuffer.h>
18 
20 #include "mape/fileicon.h"
21 #include "mape/configfile.h"
22 #include "mape/preferencesdialog.h"
23 #include "mape/header.h"
24 #include "mape/statusbar.h"
25 #include "mape/diskview.h"
26 #include "mape/mattexview.h"
27 #include "mape/editview.h"
28 #include "mape/preview.h"
29 #include "mape/window.h"
30 
31 static gboolean mape_window_file_load(MapeWindow* wnd,
32  const gchar* filename)
33 {
34  GError* error = NULL;
35  GtkWidget* error_dialog;
36  gchar* title;
37  gboolean result;
38 
39  result = mape_edit_view_open(wnd->edit_view, filename, &error);
40 
41  if(result == FALSE)
42  {
43  error_dialog = gtk_message_dialog_new(
44  GTK_WINDOW(wnd->window),
45  GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
46  GTK_MESSAGE_ERROR,
47  GTK_BUTTONS_OK,
48  "%s",
49  error->message
50  );
51 
52  gtk_dialog_run(GTK_DIALOG(error_dialog) );
53 
54  gtk_widget_destroy(error_dialog);
55  g_error_free(error);
56 
57  return FALSE;
58  }
59  else
60  {
61  title = g_strdup_printf("%s - Mape", filename);
62  gtk_window_set_title(GTK_WINDOW(wnd->window), title);
63  g_free(title);
64 
65  return TRUE;
66  }
67 }
68 
69 static gboolean mape_window_file_save(MapeWindow* wnd,
70  const gchar* filename)
71 {
72  GError* error = NULL;
73  GtkWidget* error_dialog;
74  gchar* title;
75  gboolean result;
76 
77  result = mape_edit_view_save(wnd->edit_view, filename, &error);
78 
79  if(result == FALSE)
80  {
81  error_dialog = gtk_message_dialog_new(
82  GTK_WINDOW(wnd->window),
83  GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
84  GTK_MESSAGE_ERROR,
85  GTK_BUTTONS_OK,
86  "%s",
87  error->message
88  );
89 
90  gtk_dialog_run(GTK_DIALOG(error_dialog) );
91 
92  gtk_widget_destroy(error_dialog);
93  g_error_free(error);
94 
95  return FALSE;
96  }
97  else
98  {
99  title = g_strdup_printf("%s - Mape", wnd->edit_view->file_path);
100  gtk_window_set_title(GTK_WINDOW(wnd->window), title);
101  g_free(title);
102 
103  return TRUE;
104  }
105 }
106 
107 static GtkWidget* mape_window_create_file_chooser(MapeWindow* wnd,
108  GtkFileChooserAction action)
109 {
110  GtkWidget* dialog;
111  GtkFileFilter* filter_all;
112  GtkFileFilter* filter_landscape;
113  GtkFileFilter* filter_map;
114 
115  filter_all = gtk_file_filter_new();
116  gtk_file_filter_set_name(filter_all, "All files");
117  gtk_file_filter_add_pattern(filter_all, "*");
118 
119  filter_landscape = gtk_file_filter_new();
120  gtk_file_filter_set_name(filter_landscape, "Dynamic Map Descriptions");
121  gtk_file_filter_add_pattern(filter_landscape, "[Ll]andscape.txt");
122  gtk_file_filter_add_pattern(filter_landscape, "[Mm]ap.c");
123 
124  dialog = gtk_file_chooser_dialog_new(
125  action == GTK_FILE_CHOOSER_ACTION_OPEN ?
126  "Open landscape file..." : "Save landscape file...",
127  GTK_WINDOW(wnd->window),
128  action,
129  GTK_STOCK_CANCEL,
130  GTK_RESPONSE_CANCEL,
131  action == GTK_FILE_CHOOSER_ACTION_OPEN ?
132  GTK_STOCK_OPEN : GTK_STOCK_SAVE,
133  GTK_RESPONSE_OK,
134  NULL
135  );
136 
137  gtk_file_chooser_add_filter(
138  GTK_FILE_CHOOSER(dialog),
139  filter_landscape
140  );
141 
142  gtk_file_chooser_add_filter(
143  GTK_FILE_CHOOSER(dialog),
144  filter_all
145  );
146 
147  gtk_file_chooser_set_do_overwrite_confirmation(
148  GTK_FILE_CHOOSER(dialog),
149  TRUE
150  );
151 
152  return dialog;
153 }
154 
155 static void mape_window_cb_file_save_as(GtkWidget* widget,
156  gpointer user_data)
157 {
158  MapeWindow* wnd;
159  gint response;
160  gchar* filename;
161  GtkWidget* save_dialog;
162 
163  wnd = (MapeWindow*)user_data;
164  save_dialog = mape_window_create_file_chooser(
165  wnd,
166  GTK_FILE_CHOOSER_ACTION_SAVE
167  );
168 
169  if(wnd->edit_view->file_path != NULL)
170  {
171  gtk_file_chooser_set_filename(
172  GTK_FILE_CHOOSER(save_dialog),
173  wnd->edit_view->file_path
174  );
175  }
176  else if(wnd->last_path != NULL)
177  {
178  gtk_file_chooser_set_current_folder(
179  GTK_FILE_CHOOSER(save_dialog),
180  wnd->last_path
181  );
182  }
183 
184  response = gtk_dialog_run(GTK_DIALOG(save_dialog) );
185  if(response == GTK_RESPONSE_OK)
186  {
187  filename = gtk_file_chooser_get_filename(
188  GTK_FILE_CHOOSER(save_dialog)
189  );
190 
191  g_free(wnd->last_path);
192  wnd->last_path = gtk_file_chooser_get_current_folder(
193  GTK_FILE_CHOOSER(save_dialog)
194  );
195 
196  mape_window_file_save(wnd, filename);
197 
198  g_free(filename);
199  }
200 
201  gtk_widget_destroy(save_dialog);
202 }
203 
204 static void mape_window_cb_file_save(GtkWidget* widget,
205  gpointer user_data)
206 {
207  MapeWindow* wnd;
208  wnd = (MapeWindow*)user_data;
209 
210  if(wnd->edit_view->file_path == NULL)
211  {
212  mape_window_cb_file_save_as(widget, user_data);
213  }
214  else
215  {
216  mape_window_file_save(wnd, wnd->edit_view->file_path);
217  }
218 }
219 
220 static gboolean mape_window_confirm_close(MapeWindow* wnd)
221 {
222  GtkWidget* confirm_dialog;
223  gint response;
224 
225  /* No need to confirm if the document has not been modified */
226  if(mape_edit_view_get_modified(wnd->edit_view) == FALSE)
227  return TRUE;
228 
229  confirm_dialog = gtk_message_dialog_new(
230  GTK_WINDOW(wnd->window),
231  GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
232  GTK_MESSAGE_WARNING,
233  GTK_BUTTONS_NONE,
234  "Save the changes to document before closing?"
235  );
236 
237  gtk_message_dialog_format_secondary_text(
238  GTK_MESSAGE_DIALOG(confirm_dialog),
239  "Unsaved changes will be permanently lost."
240  );
241 
242  gtk_dialog_add_buttons(
243  GTK_DIALOG(confirm_dialog),
244  "Close _without saving",
245  GTK_RESPONSE_REJECT,
246  GTK_STOCK_CANCEL,
247  GTK_RESPONSE_CANCEL,
248  GTK_STOCK_SAVE,
249  GTK_RESPONSE_ACCEPT,
250  NULL
251  );
252 
253  response = gtk_dialog_run(GTK_DIALOG(confirm_dialog) );
254  gtk_widget_destroy(confirm_dialog);
255 
256  switch(response)
257  {
258  case GTK_RESPONSE_DELETE_EVENT:
259  case GTK_RESPONSE_CANCEL:
260  return FALSE;
261  break;
262  case GTK_RESPONSE_REJECT:
263  /* Document may be closed */
264  return TRUE;
265  case GTK_RESPONSE_ACCEPT:
266  /* Save before closing */
267  mape_window_cb_file_save(wnd->window, wnd);
268  return TRUE;
269  default:
270  g_assert_not_reached();
271  return FALSE;
272  }
273 }
274 
275 static void mape_window_cb_realize(GtkWidget* widget,
276  gpointer user_data)
277 {
278  MapeWindow* wnd;
279  wnd = (MapeWindow*)user_data;
280 
281  gtk_paned_set_position(GTK_PANED(wnd->mid_paned), 200);
282 }
283 
284 static void mape_window_cb_file_new(GtkWidget* widget,
285  gpointer user_data)
286 {
287  MapeWindow* wnd;
288  wnd = (MapeWindow*)user_data;
289 
290  if(mape_window_confirm_close(wnd) == TRUE)
291  {
293  gtk_window_set_title(GTK_WINDOW(wnd->window), "Mape");
294  }
295 }
296 
297 static void mape_window_cb_file_open(GtkWidget* widget,
298  gpointer user_data)
299 {
300  MapeWindow* wnd;
301  gint response;
302  GtkWidget* open_dialog;
303  gchar* filename;
304 
305  wnd = (MapeWindow*)user_data;
306  if(mape_window_confirm_close(wnd) == FALSE)
307  return;
308 
309  open_dialog = mape_window_create_file_chooser(
310  wnd,
311  GTK_FILE_CHOOSER_ACTION_OPEN
312  );
313 
314  if(wnd->last_path != NULL)
315  {
316  gtk_file_chooser_set_current_folder(
317  GTK_FILE_CHOOSER(open_dialog),
318  wnd->last_path
319  );
320  }
321 
322  response = gtk_dialog_run(GTK_DIALOG(open_dialog) );
323  if(response == GTK_RESPONSE_OK)
324  {
325  filename = gtk_file_chooser_get_filename(
326  GTK_FILE_CHOOSER(open_dialog)
327  );
328 
329  g_free(wnd->last_path);
330  wnd->last_path = gtk_file_chooser_get_current_folder(
331  GTK_FILE_CHOOSER(open_dialog)
332  );
333 
334  mape_window_file_load(wnd, filename);
335 
336  g_free(filename);
337  }
338 
339  gtk_widget_destroy(open_dialog);
340 }
341 
342 static void mape_window_cb_file_quit(GtkWidget* widget,
343  gpointer user_data)
344 {
345  MapeWindow* wnd;
346  wnd = (MapeWindow*)user_data;
347 
348  if(mape_window_confirm_close(wnd) == TRUE)
349  gtk_widget_destroy(wnd->window);
350 }
351 
352 static gboolean mape_window_cb_delete_event(GtkWidget* widget,
353  GdkEvent* event,
354  gpointer user_data)
355 {
356  MapeWindow* wnd;
357  wnd = (MapeWindow*)user_data;
358 
359  if(mape_window_confirm_close(wnd) == TRUE)
360  return FALSE;
361  else
362  return TRUE;
363 }
364 
365 static void mape_window_cb_edit_undo(GtkAction* action,
366  gpointer user_data)
367 {
368  MapeWindow* wnd;
369  wnd = (MapeWindow*)user_data;
370 
372 }
373 
374 static void mape_window_cb_edit_redo(GtkAction* action,
375  gpointer user_data)
376 {
377  MapeWindow* wnd;
378  wnd = (MapeWindow*)user_data;
379 
381 }
382 
383 static void mape_window_cb_edit_can_undo(GObject* object,
384  GParamSpec* pspec,
385  gpointer user_data)
386 {
387  MapeWindow* wnd;
388  wnd = (MapeWindow*)user_data;
389 
390  gtk_action_set_sensitive(
391  wnd->header->edit_undo,
392  gtk_source_buffer_can_undo(GTK_SOURCE_BUFFER(object))
393  );
394 }
395 
396 static void mape_window_cb_edit_can_redo(GObject* object,
397  GParamSpec* pspec,
398  gpointer user_data)
399 {
400  MapeWindow* wnd;
401  wnd = (MapeWindow*)user_data;
402 
403  gtk_action_set_sensitive(
404  wnd->header->edit_redo,
405  gtk_source_buffer_can_redo(GTK_SOURCE_BUFFER(object))
406  );
407 }
408 
409 static void mape_window_cb_edit_preferences(GtkAction* action,
410  gpointer user_data)
411 {
412  MapeWindow* wnd;
413  MapePreferencesDialog* dialog;
414  gint result;
415 
416  wnd = (MapeWindow*)user_data;
417 
419  GTK_WINDOW(wnd->window),
420  &wnd->preferences
421  );
422 
423  result = gtk_dialog_run(GTK_DIALOG(dialog->dialog) );
424  if(result == GTK_RESPONSE_OK)
425  {
428 
430  wnd->edit_view,
431  &wnd->preferences
432  );
434  }
435 
437 }
438 
439 static void mape_window_cb_help_about(GtkAction* action,
440  gpointer user_data)
441 {
442  MapeWindow* wnd;
443  GtkWidget* about_dialog;
444 
445  const gchar* authors[] = {
446  "Developers:",
447  " Armin Burgmeier <armin@arbur.net>",
448  "",
449  "Contributors:",
450  " Tyron Madlener <tm@tyron.at>",
451  " G√ľnther Brammer <gbrammer@gmx.de>",
452  NULL
453  };
454 
455  const gchar* artists[] = {
456  "Stefan \"KaZoiTeZ\" Ryll",
457  NULL
458  };
459 
460  wnd = (MapeWindow*)user_data;
461  about_dialog = gtk_about_dialog_new();
462 
463  gtk_about_dialog_set_program_name(
464  GTK_ABOUT_DIALOG(about_dialog),
465  "Mape"
466  );
467 
468  gtk_about_dialog_set_version(
469  GTK_ABOUT_DIALOG(about_dialog),
471  );
472 
473  gtk_about_dialog_set_copyright(
474  GTK_ABOUT_DIALOG(about_dialog),
475  "Copyright \xc2\xa9 2005-2013 Armin Burgmeier"
476  );
477 
478  gtk_about_dialog_set_comments(
479  GTK_ABOUT_DIALOG(about_dialog),
480  "A Clonk Landscape.txt editor"
481  );
482 
483  gtk_about_dialog_set_authors(
484  GTK_ABOUT_DIALOG(about_dialog),
485  authors
486  );
487 
488  gtk_about_dialog_set_artists(
489  GTK_ABOUT_DIALOG(about_dialog),
490  artists
491  );
492 
493  gtk_about_dialog_set_license(
494  GTK_ABOUT_DIALOG(about_dialog),
495  "Permission to use, copy, modify, and/or distribute this "
496  "software for any purpose with or without fee is hereby "
497  "granted, provided that the above copyright notice and this "
498  "permission notice appear in all copies.\n\n"
499 
500  "THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS "
501  "ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL "
502  "IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO "
503  "EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, "
504  "INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES "
505  "WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, "
506  "WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER "
507  "TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE "
508  "USE OR PERFORMANCE OF THIS SOFTWARE."
509  );
510 
511  gtk_about_dialog_set_wrap_license(GTK_ABOUT_DIALOG(about_dialog), TRUE);
512 
513  gtk_dialog_run(GTK_DIALOG(about_dialog) );
514  gtk_widget_destroy(about_dialog);
515 }
516 
518  char* argv[],
519  GError** error)
520 {
521  MapeWindow* wnd;
522  MapeConfigFileEntry* entry;
523  gchar* config_path;
524  gchar* material_path;
525  gchar* current_dir;
526  gchar* landscape_path;
527  gchar* basename;
528  int i;
529 
530  wnd = malloc(sizeof(MapeWindow) );
531 
532  /* Load preferences */
533  config_path = g_build_filename(g_get_home_dir(), ".mape", NULL);
534  wnd->config = mape_config_file_new(config_path);
535  g_free(config_path);
536 
537  current_dir = g_get_current_dir();
538  landscape_path = NULL;
539 
540  for(i = 1; i < argc; ++ i)
541  {
542  basename = g_path_get_basename(argv[i]);
543  if(g_strcasecmp(basename, "Material.ocg") == 0)
544  {
545  if(!g_path_is_absolute(argv[i]))
546  {
547  material_path = g_build_filename(
548  current_dir,
549  argv[i],
550  NULL
551  );
552  }
553  else
554  {
555  material_path = g_strdup(argv[i]);
556  }
557 
559  wnd->config,
560  "material_path",
561  material_path
562  );
563 
564  g_free(material_path);
565  }
566  else
567  {
568  g_free(landscape_path);
569 
570  if(!g_path_is_absolute(argv[i]))
571  {
572  landscape_path = g_build_filename(
573  current_dir,
574  argv[i],
575  NULL
576  );
577  }
578  else
579  {
580  landscape_path = g_strdup(argv[i]);
581  }
582  }
583 
584  g_free(basename);
585  }
586 
587  g_free(current_dir);
588 
590 
591  wnd->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
593  wnd->last_path = NULL;
594 
595  wnd->header = mape_header_new();
596  wnd->statusbar = mape_statusbar_new();
597 
598  wnd->mat_tex_view = mape_mat_tex_view_new(wnd->icon_set, error);
599  if(wnd->mat_tex_view == NULL)
600  goto mat_tex_error;
601 
602  wnd->pre_view = mape_pre_view_new(wnd->mat_tex_view, error);
603  if(wnd->pre_view == NULL)
604  goto pre_view_error;
605 
607  wnd->pre_view,
608  wnd->statusbar,
609  error
610  );
611  if(wnd->edit_view == NULL)
612  goto edit_view_error;
613 
615  wnd->icon_set,
616  wnd->mat_tex_view,
617  wnd->edit_view,
618  wnd->config,
619  error
620  );
621 
622  if(wnd->disk_view == NULL)
623  goto disk_view_error;
624 
625  wnd->menubar = wnd->header->menubar;
626  gtk_widget_show(wnd->menubar);
627 
628  wnd->toolbar = wnd->header->toolbar;
629  gtk_toolbar_set_style(GTK_TOOLBAR(wnd->toolbar), GTK_TOOLBAR_ICONS);
630  gtk_widget_show(wnd->toolbar);
631 
632  wnd->mid_paned = gtk_hpaned_new();
633  gtk_paned_pack1(
634  GTK_PANED(wnd->mid_paned),
635  wnd->disk_view->window,
636  TRUE,
637  FALSE
638  );
639 
640  gtk_paned_pack2(
641  GTK_PANED(wnd->mid_paned),
642  wnd->edit_view->window,
643  TRUE,
644  FALSE
645  );
646 
647  gtk_widget_show(wnd->mid_paned);
648 
649  wnd->bottom_hbox = gtk_hbox_new(FALSE, 5);
650  gtk_box_pack_start(
651  GTK_BOX(wnd->bottom_hbox),
652  wnd->mat_tex_view->notebook,
653  TRUE,
654  TRUE,
655  0
656  );
657 
658  gtk_box_pack_start(
659  GTK_BOX(wnd->bottom_hbox),
660  wnd->pre_view->frame,
661  FALSE,
662  FALSE,
663  0
664  );
665  gtk_widget_show(wnd->bottom_hbox);
666 
667  wnd->topbox = gtk_vbox_new(FALSE, 0);
668  gtk_box_pack_start(
669  GTK_BOX(wnd->topbox),
670  wnd->menubar,
671  FALSE,
672  TRUE,
673  0
674  );
675 
676  gtk_box_pack_start(
677  GTK_BOX(wnd->topbox),
678  wnd->toolbar,
679  FALSE,
680  TRUE,
681  0
682  );
683 
684  gtk_box_pack_start(
685  GTK_BOX(wnd->topbox),
686  wnd->mid_paned,
687  TRUE,
688  TRUE,
689  0
690  );
691 
692  gtk_box_pack_start(
693  GTK_BOX(wnd->topbox),
694  wnd->bottom_hbox,
695  FALSE,
696  TRUE,
697  0
698  );
699 
700  gtk_box_pack_start(
701  GTK_BOX(wnd->topbox),
702  wnd->statusbar->bar,
703  FALSE,
704  TRUE,
705  0
706  );
707 
708  gtk_widget_show(wnd->topbox);
709 
710  gtk_container_add(
711  GTK_CONTAINER(wnd->window),
712  wnd->topbox
713  );
714 
715  gtk_window_add_accel_group(
716  GTK_WINDOW(wnd->window),
717  wnd->header->accel_group
718  );
719 
720  g_signal_connect(
721  G_OBJECT(wnd->window),
722  "realize",
723  G_CALLBACK(mape_window_cb_realize),
724  wnd
725  );
726 
727  g_signal_connect(
728  G_OBJECT(wnd->window),
729  "delete-event",
730  G_CALLBACK(mape_window_cb_delete_event),
731  wnd
732  );
733 
734  gtk_widget_grab_focus(wnd->edit_view->view);
735 
736  g_signal_connect(
737  G_OBJECT(wnd->header->file_new),
738  "activate",
739  G_CALLBACK(mape_window_cb_file_new),
740  wnd
741  );
742 
743  g_signal_connect(
744  G_OBJECT(wnd->header->file_open),
745  "activate",
746  G_CALLBACK(mape_window_cb_file_open),
747  wnd
748  );
749 
750  g_signal_connect(
751  G_OBJECT(wnd->header->file_save),
752  "activate",
753  G_CALLBACK(mape_window_cb_file_save),
754  wnd
755  );
756 
757  g_signal_connect(
758  G_OBJECT(wnd->header->file_save_as),
759  "activate",
760  G_CALLBACK(mape_window_cb_file_save_as),
761  wnd
762  );
763 
764  g_signal_connect(
765  G_OBJECT(wnd->header->file_quit),
766  "activate",
767  G_CALLBACK(mape_window_cb_file_quit),
768  wnd
769  );
770 
771  g_signal_connect(
772  G_OBJECT(wnd->header->edit_undo),
773  "activate",
774  G_CALLBACK(mape_window_cb_edit_undo),
775  wnd
776  );
777 
778  g_signal_connect(
779  G_OBJECT(wnd->header->edit_redo),
780  "activate",
781  G_CALLBACK(mape_window_cb_edit_redo),
782  wnd
783  );
784 
785  g_signal_connect(
786  G_OBJECT(
787  gtk_text_view_get_buffer(
788  GTK_TEXT_VIEW(wnd->edit_view->view)
789  )
790  ),
791  "notify::can-undo",
792  G_CALLBACK(mape_window_cb_edit_can_undo),
793  wnd
794  );
795 
796  g_signal_connect(
797  G_OBJECT(
798  gtk_text_view_get_buffer(
799  GTK_TEXT_VIEW(wnd->edit_view->view)
800  )
801  ),
802  "notify::can-redo",
803  G_CALLBACK(mape_window_cb_edit_can_redo),
804  wnd
805  );
806 
807  g_signal_connect(
808  G_OBJECT(wnd->header->edit_preferences),
809  "activate",
810  G_CALLBACK(mape_window_cb_edit_preferences),
811  wnd
812  );
813 
814  g_signal_connect(
815  G_OBJECT(wnd->header->help_about),
816  "activate",
817  G_CALLBACK(mape_window_cb_help_about),
818  wnd
819  );
820 
821  gtk_action_set_sensitive(wnd->header->edit_undo, FALSE);
822  gtk_action_set_sensitive(wnd->header->edit_redo, FALSE);
823 
826 
827  /* Load initial path in disk view, if any. Note this needs to go
828  * after applying preferences in edit_view, so that the map size is
829  * correct in case the newly loaded Material.ocg triggers a map update. */
831  wnd->config,
832  "material_path"
833  );
834 
835  if(entry != NULL)
836  {
838  wnd->disk_view,
840  NULL
841  );
842  }
843 
844  gtk_window_set_title(GTK_WINDOW(wnd->window), "Mape");
845  gtk_window_set_default_size(GTK_WINDOW(wnd->window), 640, 480);
846 
847  /* Load initial landscape */
848  if(landscape_path != NULL)
849  {
850  mape_window_file_load(wnd, landscape_path);
851  g_free(landscape_path);
852  }
853 
854  gtk_widget_show(wnd->window);
855 
856  return wnd;
857 
858 disk_view_error:
860 
861 edit_view_error:
863 
864 pre_view_error:
866 
867 mat_tex_error:
868  g_free(landscape_path);
869 
872 
874  gtk_widget_destroy(wnd->window);
876  free(wnd);
877 
878  return NULL;
879 }
880 
882 {
889 
892  g_free(wnd->last_path);
893  free(wnd);
894 }
GtkAction * file_save
Definition: header.h:32
void mape_preferences_to_config(MapePreferences *preferences, MapeConfigFile *config)
Definition: preferences.c:113
GtkAction * edit_preferences
Definition: header.h:39
MapeMatTexView * mape_mat_tex_view_new(MapeFileIconSet *icon_set, GError **error)
Definition: mattexview.c:24
GtkWidget * mid_paned
Definition: window.h:30
GtkWidget * menubar
Definition: window.h:33
void mape_preferences_dialog_destroy(MapePreferencesDialog *dialog)
GtkAction * file_open
Definition: header.h:31
gboolean mape_edit_view_get_modified(MapeEditView *view)
Definition: editview.c:679
GtkWidget * toolbar
Definition: header.h:27
GtkWidget * topbox
Definition: window.h:29
const gchar * mape_config_file_entry_get_value(MapeConfigFileEntry *entry)
Definition: configfile.c:174
GtkAction * file_quit
Definition: header.h:34
GtkWidget * frame
Definition: preview.h:29
void mape_window_destroy(MapeWindow *wnd)
Definition: window.c:881
MapePreferences mape_preferences_dialog_get(MapePreferencesDialog *dialog)
MapeHeader * header
Definition: window.h:36
GtkWidget * window
Definition: editview.h:32
gboolean mape_edit_view_save(MapeEditView *view, const gchar *filename, GError **error)
Definition: editview.c:632
void mape_mat_tex_view_destroy(MapeMatTexView *view)
Definition: mattexview.c:80
void mape_edit_view_undo(MapeEditView *edit_view)
Definition: editview.c:686
void mape_disk_view_destroy(MapeDiskView *disk_view)
Definition: diskview.c:974
MapePreView * pre_view
Definition: window.h:42
void mape_statusbar_destroy(MapeStatusbar *bar)
Definition: statusbar.c:42
const char * c4_version_get()
MapeEditView * mape_edit_view_new(MapePreView *pre_view, MapeStatusbar *statusbar, GError **error)
Definition: editview.c:393
MapeHeader * mape_header_new(void)
Definition: header.c:148
void mape_edit_view_apply_preferences(MapeEditView *edit_view, MapePreferences *preferences)
Definition: editview.c:704
MapePreferences preferences
Definition: window.h:45
void mape_edit_view_redo(MapeEditView *edit_view)
Definition: editview.c:695
GtkAction * file_save_as
Definition: header.h:33
GtkWidget * view
Definition: editview.h:33
GtkWidget * window
Definition: diskview.h:39
gboolean mape_edit_view_open(MapeEditView *view, const gchar *filename, GError **error)
Definition: editview.c:545
MapeDiskView * mape_disk_view_new(MapeFileIconSet *icon_set, MapeMatTexView *mat_tex, MapeEditView *edit_view, MapeConfigFile *config, GError **error)
Definition: diskview.c:823
MapeConfigFile * config
Definition: window.h:44
void mape_header_destroy(MapeHeader *header)
Definition: header.c:274
MapeConfigFileEntry * mape_config_file_get_entry_by_key(MapeConfigFile *file, const gchar *key)
Definition: configfile.c:132
gboolean mape_config_file_serialise(MapeConfigFile *file, GError **error)
Definition: configfile.c:70
gchar * file_path
Definition: editview.h:34
gboolean mape_disk_view_extend_to_path(MapeDiskView *disk_view, const gchar *filepath, GError **error)
Definition: diskview.c:989
MapeEditView * edit_view
Definition: window.h:41
GtkAction * edit_undo
Definition: header.h:37
void mape_config_file_destroy(MapeConfigFile *file)
Definition: configfile.c:56
MapeStatusbar * mape_statusbar_new(void)
Definition: statusbar.c:20
void mape_pre_view_destroy(MapePreView *view)
Definition: preview.c:47
GtkWidget * toolbar
Definition: window.h:34
MapeConfigFile * mape_config_file_new(const gchar *filename)
Definition: configfile.c:21
void mape_edit_view_clear(MapeEditView *view)
Definition: editview.c:526
MapeWindow * mape_window_new(int argc, char *argv[], GError **error)
Definition: window.c:517
GtkAccelGroup * accel_group
Definition: header.h:24
void mape_config_file_set_entry(MapeConfigFile *file, const gchar *key, const gchar *value)
Definition: configfile.c:143
void mape_file_icon_set_destroy(MapeFileIconSet *set)
Definition: fileicon.c:122
void mape_edit_view_destroy(MapeEditView *view)
Definition: editview.c:505
MapeDiskView * disk_view
Definition: window.h:39
GtkWidget * menubar
Definition: header.h:26
GtkAction * file_new
Definition: header.h:30
Definition: configfile.h:22
MapeFileIconSet * mape_file_icon_set_new(GtkWidget *widget)
Definition: fileicon.c:109
GtkAction * edit_redo
Definition: header.h:38
void mape_preferences_from_config(MapePreferences *preferences, MapeConfigFile *config)
Definition: preferences.c:84
MapeStatusbar * statusbar
Definition: window.h:37
GtkWidget * bar
Definition: statusbar.h:23
GtkWidget * notebook
Definition: mattexview.h:27
void mape_pre_view_apply_preferences(MapePreView *view, MapePreferences *preferences)
Definition: preview.c:64
MapeFileIconSet * icon_set
Definition: window.h:24
GtkWidget * window
Definition: window.h:27
GtkWidget * bottom_hbox
Definition: window.h:31
GtkAction * help_about
Definition: header.h:42
gchar * last_path
Definition: window.h:25
MapePreView * mape_pre_view_new(MapeMatTexView *mat_tex, GError **error)
Definition: preview.c:21
MapeMatTexView * mat_tex_view
Definition: window.h:40
MapePreferencesDialog * mape_preferences_dialog_new(GtkWindow *parent, MapePreferences *prefs)