[yast-commit] r58854 - in /trunk/gtk: ChangeLog src/YGPackageSelector.cc src/yzypptags.cc src/yzypptags.h src/yzyppwrapper.cc
Author: rpmcruz Date: Thu Oct 1 02:38:20 2009 New Revision: 58854 URL: http://svn.opensuse.org/viewcvs/yast?rev=58854&view=rev Log: * src/yzypptags.h/cc: bug fix: a couple mapping errors of PackageKit categories. * src/yzyppwrapper.cc: speed fix: improved startup speed by both mapping categories when needed and improving the mapping performance as well. Modified: trunk/gtk/ChangeLog trunk/gtk/src/YGPackageSelector.cc trunk/gtk/src/yzypptags.cc trunk/gtk/src/yzypptags.h trunk/gtk/src/yzyppwrapper.cc Modified: trunk/gtk/ChangeLog URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=58854&r1=58853&r2=58854&view=diff ============================================================================== --- trunk/gtk/ChangeLog (original) +++ trunk/gtk/ChangeLog Thu Oct 1 02:38:20 2009 @@ -1,5 +1,14 @@ 2009-09-30 Ricardo Cruz <rpmcruz@alunos.dcc.fc.up.pt> + * src/yzypptags.h/cc: bug fix: a couple mapping errors + of PackageKit categories. + + * src/yzyppwrapper.cc: speed fix: improved startup + speed by both mapping categories when needed and + improving the mapping performance as well. + +2009-09-30 Ricardo Cruz <rpmcruz@alunos.dcc.fc.up.pt> + * src/ygtkzyppview.h/cc: map package text-view details scrolling to the view-port they are installed on. Modified: trunk/gtk/src/YGPackageSelector.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGPackageSelector.cc?rev=58854&r1=58853&r2=58854&view=diff ============================================================================== --- trunk/gtk/src/YGPackageSelector.cc (original) +++ trunk/gtk/src/YGPackageSelector.cc Thu Oct 1 02:38:20 2009 @@ -2011,7 +2011,7 @@ m_progressbar = gtk_progress_bar_new(); GtkWidget *empty = gtk_event_box_new(); - gtk_widget_set_size_request (empty, -1, 40); + gtk_widget_set_size_request (empty, -1, 36); gtk_widget_show (empty); GtkWidget *vbox = gtk_vbox_new (FALSE, 6); Modified: trunk/gtk/src/yzypptags.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/yzypptags.cc?rev=58854&r1=58853&r2=58854&view=diff ============================================================================== --- trunk/gtk/src/yzypptags.cc (original) +++ trunk/gtk/src/yzypptags.cc Thu Oct 1 02:38:20 2009 @@ -22,16 +22,11 @@ const char * zypp_tag_group_enum_to_localised_text (YPkgGroupEnum group) { - switch (group) - { - case PK_GROUP_ENUM_ACCESSIBILITY: return _( "Accessibility" ); - case PK_GROUP_ENUM_ACCESSORIES: return _( "Accessories" ); + switch (group) { case PK_GROUP_ENUM_EDUCATION: return _( "Education" ); case PK_GROUP_ENUM_GAMES: return _( "Games" ); case PK_GROUP_ENUM_GRAPHICS: return _( "Graphics" ); - case PK_GROUP_ENUM_INTERNET: return _( "Internet" ); case PK_GROUP_ENUM_OFFICE: return _( "Office" ); - case PK_GROUP_ENUM_OTHER: return _( "Other" ); case PK_GROUP_ENUM_PROGRAMMING: return _( "Programming" ); case PK_GROUP_ENUM_MULTIMEDIA: return _( "Multimedia" ); case PK_GROUP_ENUM_SYSTEM: return _( "System" ); @@ -40,21 +35,17 @@ case PK_GROUP_ENUM_DESKTOP_XFCE: return _( "XFCE Desktop" ); case PK_GROUP_ENUM_DESKTOP_OTHER: return _( "Other Desktops" ); case PK_GROUP_ENUM_PUBLISHING: return _( "Publishing" ); - case PK_GROUP_ENUM_SERVERS: return _( "Servers" ); - case PK_GROUP_ENUM_FONTS: return _( "Fonts" ); case PK_GROUP_ENUM_ADMIN_TOOLS: return _( "Admin Tools" ); - case PK_GROUP_ENUM_LEGACY: return _( "Legacy" ); case PK_GROUP_ENUM_LOCALIZATION: return _( "Localization" ); - case PK_GROUP_ENUM_VIRTUALIZATION: return _( "Virtualization" ); case PK_GROUP_ENUM_SECURITY: return _( "Security" ); - case PK_GROUP_ENUM_POWER_MANAGEMENT: return _( "Power Management" ); case PK_GROUP_ENUM_COMMUNICATION: return _( "Communication" ); case PK_GROUP_ENUM_NETWORK: return _( "Network" ); case PK_GROUP_ENUM_DOCUMENTATION: return _( "Documentation" ); case PK_GROUP_ENUM_UTILITIES: return _( "Utilities" ); case PK_GROUP_ENUM_UNKNOWN: return _( "Unknown Group" ); + case PK_GROUP_ENUM_SIZE: break; } - return _("Unknown Group"); + return ""; } const char * @@ -63,14 +54,10 @@ // NOTE: some icons are customized (bug 404818) switch (group) { - case PK_GROUP_ENUM_ACCESSIBILITY: return( "package_main" ); - case PK_GROUP_ENUM_ACCESSORIES: return( "package_applications" ); case PK_GROUP_ENUM_EDUCATION: return( "package_edutainment" ); case PK_GROUP_ENUM_GAMES: return( "package_games" ); case PK_GROUP_ENUM_GRAPHICS: return( "package_graphics" ); - case PK_GROUP_ENUM_INTERNET: return( "package_network" ); case PK_GROUP_ENUM_OFFICE: return( "applications-office" ); - case PK_GROUP_ENUM_OTHER: return( "package_main" ); case PK_GROUP_ENUM_PROGRAMMING: return( "package_development" ); case PK_GROUP_ENUM_MULTIMEDIA: return( "package_multimedia" ); case PK_GROUP_ENUM_SYSTEM: return( "applications-system" ); @@ -79,24 +66,19 @@ case PK_GROUP_ENUM_DESKTOP_XFCE: return( "pattern-xfce" ); case PK_GROUP_ENUM_DESKTOP_OTHER: return( "user-desktop" ); case PK_GROUP_ENUM_PUBLISHING: return( "package_main" ); - case PK_GROUP_ENUM_SERVERS: return( "package_editors" ); - case PK_GROUP_ENUM_FONTS: return( "package_main" ); case PK_GROUP_ENUM_ADMIN_TOOLS: return( "yast-sysconfig" ); - case PK_GROUP_ENUM_LEGACY: return( "package_main" ); case PK_GROUP_ENUM_LOCALIZATION: return( "yast-language" ); - case PK_GROUP_ENUM_VIRTUALIZATION: return( "yast-create-new-vm" ); case PK_GROUP_ENUM_SECURITY: return( "yast-security" ); - case PK_GROUP_ENUM_POWER_MANAGEMENT: return( "package_settings_power" ); case PK_GROUP_ENUM_COMMUNICATION: return( "yast-modem" ); case PK_GROUP_ENUM_NETWORK: return( "package_network" ); case PK_GROUP_ENUM_DOCUMENTATION: return( "package_documentation" ); case PK_GROUP_ENUM_UTILITIES: return( "package_utilities" ); case PK_GROUP_ENUM_UNKNOWN: return( "package_main" ); + case PK_GROUP_ENUM_SIZE: break; } return ""; } - YPkgGroupEnum zypp_tag_convert (const std::string &groupu) { @@ -115,14 +97,14 @@ if (group.compare (0, 22, "productivity/telephony") == 0) return PK_GROUP_ENUM_COMMUNICATION; if (group.compare (0, 19, "amusements/teaching") == 0) return PK_GROUP_ENUM_EDUCATION; if (group.compare (0, 17, "publishing/office") == 0) return PK_GROUP_ENUM_OFFICE; - if (group.compare (0, 18, "producitivity/text") == 0) return PK_GROUP_ENUM_OFFICE; - if (group.compare (0, 21, "producitivity/editors") == 0) return PK_GROUP_ENUM_OFFICE; - if (group.compare (0, 20, "producitivity/graphics") == 0) return PK_GROUP_ENUM_GRAPHICS; + if (group.compare (0, 17, "productivity/text") == 0) return PK_GROUP_ENUM_OFFICE; + if (group.compare (0, 20, "productivity/editors") == 0) return PK_GROUP_ENUM_OFFICE; + if (group.compare (0, 21, "productivity/graphics") == 0) return PK_GROUP_ENUM_GRAPHICS; if (group.compare (0, 10, "amusements") == 0) return PK_GROUP_ENUM_GAMES; if (group.compare (0, 19, "system/localization") == 0) return PK_GROUP_ENUM_LOCALIZATION; if (group.compare (0, 11, "development") == 0) return PK_GROUP_ENUM_PROGRAMMING; - if (group.compare (0, 21, "producitivity/network") == 0) return PK_GROUP_ENUM_NETWORK; - if (group.compare (0, 22, "producitivity/security") == 0) return PK_GROUP_ENUM_SECURITY; + if (group.compare (0, 20, "productivity/network") == 0) return PK_GROUP_ENUM_NETWORK; + if (group.compare (0, 21, "productivity/security") == 0) return PK_GROUP_ENUM_SECURITY; if (group.compare (0, 16, "system/gui/gnome") == 0) return PK_GROUP_ENUM_DESKTOP_GNOME; if (group.compare (0, 14, "system/gui/kde") == 0) return PK_GROUP_ENUM_DESKTOP_KDE; if (group.compare (0, 15, "system/gui/xfce") == 0) return PK_GROUP_ENUM_DESKTOP_XFCE; Modified: trunk/gtk/src/yzypptags.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/yzypptags.h?rev=58854&r1=58853&r2=58854&view=diff ============================================================================== --- trunk/gtk/src/yzypptags.h (original) +++ trunk/gtk/src/yzypptags.h Thu Oct 1 02:38:20 2009 @@ -8,35 +8,27 @@ typedef enum { /* PackageKit values */ - PK_GROUP_ENUM_ACCESSIBILITY, - PK_GROUP_ENUM_ACCESSORIES, - PK_GROUP_ENUM_EDUCATION, - PK_GROUP_ENUM_GAMES, - PK_GROUP_ENUM_GRAPHICS, - PK_GROUP_ENUM_INTERNET, PK_GROUP_ENUM_OFFICE, - PK_GROUP_ENUM_OTHER, - PK_GROUP_ENUM_PROGRAMMING, + PK_GROUP_ENUM_PUBLISHING, + PK_GROUP_ENUM_GRAPHICS, PK_GROUP_ENUM_MULTIMEDIA, - PK_GROUP_ENUM_SYSTEM, + PK_GROUP_ENUM_EDUCATION, + PK_GROUP_ENUM_GAMES, PK_GROUP_ENUM_DESKTOP_GNOME, PK_GROUP_ENUM_DESKTOP_KDE, PK_GROUP_ENUM_DESKTOP_XFCE, PK_GROUP_ENUM_DESKTOP_OTHER, - PK_GROUP_ENUM_PUBLISHING, - PK_GROUP_ENUM_SERVERS, - PK_GROUP_ENUM_FONTS, - PK_GROUP_ENUM_ADMIN_TOOLS, - PK_GROUP_ENUM_LEGACY, - PK_GROUP_ENUM_LOCALIZATION, - PK_GROUP_ENUM_VIRTUALIZATION, - PK_GROUP_ENUM_SECURITY, - PK_GROUP_ENUM_POWER_MANAGEMENT, PK_GROUP_ENUM_COMMUNICATION, PK_GROUP_ENUM_NETWORK, + PK_GROUP_ENUM_PROGRAMMING, PK_GROUP_ENUM_DOCUMENTATION, + PK_GROUP_ENUM_ADMIN_TOOLS, + PK_GROUP_ENUM_SECURITY, + PK_GROUP_ENUM_LOCALIZATION, + PK_GROUP_ENUM_SYSTEM, PK_GROUP_ENUM_UTILITIES, PK_GROUP_ENUM_UNKNOWN, + PK_GROUP_ENUM_SIZE, } YPkgGroupEnum; Modified: trunk/gtk/src/yzyppwrapper.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/yzyppwrapper.cc?rev=58854&r1=58853&r2=58854&view=diff ============================================================================== --- trunk/gtk/src/yzyppwrapper.cc (original) +++ trunk/gtk/src/yzyppwrapper.cc Thu Oct 1 02:38:20 2009 @@ -191,11 +191,12 @@ // for the Primitive Pools PkgList *getPackages (Package::Type type); + Ypp::Node *mapCategory2Enum (YPkgGroupEnum group); + private: bool resolveProblems(); Node *addCategory (Ypp::Package::Type type, const std::string &str, const std::string &order); void polishCategories (Ypp::Package::Type type); - Node *addCategory2 (Ypp::Package::Type type, ZyppSelectable sel); void startTransactions(); void finishTransactions(); @@ -203,6 +204,7 @@ friend class Ypp; PkgList *packages [Package::TOTAL_TYPES]; // primitive pools StringTree *categories [Package::TOTAL_TYPES], *categories2; + Ypp::Node *mapCategories2 [PK_GROUP_ENUM_SIZE]; std::vector <Repository *> repos; const Repository *favoriteRepo; int favoriteRepoPriority; @@ -948,7 +950,26 @@ { return m_category; } virtual Ypp::Node *category2() - { return m_category2; } + { + if (!m_category2) { + YPkgGroupEnum group = PK_GROUP_ENUM_UNKNOWN; + for (int i = 0; i < 2; i++) { + ZyppObject obj; + if (i == 0) + obj = m_sel->candidateObj(); + else + obj = m_sel->installedObj(); + ZyppPackage pkg = tryCastToZyppPkg (obj); + if (pkg) { + group = zypp_tag_convert (pkg->group()); + if (group != PK_GROUP_ENUM_UNKNOWN) + break; + } + } + m_category2 = ypp->impl->mapCategory2Enum (group); + } + return m_category2; + } virtual bool isInstalled() { @@ -1375,6 +1396,21 @@ ZyppPattern pattern2 = tryCastToZyppPattern (((PackageSel *) b->impl)->m_sel->theObj()); return strcmp (pattern1->order().c_str(), pattern2->order().c_str()) < 0; } + static int pk_group_order (const char *a, const char *b) + { + const char *unknown = zypp_tag_group_enum_to_localised_text (PK_GROUP_ENUM_UNKNOWN); + if (!strcmp (a, unknown)) { + if (!strcmp (b, unknown)) + return 0; + return 1; + } + if (!strcmp (b, unknown)) { + if (!strcmp (a, unknown)) + return 0; + return -1; + } + return strcmp (a, b); + } }; if (type == Package::LANGUAGE_TYPE) { @@ -1394,9 +1430,20 @@ it = zyppPool().byKindBegin <zypp::Package>(); end = zyppPool().byKindEnd <zypp::Package>(); size = zyppPool().size(zypp::ResKind::package); + // for the categories bindtextdomain ("rpm-groups", LOCALEDIR); bind_textdomain_codeset ("rpm-groups", "utf8"); + // layout all categories2 already and assign it to packages on request + categories2 = new StringTree (inner::pk_group_order, '/', NULL); + for (int i = 0; i < PK_GROUP_ENUM_SIZE; i++) { + YPkgGroupEnum group = (YPkgGroupEnum) i; + const char *name = zypp_tag_group_enum_to_localised_text (group); + const char *icon = zypp_tag_enum_to_icon (group); + Ypp::Node *node = categories2->add (name, ""); + node->icon = icon; + mapCategories2 [i] = node; + } break; case Package::PATTERN_TYPE: it = zyppPool().byKindBegin <zypp::Pattern>(); @@ -1432,7 +1479,6 @@ if (!zpackage) continue; category = addCategory (type, zpackage->group(), ""); - category2 = addCategory2 (type, sel); break; } case Package::PATTERN_TYPE: @@ -1507,6 +1553,9 @@ return packages[type]; } +Ypp::Node *Ypp::Impl::mapCategory2Enum (YPkgGroupEnum group) +{ return mapCategories2 [group]; } + //** PkgList struct Ypp::PkgList::Impl : public Ypp::PkgList::Listener @@ -2260,49 +2309,6 @@ return categories[type]->add (category, order); } -Ypp::Node *Ypp::Impl::addCategory2 (Ypp::Package::Type type, ZyppSelectable sel) -{ - struct inner { - static int cmp (const char *a, const char *b) - { - int r = g_utf8_collate (a, b); - if (r != 0) { - const char *unknown = zypp_tag_group_enum_to_localised_text - (PK_GROUP_ENUM_UNKNOWN); - if (!strcmp (a, unknown)) - return 1; - if (!strcmp (b, unknown)) - return -1; - } - return r; - } - }; - - // different instances may be assigned different groups - YPkgGroupEnum group = PK_GROUP_ENUM_UNKNOWN; - for (int i = 0; i < 2; i++) { - ZyppObject obj; - if (i == 0) - obj = sel->candidateObj(); - else - obj = sel->installedObj(); - ZyppPackage pkg = tryCastToZyppPkg (obj); - if (pkg) { - group = zypp_tag_convert (pkg->group()); - if (group != PK_GROUP_ENUM_UNKNOWN) - break; - } - } - const char *group_name = zypp_tag_group_enum_to_localised_text (group); - const char *group_icon = zypp_tag_enum_to_icon (group); - - if (!categories2) - 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) { // some treatment on categories -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
rpmcruz@svn.opensuse.org