static void omnplay_get_content_cb(omnplay_instance_t* app, playlist_item_t* item, void* data)
{
- fprintf(stderr, "requested: id=[%s]\n", item->id);
+ gdk_threads_enter();
+ gtk_label_set_text(GTK_LABEL(app->library.refresh_ui[1]), item->id);
+ gdk_flush();
+ gdk_threads_leave();
};
-void omnplay_library_refresh(omnplay_instance_t* app)
+static void* omnplay_library_refresh_proc(void* data)
{
+ omnplay_instance_t* app = (omnplay_instance_t*)data;
int count, i;
playlist_item_t* items;
if(count > 0)
{
+ gdk_threads_enter();
+ gtk_label_set_text(GTK_LABEL(app->library.refresh_ui[1]), "Quering whois...");
+ gdk_flush();
+ gdk_threads_leave();
+
if(app->library.whois[0])
omnplay_whois_list(app, items, &count);
pthread_mutex_unlock(&app->library.lock);
+ gdk_threads_enter();
omnplay_library_draw(app);
+ gdk_flush();
+ gdk_threads_leave();
};
free(items);
+ gdk_threads_enter();
omnplay_playlist_normalize(app);
+ gtk_widget_destroy(app->library.refresh_ui[0]);
+ gdk_flush();
+ gdk_threads_leave();
+
+ return NULL;
+};
+
+void omnplay_library_refresh(omnplay_instance_t* app)
+{
+ if(app->library.refresh_ui[0])
+ 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]);
+
+ pthread_create(&app->library.refresh_thread, NULL,
+ omnplay_library_refresh_proc, app);
+
};
void omnplay_library_draw(omnplay_instance_t* app)
return r;
};
+
+void ui_library_refresh(omnplay_instance_t* app, GtkWidget **p_win, GtkWidget **p_label)
+{
+ GtkWidget *win, *box, *label;
+
+ win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(GTK_WINDOW(win), _("Library refreshing..."));
+ 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));
+
+ 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;
+};
GtkWidget* ui_omnplay(omnplay_instance_t* app);
int ui_playlist_item_dialog(omnplay_instance_t* app, playlist_item_t* item);
+void ui_library_refresh(omnplay_instance_t* app, GtkWidget **p_win, GtkWidget **p_label);
#ifdef __cplusplus
};