void ZLGtkDialogManager::wait(const ZLResourceKey &key, ZLRunnable &runnable) const { if (!myIsInitialized || myIsWaiting) { runnable.run(); } else { myIsWaiting = true; #if MAEMO_VERSION <= 3 gtk_banner_show_animation(myWindow, waitMessageText(key).c_str()); #elif MAEMO_VERSION <= 5 GtkWidget *banner = hildon_banner_show_animation(GTK_WIDGET(myWindow), NULL, waitMessageText(key).c_str()); #else #error Unknown value for MAEMO_VERSION #endif RunnableWithFlag rwf; rwf.runnable = &runnable; rwf.flag = true; pthread_t thread; pthread_create(&thread, 0, runRunnable, &rwf); while (rwf.flag) { gtk_main_iteration(); } pthread_join(thread, 0); #if MAEMO_VERSION <= 3 gtk_banner_close(myWindow); #elif MAEMO_VERSION <= 5 gtk_widget_destroy(banner); #else #error Unknown value for MAEMO_VERSION #endif myIsWaiting = false; } }
void ZLGtkProgressDialog::run(ZLRunnable &runnable) { while (gtk_events_pending()) { gtk_main_iteration(); } GtkWindow *mainWindow = GTK_WINDOW(gtk_window_new(GTK_WINDOW_POPUP)); gtk_window_set_accept_focus(mainWindow, FALSE); myLabel = gtk_label_new(messageText().c_str()); gtk_misc_set_padding(GTK_MISC(myLabel), 10, 10); // something nice? gtk_container_add(GTK_CONTAINER(mainWindow), myLabel); gtk_widget_show_all(GTK_WIDGET(mainWindow)); GdkCursor *cursor = gdk_cursor_new(GDK_WATCH); if (myParent != 0) { gdk_window_set_cursor(GTK_WIDGET(myParent)->window, cursor); } gdk_window_set_cursor(GTK_WIDGET(mainWindow)->window, cursor); gdk_cursor_unref(cursor); int x, y, w, h; if (myParent != 0) { gtk_window_get_position(myParent, &x, &y); gtk_window_get_size(myParent, &w, &h); x += w / 2; y += h / 2; } else { GdkWindow *root = gdk_screen_get_root_window(gdk_screen_get_default()); gdk_window_get_geometry(root, &x, &y, &w, &h, 0); x += w / 2; y += h / 2; } gtk_window_get_size(mainWindow, &w, &h); x -= w / 2; y -= h / 2; gtk_window_move(mainWindow, x, y); while (gtk_events_pending()) { gtk_main_iteration(); } if (myParent != 0) { gtk_widget_queue_draw(GTK_WIDGET(myParent)); } while (gtk_events_pending()) { gtk_main_iteration(); } runnable.run(); myLabel = 0; if (myParent != 0) { gdk_window_set_cursor(GTK_WIDGET(myParent)->window, 0); } gtk_widget_destroy(GTK_WIDGET(mainWindow)); }
void ZLDialogManager::wait(const ZLResourceKey &key, ZLRunnable &runnable) const { shared_ptr<ZLProgressDialog> dialog = createProgressDialog(key); if (!dialog.isNull()) { dialog->run(runnable); } else { runnable.run(); } }
void ZLQtDialogManager::wait(const ZLResourceKey &key, ZLRunnable &runnable) const { ZLQtWaitMessage waitMessage(waitMessageText(key)); runnable.run(); }
void ZLQtDialogManager::wait(const ZLResourceKey &key, ZLRunnable &runnable) const { // John: We don't need to show the waiting dialog. // ZLQtWaitMessage waitMessage(waitMessageText(key)); runnable.run(); }
void ZLEwlDialogManager::wait(const ZLResourceKey &key, ZLRunnable &runnable) const { runnable.run(); }
void GtkDialogManager::wait(ZLRunnable &runnable, const std::string &message) const { GtkWaitMessage waitMessage(myWindow, message); runnable.run(); }
void QDialogManager::wait(ZLRunnable &runnable, const std::string &message) const { QWaitMessage waitMessage(message); runnable.run(); }
void run(ZLRunnable &runnable) { runnable.run(); }