OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
mape.c File Reference
#include <stdlib.h>
#include <signal.h>
#include <glib.h>
#include <gtk/gtk.h>
#include "mape/editview.h"
#include "mape/window.h"
#include "mape/mapgen.h"
#include "mape/random.h"
Include dependency graph for mape.c:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 126 of file mape.c.

References mape_mapgen_deinit(), mape_mapgen_init(), mape_random_seed(), mape_window_destroy(), mape_window_new(), and MapeWindow_::window.

128 {
129  MapeWindow* window;
130  GError* error = NULL;
131  GtkWidget* error_dialog;
132 
133  _global_wnd = &window;
134 
135  signal(SIGSEGV, segv_handler);
136 
137  g_thread_init(NULL);
138  gtk_init(&argc, &argv);
139 
140  mape_random_seed(time(NULL));
141  mape_mapgen_init(&error);
142 
143  if(error == NULL)
144  {
145  /* TODO: Set global application icon */
146  window = mape_window_new(argc, argv, &error);
147  }
148 
149  if(error != NULL)
150  {
151  error_dialog = gtk_message_dialog_new(
152  NULL,
153  GTK_DIALOG_MODAL,
154  GTK_MESSAGE_ERROR,
155  GTK_BUTTONS_OK,
156  "Application initialization failed"
157  );
158 
159  gtk_message_dialog_format_secondary_text(
160  GTK_MESSAGE_DIALOG(error_dialog),
161  "%s",
162  error->message
163  );
164 
165  gtk_window_set_title(GTK_WINDOW(error_dialog), "Mape");
166 
167  g_error_free(error);
168  gtk_dialog_run(GTK_DIALOG(error_dialog) );
169  gtk_widget_destroy(error_dialog);
170 
171  return EXIT_FAILURE;
172  }
173 
174  g_signal_connect(
175  G_OBJECT(window->window),
176  "destroy",
177  G_CALLBACK(mape_main_window_destroy),
178  (gpointer)window
179  );
180 
181  gtk_main();
182  mape_window_destroy(window);
184 
185  return EXIT_SUCCESS;
186 }
void mape_window_destroy(MapeWindow *wnd)
Definition: window.c:881
void mape_random_seed(unsigned int seed)
Definition: random.c:42
MapeWindow * mape_window_new(int argc, char *argv[], GError **error)
Definition: window.c:517
gboolean mape_mapgen_init(GError **error)
Definition: mapgen.c:144
void mape_mapgen_deinit()
Definition: mapgen.c:156
GtkWidget * window
Definition: window.h:27

Here is the call graph for this function: