Author: rpmcruz
Date: Fri Dec 12 03:50:59 2008
New Revision: 54077
URL: http://svn.opensuse.org/viewcvs/yast?rev=54077&view=rev
Log:
* src/yzyppwrapper.h/cc: fixed pattern categories ordering.
* src/yzyppwrapper.cc: bug fix 448309: localize RPM groups.
Modified:
trunk/gtk/ChangeLog
trunk/gtk/src/YGPackageSelector.cc
trunk/gtk/src/yzyppwrapper.cc
trunk/gtk/src/yzyppwrapper.h
Modified: trunk/gtk/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=54077&r1=54076&r2=54077&view=diff
==============================================================================
--- trunk/gtk/ChangeLog (original)
+++ trunk/gtk/ChangeLog Fri Dec 12 03:50:59 2008
@@ -7,6 +7,10 @@
* src/YGPackageSelector.cc: instead of passing pkg-selector all
around the code, keep a singleton point for it.
+ * src/yzyppwrapper.h/cc: fixed pattern categories ordering.
+
+ * src/yzyppwrapper.cc: bug fix 448309: localize RPM groups.
+
2008-12-10 Ricardo Cruz
* src/ygtksteps.c: bug fix 457752: ensure space between tick and
Modified: trunk/gtk/src/YGPackageSelector.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGPackageSelector.cc?rev=54077&r1=54076&r2=54077&view=diff
==============================================================================
--- trunk/gtk/src/YGPackageSelector.cc (original)
+++ trunk/gtk/src/YGPackageSelector.cc Fri Dec 12 03:50:59 2008
@@ -1076,7 +1076,8 @@
gtk_container_add (GTK_CONTAINER (m_scroll), m_view);
gtk_widget_show (m_view);
- ensure_view_visible_hook (m_view);
+ if (!tree_mode)
+ ensure_view_visible_hook (m_view);
}
void block()
Modified: trunk/gtk/src/yzyppwrapper.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/yzyppwrapper.cc?rev=54077&r1=54076&r2=54077&view=diff
==============================================================================
--- trunk/gtk/src/yzyppwrapper.cc (original)
+++ trunk/gtk/src/yzyppwrapper.cc Fri Dec 12 03:50:59 2008
@@ -60,10 +60,11 @@
typedef int (*Compare)(const char *, const char *);
Compare compare;
char delim;
+ const char *trans_domain;
GNode *root;
- StringTree (Compare compare, char delim)
- : compare (compare), delim (delim)
+ StringTree (Compare compare, char delim, const char *trans_domain)
+ : compare (compare), delim (delim), trans_domain (trans_domain)
{
// the root is a dummy node to keep GNode happy
root = g_node_new (NULL);
@@ -86,7 +87,7 @@
return NULL;
}
- Ypp::Node *add (const std::string &tree_str, const std::string &order, const char *icon)
+ Ypp::Node *add (const std::string &tree_str, const std::string &order)
{
const gchar delimiter[2] = { delim, '\0' };
gchar **nodes_str = g_strsplit (tree_str.c_str(), delimiter, -1);
@@ -97,25 +98,30 @@
for (i = nodes_str; *i; i++) {
if (!**i)
continue;
+ const char *str = *i;
+ if (trans_domain)
+ str = dgettext (trans_domain, str);
bool found = false;
if (!order.empty())
+ // when ordered, make sure it already doesn't exist with another order
for (sibling = parent->children; sibling; sibling = sibling->next) {
- Ypp::Node *yNode = (Ypp::Node *) sibling->data;
- int cmp = (*compare) (*i, yNode->name.c_str());
+ Ypp::Node *node = (Ypp::Node *) sibling->data;
+ int cmp = (*compare) (str, node->name.c_str());
if (cmp == 0) {
found = true;
- ret = yNode;
+ ret = node;
break;
}
}
if (!found) {
- const char *order_str = order.empty() ? *i : order.c_str();
+ const char *s1 = order.empty() ? str : order.c_str();
for (sibling = parent->children; sibling; sibling = sibling->next) {
- Ypp::Node *yNode = (Ypp::Node *) sibling->data;
- int cmp = (*compare) (order_str, yNode->name.c_str());
+ Ypp::Node *node = (Ypp::Node *) sibling->data;
+ const char *s2 = order.empty() ? node->name.c_str() : node->order.c_str();
+ int cmp = (*compare) (s1, s2);
if (cmp == 0) {
found = true;
- ret = yNode;
+ ret = node;
break;
}
else if (cmp < 0)
@@ -128,15 +134,19 @@
}
for (; *i; i++) {
- Ypp::Node *yNode = new Ypp::Node();
- GNode *n = g_node_new ((void *) yNode);
- yNode->name = *i;
- yNode->icon = icon;
- yNode->impl = (void *) n;
+ Ypp::Node *node = new Ypp::Node();
+ GNode *n = g_node_new ((void *) node);
+ const char *str = *i;
+ if (trans_domain)
+ str = dgettext (trans_domain, str);
+ node->name = str;
+ node->order = order;
+ node->icon = NULL;
+ node->impl = (void *) n;
g_node_insert_before (parent, sibling, n);
parent = n;
sibling = NULL;
- ret = yNode;
+ ret = node;
}
g_strfreev (nodes_str);
return ret;
@@ -573,12 +583,12 @@
ZyppPackage package = tryCastToZyppPkg (object);
if (package) {
if (rich) {
- StringTree tree (strcmp, '/');
+ StringTree tree (strcmp, '/', NULL);
const std::list std::string &filesList = package->filenames();
for (std::list std::string::const_iterator it = filesList.begin();
it != filesList.end(); it++)
- tree.add (*it, "", 0);
+ tree.add (*it, "");
struct inner {
static std::string getPath (GNode *node)
@@ -1318,6 +1328,10 @@
case Package::PACKAGE_TYPE:
it = zyppPool().byKindBegin zypp::Package();
end = zyppPool().byKindEnd zypp::Package();
+
+ // for the categories
+ bindtextdomain ("rpm-groups", LOCALEDIR);
+ bind_textdomain_codeset ("rpm-groups", "utf8");
break;
case Package::PATTERN_TYPE:
it = zyppPool().byKindBegin zypp::Pattern();
@@ -2041,11 +2055,12 @@
static int cmp (const char *a, const char *b)
{
// Other group should always go as last
- if (!strcmp (a, "Other"))
- return !strcmp (b, "Other") ? 0 : 1;
- if (!strcmp (b, "Other"))
+ if (!strcmp (a, _("Other")))
+ return !strcmp (b, _("Other")) ? 0 : 1;
+ if (!strcmp (b, _("Other")))
return -1;
return strcasecmp (a, b);
+// return g_utf8_collate (a, b); // slow?
}
};
@@ -2063,9 +2078,13 @@
category = _("Documentation");
}
- if (!categories[type])
- categories[type] = new StringTree (inner::cmp, '/');
- return categories[type]->add (category, order, 0);
+ if (!categories[type]) {
+ const char *trans_domain = 0;
+ if (type == Package::PACKAGE_TYPE)
+ trans_domain = "rpm-groups";
+ categories[type] = new StringTree (inner::cmp, '/', trans_domain);
+ }
+ return categories[type]->add (category, order);
}
Ypp::Node *Ypp::Impl::addCategory2 (Ypp::Package::Type type, ZyppSelectable sel)
@@ -2105,8 +2124,10 @@
const char *group_icon = zypp_tag_enum_to_icon (group);
if (!categories2)
- categories2 = new StringTree (inner::cmp, '/');
- return categories2->add (group_name, "", group_icon);
+ categories2 = new StringTree (inner::cmp, '/', NULL);
+ Ypp::Node *node = categories2->add (group_name, "");
+ node->icon = group_icon;
+ return node;
}
void Ypp::Impl::polishCategories (Ypp::Package::Type type)
Modified: trunk/gtk/src/yzyppwrapper.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/yzyppwrapper.h?rev=54077&r1=54076&r2=54077&view=diff
==============================================================================
--- trunk/gtk/src/yzyppwrapper.h (original)
+++ trunk/gtk/src/yzyppwrapper.h Fri Dec 12 03:50:59 2008
@@ -35,7 +35,7 @@
// Utilities
struct Node {
- std::string name;
+ std::string name, order;
const char *icon;
Node *next();
Node *child();
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org