Author: rpmcruz Date: Wed Oct 10 20:55:43 2007 New Revision: 41351 URL: http://svn.opensuse.org/viewcvs/yast?rev=41351&view=rev Log: * src/YGDialog.cc: fixed bug #330777. The value we need to return from the delete-event callback (close window) is always True, because we don't want GTK destroying the window for us. We just want to let YCP know about it, and then YCP does it explicitely if and when it wants to. For the record, the abandon dialog from the package selector is working. Neat dialog btw. Modified: trunk/gtk/ChangeLog trunk/gtk/src/YGDialog.cc trunk/gtk/src/YGDialog.h trunk/gtk/src/YGPackageSelector.cc trunk/gtk/src/YGWidget.cc trunk/gtk/src/ygtkwizard.c Modified: trunk/gtk/ChangeLog URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=41351&r1=41350&r2=41351&view=diff ============================================================================== --- trunk/gtk/ChangeLog (original) +++ trunk/gtk/ChangeLog Wed Oct 10 20:55:43 2007 @@ -5,6 +5,13 @@ * fixed a couple of warnings. + * src/YGDialog.cc: fixed bug #330777. The value we need to return from the + delete-event callback (close window) is always True, because we don't want + GTK destroying the window for us. We just want to let YCP know about it, + and then YCP does it explicitely if and when it wants to. + For the record, the abandon dialog from the package selector is working. Neat + dialog btw. + 2007-10-03 Boyd Timothy <btimothy@novell.com> * src/YGPackageSelector.cc: Use the "available" name to sort Modified: trunk/gtk/src/YGDialog.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGDialog.cc?rev=41351&r1=41350&r2=41351&view=diff ============================================================================== --- trunk/gtk/src/YGDialog.cc (original) +++ trunk/gtk/src/YGDialog.cc Wed Oct 10 20:55:43 2007 @@ -24,7 +24,7 @@ YGWindow::~YGWindow() { IMPL - setChild (NULL); + setChild (NULL); gtk_widget_destroy (m_widget); g_object_unref (G_OBJECT (m_widget)); } @@ -108,17 +108,16 @@ YGWindow *pThis) { IMPL - return !pThis->checkDelete(); + // never let GTK+ destroy the window! just inform YCP, and let it + // do its thing. + pThis->closeWindow(); + return TRUE; } -bool YGWindow::checkDelete() +void YGWindow::closeWindow() { - fprintf (stderr, "YGDialog close event ...\n"); - if (!m_canDelete) { + if (!m_canClose || m_canClose (m_canCloseData)) YGUI::ui()->sendEvent (new YCancelEvent()); - return TRUE; - } - return m_canDelete (m_closure); } static gboolean key_pressed_cb (GtkWidget *widget, GdkEventKey *event, @@ -128,7 +127,11 @@ // if not main dialog, close it on escape if (event->keyval == GDK_Escape && /* not main window */ main_window != pThis) - return pThis->checkDelete(); + { + pThis->closeWindow(); + return TRUE; + + } if ((event->state & GDK_CONTROL_MASK) && (event->state & GDK_SHIFT_MASK) && (event->state & GDK_MOD1_MASK)) { @@ -180,7 +183,7 @@ if (main_window) ::main_window = this; m_child = NULL; - m_canDelete = NULL; + m_canClose = NULL; { GtkWindow *parent = YGUI::ui()->currentWindow(); @@ -218,10 +221,10 @@ G_CALLBACK (key_pressed_cb), this); } -void YGWindow::setDeleteCallback (YGWindowDeleteFn canDelete, void *closure) +void YGWindow::setCloseCallback (YGWindowCloseFn canClose, void *canCloseData) { - m_canDelete = canDelete; - m_closure = closure; + m_canClose = canClose; + m_canCloseData = canCloseData; } YGDialog::YGDialog (YWidgetOpt &opt) @@ -338,3 +341,4 @@ else return NULL; } + Modified: trunk/gtk/src/YGDialog.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGDialog.h?rev=41351&r1=41350&r2=41351&view=diff ============================================================================== --- trunk/gtk/src/YGDialog.h (original) +++ trunk/gtk/src/YGDialog.h Wed Oct 10 20:55:43 2007 @@ -4,7 +4,7 @@ #include "YGWidget.h" #include "YDialog.h" -typedef bool (*YGWindowDeleteFn) (void *closure); +typedef bool (*YGWindowCloseFn) (void *closure); class YGWindow { @@ -13,8 +13,8 @@ // we keep a pointer of the child just for debugging // (ie. dump yast tree) YWidget *m_child; - YGWindowDeleteFn m_canDelete; - void *m_closure; + YGWindowCloseFn m_canClose; + void *m_canCloseData; private: static gboolean close_window_cb (GtkWidget *widget, GdkEvent *event, @@ -25,8 +25,8 @@ void setChild (YWidget *new_child); static void ref (YGWindow *window); static void unref (YGWindow *window); - void setDeleteCallback (YGWindowDeleteFn canDelete, void *closure); - bool checkDelete(); + void setCloseCallback (YGWindowCloseFn canClose, void *canCloseData); + void closeWindow(); // Y(G)Widget-like methods GtkWidget *getWidget() { return m_widget; } @@ -47,8 +47,8 @@ void hideWindow(); GtkWindow *getWindow() { return GTK_WINDOW (m_window->getWidget()); } - void setDeleteCallback (bool (*canDelete) (void *closure), void *closure) - { m_window->setDeleteCallback (canDelete, closure); } + void setCloseCallback (YGWindowCloseFn closeCallback, void *closeData) + { m_window->setCloseCallback (closeCallback, closeData); } YGWIDGET_IMPL_COMMON @@ -57,3 +57,4 @@ }; #endif // YGDIALOG_H + Modified: trunk/gtk/src/YGPackageSelector.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGPackageSelector.cc?rev=41351&r1=41350&r2=41351&view=diff ============================================================================== --- trunk/gtk/src/YGPackageSelector.cc (original) +++ trunk/gtk/src/YGPackageSelector.cc Wed Oct 10 20:55:43 2007 @@ -2328,7 +2328,7 @@ GtkWindow *window = GTK_WINDOW (dialog->getWindow()); gtk_window_resize (window, 680, 580); - dialog->setDeleteCallback (confirm_cb, this); + dialog->setCloseCallback (confirm_cb, this); YGtkWizard *wizard = YGTK_WIZARD (getWidget()); Modified: trunk/gtk/src/YGWidget.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGWidget.cc?rev=41351&r1=41350&r2=41351&view=diff ============================================================================== --- trunk/gtk/src/YGWidget.cc (original) +++ trunk/gtk/src/YGWidget.cc Wed Oct 10 20:55:43 2007 @@ -33,8 +33,7 @@ m_min_size = m_widget; else { m_min_size = ygtk_min_size_new (0, 0); - g_object_ref (G_OBJECT (m_min_size)); - gtk_object_sink (GTK_OBJECT (m_min_size)); + g_object_ref_sink (G_OBJECT (m_min_size)); gtk_widget_show (m_min_size); gtk_container_add (GTK_CONTAINER (m_min_size), m_widget); } @@ -286,3 +285,4 @@ hpolicy == GTK_POLICY_AUTOMATIC ? MAX_SCROLL_SIZE : 0, vpolicy == GTK_POLICY_AUTOMATIC ? MAX_SCROLL_SIZE : 0); } + Modified: trunk/gtk/src/ygtkwizard.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkwizard.c?rev=41351&r1=41350&r2=41351&view=diff ============================================================================== --- trunk/gtk/src/ygtkwizard.c (original) +++ trunk/gtk/src/ygtkwizard.c Wed Oct 10 20:55:43 2007 @@ -1244,3 +1244,4 @@ GtkBindingSet *binding_set = gtk_binding_set_by_class (klass); gtk_binding_entry_add_signal (binding_set, GDK_F1, 0, "popup_help", 0); } + -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org