Author: rpmcruz
Date: Sat Nov 29 02:07:23 2008
New Revision: 53753
URL: http://svn.opensuse.org/viewcvs/yast?rev=53753&view=rev
Log:
* src/YGLayout.cc, src/YGPushButton.cc & src/YGComboBox.cc: realize
doesn't seem very reliable, so was using timeouts. Those can get
trigger while the widget is destroyed though which can mean trouble.
Use expose then disconnect. Also moved stock button stuff from
YGLayout.cc to YGPushButton.cc.
Modified:
trunk/gtk/ChangeLog
trunk/gtk/src/YGComboBox.cc
trunk/gtk/src/YGLayout.cc
trunk/gtk/src/YGPushButton.cc
trunk/gtk/src/YGUtils.cc
Modified: trunk/gtk/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=53753&r1=53752&r2=53753&view=diff
==============================================================================
--- trunk/gtk/ChangeLog (original)
+++ trunk/gtk/ChangeLog Sat Nov 29 02:07:23 2008
@@ -48,6 +48,12 @@
* src/YGLayout.cc: bug fix 446524: disable those orphan icon buttons
in the middle of a box.
+ * src/YGLayout.cc, src/YGPushButton.cc & src/YGComboBox.cc: realize
+ doesn't seem very reliable, so was using timeouts. Those can get
+ trigger while the widget is destroyed though which can mean trouble.
+ Use expose then disconnect. Also moved stock button stuff from
+ YGLayout.cc to YGPushButton.cc.
+
2008-11-23 Ricardo Cruz
* src/ygtkwizard.c: don't show "more" link on help line if the rest
Modified: trunk/gtk/src/YGComboBox.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGComboBox.cc?rev=53753&r1=53752&r2=53753&view=diff
==============================================================================
--- trunk/gtk/src/YGComboBox.cc (original)
+++ trunk/gtk/src/YGComboBox.cc Sat Nov 29 02:07:23 2008
@@ -37,8 +37,9 @@
connect (getWidget(), "changed",
G_CALLBACK (selected_changed_cb), this);
- // realize doesn't seem to work, so...
- g_timeout_add_full (G_PRIORITY_LOW, 500, realize_cb, this, NULL);
+ // realize doesn't seem reliable -- expose then disconnect
+ g_signal_connect (G_OBJECT (getWidget()), "expose-event",
+ G_CALLBACK (realize_cb), this);
}
inline GtkComboBox *getComboBox()
@@ -130,15 +131,16 @@
YGLABEL_WIDGET_IMPL_SET_LABEL_CHAIN (YComboBox)
YGSELECTION_WIDGET_IMPL_ALL (YComboBox)
- static gboolean realize_cb (gpointer pData)
+ static gboolean realize_cb (GtkWidget *widget, GdkEventExpose *event,
+ YGComboBox *pThis)
{
// some combo boxes have too many items -- wrap the thing in columns
- YGComboBox *pThis = (YGComboBox *) pData;
int rows;
pThis->getMaxDepth (&rows);
- int cols = MIN (rows / 20, 3) + 1;
+ int cols = MIN (rows / 20, 5) + 1;
if (cols > 1) // this changes the popup width, so only set it for cols > 1
gtk_combo_box_set_wrap_width (pThis->getComboBox(), cols);
+ g_signal_handlers_disconnect_by_func (widget, (gpointer) realize_cb, pThis);
return FALSE;
}
};
Modified: trunk/gtk/src/YGLayout.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGLayout.cc?rev=53753&r1=53752&r2=53753&view=diff
==============================================================================
--- trunk/gtk/src/YGLayout.cc (original)
+++ trunk/gtk/src/YGLayout.cc Sat Nov 29 02:07:23 2008
@@ -78,9 +78,6 @@
{
setBorder (0);
YGLAYOUT_INIT
- if (dim == YD_HORIZ)
- // realize doesn't seem to work, so...
- g_timeout_add_full (G_PRIORITY_LOW, 50, treat_button_icons_cb, this, NULL);
}
virtual void addChild (YWidget *ychild)
@@ -93,26 +90,6 @@
YGWIDGET_IMPL_CHILD_REMOVED (getWidget())
YGLAYOUT_PREFERRED_SIZE_IMPL (YLayoutBox)
YGLAYOUT_SET_SIZE_IMPL (YLayoutBox)
-
- static gboolean treat_button_icons_cb (gpointer pData)
- {
- YGLayoutBox *pThis = (YGLayoutBox *) pData;
- // only set stock icons if all to the left have them
- bool enable = true;
- for (YWidgetListConstIterator it = pThis->childrenBegin();
- it != pThis->childrenEnd(); it++) {
- YPushButton *ybutton = dynamic_cast (*it);
- if (ybutton) {
- GtkWidget *button = YGWidget::get (ybutton)->getWidget();
- GtkWidget *icon = gtk_button_get_image (GTK_BUTTON (button));
- if (enable)
- enable = icon != NULL;
- else if (icon)
- gtk_widget_hide (icon);
- }
- }
- return FALSE;
- }
};
YLayoutBox *YGWidgetFactory::createLayoutBox (YWidget *parent, YUIDimension dimension)
Modified: trunk/gtk/src/YGPushButton.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGPushButton.cc?rev=53753&r1=53752&r2=53753&view=diff
==============================================================================
--- trunk/gtk/src/YGPushButton.cc (original)
+++ trunk/gtk/src/YGPushButton.cc Sat Nov 29 02:07:23 2008
@@ -4,10 +4,12 @@
#include
#include
-#include "YPushButton.h"
+#include
#include "YGUtils.h"
#include "YGWidget.h"
+#include
+
class YGPushButton : public YPushButton, public YGWidget
{
bool m_customIcon, m_labelIcon;
@@ -21,7 +23,9 @@
m_customIcon = m_labelIcon = false;
gtk_button_set_use_underline (GTK_BUTTON (getWidget()), TRUE);
setLabel (label);
- connect (getWidget (), "clicked", G_CALLBACK (clicked_cb), this);
+ connect (getWidget(), "clicked", G_CALLBACK (clicked_cb), this);
+ g_signal_connect (G_OBJECT (getWidget()), "expose-event",
+ G_CALLBACK (treat_icon_cb), this);
}
void setStockIcon (const std::string &label)
@@ -125,6 +129,33 @@
}
}
+ static gboolean treat_icon_cb (GtkWidget *widget, GdkEventExpose *event,
+ YGPushButton *pThis)
+ {
+ // only set stock icons if all to the left have them
+ YLayoutBox *ybox = dynamic_cast (pThis->parent());
+ if (ybox && ybox->primary() == YD_HORIZ && !pThis->m_customIcon) {
+ YWidget *ylast = 0;
+ for (YWidgetListConstIterator it = ybox->childrenBegin();
+ it != ybox->childrenEnd(); it++) {
+ if ((YWidget *) pThis == *it) {
+ if (ylast) {
+ GtkWidget *button = YGWidget::get (ylast)->getWidget();
+ GtkWidget *icon = gtk_button_get_image (GTK_BUTTON (button));
+ if (!icon || !GTK_WIDGET_VISIBLE (icon))
+ pThis->setIcon ("");
+ }
+ break;
+ }
+ ylast = *it;
+ if (!dynamic_cast (ylast))
+ ylast = NULL;
+ }
+ }
+ g_signal_handlers_disconnect_by_func (widget, (gpointer) treat_icon_cb, pThis);
+ return FALSE;
+ }
+
// Events
static void clicked_cb (GtkButton *button, YGPushButton *pThis)
{ pThis->emitEvent (YEvent::Activated, IGNORE_NOTIFY_EVENT); }
Modified: trunk/gtk/src/YGUtils.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUtils.cc?rev=53753&r1=53752&r2=53753&view=diff
==============================================================================
--- trunk/gtk/src/YGUtils.cc (original)
+++ trunk/gtk/src/YGUtils.cc Sat Nov 29 02:07:23 2008
@@ -331,6 +331,7 @@
// we want to use GtkImage stock mode so it honors sensitive
GtkWidget *image = gtk_image_new_from_stock (icon, GTK_ICON_SIZE_BUTTON);
gtk_button_set_image (GTK_BUTTON (button), image);
+ gtk_widget_show (image);
}
}
else {
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org