makes lib refresh status window works (not hang) under mingw32
authorMaksym Veremeyenko <verem@m1stereo.tv>
Fri, 24 Jun 2011 10:49:58 +0000 (13:49 +0300)
committerMaksym Veremeyenko <verem@m1stereo.tv>
Fri, 24 Jun 2011 10:49:58 +0000 (13:49 +0300)
src/library.c
src/omnplay.cpp
src/omnplay.h
src/ui.c

index decaee7..ab6cee7 100644 (file)
@@ -225,25 +225,38 @@ void omnplay_library_save(omnplay_instance_t* app)
 static void omnplay_get_content_cb(omnplay_instance_t* app, playlist_item_t* item, void* data)
 {
     gdk_threads_enter();
-    gtk_label_set_text(GTK_LABEL(app->library.refresh_ui[1]), item->id);
+    gtk_label_set_text(GTK_LABEL(data), item->id);
     gdk_flush();
     gdk_threads_leave();
 };
 
 static void* omnplay_library_refresh_proc(void* data)
 {
+    GtkWidget *refresh_ui[2];
     omnplay_instance_t* app = (omnplay_instance_t*)data;
     int count, i;
     playlist_item_t* items;
 
+#ifndef _WIN32
+    gdk_threads_enter();
+#endif /* _WIN32 */
+    /* create UI for monitoring update */
+    ui_library_refresh(app, &refresh_ui[0], &refresh_ui[1]);
+    gtk_widget_show_all(refresh_ui[0]);
+    gtk_window_present(GTK_WINDOW(refresh_ui[0]));
+#ifndef _WIN32
+    gdk_flush();
+    gdk_threads_leave();
+#endif /* _WIN32 */
+
     items = (playlist_item_t*)malloc(sizeof(playlist_item_t) * MAX_LIBRARY_ITEMS);
 
-    count = omnplay_get_content(app, items, MAX_LIBRARY_ITEMS, omnplay_get_content_cb, NULL);
+    count = omnplay_get_content(app, items, MAX_LIBRARY_ITEMS, omnplay_get_content_cb, refresh_ui[1]);
 
     if(count > 0)
     {
         gdk_threads_enter();
-        gtk_label_set_text(GTK_LABEL(app->library.refresh_ui[1]), "Quering whois...");
+        gtk_label_set_text(GTK_LABEL(refresh_ui[1]), "Quering whois...");
         gdk_flush();
         gdk_threads_leave();
 
@@ -271,24 +284,29 @@ static void* omnplay_library_refresh_proc(void* data)
 
     gdk_threads_enter();
     omnplay_playlist_normalize(app);
-    gtk_widget_destroy(app->library.refresh_ui[0]);
     gdk_flush();
     gdk_threads_leave();
 
+#ifndef _WIN32
+    gdk_threads_enter();
+#endif /* _WIN32 */
+    gtk_widget_destroy(refresh_ui[0]);
+#ifndef _WIN32
+    gdk_flush();
+    gdk_threads_leave();
+#endif /* _WIN32 */
+
     return NULL;
 };
 
 void omnplay_library_refresh(omnplay_instance_t* app)
 {
-    if(app->library.refresh_ui[0])
+    if(app->library.refresh_thread_r)
         pthread_join(app->library.refresh_thread, NULL);
-
-    /* create UI for monitoring update */
-    ui_library_refresh(app, &app->library.refresh_ui[0], &app->library.refresh_ui[1]);
+    app->library.refresh_thread_r = 1;
 
     pthread_create(&app->library.refresh_thread, NULL,
         omnplay_library_refresh_proc, app);
-
 };
 
 void omnplay_library_draw(omnplay_instance_t* app)
index d54f78d..219f5d6 100644 (file)
@@ -1236,6 +1236,9 @@ void omnplay_init(omnplay_instance_t* app)
     omnplay_library_load(app);
 
     pthread_mutexattr_destroy(&attr);
+
+    /* create UI for monitoring update */
+//    ui_library_refresh(app, &app->library.refresh_ui[0], &app->library.refresh_ui[1]);
 };
 
 void omnplay_release(omnplay_instance_t* app)
index e92196e..1fdec39 100644 (file)
@@ -156,7 +156,7 @@ typedef struct omnplay_instance
         char whois[PATH_MAX];
         pthread_mutex_t lock;
         pthread_t refresh_thread;
-        GtkWidget *refresh_ui[2];
+        int refresh_thread_r;
         GtkWidget *search;
     } library;
     struct
index 1a6a2f9..c30ef55 100644 (file)
--- a/src/ui.c
+++ b/src/ui.c
@@ -719,18 +719,16 @@ void ui_library_refresh(omnplay_instance_t* app, GtkWidget **p_win, GtkWidget **
     gtk_window_set_default_size(GTK_WINDOW(win), 250, 100);
     gtk_window_set_modal(GTK_WINDOW(win), TRUE);
     gtk_window_set_transient_for(GTK_WINDOW(win), GTK_WINDOW(app->window));
+//    gtk_window_set_deletable(GTK_WINDOW(win), FALSE);
+//    gtk_window_set_resizable(GTK_WINDOW(win), FALSE);
 
     box = gtk_vbox_new(FALSE, 0);
     gtk_widget_show(box);
     gtk_container_add(GTK_CONTAINER(win), box);
 
     label = create_label(NULL, "Requsting status...", NULL, 0),
-    gtk_widget_show(label);
     gtk_box_pack_start (GTK_BOX(box), label, TRUE, TRUE, 0);
 
-    gtk_window_present(GTK_WINDOW(win));
-    gtk_widget_show(win);
-
     *p_win = win;
     *p_label = label;
 };