Author: rpmcruz
Date: Fri Aug 29 20:15:45 2008
New Revision: 50494
URL: http://svn.opensuse.org/viewcvs/yast?rev=50494&view=rev
Log:
* src/YGLayout.cc: implemented new libyui widget YButtonBox, making
buttons order comply with Gnome's guideline.
Also made sure all buttons in a hbox have the same height as some may
have an icon.
* src/yzyppwrapper.h/cc: added filelist and authors filter options, also
improving the overall support.
* src/YGPackageSelector.cc: added search options: file list and authors.
* src/YGPackageSelector.cc: bug fix 418896: when filtering a repository,
the most appropriate version wasn't the one selected.
* src/YGUtils.cc: fixed truncate() to cope with utf-8 characters. (maybe
related to bug 418781)
* src/test.cc: added tests for the purpose.
* src/YGUtils.cc: replaced the old button icon approach based on English
strings by one that tests button labels to stock ones.
Modified:
trunk/gtk/ChangeLog
trunk/gtk/src/YGInputField.cc
trunk/gtk/src/YGLayout.cc
trunk/gtk/src/YGPackageSelector.cc
trunk/gtk/src/YGPushButton.cc
trunk/gtk/src/YGUI.h
trunk/gtk/src/YGUtils.cc
trunk/gtk/src/YGUtils.h
trunk/gtk/src/YGWizard.cc
trunk/gtk/src/test.cc
trunk/gtk/src/ygtkwizard.c
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=50494&r1=50493&r2=50494&view=diff
==============================================================================
--- trunk/gtk/ChangeLog (original)
+++ trunk/gtk/ChangeLog Fri Aug 29 20:15:45 2008
@@ -1,3 +1,25 @@
+2008-08-29 Ricardo Cruz
+
+ * src/YGLayout.cc: implemented new libyui widget YButtonBox, making
+ buttons order comply with Gnome's guideline.
+ Also made sure all buttons in a hbox have the same height as some may
+ have an icon.
+
+ * src/yzyppwrapper.h/cc: added filelist and authors filter options, also
+ improving the overall support.
+
+ * src/YGPackageSelector.cc: added search options: file list and authors.
+
+ * src/YGPackageSelector.cc: bug fix 418896: when filtering a repository,
+ the most appropriate version wasn't the one selected.
+
+ * src/YGUtils.cc: fixed truncate() to cope with utf-8 characters. (maybe
+ related to bug 418781)
+ * src/test.cc: added tests for the purpose.
+
+ * src/YGUtils.cc: replaced the old button icon approach based on English
+ strings by one that tests button labels to stock ones.
+
2008-08-22 Ricardo Cruz
* src/yzypptags.cc: bug request 418676: use title capitalization for
Modified: trunk/gtk/src/YGInputField.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGInputField.cc?rev=50494&r1=50493&r2=50494&view=diff
==============================================================================
--- trunk/gtk/src/YGInputField.cc (original)
+++ trunk/gtk/src/YGInputField.cc Fri Aug 29 20:15:45 2008
@@ -333,10 +333,10 @@
{
const std::map *timezones =
(std::map *) pData;
- std::map ::const_iterator name =
- timezones->find (code);
- if (name == timezones->end())
- return NULL;
+ std::map ::const_iterator name =
+ timezones->find (code);
+ if (name == timezones->end())
+ return NULL;
return name->second.c_str();
}
Modified: trunk/gtk/src/YGLayout.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGLayout.cc?rev=50494&r1=50493&r2=50494&view=diff
==============================================================================
--- trunk/gtk/src/YGLayout.cc (original)
+++ trunk/gtk/src/YGLayout.cc Fri Aug 29 20:15:45 2008
@@ -41,10 +41,36 @@
doSetEnabled (enabled); \
}
+#include "YPushButton.h"
+
+class ButtonHeightGroup
+{
+GtkSizeGroup *group;
+
+public:
+ ButtonHeightGroup() { group = NULL; }
+
+ void addWidget (YWidget *ywidget)
+ {
+ YPushButton *button = dynamic_cast (ywidget);
+ if (button) {
+ bool create_group = !group;
+ if (create_group)
+ group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
+ gtk_size_group_add_widget (group, YGWidget::get (ywidget)->getLayout());
+ if (create_group)
+ g_object_unref (G_OBJECT (group));
+ }
+ }
+};
+
#include "YLayoutBox.h"
class YGLayoutBox : public YLayoutBox, public YGWidget
{
+// set all buttons in a HBox the same height (some may have icons)
+ButtonHeightGroup group;
+
public:
YGLayoutBox (YWidget *parent, YUIDimension dim)
: YLayoutBox (NULL, dim),
@@ -54,7 +80,13 @@
YGLAYOUT_INIT
}
- YGWIDGET_IMPL_CHILD_ADDED (getWidget())
+ virtual void addChild (YWidget *ychild)
+ {
+ YWidget::addChild (ychild);
+ doAddChild (ychild, getWidget());
+ if (primary() == YD_HORIZ)
+ group.addWidget (ychild);
+ }
YGWIDGET_IMPL_CHILD_REMOVED (getWidget())
YGLAYOUT_PREFERRED_SIZE_IMPL (YLayoutBox)
YGLAYOUT_SET_SIZE_IMPL (YLayoutBox)
@@ -66,6 +98,42 @@
return new YGLayoutBox (parent, dimension);
}
+#if YAST2_VERSION >= 2017006
+#include "YButtonBox.h"
+
+class YGButtonBox : public YButtonBox, public YGWidget
+{
+ButtonHeightGroup group;
+
+public:
+ YGButtonBox (YWidget *parent)
+ : YButtonBox (NULL),
+ YGWidget (this, parent, true, YGTK_TYPE_FIXED, NULL)
+ {
+ setBorder (0);
+ setLayoutPolicy (gnomeLayoutPolicy());
+ YGLAYOUT_INIT
+ }
+
+ virtual void addChild (YWidget *ychild)
+ {
+ YWidget::addChild (ychild);
+ doAddChild (ychild, getWidget());
+ group.addWidget (ychild);
+ }
+ YGWIDGET_IMPL_CHILD_REMOVED (getWidget())
+ YGLAYOUT_PREFERRED_SIZE_IMPL (YButtonBox)
+ YGLAYOUT_SET_SIZE_IMPL (YButtonBox)
+};
+
+YButtonBox *YGWidgetFactory::createButtonBox (YWidget *parent)
+{
+ IMPL
+ return new YGButtonBox (parent);
+}
+
+#endif
+
#include "YAlignment.h"
class YGAlignment : public YAlignment, public YGWidget
Modified: trunk/gtk/src/YGPackageSelector.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGPackageSelector.cc?rev=50494&r1=50493&r2=50494&view=diff
==============================================================================
--- trunk/gtk/src/YGPackageSelector.cc (original)
+++ trunk/gtk/src/YGPackageSelector.cc Fri Aug 29 20:15:45 2008
@@ -522,7 +522,7 @@
gtk_tree_view_set_tooltip_row (GTK_TREE_VIEW (view), tooltip, path);
gtk_tree_path_free (path);
if (package) {
- gtk_tooltip_set_text (tooltip, package->description().c_str());
+ gtk_tooltip_set_text (tooltip, package->description (true).c_str());
const std::string &icon = package->icon();
if (!icon.empty()) {
GdkPixbuf *pixbuf = loadThemeIcon (icon.c_str(), 32);
@@ -1470,6 +1470,8 @@
inner::appendCheckItem (name_menu, _("Name"), true, this);
inner::appendCheckItem (name_menu, _("Summary"), true, this);
inner::appendCheckItem (name_menu, _("Description"), false, this);
+ inner::appendCheckItem (name_menu, _("File list"), false, this);
+ inner::appendCheckItem (name_menu, _("Authors"), false, this);
gtk_widget_show_all (name_menu);
ygtk_find_entry_attach_menu (YGTK_FIND_ENTRY (m_name), GTK_MENU (name_menu));
@@ -1524,7 +1526,7 @@
const char *name = gtk_entry_get_text (GTK_ENTRY (m_name));
if (*name) {
- bool use_name, use_summary, use_description;
+ bool use_name, use_summary, use_description, use_filelist, use_authors;
GtkMenu *name_menu = YGTK_FIND_ENTRY (m_name)->context_menu;
GList *items = gtk_container_get_children (GTK_CONTAINER (name_menu));
use_name = gtk_check_menu_item_get_active (
@@ -1533,8 +1535,13 @@
(GtkCheckMenuItem *) g_list_nth_data (items, 1));
use_description = gtk_check_menu_item_get_active (
(GtkCheckMenuItem *) g_list_nth_data (items, 2));
+ use_filelist = gtk_check_menu_item_get_active (
+ (GtkCheckMenuItem *) g_list_nth_data (items, 3));
+ use_authors = gtk_check_menu_item_get_active (
+ (GtkCheckMenuItem *) g_list_nth_data (items, 4));
g_list_free (items);
- query->addNames (name, ' ', use_name, use_summary, use_description);
+ query->addNames (name, ' ', use_name, use_summary, use_description,
+ use_filelist, use_authors);
}
switch (m_statuses->getActive())
@@ -1716,8 +1723,10 @@
GtkTreeIter iter;
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, text.c_str(), -1);
- if (version->repo == favoriteRepo)
+ if (version->repo == favoriteRepo) {
gtk_combo_box_set_active (GTK_COMBO_BOX (m_available_versions), i);
+ favoriteRepo = 0; // select only the 1st hit
+ }
else if (i == 0)
gtk_combo_box_set_active (GTK_COMBO_BOX (m_available_versions), 0);
}
@@ -1985,11 +1994,11 @@
gtk_widget_hide (m_icon_frame);
if (packages.single()) {
string description = "<b>" + package->name() + "</b><br>";
- description += package->description();
+ description += package->description (true);
ygtk_html_wrap_set_text (m_description, description.c_str(), FALSE);
- if (m_filelist) m_filelist->setText (package->filelist());
+ if (m_filelist) m_filelist->setText (package->filelist (true));
if (m_changelog) m_changelog->setText (package->changelog());
- if (m_authors) m_authors->setText (package->authors());
+ if (m_authors) m_authors->setText (package->authors (true));
if (m_dependencies) m_dependencies->setPackage (package);
gtk_image_clear (GTK_IMAGE (m_icon));
Modified: trunk/gtk/src/YGPushButton.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGPushButton.cc?rev=50494&r1=50493&r2=50494&view=diff
==============================================================================
--- trunk/gtk/src/YGPushButton.cc (original)
+++ trunk/gtk/src/YGPushButton.cc Fri Aug 29 20:15:45 2008
@@ -29,7 +29,7 @@
IMPL
string str = YGUtils::mapKBAccel (label);
gtk_button_set_label (GTK_BUTTON (getWidget()), str.c_str());
- YGUtils::setStockIcon (getWidget(), str);
+ YGUtils::setStockIcon (str, getWidget());
YPushButton::setLabel (label);
}
Modified: trunk/gtk/src/YGUI.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUI.h?rev=50494&r1=50493&r2=50494&view=diff
==============================================================================
--- trunk/gtk/src/YGUI.h (original)
+++ trunk/gtk/src/YGUI.h Fri Aug 29 20:15:45 2008
@@ -122,6 +122,9 @@
IMPL_RET (NULL) // for ncurses
virtual YLayoutBox *createLayoutBox (YWidget *parent, YUIDimension dimension);
+#if YAST2_VERSION >= 2017006
+ virtual YButtonBox *createButtonBox (YWidget *parent);
+#endif
virtual YSpacing *createSpacing (YWidget *parent, YUIDimension dim, bool stretchable, YLayoutSize_t size);
virtual YEmpty *createEmpty (YWidget *parent);
Modified: trunk/gtk/src/YGUtils.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUtils.cc?rev=50494&r1=50493&r2=50494&view=diff
==============================================================================
--- trunk/gtk/src/YGUtils.cc (original)
+++ trunk/gtk/src/YGUtils.cc Fri Aug 29 20:15:45 2008
@@ -79,22 +79,36 @@
}
}
-std::string YGUtils::truncate (const std::string &str, std::string::size_type length, int pos)
+std::string YGUtils::truncate (const std::string &str, int length, int pos)
{
std::string ret (str);
- if (ret.size() > length) {
+ const char *pstr = ret.c_str(); char *pi;
+ int size = g_utf8_strlen (pstr, -1);
+ if (size > length) {
if (pos > 0) {
- ret.erase (length-3);
+ pi = g_utf8_offset_to_pointer (pstr, length-3);
+ ret.erase (pi-pstr);
ret.append ("...");
}
else if (pos < 0) {
- ret.erase (0, ret.size()-(length-3));
+ pi = g_utf8_offset_to_pointer (pstr, size-(length-3));
+ ret.erase (0, pi-pstr);
ret.insert (0, "...");
}
else /* (pos == 0) */ {
- std::string::size_type delta = ret.size()-(length-3);
- ret.erase ((ret.size()-delta)/2, delta);
- ret.insert (ret.size()/2, "...");
+ pi = g_utf8_offset_to_pointer (pstr, size/2);
+ int delta = size - (length-3);
+ gchar *pn = pi, *pp = pi;
+ for (int i = 0;;) {
+ if (i++ == delta) break;
+ pn = g_utf8_next_char (pn);
+ if (i++ == delta) break;
+ pp = g_utf8_prev_char (pp);
+ }
+ g_assert (pp != NULL && pn != NULL);
+
+ ret.erase (pp-pstr, pn-pp);
+ ret.insert (pp-pstr, "...");
}
}
return ret;
@@ -462,85 +476,68 @@
return pixbuf;
}
-#define ENGLISH_STOCK_ITEMS
+static std::string cutUnderline (const std::string &str)
+{
+ std::string ret (str);
+ std::string::size_type i = 0;
+ if ((i = ret.find ('_', i)) != std::string::npos)
+ ret.erase (i, 1);
+ return ret;
+}
-#ifdef ENGLISH_STOCK_ITEMS
-struct StockMap { const char *ycp_label, *gtk_stock; };
-static const StockMap stockMap[] = {
- // keep them sorted!
- {"Abort", GTK_STOCK_CANCEL },
- {"Accept", GTK_STOCK_APPLY },
- {"Add", GTK_STOCK_ADD },
- {"Apply", GTK_STOCK_APPLY },
- {"Back", GTK_STOCK_GO_BACK },
- {"Cancel", GTK_STOCK_CANCEL },
- {"Close", GTK_STOCK_CLOSE },
- {"Configure", GTK_STOCK_PREFERENCES },
- {"Continue", GTK_STOCK_OK },
- {"Delete", GTK_STOCK_DELETE },
- {"Down", GTK_STOCK_GO_DOWN },
- {"Edit", GTK_STOCK_EDIT },
- {"Finish", GTK_STOCK_APPLY },
- {"Install", GTK_STOCK_SAVE },
- {"Launch", GTK_STOCK_EXECUTE },
- {"Next", GTK_STOCK_GO_FORWARD },
- {"No", GTK_STOCK_NO },
- {"OK", GTK_STOCK_OK },
- {"Quit", GTK_STOCK_QUIT },
- {"Remove", GTK_STOCK_REMOVE },
- {"Reset", GTK_STOCK_REVERT_TO_SAVED },
- {"Reset all", GTK_STOCK_REVERT_TO_SAVED },
- {"Retry", GTK_STOCK_REFRESH },
- {"Search", GTK_STOCK_FIND },
- {"Up", GTK_STOCK_GO_UP },
- {"Yes", GTK_STOCK_YES },
-};
-#define STOCKMAP_SIZE (sizeof (stockMap)/sizeof(StockMap))
-static int strcmp_cb (const void *a, const void *b)
-{ return strcmp ((char *) a, ((StockMap *) b)->ycp_label); }
+static void stripStart (std::string &str, char ch)
+{
+ while (!str.empty() && str[0] == ch)
+ str.erase (0, 1);
+}
+static void stripEnd (std::string &str, char ch)
+{
+ while (!str.empty() && str[str.size()-1] == ch)
+ str.erase (str.size()-1, 1);
+}
-void YGUtils::setStockIcon (GtkWidget *button, std::string ycp_str)
+void YGUtils::setStockIcon (const std::string &label, GtkWidget *button)
{
- // is English the current locale?
- static bool firstTime = true, isEnglish;
+ static bool firstTime = true; static std::map stockMap;
if (firstTime) {
- char *lang = getenv ("LANG");
- isEnglish = !lang || (!*lang) || !strcmp (lang, "C") ||
- (lang[0] == 'e' && lang[1] == 'n') ||
- !strcmp (lang, "POSIX");
+ GSList *list = gtk_stock_list_ids();
+ for (GSList *i = list; i; i = i->next) {
+ gchar *id = (gchar *) i->data;
+ GtkStockItem item;
+ if (gtk_stock_lookup (id, &item))
+ stockMap[cutUnderline (item.label)] = id;
+ // some may not have a stock item because they can't be set on a label
+ // e.g.: gtk-directory, gtk-missing-image, gtk-dnd
+ g_free (id);
+ }
+ g_slist_free (list);
firstTime = false;
}
- if (!isEnglish)
- return;
- std::string::size_type i = 0;
- while ((i = ycp_str.find ('_', i)) != string::npos)
- ycp_str.erase (i, 1);
-
- bool failed = true;
- void *ptr;
- ptr = bsearch (ycp_str.c_str(), stockMap, STOCKMAP_SIZE,
- sizeof(stockMap[0]), strcmp_cb);
- if (ptr) {
- const char *stock = ((StockMap *) ptr)->gtk_stock;
+ std::string id = cutUnderline (label);
+ stripStart (id, ' ');
+ stripEnd (id, ' ');
+ stripEnd (id, '.');
+
+ std::map ::const_iterator it;
+ it = stockMap.find (id);
+ if (it != stockMap.end()) {
+ const std::string &stock_id = it->second;
GdkPixbuf *pixbuf;
- pixbuf = gtk_widget_render_icon (button, stock,
- GTK_ICON_SIZE_BUTTON, NULL);
+ pixbuf = gtk_widget_render_icon (button, stock_id.c_str(), GTK_ICON_SIZE_BUTTON, NULL);
if (pixbuf) {
GtkWidget *image = gtk_image_new_from_pixbuf (pixbuf);
gtk_button_set_image (GTK_BUTTON (button), image);
g_object_unref (G_OBJECT (pixbuf));
- failed = false;
}
+ else
+ g_warning ("yast2-gtk: setStockIcon(): id '%s' exists, but has no pixbuf",
+ stock_id.c_str());
}
- if (failed)
+ else
gtk_button_set_image (GTK_BUTTON (button), NULL);
}
-void ygutils_setStockIcon (GtkWidget *button, const char *ycp_str)
-{ YGUtils::setStockIcon (button, ycp_str); }
-
-#else
-void ygutils_setStockIcon (GtkWidget *button, const char *ycp_str) {}
-#endif
+void ygutils_setStockIcon (const char *label, GtkWidget *button)
+{ YGUtils::setStockIcon (label, button); }
Modified: trunk/gtk/src/YGUtils.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUtils.h?rev=50494&r1=50493&r2=50494&view=diff
==============================================================================
--- trunk/gtk/src/YGUtils.h (original)
+++ trunk/gtk/src/YGUtils.h Fri Aug 29 20:15:45 2008
@@ -25,8 +25,8 @@
void replace (std::string &str, const char *mouth, int mouth_len, const char *food);
/* Truncates the text with "..." past the given length.
- pos: -1 = start, 0 = middle, 1 = end */
- std::string truncate (const std::string &str, std::string::size_type length, int pos);
+ pos: -1 = start, 0 = middle, 1 = end. Honors utf-8 characters. */
+ std::string truncate (const std::string &str, int length, int pos);
/* Escapes markup text (eg. changes '<' by '\<'). */
void escapeMarkup (std::string &str);
@@ -45,7 +45,7 @@
GdkPixbuf *loadPixbuf (const std::string &fileneme);
/* Tries to make sense out of the string, applying some stock icon to the button. */
- void setStockIcon (GtkWidget *button, std::string ycp_str);
+ void setStockIcon (const std::string &label, GtkWidget *button);
};
extern "C" {
@@ -60,7 +60,7 @@
/* Convert html to xhtml (or at least try) */
gchar *ygutils_convert_to_xhtml (const char *instr);
- void ygutils_setStockIcon (GtkWidget *button, const char *ycp_str);
+ void ygutils_setStockIcon (const char *label, GtkWidget *button);
};
#endif // YGUTILS_H
Modified: trunk/gtk/src/YGWizard.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGWizard.cc?rev=50494&r1=50493&r2=50494&view=diff
==============================================================================
--- trunk/gtk/src/YGWizard.cc (original)
+++ trunk/gtk/src/YGWizard.cc Fri Aug 29 20:15:45 2008
@@ -45,7 +45,7 @@
string str = YGUtils::mapKBAccel (label.c_str());
gtk_button_set_label (GTK_BUTTON (m_widget), str.c_str());
str.empty() ? gtk_widget_hide (m_widget) : gtk_widget_show (m_widget);
- YGUtils::setStockIcon (m_widget, str);
+ YGUtils::setStockIcon (str, m_widget);
YPushButton::setLabel (label);
}
Modified: trunk/gtk/src/test.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/test.cc?rev=50494&r1=50493&r2=50494&view=diff
==============================================================================
--- trunk/gtk/src/test.cc (original)
+++ trunk/gtk/src/test.cc Fri Aug 29 20:15:45 2008
@@ -124,13 +124,20 @@
} aTests[] = {
{ "this-is-a-very-long-and-tedious-string", "this-is-a-very-lo...", 20, 1 },
{ "this-is-a-very-long-and-tedious-string", "...nd-tedious-string", 20, -1 },
- { "this-is-a-very-long-and-tedious-string", "this-is-...us-string", 20, 0 },
+ { "this-is-a-very-long-and-tedious-string", "this-is-a...s-string", 20, 0 },
{ "this-is-a-very-long-and-tedious-string2", "this-is-...s-string2", 20, 0 },
{ "abc", "abc", 3, 1 },
{ "abcd", "...", 3, 1 },
{ "abcd", "...", 3, -1 },
{ "abcd", "...", 3, 0 },
- { "abcdef", "...f", 4, 0 },
+ { "abcdef", "a...", 4, 0 },
+ { "áéÃóúçö", "áé...", 5, 1 },
+ { "áéÃóúçö", "áéÃ...", 6, 1 },
+ { "áéÃóúçö", "...çö", 5, -1 },
+ { "áéÃóúçö", "...úçö", 6, -1 },
+ { "áéÃóúçö", "á...ö", 5, 0 },
+ { "áéÃóúçö", "á...çö", 6, 0 },
+ { "áéÃóú", "áéÃóú", 5, 0 },
{ NULL, NULL }
};
for (int i = 0; aTests[i].in; i++) {
Modified: trunk/gtk/src/ygtkwizard.c
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkwizard.c?rev=50494&r1=50493&r2=50494&view=diff
==============================================================================
--- trunk/gtk/src/ygtkwizard.c (original)
+++ trunk/gtk/src/ygtkwizard.c Fri Aug 29 20:15:45 2008
@@ -25,7 +25,7 @@
// YGUtils bridge
extern void ygutils_setWidgetFont (GtkWidget *widget, PangoWeight weight,
double scale);
-extern void ygutils_setStockIcon (GtkWidget *button, const char *ycp_str);
+extern void ygutils_setStockIcon (const char *label, GtkWidget *button);
//** YGtkHelpDialog
@@ -742,21 +742,21 @@
{
gtk_button_set_label (GTK_BUTTON (wizard->m_abort_button), text);
ENABLE_WIDGET_STR (text, wizard->m_abort_button);
- ygutils_setStockIcon (wizard->m_abort_button, text);
+ ygutils_setStockIcon (text, wizard->m_abort_button);
}
void ygtk_wizard_set_back_button_label (YGtkWizard *wizard, const char *text)
{
gtk_button_set_label (GTK_BUTTON (wizard->m_back_button), text);
ENABLE_WIDGET_STR (text, wizard->m_back_button);
- ygutils_setStockIcon (wizard->m_back_button, text);
+ ygutils_setStockIcon (text, wizard->m_back_button);
}
void ygtk_wizard_set_next_button_label (YGtkWizard *wizard, const char *text)
{
gtk_button_set_label (GTK_BUTTON (wizard->m_next_button), text);
ENABLE_WIDGET_STR (text, wizard->m_next_button);
- ygutils_setStockIcon (wizard->m_next_button, text);
+ ygutils_setStockIcon (text, wizard->m_next_button);
}
void ygtk_wizard_set_back_button_ptr_id (YGtkWizard *wizard, gpointer id)
Modified: trunk/gtk/src/yzyppwrapper.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/yzyppwrapper.cc?rev=50494&r1=50493&r2=50494&view=diff
==============================================================================
--- trunk/gtk/src/yzyppwrapper.cc (original)
+++ trunk/gtk/src/yzyppwrapper.cc Fri Aug 29 20:15:45 2008
@@ -289,10 +289,12 @@
return ret;
}
-std::string Ypp::Package::description()
+std::string Ypp::Package::description (bool rich)
{
ZyppObject object = impl->zyppSel->theObj();
std::string text = object->description(), br = "<br>";
+ if (!rich)
+ return text;
switch (impl->type) {
case PACKAGE_TYPE:
@@ -363,65 +365,73 @@
return text;
}
-std::string Ypp::Package::filelist()
+std::string Ypp::Package::filelist (bool rich)
{
std::string text;
ZyppObject object = impl->zyppSel->installedObj();
ZyppPackage package = tryCastToZyppPkg (object);
if (package) {
- StringTree tree (strcmp, '/');
+ if (rich) {
+ StringTree tree (strcmp, '/');
- 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);
+ 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);
- struct inner {
- static std::string getPath (GNode *node)
- {
- Node *yNode = (Node *) node->data;
- if (!yNode)
- return std::string();
- return getPath (node->parent) + "/" + yNode->name;
- }
- static bool hasNextLeaf (GNode *node)
- {
- GNode *i;
- for (i = node->next; i; i = i->next)
- if (!i->children)
- return true;
- return false;
- }
- static bool hasPrevLeaf (GNode *node)
- {
- GNode *i;
- for (i = node->prev; i; i = i->prev)
- if (!i->children)
- return true;
- return false;
- }
- static gboolean traverse (GNode *node, void *_data)
- {
- Node *yNode = (Node *) node->data;
- if (yNode) {
- std::string *str = (std::string *) _data;
- if (!hasPrevLeaf (node)) {
- std::string path = getPath (node->parent);
- *str += "<a href=" + path + ">" + path + "</a>";
- *str += "<blockquote>";
- }
- else
- *str += ", ";
- *str += yNode->name;
+ struct inner {
+ static std::string getPath (GNode *node)
+ {
+ Node *yNode = (Node *) node->data;
+ if (!yNode)
+ return std::string();
+ return getPath (node->parent) + "/" + yNode->name;
+ }
+ static bool hasNextLeaf (GNode *node)
+ {
+ GNode *i;
+ for (i = node->next; i; i = i->next)
+ if (!i->children)
+ return true;
+ return false;
+ }
+ static bool hasPrevLeaf (GNode *node)
+ {
+ GNode *i;
+ for (i = node->prev; i; i = i->prev)
+ if (!i->children)
+ return true;
+ return false;
+ }
+ static gboolean traverse (GNode *node, void *_data)
+ {
+ Node *yNode = (Node *) node->data;
+ if (yNode) {
+ std::string *str = (std::string *) _data;
+ if (!hasPrevLeaf (node)) {
+ std::string path = getPath (node->parent);
+ *str += "<a href=" + path + ">" + path + "</a>";
+ *str += "<blockquote>";
+ }
+ else
+ *str += ", ";
+ *str += yNode->name;
- if (!hasNextLeaf (node))
- *str += "</blockquote>";
+ if (!hasNextLeaf (node))
+ *str += "</blockquote>";
+ }
+ return FALSE;
}
- return FALSE;
- }
- };
- g_node_traverse (tree.root, G_LEVEL_ORDER, G_TRAVERSE_LEAFS, -1,
- inner::traverse, (void *) &text);
+ };
+ g_node_traverse (tree.root, G_LEVEL_ORDER, G_TRAVERSE_LEAFS, -1,
+ inner::traverse, (void *) &text);
+ }
+ else {
+ const std::list std::string &filesList = package->filenames();
+ for (std::list std::string::const_iterator it = filesList.begin();
+ it != filesList.end(); it++)
+ text += *it + " ";
+ }
}
return text;
}
@@ -448,7 +458,7 @@
return text;
}
-std::string Ypp::Package::authors()
+std::string Ypp::Package::authors (bool rich)
{
std::string text;
ZyppObject object = impl->zyppSel->theObj();
@@ -459,10 +469,15 @@
const std::list std::string &authorsList = package->authors();
for (std::list std::string::const_iterator it = authorsList.begin();
it != authorsList.end(); it++) {
- std::string author = *it;
- YGUtils::escapeMarkup (author);
- if (!authors.empty())
- authors += "<br>";
+ std::string author (*it);
+ if (rich)
+ YGUtils::escapeMarkup (author);
+ if (!authors.empty()) {
+ if (rich)
+ authors += "<br>";
+ else
+ authors += "\n";
+ }
authors += author;
}
// look for Authors line in description
@@ -474,18 +489,23 @@
i = description.find ("\n", i+1);
if (i != std::string::npos) {
std::string str = description.substr (i+1);
- YGUtils::escapeMarkup (str);
- YGUtils::replace (str, "\n", 1, "<br>");
+ if (rich) {
+ YGUtils::escapeMarkup (str);
+ YGUtils::replace (str, "\n", 1, "<br>");
+ }
authors += str;
-
}
}
}
- if (!authors.empty())
- text += _("Developed by:") + ("<blockquote>" + authors) + "</blockquote>";
- if (!packager.empty())
- text += _("Packaged by:") + ("<blockquote>" + packager) + "</blockquote>";
+ if (rich) {
+ if (!authors.empty())
+ text += _("Developed by:") + ("<blockquote>" + authors) + "</blockquote>";
+ if (!packager.empty())
+ text += _("Packaged by:") + ("<blockquote>" + packager) + "</blockquote>";
+ }
+ else
+ return authors;
}
return text;
}
@@ -893,7 +913,8 @@
Keys Ypp::Package::Type types;
Keys std::string names;
- bool use_name, use_summary, use_description;
+ unsigned int use_name : 1, use_summary : 1, use_description : 1, use_filelist : 1,
+ use_authors : 1;
Keys categories, categories2;
Keys collections;
Keys repositories;
@@ -940,14 +961,18 @@
if (!str_match && use_summary)
str_match = strcasestr (package->summary().c_str(), key);
if (!str_match && use_description)
- str_match = strcasestr (package->description().c_str(), key);
+ str_match = strcasestr (package->description (false).c_str(), key);
+ if (!str_match && use_filelist)
+ str_match = strcasestr (package->filelist (false).c_str(), key);
+ if (!str_match && use_authors)
+ str_match = strcasestr (package->authors (false).c_str(), key);
if (!str_match) {
match = false;
break;
}
}
if (match && !highlight) {
- if (values.size() == 1 && values.front() == package->name())
+ if (values.size() == 1 && !strcasecmp (values.front().c_str(), package->name().c_str()))
highlight = package;
}
}
@@ -1016,7 +1041,7 @@
void Ypp::QueryPool::Query::addType (Ypp::Package::Type value)
{ impl->types.add (value); }
void Ypp::QueryPool::Query::addNames (std::string value, char separator, bool use_name,
- bool use_summary, bool use_description)
+ bool use_summary, bool use_description, bool use_filelist, bool use_authors)
{
if (separator) {
const gchar delimiter[2] = { separator, '\0' };
@@ -1030,6 +1055,8 @@
impl->use_name = use_name;
impl->use_summary = use_summary;
impl->use_description = use_description;
+ impl->use_filelist = use_filelist;
+ impl->use_authors = use_authors;
}
void Ypp::QueryPool::Query::addCategory (Ypp::Node *value)
{ impl->categories.add (value); }
Modified: trunk/gtk/src/yzyppwrapper.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/yzyppwrapper.h?rev=50494&r1=50493&r2=50494&view=diff
==============================================================================
--- trunk/gtk/src/yzyppwrapper.h (original)
+++ trunk/gtk/src/yzyppwrapper.h Fri Aug 29 20:15:45 2008
@@ -51,10 +51,10 @@
Node *category2();
bool fromCollection (const Ypp::Package *collection) const;
- std::string description();
- std::string filelist();
+ std::string description (bool rich);
+ std::string filelist (bool rich);
std::string changelog();
- std::string authors();
+ std::string authors (bool rich);
std::string icon();
bool isRecommended() const;
bool isSuggested() const;
@@ -136,7 +136,8 @@
Query();
void addType (Package::Type type);
void addNames (std::string name, char separator = 0, bool use_name = true,
- bool use_summary = true, bool use_description = false);
+ bool use_summary = true, bool use_description = false,
+ bool use_filelist = false, bool use_authors = false);
void addCategory (Ypp::Node *category);
void addCategory2 (Ypp::Node *category);
void addCollection (const Ypp::Package *package);
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org