Author: rpmcruz
Date: Fri Dec 7 13:39:17 2007
New Revision: 42792
URL: http://svn.opensuse.org/viewcvs/yast?rev=42792&view=rev
Log:
* Some fixes overall. YGTree and YGMultiSelectionBox were not working.
Polished YGSelectionModel. Fixed support for icons.
* ygtkcellrenderertextpixbuf.h/c: a cell renderer that combines both
GtkCellRendererText and GtkCellRendererPixbuf. We need this as yast can
set either an icon or text on a cell, or both.
Added:
trunk/gtk/unstable-libyui/src/ygtkcellrenderertextpixbuf.c
trunk/gtk/unstable-libyui/src/ygtkcellrenderertextpixbuf.h
Modified:
trunk/gtk/unstable-libyui/ChangeLog
trunk/gtk/unstable-libyui/src/Makefile.am
trunk/gtk/unstable-libyui/src/YGComboBox.cc
trunk/gtk/unstable-libyui/src/YGDialog.cc
trunk/gtk/unstable-libyui/src/YGDumbTab.cc
trunk/gtk/unstable-libyui/src/YGInputField.cc
trunk/gtk/unstable-libyui/src/YGLayout.cc
trunk/gtk/unstable-libyui/src/YGSelectionModel.cc
trunk/gtk/unstable-libyui/src/YGSelectionModel.h
trunk/gtk/unstable-libyui/src/YGTable.cc
trunk/gtk/unstable-libyui/src/YGUI.cc
trunk/gtk/unstable-libyui/src/YGUI.h
trunk/gtk/unstable-libyui/src/YGWizard.cc
trunk/gtk/unstable-libyui/src/ygtkfieldentry.c
trunk/gtk/unstable-libyui/src/ygtkmenubutton.c
trunk/gtk/unstable-libyui/src/ygtkratiobox.c
Modified: trunk/gtk/unstable-libyui/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/ChangeLog?rev=42792&r1=42791&r2=42792&view=diff
==============================================================================
--- trunk/gtk/unstable-libyui/ChangeLog (original)
+++ trunk/gtk/unstable-libyui/ChangeLog Fri Dec 7 13:39:17 2007
@@ -1,3 +1,12 @@
+2007-12-07 Ricardo Cruz
+
+ * Some fixes overall. YGTree and YGMultiSelectionBox were not working.
+ Polished YGSelectionModel. Fixed support for icons.
+
+ * ygtkcellrenderertextpixbuf.h/c: a cell renderer that combines both
+ GtkCellRendererText and GtkCellRendererPixbuf. We need this as yast can
+ set either an icon or text on a cell, or both.
+
2007-12-06 Ricardo Cruz
* Fixed previous crash, some other problems and some improvements.
Modified: trunk/gtk/unstable-libyui/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/Makefile.am?rev=42792&r1=42791&r2=42792&view=diff
==============================================================================
--- trunk/gtk/unstable-libyui/src/Makefile.am (original)
+++ trunk/gtk/unstable-libyui/src/Makefile.am Fri Dec 7 13:39:17 2007
@@ -48,6 +48,7 @@
ygtkfindentry.c \
ygdkmngloader.c \
ygtkimage.c \
+ ygtkcellrenderertextpixbuf.c \
ygtkhtmlwrap.c \
ygtkrichtext.c \
yzyppwrapper.cc \
Modified: trunk/gtk/unstable-libyui/src/YGComboBox.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGComboBox.cc?rev=42792&r1=42791&r2=42792&view=diff
==============================================================================
--- trunk/gtk/unstable-libyui/src/YGComboBox.cc (original)
+++ trunk/gtk/unstable-libyui/src/YGComboBox.cc Fri Dec 7 13:39:17 2007
@@ -17,11 +17,13 @@
: YComboBox (NULL, label, editable)
, YGLabeledWidget (this, parent, label, YD_HORIZ, true,
editable ? GTK_TYPE_COMBO_BOX_ENTRY : GTK_TYPE_COMBO_BOX, NULL)
- , YGSelectionModel (true, false)
+ , YGSelectionModel (this, true, false)
{
+ gtk_combo_box_set_model (getComboBox(), getModel());
GtkCellRenderer* cell;
if (editable) {
- gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (getWidget()), 0);
+ gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (getWidget()),
+ YGSelectionModel::LABEL_COLUMN);
}
else {
cell = gtk_cell_renderer_text_new ();
@@ -33,7 +35,6 @@
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (getWidget()), cell, FALSE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (getWidget()), cell,
"pixbuf", YGSelectionModel::ICON_COLUMN, NULL);
- gtk_combo_box_set_model (getComboBox(), getModel());
g_signal_connect (G_OBJECT (getWidget()), "changed",
G_CALLBACK (selected_changed_cb), this);
@@ -69,17 +70,23 @@
gtk_entry_set_text (getEntry(), value.c_str());
}
- virtual void focusItem (GtkTreeIter *iter)
+ // YGSelectionModel
+ virtual void setFocusItem (GtkTreeIter *iter, bool addingRow)
{
+ // GtkComboBox wants a string on the model, not NULL, when setting it as
+ // the active row. As, we only set that value after addingRow, we need to
+ // initialize it here...
+ if (addingRow)
+ setCellLabel (iter, YGSelectionModel::LABEL_COLUMN, string());
gtk_combo_box_set_active_iter (getComboBox(), iter);
}
- virtual void unfocusAllItems()
+ virtual void unsetFocus()
{
gtk_combo_box_set_active (getComboBox(), -1);
}
- virtual YItem *selectedItem()
+ virtual YItem *focusItem()
{
GtkTreeIter iter;
if (gtk_combo_box_get_active_iter (getComboBox(), &iter))
@@ -87,6 +94,7 @@
return NULL;
}
+ // YComboBox
virtual void setInputMaxLength (const YCPInteger &numberOfChars)
{
gtk_entry_set_width_chars (getEntry(), numberOfChars->asInteger()->value());
Modified: trunk/gtk/unstable-libyui/src/YGDialog.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGDialog.cc?rev=42792&r1=42791&r2=42792&view=diff
==============================================================================
--- trunk/gtk/unstable-libyui/src/YGDialog.cc (original)
+++ trunk/gtk/unstable-libyui/src/YGDialog.cc Fri Dec 7 13:39:17 2007
@@ -64,8 +64,8 @@
}
if (_main_window) {
- int w = YGUI::ui()->getDefaultWidth(),
- h = YGUI::ui()->getDefaultHeight();
+ int w = YGUI::ui()->_getDefaultWidth(),
+ h = YGUI::ui()->_getDefaultHeight();
gtk_window_set_default_size (window, w, h);
}
Modified: trunk/gtk/unstable-libyui/src/YGDumbTab.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGDumbTab.cc?rev=42792&r1=42791&r2=42792&view=diff
==============================================================================
--- trunk/gtk/unstable-libyui/src/YGDumbTab.cc (original)
+++ trunk/gtk/unstable-libyui/src/YGDumbTab.cc Fri Dec 7 13:39:17 2007
@@ -52,7 +52,8 @@
gtk_widget_show (label);
if (item->hasIconName()) {
- GdkPixbuf *pixbuf = YGUtils::loadPixbuf (item->iconName());
+ string path = iconFullPath (item->iconName());
+ GdkPixbuf *pixbuf = YGUtils::loadPixbuf (path);
if (pixbuf)
image = gtk_image_new_from_pixbuf (pixbuf);
}
Modified: trunk/gtk/unstable-libyui/src/YGInputField.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGInputField.cc?rev=42792&r1=42791&r2=42792&view=diff
==============================================================================
--- trunk/gtk/unstable-libyui/src/YGInputField.cc (original)
+++ trunk/gtk/unstable-libyui/src/YGInputField.cc Fri Dec 7 13:39:17 2007
@@ -158,14 +158,13 @@
ygtk_field_entry_setup_field (getField(), 1, 2, "0123456789");
ygtk_field_entry_setup_field (getField(), 2, 2, "0123456789");
- GtkWidget *menu_button = ygtk_menu_button_new();
m_calendar = gtk_calendar_new();
gtk_widget_show (m_calendar);
GtkWidget *popup = ygtk_popup_window_new (m_calendar);
- ygtk_menu_button_set_popup (YGTK_MENU_BUTTON (menu_button), popup);
- gtk_widget_show_all (popup);
- gtk_widget_show_all (menu_button);
+ GtkWidget *menu_button = ygtk_menu_button_new();
+ ygtk_menu_button_set_popup (YGTK_MENU_BUTTON (menu_button), popup);
+ gtk_widget_show (menu_button);
gtk_box_pack_start (GTK_BOX (getWidget()), menu_button, FALSE, TRUE, 6);
g_signal_connect (G_OBJECT (getField()), "field-entry-changed",
Modified: trunk/gtk/unstable-libyui/src/YGLayout.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGLayout.cc?rev=42792&r1=42791&r2=42792&view=diff
==============================================================================
--- trunk/gtk/unstable-libyui/src/YGLayout.cc (original)
+++ trunk/gtk/unstable-libyui/src/YGLayout.cc Fri Dec 7 13:39:17 2007
@@ -144,26 +144,16 @@
void setAlignment (YAlignmentType halign, YAlignmentType valign)
{
- // special case (which YAlignment.cc also uses); let stretchable
- // children stretch if opt.stretch is set (exploitable by the wizard)
- GValue hstretch, vstretch;
- hstretch = YGUtils::floatToGValue (0);
- if (stretchable (YD_HORIZ))
- hstretch = YGUtils::floatToGValue (1);
- vstretch = YGUtils::floatToGValue (0);
- if (stretchable (YD_VERT))
- vstretch = YGUtils::floatToGValue (1);
-
- if (halign != YAlignUnchanged) {
- GValue xalign = YGUtils::floatToGValue (yToGtkAlign (halign));
- g_object_set_property (G_OBJECT (getWidget()), "xalign", &xalign);
- g_object_set_property (G_OBJECT (getWidget()), "xscale", &hstretch);
- }
- if (valign != YAlignUnchanged) {
- GValue yalign = YGUtils::floatToGValue (yToGtkAlign (valign));
- g_object_set_property (G_OBJECT (getWidget()), "yalign", &yalign);
- g_object_set_property (G_OBJECT (getWidget()), "yscale", &vstretch);
- }
+ GValue xalign, yalign, xscale, yscale;
+ xalign = YGUtils::floatToGValue (yToGtkAlign (halign));
+ yalign = YGUtils::floatToGValue (yToGtkAlign (valign));
+ xscale = YGUtils::floatToGValue (halign == YAlignUnchanged ? 1 : 0);
+ yscale = YGUtils::floatToGValue (valign == YAlignUnchanged ? 1 : 0);
+
+ g_object_set_property (G_OBJECT (getWidget()), "xalign", &xalign);
+ g_object_set_property (G_OBJECT (getWidget()), "yalign", &yalign);
+ g_object_set_property (G_OBJECT (getWidget()), "xscale", &xscale);
+ g_object_set_property (G_OBJECT (getWidget()), "yscale", &yscale);
}
void setPadding (int top, int bottom, int left, int right)
Modified: trunk/gtk/unstable-libyui/src/YGSelectionModel.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGSelectionModel.cc?rev=42792&r1=42791&r2=42792&view=diff
==============================================================================
--- trunk/gtk/unstable-libyui/src/YGSelectionModel.cc (original)
+++ trunk/gtk/unstable-libyui/src/YGSelectionModel.cc Fri Dec 7 13:39:17 2007
@@ -5,11 +5,12 @@
#include
#include
#include
+#include
#include "YGSelectionModel.h"
#include "YGUtils.h"
-YGSelectionModel::YGSelectionModel (bool ordinaryModel, bool isTree)
- : isTree (isTree)
+YGSelectionModel::YGSelectionModel (YSelectionWidget *ywidget, bool ordinaryModel, bool isTree)
+ : isTree (isTree), ywidget (ywidget)
{
if (ordinaryModel) {
vector <GType> cols;
@@ -47,7 +48,7 @@
bool YGSelectionModel::isEmpty()
{
GtkTreeIter iter;
- return gtk_tree_model_get_iter_first (getModel(), &iter);
+ return !gtk_tree_model_get_iter_first (getModel(), &iter);
}
void YGSelectionModel::doAddItem (YItem *item)
@@ -56,6 +57,8 @@
addRow (&iter, item);
setCellLabel (&iter, LABEL_COLUMN, item->label());
setCellIcon (&iter, ICON_COLUMN, item->iconName());
+ for (YItemIterator it = item->childrenBegin(); it != item->childrenEnd(); it++)
+ doAddItem (*it);
}
void YGSelectionModel::doDeleteAllItems()
@@ -77,38 +80,22 @@
{
if (!item)
return false;
- if (!gtk_tree_model_get_iter_first (getModel(), iter))
- return false;
-
- struct inner {
- static bool getIter (GtkTreeModel *model, int col, YItem *item, GtkTreeIter *iter)
- {
- gpointer ptr;
- gtk_tree_model_get (model, iter, col, &ptr, -1);
- if (((YItem *) ptr)->index() == item->index())
- return true;
-
- GtkTreeIter child;
- if (gtk_tree_model_iter_children (model, &child, iter)) {
- if (getIter (model, col, item, &child)) {
- *iter = child;
- return true;
- }
- }
- if (gtk_tree_model_iter_next (model, iter))
- return getIter (model, col, item, iter);
- return false;
- }
- };
+ GtkTreePath *path = gtk_tree_path_new();
+ for (; item; item = item->parent()) {
+ int index = GPOINTER_TO_INT (item->data());
+ gtk_tree_path_prepend_index (path, index);
+ }
- return inner::getIter (getModel(), getPtrCol(), item, iter);
+ bool ret = gtk_tree_model_get_iter (getModel(), iter, path);
+ gtk_tree_path_free (path);
+ return ret;
}
void YGSelectionModel::implFocusItem (YItem *item)
{
GtkTreeIter iter;
if (getIter (item, &iter))
- focusItem (&iter);
+ setFocusItem (&iter, false);
}
int YGSelectionModel::getPtrCol()
@@ -118,23 +105,50 @@
void YGSelectionModel::addRow (GtkTreeIter *iter, YItem *item)
{
+ struct inner {
+ static void setItemData (GtkTreeModel *model, GtkTreeIter *iter, YItem *item)
+ {
+ int index;
+ GtkTreePath *path = gtk_tree_model_get_path (model, iter);
+
+ int depth = gtk_tree_path_get_depth (path);
+ int *path_int = gtk_tree_path_get_indices (path);
+ g_assert (path_int != NULL);
+ index = path_int [depth-1];
+
+ gtk_tree_path_free (path);
+ g_assert (index != -1);
+ item->setData (GINT_TO_POINTER (index));
+ }
+ };
+
bool empty = isEmpty();
if (isTree) {
- GtkTreeIter *parent = NULL;
- getIter (item->parent(), parent);
GtkTreeStore *store = getTreeStore();
- gtk_tree_store_append (store, iter, parent);
+ if (item->parent()) {
+ GtkTreeIter parent;
+ getIter (item->parent(), &parent);
+ gtk_tree_store_append (store, iter, &parent);
+ }
+ else
+ gtk_tree_store_append (store, iter, NULL);
gtk_tree_store_set (store, iter, getPtrCol(), item, -1);
+ inner::setItemData (getModel(), iter, item);
+
+ YTreeItem *tree_item = dynamic_cast (item);
+ if (tree_item && tree_item->isOpen())
+ expand (iter);
}
else {
GtkListStore *store = getListStore();
gtk_list_store_append (store, iter);
gtk_list_store_set (store, iter, getPtrCol(), item, -1);
+ inner::setItemData (getModel(), iter, item);
}
if (item->selected() || empty)
- implFocusItem (item);
+ setFocusItem (iter, true);
}
void YGSelectionModel::setCellLabel (GtkTreeIter *iter, int col, const string &label)
@@ -147,18 +161,19 @@
void YGSelectionModel::setCellIcon (GtkTreeIter *iter, int col, const string &icon)
{
- GdkPixbuf *pixbuf = YGUtils::loadPixbuf (icon);
+ string path = ywidget->iconFullPath (icon);
+ GdkPixbuf *pixbuf = YGUtils::loadPixbuf (path.c_str());
if (isTree)
gtk_tree_store_set (getTreeStore(), iter, col, pixbuf, -1);
else
gtk_list_store_set (getListStore(), iter, col, pixbuf, -1);
}
-void YGSelectionModel::setCellToggle (GtkTreeIter *iter, int col, bool selected)
+void YGSelectionModel::setCellToggle (GtkTreeIter *iter, int col, bool select)
{
if (isTree)
- gtk_tree_store_set (getTreeStore(), iter, col, selected, -1);
+ gtk_tree_store_set (getTreeStore(), iter, col, select, -1);
else
- gtk_list_store_set (getListStore(), iter, col, selected, -1);
+ gtk_list_store_set (getListStore(), iter, col, select, -1);
}
Modified: trunk/gtk/unstable-libyui/src/YGSelectionModel.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGSelectionModel.h?rev=42792&r1=42791&r2=42792&view=diff
==============================================================================
--- trunk/gtk/unstable-libyui/src/YGSelectionModel.h (original)
+++ trunk/gtk/unstable-libyui/src/YGSelectionModel.h Fri Dec 7 13:39:17 2007
@@ -20,7 +20,7 @@
LABEL_COLUMN, ICON_COLUMN
};
- YGSelectionModel (bool ordinaryModel, bool isTree);
+ YGSelectionModel (YSelectionWidget *ywidget, bool ordinaryModel, bool isTree);
virtual ~YGSelectionModel();
GtkTreeModel *getModel();
@@ -29,8 +29,12 @@
void doAddItem (YItem *item);
void doDeleteAllItems();
- virtual void focusItem (GtkTreeIter *iter) = 0;
- virtual void unfocusAllItems() = 0;
+ virtual YItem *focusItem() = 0;
+ virtual void setFocusItem (GtkTreeIter *iter, bool addingRow) = 0;
+ virtual void unsetFocus() = 0;
+
+ // to be implemented by trees
+ virtual void expand (GtkTreeIter *iter) {}
YItem *getItem (GtkTreeIter *iter);
bool getIter (YItem *item, GtkTreeIter *iter);
@@ -50,12 +54,13 @@
GtkListStore *getListStore();
GtkTreeStore *getTreeStore();
bool isEmpty();
+ YSelectionWidget *ywidget; // we use it, to get the path for icons
};
#define YGSELECTION_WIDGET_IMPL_ADD(ParentClass) \
virtual void addItem(YItem *item) { \
- doAddItem (item); \
ParentClass::addItem (item); \
+ doAddItem (item); \
}
#define YGSELECTION_WIDGET_IMPL_CLEAR(ParentClass) \
@@ -65,14 +70,18 @@
}
#define YGSELECTION_WIDGET_IMPL_SELECT(ParentClass) \
- virtual void selectItem (YItem *item) { \
- implFocusItem (item); \
- ParentClass::selectItem (item); \
+ virtual void selectItem (YItem *item, bool select) { \
+ if (select) \
+ implFocusItem (item); \
+ ParentClass::selectItem (item, select); \
} \
virtual void deselectAllItems() { \
- unfocusAllItems(); \
+ unsetFocus(); \
ParentClass::deselectAllItems(); \
- }
+ } \
+ virtual YItem *selectedItem() { \
+ return focusItem(); \
+ } \
#define YGSELECTION_WIDGET_IMPL_ALL(ParentClass) \
YGSELECTION_WIDGET_IMPL_ADD(ParentClass) \
Modified: trunk/gtk/unstable-libyui/src/YGTable.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGTable.cc?rev=42792&r1=42791&r2=42792&view=diff
==============================================================================
--- trunk/gtk/unstable-libyui/src/YGTable.cc (original)
+++ trunk/gtk/unstable-libyui/src/YGTable.cc Fri Dec 7 13:39:17 2007
@@ -9,6 +9,7 @@
#include "YGWidget.h"
#include "YSelectionWidget.h"
#include "YGSelectionModel.h"
+#include "ygtkcellrenderertextpixbuf.h"
/* A generic widget for table related widgets. */
class YGTableView : public YGScrolledWidget, public YGSelectionModel
@@ -21,12 +22,12 @@
bool ordinaryModel, bool isTree)
: YGScrolledWidget (ywidget, parent, label, YD_VERT, true,
GTK_TYPE_TREE_VIEW, NULL)
- , YGSelectionModel (ordinaryModel, isTree)
+ , YGSelectionModel ((YSelectionWidget *) ywidget, ordinaryModel, isTree)
{
IMPL
if (ordinaryModel) {
- addColumn (G_TYPE_STRING, "", YAlignUnchanged, YGSelectionModel::LABEL_COLUMN);
addColumn (GDK_TYPE_PIXBUF, "", YAlignUnchanged, YGSelectionModel::ICON_COLUMN);
+ addColumn (G_TYPE_STRING, "", YAlignUnchanged, YGSelectionModel::LABEL_COLUMN);
gtk_tree_view_set_model (getView(), getModel());
}
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (getWidget()), FALSE);
@@ -43,8 +44,7 @@
inline GtkTreeView *getView()
{ return GTK_TREE_VIEW (getWidget()); }
- void addColumn (GType type, string header, YAlignmentType header_align,
- int col_nb, bool isEllipsize = false)
+ void addColumn (GType type, string header, YAlignmentType header_align, int col_nb)
{
IMPL
GtkTreeViewColumn *column = 0;
@@ -68,9 +68,6 @@
GtkCellRenderer *renderer = 0;
if (type == G_TYPE_STRING) {
renderer = gtk_cell_renderer_text_new();
- // set the last column, the expandable one, as wrapable
- if (isEllipsize)
- g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
column = gtk_tree_view_column_new_with_attributes (header.c_str(),
renderer, "text", col_nb, NULL);
}
@@ -88,6 +85,12 @@
g_signal_connect (G_OBJECT (renderer), "toggled",
G_CALLBACK (toggled_cb), this);
}
+ else if (type == YGTK_TYPE_CELL_RENDERER_TEXT_PIXBUF) { // string, pixbuf combo
+ renderer = ygtk_cell_renderer_text_pixbuf_new();
+ g_object_set_data (G_OBJECT (renderer), "column", GINT_TO_POINTER (col_nb));
+ column = gtk_tree_view_column_new_with_attributes (header.c_str(),
+ renderer, "pixbuf", col_nb, "text", col_nb+1, NULL);
+ }
else
g_error ("YGTable: no support for column of given type");
@@ -101,28 +104,24 @@
virtual void setModel (GtkTreeModel *model)
{ gtk_tree_view_set_model (GTK_TREE_VIEW (getWidget()), model); }
- YItem *getFocusItem()
- {
- GtkTreeIter iter;
- GtkTreePath *path;
- gtk_tree_view_get_cursor (getView(), &path, NULL);
- gtk_tree_model_get_iter (getModel(), &iter, path);
- gtk_tree_path_free (path);
- return getItem (&iter);
- }
-
- virtual void focusItem (GtkTreeIter *iter)
+ // YGSelectionModel
+ virtual void setFocusItem (GtkTreeIter *iter, bool addingRow)
{
blockEvents();
GtkTreePath *path = gtk_tree_model_get_path (getModel(), iter);
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (getWidget()), path, NULL, false);
- gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (getWidget()), path, NULL,
- TRUE, 0.5, 0.5);
+
+ gtk_tree_view_expand_to_path (getView(), path);
+
+ GtkTreeSelection *selection = gtk_tree_view_get_selection (getView());
+ gtk_tree_selection_select_path (selection, path);
+ gtk_tree_view_set_cursor (getView(), path, NULL, FALSE);
+ gtk_tree_view_scroll_to_cell (getView(), path, NULL, TRUE, 0.5, 0.5);
gtk_tree_path_free (path);
+ gtk_widget_grab_focus (getWidget());
unblockEvents();
}
- virtual void unfocusAllItems()
+ virtual void unsetFocus()
{
blockEvents();
GtkTreeSelection *selection = gtk_tree_view_get_selection (getView());
@@ -130,6 +129,15 @@
unblockEvents();
}
+ virtual YItem *focusItem()
+ {
+ GtkTreeSelection *selection = gtk_tree_view_get_selection (getView());
+ GtkTreeIter iter;
+ if (gtk_tree_selection_get_selected (selection, NULL, &iter))
+ return getItem (&iter);
+ return NULL;
+ }
+
protected:
void blockEvents()
{
@@ -162,7 +170,7 @@
static void selected_cb (GtkTreeView *tree_view, YGTableView* pThis)
{
IMPL
- pThis->emitEvent (YEvent::SelectionChanged);
+ pThis->emitEvent (YEvent::SelectionChanged, true, true);
}
static void selected_delayed_cb (GtkTreeView *tree_view, YGTableView* pThis)
@@ -200,19 +208,17 @@
{
IMPL
gtk_tree_view_set_headers_visible (getView(), TRUE);
- if (columns() >= 3)
- gtk_tree_view_set_rules_hint (getView(), TRUE);
+ gtk_tree_view_set_rules_hint (getView(), columns() > 1);
vector <GType> types;
- types.assign (columns(), G_TYPE_STRING);
-/* for (int i = 0; i < columns(); i++)
- if (item->hasIconName (i))
- types[i] = GDK_TYPE_PIXBUF;*/
- createModel (types);
for (int i = 0; i < columns(); i++) {
- bool ellipsize = columns() >= 3 && i == columns()-1;
- addColumn (types[i], header (i), alignment (i), i, ellipsize);
+ types.push_back (GDK_TYPE_PIXBUF);
+ types.push_back (G_TYPE_STRING);
}
+ createModel (types);
+ for (int i = 0; i < columns(); i++)
+ addColumn (YGTK_TYPE_CELL_RENDERER_TEXT_PIXBUF,
+ header (i), alignment (i), i*2);
gtk_tree_view_set_model (getView(), getModel());
g_signal_connect (G_OBJECT (getWidget()), "row-activated",
@@ -224,23 +230,20 @@
virtual void setKeepSorting (bool keepSorting)
{
- // TODO: allow to toggle modes
+ // FIXME: GTK doesn't let us get back to unsorted mode...
if (!keepSorting)
- YGUtils::tree_view_set_sortable (GTK_TREE_VIEW (getWidget()), 0);
+ YGUtils::tree_view_set_sortable (getView(), 0);
+ YTable::setKeepSorting (keepSorting);
}
- virtual void addItem (YItem *_item)
- {
+ virtual void addItem (YItem *_item)
+ {
YTableItem *item = dynamic_cast (_item);
if (item) {
GtkTreeIter iter;
addRow (&iter, _item);
- for (int i = 0; i < columns(); i++) {
-/* if (item->hasIconName (i))
- setCellIcon (&iter, i, item->iconName (i));
- else*/
- setCellLabel (&iter, i, item->label (i));
- }
+ for (int i = 0; i < columns(); i++)
+ setCell (&iter, item->cell (i));
}
else
y2error ("Can only add YTableItems to a YTable.");
@@ -250,12 +253,15 @@
virtual void cellChanged (const YTableCell *cell)
{
GtkTreeIter iter;
- if (getIter (cell->parent(), &iter)) {
- if (cell->hasIconName())
- setCellIcon (&iter, cell->column(), cell->iconName());
- else
- setCellLabel (&iter, cell->column(), cell->label());
- }
+ if (getIter (cell->parent(), &iter))
+ setCell (&iter, cell);
+ }
+
+ void setCell (GtkTreeIter *iter, const YTableCell *cell)
+ {
+ int index = cell->column() * 2;
+ setCellIcon (iter, index, cell->iconName());
+ setCellLabel (iter, index+1, cell->label());
}
YGWIDGET_IMPL_COMMON
@@ -324,21 +330,22 @@
G_CALLBACK (multi_activated_cb), this);
}
+ // YMultiSelectionBox
virtual void addItem (YItem *item)
{
GtkTreeIter iter;
addRow (&iter, item);
setCellToggle (&iter, 0, item->selected());
- setCellIcon (&iter, 1, item->iconName());
- setCellLabel (&iter, 2, item->label());
+ setCellIcon (&iter, 1, item->iconName());
+ setCellLabel (&iter, 2, item->label());
YMultiSelectionBox::addItem (item);
}
- virtual void selectItem (YItem *item)
+ virtual void selectItem (YItem *item, bool select)
{
GtkTreeIter iter;
if (getIter (item, &iter))
- setCellToggle (&iter, 0, item->selected());
+ setCellToggle (&iter, 0, select);
YMultiSelectionBox::selectItem (item);
}
@@ -354,22 +361,24 @@
}
virtual YItem *currentItem()
- {
- return getFocusItem();
- }
+ { return focusItem(); }
virtual void setCurrentItem (YItem *item)
+ { implFocusItem (item); }
+
+ virtual void setFocusItem (GtkTreeIter *iter, bool addingRow)
{
- GtkTreeIter iter;
- if (getIter (item, &iter))
- focusItem (&iter);
+ // item->selected() doesn't apply to focus, filter them
+ if (!addingRow)
+ YGTableView::setFocusItem (iter, addingRow);
}
+ // Events
static void multi_activated_cb (GtkTreeView *tree_view, GtkTreePath *path,
GtkTreeViewColumn *column, YGMultiSelectionBox* pThis)
{
IMPL
- pThis->toggle (path, 1);
+ pThis->toggle (path, 0);
}
YGWIDGET_IMPL_COMMON
@@ -390,30 +399,43 @@
public:
YGTree (YWidget *parent, const string &label)
: YTree (NULL, label)
- , YGTableView (this, parent, label, false, true)
+ , YGTableView (this, parent, label, true, true)
{
- // Events
- if (notify()) {
- g_signal_connect (G_OBJECT (getWidget()), "row-activated",
- G_CALLBACK (activated_cb), (YGTableView*) this);
- g_signal_connect (G_OBJECT (getWidget()), "cursor-changed",
- G_CALLBACK (selected_delayed_cb), (YGTableView*) this);
- }
- else {
- GtkTreeSelection *selection = gtk_tree_view_get_selection (getView());
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_NONE);
- }
+ g_signal_connect (G_OBJECT (getWidget()), "row-activated",
+ G_CALLBACK (activated_cb), (YGTableView*) this);
+ g_signal_connect (G_OBJECT (getWidget()), "cursor-changed",
+ G_CALLBACK (selected_cb), (YGTableView*) this);
}
// YTree
virtual void rebuildTree()
{
- // we are already implement addItem()...
+ doDeleteAllItems();
+ for (YItemConstIterator it = itemsBegin(); it != itemsEnd(); it++)
+ doAddItem (*it);
+ }
+
+ virtual const YTreeItem *getCurrentItem() const
+ {
+ YGTree *pThis = const_cast (this);
+ return (YTreeItem *) pThis->focusItem();
+ }
+
+ virtual void setCurrentItem (YTreeItem *item)
+ { implFocusItem ((YItem *) item); }
+
+ // YGSelectionModel
+ virtual void expand (GtkTreeIter *iter)
+ {
+ GtkTreePath *path = gtk_tree_model_get_path (getModel(), iter);
+ gtk_tree_view_expand_to_path (getView(), path);
+ gtk_tree_path_free (path);
}
YGWIDGET_IMPL_COMMON
YGLABEL_WIDGET_IMPL_SET_LABEL_CHAIN (YTree)
- YGSELECTION_WIDGET_IMPL_ALL (YTree)
+ YGSELECTION_WIDGET_IMPL_CLEAR (YTree)
+ YGSELECTION_WIDGET_IMPL_SELECT (YTree)
};
YTree *YGWidgetFactory::createTree (YWidget *parent, const string &label)
Modified: trunk/gtk/unstable-libyui/src/YGUI.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGUI.cc?rev=42792&r1=42791&r2=42792&view=diff
==============================================================================
--- trunk/gtk/unstable-libyui/src/YGUI.cc (original)
+++ trunk/gtk/unstable-libyui/src/YGUI.cc Fri Dec 7 13:39:17 2007
@@ -109,7 +109,7 @@
}
}
-#define PRINT_EVENTS
+//#define PRINT_EVENTS
void YGUI::idleLoop (int fd_ycp)
{
@@ -159,7 +159,7 @@
{
IMPL
#ifdef PRINT_EVENTS
-fprintf (stderr, "waitInput()\n");
+fprintf (stderr, "%s()\n", block ? "userInput" : "pollInput");
#endif
if (!YDialog::currentDialog (false))
return NULL;
@@ -218,25 +218,23 @@
long YGUI::getDisplayColors()
{ return 1L << getDisplayDepth(); /*from yast-qt*/ }
-int YGUI::getDefaultWidth()
-{
- if (!m_default_size.width) {
-/* if (m_fullscreen)
- m_default_size.width = getDisplayWidth();
- else*/
- m_default_size.width = MIN (600, getDisplayWidth());
- }
+// YCP writers use getDefaultWidth/Height() to do space saving if needed,
+// so just tell me the displayWidth/Height(). If that size is decent, let's
+// us deal with it.
+int YGUI::getDefaultWidth() { return getDisplayWidth(); }
+int YGUI::getDefaultHeight() { return getDisplayHeight(); }
+
+int YGUI::_getDefaultWidth()
+{
+ if (!m_default_size.width)
+ m_default_size.width = MIN (600, getDisplayWidth());
return m_default_size.width;
}
-int YGUI::getDefaultHeight()
-{
- if (!m_default_size.height) {
-/* if (m_fullscreen)
- m_default_size.height = getDisplayHeight();
- else*/
- m_default_size.height = MIN (450, getDisplayHeight());
- }
+int YGUI::_getDefaultHeight()
+{
+ if (!m_default_size.height)
+ m_default_size.height = MIN (450, getDisplayHeight());
return m_default_size.height;
}
@@ -591,6 +589,11 @@
}
}
+YGApplication::YGApplication()
+{
+ setIconBasePath (ICON_DIR);
+}
+
YWidgetFactory *YGUI::createWidgetFactory()
{ return new YGWidgetFactory; }
YOptionalWidgetFactory *YGUI::createOptionalWidgetFactory()
Modified: trunk/gtk/unstable-libyui/src/YGUI.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGUI.h?rev=42792&r1=42791&r2=42792&view=diff
==============================================================================
--- trunk/gtk/unstable-libyui/src/YGUI.h (original)
+++ trunk/gtk/unstable-libyui/src/YGUI.h Fri Dec 7 13:39:17 2007
@@ -128,7 +128,7 @@
public:
// Helpers for internal use [ visibility hidden ]
- int getDefaultSize (YUIDimension dim);
+ int _getDefaultWidth(); int _getDefaultHeight();
bool setFullscreen() const { return m_fullscreen; }
bool hasWM() const { return m_have_wm; }
bool unsetBorder() const { return m_no_border; }
@@ -234,8 +234,9 @@
class YGApplication : public YApplication
{
- /* we may need to expand it on the future */
+public:
+ YGApplication();
};
-#endif // YGUI_H
+#endif /*YGUI_H*/
Modified: trunk/gtk/unstable-libyui/src/YGWizard.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/YGWizard.cc?rev=42792&r1=42791&r2=42792&view=diff
==============================================================================
--- trunk/gtk/unstable-libyui/src/YGWizard.cc (original)
+++ trunk/gtk/unstable-libyui/src/YGWizard.cc Fri Dec 7 13:39:17 2007
@@ -291,6 +291,7 @@
const string &backButtonLabel, const string &abortButtonLabel,
const string &nextButtonLabel, YWizardMode wizardMode)
{
+fprintf (stderr, "** createWizard()\n");
return new YGWizard (parent, backButtonLabel, abortButtonLabel, nextButtonLabel,
wizardMode);
}
Added: trunk/gtk/unstable-libyui/src/ygtkcellrenderertextpixbuf.c
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/ygtkcellrenderertextpixbuf.c?rev=42792&view=auto
==============================================================================
--- trunk/gtk/unstable-libyui/src/ygtkcellrenderertextpixbuf.c (added)
+++ trunk/gtk/unstable-libyui/src/ygtkcellrenderertextpixbuf.c Fri Dec 7 13:39:17 2007
@@ -0,0 +1,212 @@
+/********************************************************************
+ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK *
+ ********************************************************************/
+
+/* YGtkCellRendererTextPixbuf widget */
+// check the header file for information about this widget
+
+#include
+#include "ygtkcellrenderertextpixbuf.h"
+
+#define PIXBUF_TEXT_SPACING 4
+
+enum {
+ PROP_0,
+ PROP_TEXT,
+ PROP_PIXBUF
+};
+
+G_DEFINE_TYPE (YGtkCellRendererTextPixbuf, ygtk_cell_renderer_text_pixbuf, GTK_TYPE_CELL_RENDERER)
+
+static void ygtk_cell_renderer_text_pixbuf_init (YGtkCellRendererTextPixbuf *tpcell)
+{
+ GtkCellRenderer *cell = GTK_CELL_RENDERER (tpcell);
+ cell->mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE;
+ cell->xalign = 0.0;
+ cell->yalign = 0.5;
+ cell->xpad = 0;
+ cell->ypad = 0;
+ tpcell->text = NULL;
+ tpcell->pixbuf = NULL;
+}
+
+static void ygtk_cell_renderer_text_pixbuf_finalize (GObject *object)
+{
+ YGtkCellRendererTextPixbuf *tpcell = YGTK_CELL_RENDERER_TEXT_PIXBUF (object);
+ if (tpcell->text) {
+ g_free (tpcell->text);
+ tpcell->text = NULL;
+ }
+ if (tpcell->pixbuf) {
+ g_object_unref (G_OBJECT (tpcell->pixbuf));
+ tpcell->pixbuf = NULL;
+ }
+ G_OBJECT_CLASS (ygtk_cell_renderer_text_pixbuf_parent_class)->finalize (object);
+}
+
+static void ygtk_cell_renderer_text_pixbuf_get_property (GObject *object,
+ guint param_id, GValue *value, GParamSpec *pspec)
+{
+ YGtkCellRendererTextPixbuf *tpcell = YGTK_CELL_RENDERER_TEXT_PIXBUF (object);
+ switch (param_id) {
+ case PROP_TEXT:
+ g_value_set_string (value, tpcell->text);
+ break;
+ case PROP_PIXBUF:
+ g_value_set_object (value, G_OBJECT (tpcell->pixbuf));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void ygtk_cell_renderer_text_pixbuf_set_property (GObject *object,
+ guint param_id, const GValue *value, GParamSpec *pspec)
+{
+ YGtkCellRendererTextPixbuf *tpcell = YGTK_CELL_RENDERER_TEXT_PIXBUF (object);
+ switch (param_id) {
+ case PROP_TEXT:
+ if (tpcell->text)
+ g_free (tpcell->text);
+ tpcell->text = g_strdup (g_value_get_string (value));
+ break;
+ case PROP_PIXBUF:
+ if (tpcell->pixbuf)
+ g_object_unref (G_OBJECT (tpcell->pixbuf));
+ tpcell->pixbuf = (GdkPixbuf *) g_value_dup_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static PangoLayout *create_layout (YGtkCellRendererTextPixbuf *tpcell, GtkWidget *widget)
+{
+ if (tpcell->text)
+ return gtk_widget_create_pango_layout (widget, tpcell->text);
+ return NULL;
+}
+
+static void ygtk_cell_renderer_text_pixbuf_get_size (GtkCellRenderer *cell,
+ GtkWidget *widget, GdkRectangle *cell_area, gint *xoffset, gint *yoffset,
+ gint *width, gint *height)
+{
+ YGtkCellRendererTextPixbuf *tpcell = YGTK_CELL_RENDERER_TEXT_PIXBUF (cell);
+
+ // will be calculated at expose, as both pixbuf and text have their offsets...
+ if (xoffset) *xoffset = 0;
+ if (yoffset) *yoffset = 0;
+ if (!width && !height)
+ return;
+
+ if (tpcell->pixbuf) {
+ *width += gdk_pixbuf_get_width (tpcell->pixbuf);
+ *height = MAX (*height, gdk_pixbuf_get_height (tpcell->pixbuf));
+ }
+ if (tpcell->text) {
+ if (tpcell->pixbuf)
+ *width += PIXBUF_TEXT_SPACING;
+
+ PangoLayout *layout = create_layout (tpcell, widget);
+ int lw, lh;
+ pango_layout_get_pixel_size (layout, &lw, &lh);
+ *width += lw;
+ *height = MAX (*height, lh);
+
+ g_object_unref (G_OBJECT (layout));
+ }
+
+ *width += cell->xpad*2;
+ *height += cell->ypad*2;
+}
+
+static void ygtk_cell_renderer_text_pixbuf_render (GtkCellRenderer *cell,
+ GdkDrawable *window, GtkWidget *widget, GdkRectangle *background_area,
+ GdkRectangle *cell_area, GdkRectangle *expose_area, GtkCellRendererState flags)
+{
+ YGtkCellRendererTextPixbuf *tpcell = YGTK_CELL_RENDERER_TEXT_PIXBUF (cell);
+
+ GtkStateType state;
+ // like GtkCellRendererText...
+ if (!cell->sensitive)
+ state = GTK_STATE_INSENSITIVE;
+ else if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED) {
+ gboolean has_focus = GTK_WIDGET_HAS_FOCUS (widget);
+ state = has_focus ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE;
+ }
+ else if ((flags & GTK_CELL_RENDERER_PRELIT) == GTK_CELL_RENDERER_PRELIT &&
+ GTK_WIDGET_STATE (widget) == GTK_STATE_PRELIGHT) {
+ state = GTK_STATE_PRELIGHT;
+ }
+ else {
+ if (GTK_WIDGET_STATE (widget) == GTK_STATE_INSENSITIVE)
+ state = GTK_STATE_INSENSITIVE;
+ else
+ state = GTK_STATE_NORMAL;
+ }
+
+ int x = cell_area->x, y = cell_area->y;
+
+ if (tpcell->pixbuf) {
+ int w, h;
+ w = gdk_pixbuf_get_width (tpcell->pixbuf);
+ h = gdk_pixbuf_get_height (tpcell->pixbuf);
+
+ cairo_t *cr = gdk_cairo_create (window);
+ gdk_cairo_set_source_pixbuf (cr, tpcell->pixbuf, x, y);
+
+ cairo_rectangle (cr, x, y, w, h);
+ cairo_fill (cr);
+ cairo_destroy (cr);
+
+ x += w + PIXBUF_TEXT_SPACING;
+ }
+
+ if (tpcell->text) {
+ PangoLayout *layout = create_layout (tpcell, widget);
+
+ PangoRectangle rect;
+ pango_layout_get_pixel_extents (layout, NULL, &rect);
+
+ gfloat xalign = cell->xalign, yalign = cell->yalign;
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+ xalign = 1.0 - xalign;
+
+ gint xoffset, yoffset;
+ xoffset = xalign * (cell_area->width - (rect.width + (2*cell->xpad)));
+ yoffset = yalign * (cell_area->height - (rect.height + (2*cell->ypad)));
+
+ GtkStyle *style = gtk_widget_get_style (widget);
+ gtk_paint_layout (style, window, state, TRUE, expose_area, widget,
+ "cellrenderertext", x+xoffset, y+yoffset, layout);
+
+ g_object_unref (G_OBJECT (layout));
+ }
+}
+
+GtkCellRenderer *ygtk_cell_renderer_text_pixbuf_new (void)
+{
+ return g_object_new (YGTK_TYPE_CELL_RENDERER_TEXT_PIXBUF, NULL);
+}
+
+static void ygtk_cell_renderer_text_pixbuf_class_init (YGtkCellRendererTextPixbufClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ object_class->get_property = ygtk_cell_renderer_text_pixbuf_get_property;
+ object_class->set_property = ygtk_cell_renderer_text_pixbuf_set_property;
+ object_class->finalize = ygtk_cell_renderer_text_pixbuf_finalize;
+
+ GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (class);
+ cell_class->get_size = ygtk_cell_renderer_text_pixbuf_get_size;
+ cell_class->render = ygtk_cell_renderer_text_pixbuf_render;
+
+ g_object_class_install_property (object_class, PROP_TEXT,
+ g_param_spec_string ("text", "Text", "The text", NULL,
+ G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
+ g_object_class_install_property (object_class, PROP_PIXBUF,
+ g_param_spec_object ("pixbuf", "Image", "Side image", GDK_TYPE_PIXBUF,
+ G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
+}
+
Added: trunk/gtk/unstable-libyui/src/ygtkcellrenderertextpixbuf.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/ygtkcellrenderertextpixbuf.h?rev=42792&view=auto
==============================================================================
--- trunk/gtk/unstable-libyui/src/ygtkcellrenderertextpixbuf.h (added)
+++ trunk/gtk/unstable-libyui/src/ygtkcellrenderertextpixbuf.h Fri Dec 7 13:39:17 2007
@@ -0,0 +1,47 @@
+/********************************************************************
+ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK *
+ ********************************************************************/
+
+/* YGtkCellRendererTextPixbuf is a combination of GtkCellRendererText and
+ GtkCellRendererPixbuf. It allows text and icons to be mixed on the same
+ column.
+*/
+
+#ifndef YGTK_CELL_RENDERER_TEXT_PIXBUF_H
+#define YGTK_CELL_RENDERER_TEXT_PIXBUF_H
+
+#include
+G_BEGIN_DECLS
+
+#define YGTK_TYPE_CELL_RENDERER_TEXT_PIXBUF (ygtk_cell_renderer_text_pixbuf_get_type ())
+#define YGTK_CELL_RENDERER_TEXT_PIXBUF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ YGTK_TYPE_CELL_RENDERER_TEXT_PIXBUF, YGtkCellRendererTextPixbuf))
+#define YGTK_CELL_RENDERER_TEXT_PIXBUF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ YGTK_TYPE_CELL_RENDERER_TEXT_PIXBUF, YGtkCellRendererTextPixbufClass))
+#define YGTK_IS_CELL_RENDERER_TEXT_PIXBUF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ YGTK_TYPE_CELL_RENDERER_TEXT_PIXBUF))
+#define YGTK_IS_CELL_RENDERER_TEXT_PIXBUF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ YGTK_TYPE_CELL_RENDERER_TEXT_PIXBUF))
+#define YGTK_CELL_RENDERER_TEXT_PIXBUF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ YGTK_TYPE_CELL_RENDERER_TEXT_PIXBUF, YGtkCellRendererTextPixbufClass))
+
+typedef struct _YGtkCellRendererTextPixbuf
+{
+ GtkCellRenderer parent;
+
+ // private:
+ gchar *text;
+ GdkPixbuf *pixbuf;
+} YGtkCellRendererTextPixbuf;
+
+typedef struct _YGtkCellRendererTextPixbufClass
+{
+ GtkCellRendererClass parent_class;
+} YGtkCellRendererTextPixbufClass;
+
+GtkCellRenderer *ygtk_cell_renderer_text_pixbuf_new (void);
+GType ygtk_cell_renderer_text_pixbuf_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+#endif /*YGTK_CELL_RENDERER_TEXT_PIXBUF_H*/
+
Modified: trunk/gtk/unstable-libyui/src/ygtkfieldentry.c
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/ygtkfieldentry.c?rev=42792&r1=42791&r2=42792&view=diff
==============================================================================
--- trunk/gtk/unstable-libyui/src/ygtkfieldentry.c (original)
+++ trunk/gtk/unstable-libyui/src/ygtkfieldentry.c Fri Dec 7 13:39:17 2007
@@ -101,11 +101,12 @@
GList *children = gtk_container_get_children (GTK_CONTAINER (fields));
entry = g_list_nth_data (children, index_to_child (fields, index));
g_list_free (children);
+ g_assert (GTK_IS_ENTRY (entry));
return entry;
}
guint ygtk_field_entry_add_field (YGtkFieldEntry *fields, gchar separator)
{
- guint new_index = child_to_index (fields, ygtk_field_entry_length (fields));
+ guint new_index = child_to_index (fields, ygtk_field_entry_length (fields)+1);
GtkWidget *label = 0, *entry;
if (new_index > 0) {
@@ -123,12 +124,11 @@
GtkBox *box = GTK_BOX (fields);
if (label) {
- gtk_box_pack_start (box, label, FALSE, FALSE, 0);
+ gtk_box_pack_start (box, label, FALSE, TRUE, 0);
gtk_widget_show (label);
}
gtk_box_pack_start (box, entry, TRUE, TRUE, 0);
gtk_widget_show (entry);
-
return new_index;
}
@@ -136,8 +136,11 @@
gint max_length, const gchar *valid_chars)
{
GtkEntry *entry = ygtk_field_entry_get_field_widget (fields, index);
- gtk_entry_set_max_length (entry, max_length == -1 ? 0 : max_length);
- gtk_entry_set_width_chars (entry, max_length);
+ gboolean disable_len = (max_length <= 0);
+ gtk_entry_set_max_length (entry, disable_len ? 0 : max_length);
+ gtk_entry_set_width_chars (entry, disable_len ? -1 : max_length);
+ gtk_box_set_child_packing (GTK_BOX (fields), GTK_WIDGET (entry),
+ disable_len, TRUE, 0, GTK_PACK_START);
ygutils_setFilter (entry, valid_chars);
}
Modified: trunk/gtk/unstable-libyui/src/ygtkmenubutton.c
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/ygtkmenubutton.c?rev=42792&r1=42791&r2=42792&view=diff
==============================================================================
--- trunk/gtk/unstable-libyui/src/ygtkmenubutton.c (original)
+++ trunk/gtk/unstable-libyui/src/ygtkmenubutton.c Fri Dec 7 13:39:17 2007
@@ -104,22 +104,13 @@
button->label = gtk_label_new ("");
GtkWidget *hbox, *arrow;
- hbox = gtk_hbox_new (FALSE, 0);
+ hbox = gtk_hbox_new (FALSE, 4);
arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_IN);
+ gtk_widget_show (hbox);
+ gtk_widget_show (arrow);
- if (gtk_widget_get_direction (arrow) == GTK_TEXT_DIR_LTR) {
- gtk_container_add (GTK_CONTAINER (hbox), button->label);
- gtk_container_add (GTK_CONTAINER (hbox), arrow);
- }
- else {
- gtk_container_add (GTK_CONTAINER (hbox), arrow);
- gtk_container_add (GTK_CONTAINER (hbox), button->label);
- }
-
- gtk_box_set_child_packing (GTK_BOX (hbox), arrow, FALSE, FALSE,
- 5, GTK_PACK_START);
-
- gtk_widget_show_all (hbox);
+ gtk_box_pack_start (GTK_BOX (hbox), button->label, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), arrow, FALSE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (button), hbox);
}
Modified: trunk/gtk/unstable-libyui/src/ygtkratiobox.c
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/unstable-libyui/src/ygtkratiobox.c?rev=42792&r1=42791&r2=42792&view=diff
==============================================================================
--- trunk/gtk/unstable-libyui/src/ygtkratiobox.c (original)
+++ trunk/gtk/unstable-libyui/src/ygtkratiobox.c Fri Dec 7 13:39:17 2007
@@ -556,9 +556,10 @@
}
GTK_WIDGET_CLASS (ygtk_scrolled_window_parent_class)->size_request (widget, requisition);
- // to avoid disruptions:
- requisition->width = MIN (requisition->width, scroll->max_width);
- requisition->height = MIN (requisition->height, scroll->max_height);
+ if (scroll->max_width)
+ requisition->width = MIN (requisition->width, scroll->max_width);
+ if (scroll->max_height)
+ requisition->height = MIN (requisition->height, scroll->max_height);
}
GtkWidget* ygtk_scrolled_window_new (GtkWidget *child)
@@ -583,3 +584,4 @@
GtkWidgetClass* widget_class = GTK_WIDGET_CLASS (klass);
widget_class->size_request = ygtk_scrolled_window_size_request;
}
+
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org