Author: rpmcruz
Date: Thu Oct 2 21:44:40 2008
New Revision: 51807
URL: http://svn.opensuse.org/viewcvs/yast?rev=51807&view=rev
Log:
* src/YGTable.cc: bug fix 428966: set tree lines only for big trees
(higher than 4 in depth, and 100 in rows).
Modified:
trunk/gtk/ChangeLog
trunk/gtk/src/YGSelectionModel.cc
trunk/gtk/src/YGSelectionModel.h
trunk/gtk/src/YGTable.cc
Modified: trunk/gtk/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=51807&r1=51806&r2=51807&view=diff
==============================================================================
--- trunk/gtk/ChangeLog (original)
+++ trunk/gtk/ChangeLog Thu Oct 2 21:44:40 2008
@@ -15,6 +15,11 @@
* src/YGDialog.cc: for bug 428965, set instead a higher default
height. Already has big as qt: ycp progs should cope.
+ * src/YGSelectionModel.h/cc: added method to calculate a tree's depth.
+
+ * src/YGTable.cc: bug fix 428966: set tree lines only for big trees
+ (higher than 4 in depth, and 100 in rows).
+
2008-09-30 Ricardo Cruz
* src/ygtkbargraph.h/.c: replaced usage of deprecated GtkTooltips API
Modified: trunk/gtk/src/YGSelectionModel.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGSelectionModel.cc?rev=51807&r1=51806&r2=51807&view=diff
==============================================================================
--- trunk/gtk/src/YGSelectionModel.cc (original)
+++ trunk/gtk/src/YGSelectionModel.cc Thu Oct 2 21:44:40 2008
@@ -184,6 +184,34 @@
gtk_list_store_set (getListStore(), iter, col, select, -1);
}
+static int getChildrenDepth (GtkTreeModel *model, GtkTreeIter *parent, int *rows)
+{
+ int depth = 0;
+ GtkTreeIter iter;
+ if (gtk_tree_model_iter_children (model, &iter, parent)) {
+ do {
+ depth = MAX (depth, getChildrenDepth (model, &iter, rows));
+ *rows++;
+ } while (gtk_tree_model_iter_next (model, &iter));
+ }
+ return depth+1;
+}
+
+int YGSelectionModel::getMaxDepth (int *rows)
+{
+ if (!isTree) return 0;
+ GtkTreeModel *model = getModel();
+ int depth = 0;
+ GtkTreeIter iter;
+ if (gtk_tree_model_get_iter_first (model, &iter)) {
+ do {
+ depth = MAX (depth, getChildrenDepth (model, &iter, rows));
+ *rows++;
+ } while (gtk_tree_model_iter_next (model, &iter));
+ }
+ return depth;
+}
+
extern "C" {
struct FindClosure {
const string &text;
@@ -218,3 +246,4 @@
gtk_tree_model_foreach (getModel(), find_text, (gpointer) &cl);
return cl.found;
}
+
Modified: trunk/gtk/src/YGSelectionModel.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGSelectionModel.h?rev=51807&r1=51806&r2=51807&view=diff
==============================================================================
--- trunk/gtk/src/YGSelectionModel.h (original)
+++ trunk/gtk/src/YGSelectionModel.h Thu Oct 2 21:44:40 2008
@@ -50,6 +50,8 @@
int getPtrCol();
+ int getMaxDepth (int *rows); // not cached
+
protected:
void implFocusItem (YItem *item);
private:
Modified: trunk/gtk/src/YGTable.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGTable.cc?rev=51807&r1=51806&r2=51807&view=diff
==============================================================================
--- trunk/gtk/src/YGTable.cc (original)
+++ trunk/gtk/src/YGTable.cc Thu Oct 2 21:44:40 2008
@@ -432,7 +432,6 @@
: YTree (NULL, label)
, YGTableView (this, parent, label, true, true)
{
- gtk_tree_view_set_enable_tree_lines (getView(), TRUE);
g_signal_connect (G_OBJECT (getWidget()), "row-activated",
G_CALLBACK (activated_cb), (YGTableView*) this);
g_signal_connect (G_OBJECT (getWidget()), "cursor-changed",
@@ -449,6 +448,10 @@
doDeleteAllItems();
for (YItemConstIterator it = YTree::itemsBegin(); it != YTree::itemsEnd(); it++)
doAddItem (*it);
+ int depth, rows;
+ depth = getMaxDepth (&rows);
+ gtk_tree_view_set_show_expanders (getView(), depth > 1);
+ gtk_tree_view_set_enable_tree_lines (getView(), depth > 4 && rows > 100);
}
virtual const YTreeItem *getCurrentItem() const
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org