diff options
author | Nikias Bassen | 2010-02-02 23:53:24 +0100 |
---|---|---|
committer | Martin Szulecki | 2010-02-03 00:03:56 +0100 |
commit | af1d9663197fc1b836cecdc3f47771c7967c07cb (patch) | |
tree | 860f15d6794d982a2f511f9fa7cf50847c867e34 /src | |
parent | f86d923ed490dd226f5e9c162073d9e3bd31f297 (diff) | |
download | sbmanager-af1d9663197fc1b836cecdc3f47771c7967c07cb.tar.gz sbmanager-af1d9663197fc1b836cecdc3f47771c7967c07cb.tar.bz2 |
Use state variables to init global stuff only once
Diffstat (limited to 'src')
-rw-r--r-- | src/gui.c | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -111,6 +111,8 @@ int current_page = 0; struct timeval last_page_switch; static int gui_deinitialized = 0; +static int clutter_threads_initialized = 0; +static int clutter_initialized = 0; static void gui_page_indicator_group_add(GList *page, int page_index); static void gui_page_align_icons(guint page_num, gboolean animated); @@ -1244,13 +1246,21 @@ GtkWidget *gui_init() if (!g_thread_supported()) g_thread_init(NULL); - icon_loader_mutex = g_mutex_new(); + if (icon_loader_mutex == NULL) + icon_loader_mutex = g_mutex_new(); /* initialize clutter threading environment */ - clutter_threads_init(); + if (!clutter_threads_initialized) { + clutter_threads_init(); + clutter_threads_initialized = 1; + } - if (gtk_clutter_init(NULL, NULL) != CLUTTER_INIT_SUCCESS) { - g_error("Unable to initialize GtkClutter"); + if (!clutter_initialized) { + if (gtk_clutter_init(NULL, NULL) != CLUTTER_INIT_SUCCESS) { + g_error("Unable to initialize GtkClutter"); + return NULL; + } + clutter_initialized = 1; } gettimeofday(&last_page_switch, NULL); @@ -1344,7 +1354,8 @@ GtkWidget *gui_init() /* and start it */ clutter_timeline_start(clock_timeline); - selected_mutex = g_mutex_new(); + if (selected_mutex == NULL) + selected_mutex = g_mutex_new(); /* Position and update the clock */ clock_set_time(clock_label, time(NULL)); |