Author: rpmcruz
Date: Wed Jan 16 11:26:07 2008
New Revision: 43652
URL: http://svn.opensuse.org/viewcvs/yast?rev=43652&view=rev
Log:
* src/YGDialog.cc, src/YGLayout.cc & src/YGWidget.cc: ditched the old
sync-stretchable approach by an iteration on YDialog::setSize() (called
by UI::Recalc() and similar).
* src/ygtkratiobox.h/.c: merged and removed some calls.
* src/ygtkfieldentry.c: bug fix: mnemonic on YGTextEntry (and also, but less
significatively, to YGDate and YGTime) was not functional.
Modified:
trunk/gtk/ChangeLog
trunk/gtk/src/YGDialog.cc
trunk/gtk/src/YGDialog.h
trunk/gtk/src/YGLayout.cc
trunk/gtk/src/YGPackageSelector.cc
trunk/gtk/src/YGWidget.cc
trunk/gtk/src/YGWidget.h
trunk/gtk/src/ygtkbargraph.c
trunk/gtk/src/ygtkfieldentry.c
trunk/gtk/src/ygtkratiobox.c
trunk/gtk/src/ygtkratiobox.h
Modified: trunk/gtk/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=43652&r1=43651&r2=43652&view=diff
==============================================================================
--- trunk/gtk/ChangeLog (original)
+++ trunk/gtk/ChangeLog Wed Jan 16 11:26:07 2008
@@ -1,3 +1,13 @@
+2008-01-16 Ricardo Cruz
+
+ * src/YGDialog.cc, src/YGLayout.cc & src/YGWidget.cc: ditched the old
+ sync-stretchable approach by an iteration on YDialog::setSize() (called
+ by UI::Recalc() and similar).
+ * src/ygtkratiobox.h/.c: merged and removed some calls.
+
+ * src/ygtkfieldentry.c: bug fix: mnemonic on YGTextEntry (and also, but less
+ significatively, to YGDate and YGTime) was not functional.
+
2008-01-15 Ricardo Cruz
* src/YGProgressBar.cc (YGBusyIndicator): implemented YBusyIndicator
Modified: trunk/gtk/src/YGDialog.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGDialog.cc?rev=43652&r1=43651&r2=43652&view=diff
==============================================================================
--- trunk/gtk/src/YGDialog.cc (original)
+++ trunk/gtk/src/YGDialog.cc Wed Jan 16 11:26:07 2008
@@ -386,6 +386,35 @@
gdk_window_set_cursor (m_window->getWidget()->window, cursor);
}
+
+// YWidget
+void YGDialog::setEnabled (bool enabled)
+{
+ doSetEnabled (enabled);
+ YWidget::setEnabled (enabled);
+}
+
+void YGDialog::setSize (int width, int height)
+{
+ // libyui calls YDialog::setSize() to force a geometry recalculation as a
+ // result of changed layout properties
+ struct inner {
+ static void syncStretchable (YWidget *ywidget, YGWidget *widget)
+ {
+ for (YWidgetListConstIterator it = ywidget->childrenBegin();
+ it != ywidget->childrenEnd(); it++) {
+ YWidget *ychild = const_cast (*it);
+ YGWidget *child = YGWidget::get (ychild);
+ if (child) {
+ widget->syncStretchable (ychild, child);
+ syncStretchable (ychild, child);
+ }
+ }
+ }
+ };
+ inner::syncStretchable (this, this);
+}
+
YDialog *YGWidgetFactory::createDialog (YDialogType dialogType, YDialogColorMode colorMode)
{
IMPL
Modified: trunk/gtk/src/YGDialog.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGDialog.h?rev=43652&r1=43651&r2=43652&view=diff
==============================================================================
--- trunk/gtk/src/YGDialog.h (original)
+++ trunk/gtk/src/YGDialog.h Wed Jan 16 11:26:07 2008
@@ -28,7 +28,11 @@
static YGDialog *currentDialog();
static GtkWindow *currentWindow();
- YGWIDGET_IMPL_COMMON
+ virtual void setSize (int width, int height);
+ virtual void setEnabled (bool enabled);
+ virtual int preferredWidth() { return 0; }
+ virtual int preferredHeight() { return 0; }
+
YGWIDGET_IMPL_CHILD_ADDED (m_containee)
YGWIDGET_IMPL_CHILD_REMOVED (m_containee)
};
Modified: trunk/gtk/src/YGLayout.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGLayout.cc?rev=43652&r1=43651&r2=43652&view=diff
==============================================================================
--- trunk/gtk/src/YGLayout.cc (original)
+++ trunk/gtk/src/YGLayout.cc Wed Jan 16 11:26:07 2008
@@ -36,63 +36,58 @@
g_object_unref (G_OBJECT (m_labels_group));
}
+ YGWIDGET_IMPL_CHILD_ADDED (getWidget())
+ YGWIDGET_IMPL_CHILD_REMOVED (getWidget())
virtual string getDebugLabel() const
{ return primary() == YD_HORIZ ? "horizontal" : "vertical"; }
+ virtual void moveChild (YWidget *child, int x, int y) {}
- virtual void doAddChild (YWidget *ychild, GtkWidget *container)
- {
- IMPL
- YGWidget::doAddChild (ychild, container);
- // set labels of YGLabeledWidgets to the same width
- // we have to do quite some work due to over-clutter on YCP progs
- while (ychild) {
- if (ychild->hasChildren()) { // container
- // try to see if there is a YGLabeledWidget at start
- // (and ignore YSpacings)
- YWidget *container = ychild;
- for (YWidgetListConstIterator it = container->childrenBegin();
- it != container->childrenEnd(); it++) {
- ychild = *it;
- if (!dynamic_cast (ychild))
- break;
- }
- }
- else {
- YGWidget *ygchild = YGWidget::get (ychild);
- YGLabeledWidget *labeled_child = dynamic_cast (ygchild);
- if (labeled_child && labeled_child->orientation() == YD_HORIZ) {
- if (!m_labels_group)
- m_labels_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
- gtk_size_group_add_widget (m_labels_group,
- labeled_child->getLabelWidget());
- }
- break;
- }
+ void addSizeGroup (YGLabeledWidget *labeledWidget)
+ {
+ GtkWidget *label = labeledWidget->getLabelWidget();
+ if (m_labels_group) {
+ GSList *labels = gtk_size_group_get_widgets (m_labels_group);
+ if (g_slist_find (labels, label)) // contains label already?
+ return;
+ // labels is not to be freed!
}
+ else
+ m_labels_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ gtk_size_group_add_widget (m_labels_group, label);
}
- YGWIDGET_IMPL_CHILD_ADDED (getWidget())
- YGWIDGET_IMPL_CHILD_REMOVED (getWidget())
-
- virtual void sync_stretchable (YWidget *ychild)
+ virtual void syncStretchable (YWidget *ychild, YGWidget *child)
{
IMPL
YGtkRatioBox *box = YGTK_RATIO_BOX (getWidget());
- YGWidget *child = YGWidget::get (ychild);
YUIDimension dim = primary();
bool horiz_fill = ychild->stretchable (YD_HORIZ) || ychild->hasWeight (YD_HORIZ);
bool vert_fill = ychild->stretchable (YD_VERT) || ychild->hasWeight (YD_VERT);
- ygtk_ratio_box_set_child_packing (box, child->getLayout(), ychild->weight (dim),
- horiz_fill, vert_fill, 0);
- ygtk_ratio_box_set_child_expand (box, child->getLayout(),
- ychild->stretchable (dim), isLayoutStretch (ychild, dim));
- YGWidget::sync_stretchable();
- }
+ ygtk_ratio_box_set_child_packing (box, child->getLayout(), ychild->stretchable (dim),
+ isLayoutStretch (ychild, dim), ychild->weight (dim), horiz_fill, vert_fill, 0);
- virtual void moveChild (YWidget *, int, int) {} // ignore
+ // align horizontal widget labels to the same width
+ // we do some work here, since they may be placed inside a HBox or something...
+ if (!horiz_fill)
+ return;
+ YWidget *yLabeledWidget = ychild;
+ while (yLabeledWidget->hasChildren()) { // container
+ YWidget *container = yLabeledWidget;
+ for (YWidgetListConstIterator it = container->childrenBegin();
+ it != container->childrenEnd(); it++) {
+ yLabeledWidget = *it;
+ if (!dynamic_cast (yLabeledWidget) /*ignore spacings*/)
+ break;
+ }
+ }
+ YGLabeledWidget *labeledWidget =
+ dynamic_cast (YGWidget::get (yLabeledWidget));
+ if (labeledWidget && labeledWidget->orientation() == YD_HORIZ)
+ addSizeGroup (labeledWidget);
+ }
};
YLayoutBox *YGWidgetFactory::createLayoutBox (YWidget *parent, YUIDimension dimension)
@@ -134,12 +129,12 @@
}
YGWIDGET_IMPL_CHILD_ADDED (m_widget)
YGWIDGET_IMPL_CHILD_REMOVED (m_widget)
+ virtual void moveChild (YWidget *child, int x, int y) {}
- virtual void sync_stretchable (YWidget *child)
+ virtual void syncStretchable (YWidget *ychild, YGWidget *child)
{
IMPL
setAlignment (alignment (YD_HORIZ), alignment (YD_VERT));
- YGWidget::sync_stretchable();
}
void setAlignment (YAlignmentType halign, YAlignmentType valign)
@@ -223,8 +218,6 @@
return TRUE;
}
- virtual void moveChild (YWidget *, int, int) {}; // ignore
-
virtual string getDebugLabel() const
{
struct inner {
Modified: trunk/gtk/src/YGPackageSelector.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGPackageSelector.cc?rev=43652&r1=43651&r2=43652&view=diff
==============================================================================
--- trunk/gtk/src/YGPackageSelector.cc (original)
+++ trunk/gtk/src/YGPackageSelector.cc Wed Jan 16 11:26:07 2008
@@ -1784,7 +1784,7 @@
}
return FALSE;
}
- static void truncate (std::string &str, int size)
+ static void truncate (std::string &str, unsigned int size)
{
if (str.size() > size) {
str.erase (size-3);
Modified: trunk/gtk/src/YGWidget.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGWidget.cc?rev=43652&r1=43651&r2=43652&view=diff
==============================================================================
--- trunk/gtk/src/YGWidget.cc (original)
+++ trunk/gtk/src/YGWidget.cc Wed Jan 16 11:26:07 2008
@@ -74,11 +74,17 @@
return gtk_widget_is_focus (GTK_WIDGET (getWidget()));
}
-void YGWidget::doSetEnabling (bool enabled)
+void YGWidget::doSetEnabled (bool enabled)
{
gtk_widget_set_sensitive (getWidget(), enabled);
}
+void YGWidget::doSetUseBoldFont (bool useBold)
+{
+ PangoWeight weight = useBold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL;
+ YGUtils::setWidgetFont (getWidget(), weight, PANGO_SCALE_MEDIUM);
+}
+
void YGWidget::doAddChild (YWidget *ychild, GtkWidget *container)
{
GtkWidget *child = YGWidget::get (ychild)->getLayout();
@@ -147,14 +153,6 @@
setMinSize (width, height);
}
-void YGWidget::sync_stretchable (YWidget *child)
-{
- IMPL
- YWidget *parent = m_ywidget->parent();
- if (parent)
- YGWidget::get (parent)->sync_stretchable (m_ywidget);
-}
-
/* YGLabeledWidget follows */
YGLabeledWidget::YGLabeledWidget (YWidget *ywidget, YWidget *parent,
Modified: trunk/gtk/src/YGWidget.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGWidget.h?rev=43652&r1=43651&r2=43652&view=diff
==============================================================================
--- trunk/gtk/src/YGWidget.h (original)
+++ trunk/gtk/src/YGWidget.h Wed Jan 16 11:26:07 2008
@@ -33,9 +33,10 @@
// for YWidget
virtual bool doSetKeyboardFocus();
- virtual void doSetEnabling (bool enabled);
+ virtual void doSetEnabled (bool enabled);
virtual void doAddChild (YWidget *child, GtkWidget *container);
virtual void doRemoveChild (YWidget *child, GtkWidget *container);
+ void doSetUseBoldFont (bool useBold);
// Event handling
void emitEvent(YEvent::EventReason reason, bool if_notify = true,
@@ -48,7 +49,7 @@
// whenever the stretchable property may change (eg. when adding a child
// for a container), call this function to make sure it is honored.
- virtual void sync_stretchable (YWidget *child = 0);
+ virtual void syncStretchable (YWidget *ychild, YGWidget *child) {}
protected:
void show();
@@ -70,17 +71,17 @@
#define YGWIDGET_IMPL_COMMON \
virtual bool setKeyboardFocus() \
{ return doSetKeyboardFocus(); } \
- virtual void setEnabling (bool enabled) \
- { doSetEnabling (enabled); } \
+ virtual void setEnabled (bool enabled) { \
+ doSetEnabled (enabled); \
+ YWidget::setEnabled (enabled); \
+ } \
virtual int preferredWidth() { return 0; } \
virtual int preferredHeight() { return 0; } \
- virtual void moveChild (YWidget *child, int x, int y) {} \
virtual void setSize (int width, int height) {}
#define YGWIDGET_IMPL_USE_BOLD(ParentClass) \
virtual void setUseBoldFont (bool useBold) { \
- PangoWeight weight = useBold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL; \
- YGUtils::setWidgetFont (getWidget(), weight, PANGO_SCALE_MEDIUM); \
+ doSetUseBoldFont (useBold); \
ParentClass::setUseBoldFont (useBold); \
}
@@ -89,7 +90,6 @@
virtual void addChild (YWidget *ychild) { \
YWidget::addChild (ychild); \
doAddChild (ychild, container); \
- sync_stretchable (ychild); \
}
#define YGWIDGET_IMPL_CHILD_REMOVED(container) \
virtual void removeChild (YWidget *ychild) { \
Modified: trunk/gtk/src/ygtkbargraph.c
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkbargraph.c?rev=43652&r1=43651&r2=43652&view=diff
==============================================================================
--- trunk/gtk/src/ygtkbargraph.c (original)
+++ trunk/gtk/src/ygtkbargraph.c Wed Jan 16 11:26:07 2008
@@ -95,8 +95,8 @@
// Set proportion
gtk_widget_set_size_request (box, 10, -1); // for homogeneous...
- ygtk_ratio_box_set_child_packing (YGTK_RATIO_BOX (bar), box, MAX (value, 1),
- TRUE, TRUE, 0);
+ ygtk_ratio_box_set_child_packing (YGTK_RATIO_BOX (bar), box, TRUE, FALSE,
+ MAX (value, 1), TRUE, TRUE, 0);
// Set background color
// The Tango palette
Modified: trunk/gtk/src/ygtkfieldentry.c
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkfieldentry.c?rev=43652&r1=43651&r2=43652&view=diff
==============================================================================
--- trunk/gtk/src/ygtkfieldentry.c (original)
+++ trunk/gtk/src/ygtkfieldentry.c Wed Jan 16 11:26:07 2008
@@ -167,10 +167,21 @@
return gtk_entry_get_text (entry);
}
+static gboolean ygtk_field_entry_mnemonic_activate (GtkWidget *widget, gboolean cycling)
+{
+ YGtkFieldEntry *fields = YGTK_FIELD_ENTRY (widget);
+ GtkEntry *entry = ygtk_field_entry_get_field_widget (fields, 0);
+ gtk_widget_grab_focus (GTK_WIDGET (entry));
+ return TRUE;
+}
+
static void ygtk_field_entry_class_init (YGtkFieldEntryClass *klass)
{
ygtk_field_entry_parent_class = g_type_class_peek_parent (klass);
+ GtkWidgetClass* widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class->mnemonic_activate = ygtk_field_entry_mnemonic_activate;
+
filter_entry_signal = g_signal_new ("field_entry_changed",
G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (YGtkFieldEntryClass, filter_entry_changed),
Modified: trunk/gtk/src/ygtkratiobox.c
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkratiobox.c?rev=43652&r1=43651&r2=43652&view=diff
==============================================================================
--- trunk/gtk/src/ygtkratiobox.c (original)
+++ trunk/gtk/src/ygtkratiobox.c Wed Jan 16 11:26:07 2008
@@ -285,8 +285,8 @@
}
void ygtk_ratio_box_set_child_packing (YGtkRatioBox *box, GtkWidget *child,
- gfloat ratio, gboolean xfill, gboolean yfill,
- guint padding)
+ gboolean expand, gboolean must_expand, gfloat ratio, gboolean xfill, gboolean yfill,
+ guint padding)
{
YGtkRatioBoxChild *child_info;
child_info = ygtk_ratio_get_child_info (box, child);
@@ -297,8 +297,8 @@
child_info->xfill = xfill;
child_info->yfill = yfill;
child_info->padding = padding;
- child_info->expand = 0;
- child_info->must_expand = 0;
+ child_info->expand = expand;
+ child_info->must_expand = expand && must_expand;
if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (box))
gtk_widget_queue_resize (child);
@@ -307,47 +307,6 @@
}
}
-void ygtk_ratio_box_get_child_packing (YGtkRatioBox *box, GtkWidget *child,
- gfloat *ratio, gboolean *xfill,
- gboolean *yfill, guint *padding,
- gboolean *expand)
-{
- YGtkRatioBoxChild *child_info;
- child_info = ygtk_ratio_get_child_info (box, child);
-
- if (child_info) {
- gtk_widget_freeze_child_notify (child);
-
- if (ratio) *ratio = child_info->ratio;
- if (xfill) *xfill = child_info->xfill;
- if (yfill) *yfill = child_info->yfill;
- if (padding) *padding = child_info->padding;
- if (expand) *expand = child_info->expand;
- }
-}
-
-void ygtk_ratio_box_set_child_expand (YGtkRatioBox *box, GtkWidget *child,
- gboolean expand, gboolean must_expand)
-{
- YGtkRatioBoxChild *child_info;
- child_info = ygtk_ratio_get_child_info (box, child);
- if (child_info)
- {
- child_info->expand = expand;
- if (expand)
- child_info->must_expand = must_expand;
- }
-}
-
-void ygtk_ratio_box_set_child_ratio (YGtkRatioBox *box, GtkWidget *child,
- gfloat ratio)
-{
- YGtkRatioBoxChild *child_info;
- child_info = ygtk_ratio_get_child_info (box, child);
- if (child_info)
- child_info->ratio = ratio;
-}
-
void ygtk_ratio_box_set_spacing (YGtkRatioBox *box, gint spacing)
{
box->spacing = spacing;
Modified: trunk/gtk/src/ygtkratiobox.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkratiobox.h?rev=43652&r1=43651&r2=43652&view=diff
==============================================================================
--- trunk/gtk/src/ygtkratiobox.h (original)
+++ trunk/gtk/src/ygtkratiobox.h Wed Jan 16 11:26:07 2008
@@ -79,22 +79,13 @@
void ygtk_ratio_box_pack (YGtkRatioBox *box, GtkWidget *child, gfloat ratio,
gboolean xfill, gboolean yfill, guint padding);
-// If you don't want to use ratios, you can use the ordinary expand flag. NOTE:
-// If some other child has ratio > 0, this one won't expand.
-// All this mess is so we can conform with yast-core.
-void ygtk_ratio_box_set_child_expand (YGtkRatioBox *box, GtkWidget *child,
- gboolean expand, gboolean must_expand);
-void ygtk_ratio_box_set_child_ratio (YGtkRatioBox *box, GtkWidget *child,
- gfloat ratio);
-
+// You can either use ratios or the expand boolean. If some child has a ratio set (to
+// a value other than 0), then expand flags will be ignored -- use must_expand in such
+// cases, when you want a child to expand like the child of the most ratio.
+// (rules based on those of libyui -- check top)
void ygtk_ratio_box_set_child_packing (YGtkRatioBox *box, GtkWidget *child,
- gfloat ratio, gboolean xfill,
- gboolean yfill, guint padding);
-
-void ygtk_ratio_box_get_child_packing (YGtkRatioBox *box, GtkWidget *child,
- gfloat *ratio, gboolean *xfill,
- gboolean *yfill, guint *padding,
- gboolean *expandable);
+ gboolean expand, gboolean must_expand, gfloat ratio, gboolean xfill, gboolean yfill,
+ guint padding);
/* RatioHBox */
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org