[yast-commit] r41961 - in /trunk/gtk: ChangeLog src/YGDialog.cc src/YGDialog.h src/YGPackageSelector.cc src/YGTree.cc src/YGUI.cc src/YGUI.h tests/PollInput.ycp
Author: rpmcruz Date: Mon Nov 12 02:05:57 2007 New Revision: 41961 URL: http://svn.opensuse.org/viewcvs/yast?rev=41961&view=rev Log: 2007-11-11 Ricardo Cruz <rpmcruz@alunos.dcc.fc.up.pt> * src/YGDialog.h/cc & YGPackageSelector.cc: bug fix #340555: package manager post-selection process hangs when trying to exit (by the window manager: e.g. Alt+F4). You need to unset the callback thing that was installed on YGDialog for the "Abandon Changes" dialog. * src/YGUI.cc: bug fix: cannot abort package manager post-selection process (related to previous). We were not implementing UI::PollInput(), which is a non-blocker UI::UserInput() used by this kind of processes. * example/PollInput.ycp: a test case for User & PollInput(). Added: trunk/gtk/tests/PollInput.ycp Modified: trunk/gtk/ChangeLog trunk/gtk/src/YGDialog.cc trunk/gtk/src/YGDialog.h trunk/gtk/src/YGPackageSelector.cc trunk/gtk/src/YGTree.cc trunk/gtk/src/YGUI.cc trunk/gtk/src/YGUI.h Modified: trunk/gtk/ChangeLog URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=41961&r1=41960&r2=41961&view=diff ============================================================================== --- trunk/gtk/ChangeLog (original) +++ trunk/gtk/ChangeLog Mon Nov 12 02:05:57 2007 @@ -1,3 +1,15 @@ +2007-11-11 Ricardo Cruz <rpmcruz@alunos.dcc.fc.up.pt> + + * src/YGDialog.h/cc & YGPackageSelector.cc: bug fix #340555: package + manager post-selection process hangs when trying to exit (by the window + manager: e.g. Alt+F4). You need to unset the callback thing that was + installed on YGDialog for the "Abandon Changes" dialog. + + * src/YGUI.cc: bug fix: cannot abort package manager post-selection + process (related to previous). We were not implementing UI::PollInput(), + which is a non-blocker UI::UserInput() used by this kind of processes. + * example/PollInput.ycp: a test case for User & PollInput(). + 2007-11-07 Ricardo Cruz <rpmcruz@alunos.dcc.fc.up.pt> * src/ygtkratiobox.c: bug fix, dialog on disk.ycp tool was gutted. Modified: trunk/gtk/src/YGDialog.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGDialog.cc?rev=41961&r1=41960&r2=41961&view=diff ============================================================================== --- trunk/gtk/src/YGDialog.cc (original) +++ trunk/gtk/src/YGDialog.cc Mon Nov 12 02:05:57 2007 @@ -227,6 +227,11 @@ m_canCloseData = canCloseData; } +void YGWindow::unsetCloseCallback() +{ + m_canClose = NULL; +} + YGDialog::YGDialog (YWidgetOpt &opt) : YDialog (opt), YGWidget (this, NULL, FALSE, GTK_TYPE_HBOX, NULL) Modified: trunk/gtk/src/YGDialog.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGDialog.h?rev=41961&r1=41960&r2=41961&view=diff ============================================================================== --- trunk/gtk/src/YGDialog.h (original) +++ trunk/gtk/src/YGDialog.h Mon Nov 12 02:05:57 2007 @@ -26,6 +26,7 @@ static void ref (YGWindow *window); static void unref (YGWindow *window); void setCloseCallback (YGWindowCloseFn canClose, void *canCloseData); + void unsetCloseCallback(); void closeWindow(); // Y(G)Widget-like methods @@ -49,6 +50,8 @@ void setCloseCallback (YGWindowCloseFn closeCallback, void *closeData) { m_window->setCloseCallback (closeCallback, closeData); } + void unsetCloseCallback() + { m_window->unsetCloseCallback(); } YGWIDGET_IMPL_COMMON Modified: trunk/gtk/src/YGPackageSelector.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGPackageSelector.cc?rev=41961&r1=41960&r2=41961&view=diff ============================================================================== --- trunk/gtk/src/YGPackageSelector.cc (original) +++ trunk/gtk/src/YGPackageSelector.cc Mon Nov 12 02:05:57 2007 @@ -2392,23 +2392,22 @@ bool checkDelete() { - GtkWidget *dialog; - bool changed = zyppPool().diffState<zypp::Package >() || zyppPool().diffState<zypp::Pattern >() || zyppPool().diffState<zypp::Selection>() || zyppPool().diffState<zypp::Language >() || zyppPool().diffState<zypp::Patch >(); - if (!changed) return true; + GtkWidget *dialog; dialog = gtk_message_dialog_new_with_markup (YGUI::ui()->currentWindow(), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, - GTK_BUTTONS_YES_NO, - _("<b>Abandon all changes?</b>")); + GTK_BUTTONS_NONE, _("<b>Abandon all changes?</b>")); + gtk_dialog_add_buttons (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_NO, + GTK_STOCK_QUIT, GTK_RESPONSE_YES, NULL); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_NO); bool ok = gtk_dialog_run (GTK_DIALOG (dialog)) == @@ -2425,18 +2424,16 @@ setBorder (0); YGDialog *dialog = YGUI::ui()->currentYGDialog(); - - GtkWindow *window = GTK_WINDOW (dialog->getWindow()); - gtk_window_resize (window, 680, 580); - dialog->setCloseCallback (confirm_cb, this); + GtkWindow *window = dialog->getWindow(); + gtk_window_resize (window, MAX (680, GTK_WIDGET (window)->allocation.width), + MAX (580, GTK_WIDGET (window)->allocation.height)); YGtkWizard *wizard = YGTK_WIZARD (getWidget()); ygtk_wizard_set_header_icon (wizard, window, THEMEDIR "/icons/32x32/apps/yast-software.png"); - ygtk_wizard_set_header_text (wizard, YGUI::ui()->currentWindow(), - "Package Selector"); + ygtk_wizard_set_header_text (wizard, window, "Package Selector"); ygtk_wizard_set_help_text (wizard, _("Two pools are presented; one with the available software, the other " "with the installed one. To install software you choose a package " @@ -2462,6 +2459,8 @@ virtual ~YGPackageSelector() { + YGDialog *dialog = YGUI::ui()->currentYGDialog(); + dialog->unsetCloseCallback(); delete m_package_selector; } Modified: trunk/gtk/src/YGTree.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGTree.cc?rev=41961&r1=41960&r2=41961&view=diff ============================================================================== --- trunk/gtk/src/YGTree.cc (original) +++ trunk/gtk/src/YGTree.cc Mon Nov 12 02:05:57 2007 @@ -150,3 +150,4 @@ { return new YGTree (opt, YGWidget::get (parent), label); } + Modified: trunk/gtk/src/YGUI.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUI.cc?rev=41961&r1=41960&r2=41961&view=diff ============================================================================== --- trunk/gtk/src/YGUI.cc (original) +++ trunk/gtk/src/YGUI.cc Mon Nov 12 02:05:57 2007 @@ -114,8 +114,8 @@ { if (!m_done_init) { gtk_init (&m_argc, &m_argv); + m_done_init = TRUE; } - m_done_init = TRUE; } void @@ -128,7 +128,6 @@ checkInit(); GIOChannel *wakeup; - wakeup = g_io_channel_unix_new (fd_ycp); g_io_channel_set_encoding (wakeup, NULL, NULL); g_io_channel_set_buffered (wakeup, FALSE); @@ -143,8 +142,7 @@ g_io_channel_unref (wakeup); } -static gboolean -set_timeout (YGUI *pThis) +static gboolean user_input_timeout_cb (YGUI *pThis) { IMPL; if (!pThis->pendingEvent()) @@ -159,34 +157,56 @@ g_main_context_wakeup (NULL); } +// utility that implements both userInput() and pollInput() YEvent * -YGUI::userInput( unsigned long timeout_millisec ) +YGUI::waitInput (unsigned long timeout_ms, bool block) { IMPL - normalCursor(); // waiting for input, so no more busy + if (block) + normalCursor(); // waiting for input, so no more busy + else + busyCursor(); guint timeout = 0; YEvent *event = NULL; - if (timeout_millisec > 0) - timeout = g_timeout_add (timeout_millisec, - (GSourceFunc) set_timeout, this); + if (timeout_ms > 0) + timeout = g_timeout_add (timeout_ms, + (GSourceFunc) user_input_timeout_cb, this); // FIXME: do it only if currentDialog (?) ... - while (!pendingEvent()) - g_main_iteration (TRUE); + if (block) + { + while (!pendingEvent()) + g_main_context_iteration (NULL, TRUE); + } + else + g_main_context_iteration (NULL, FALSE); - event = m_event_handler.consumePendingEvent(); + if (pendingEvent()) + event = m_event_handler.consumePendingEvent(); if (timeout) g_source_remove (timeout); // if YCP keeps working for more than X time, set busy cursor - busy_timeout = g_timeout_add (BUSY_CURSOR_TIMEOUT, busy_timeout_cb, this); + if (block) + busy_timeout = g_timeout_add (BUSY_CURSOR_TIMEOUT, busy_timeout_cb, this); return event; } +YEvent * +YGUI::userInput (unsigned long timeout_ms) +{ + return waitInput (timeout_ms, true); +} + +YEvent *YGUI::pollInput() +{ + return waitInput (0, false); +} + // dialog bits static void dumpYastTree (YWidget *widget, GtkTreeStore *store, @@ -678,3 +698,4 @@ sendEvent (new YEvent()); // flush } } + Modified: trunk/gtk/src/YGUI.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUI.h?rev=41961&r1=41960&r2=41961&view=diff ============================================================================== --- trunk/gtk/src/YGUI.h (original) +++ trunk/gtk/src/YGUI.h Mon Nov 12 02:05:57 2007 @@ -55,8 +55,9 @@ virtual bool eventsBlocked() const IMPL_RET (false) virtual void internalError (const char *msg); virtual void idleLoop (int fd_ycp); + virtual YEvent * waitInput (unsigned long timeout_ms, bool block); virtual YEvent * userInput (unsigned long timeout_millisec); - virtual YEvent * pollInput() IMPL_NULL + virtual YEvent * pollInput(); virtual void showDialog (YDialog *dialog); virtual void closeDialog (YDialog *dialog); Added: trunk/gtk/tests/PollInput.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/tests/PollInput.ycp?rev=41961&view=auto ============================================================================== --- trunk/gtk/tests/PollInput.ycp (added) +++ trunk/gtk/tests/PollInput.ycp Mon Nov 12 02:05:57 2007 @@ -0,0 +1,22 @@ +// Event pooling -- test bug that causes package manager post-script +// `cancel events to be ignored. +{ + UI::OpenDialog ( + `Label ("Blocked - UserInput()"), + `PushButton (`id (`button), "Ok") + ); + UI::UserInput(); + UI::CloseDialog(); + + UI::OpenDialog ( + `Label ("Un-blocked - PollInput()"), + `PushButton (`id (`button), "Ok") + ); + any event = nil; + repeat { + sleep (1000); + event = UI::PollInput(); + } until (event != nil); + UI::CloseDialog(); +} + -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
rpmcruz@svn.opensuse.org