Author: rpmcruz
Date: Thu May 8 04:31:36 2008
New Revision: 47372
URL: http://svn.opensuse.org/viewcvs/yast?rev=47372&view=rev
Log:
* src/YGPackageSelector.cc: added support for links in package
descriptions.
Modified:
trunk/gtk/ChangeLog
trunk/gtk/src/YGPackageSelector.cc
trunk/gtk/src/YGUtils.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=47372&r1=47371&r2=47372&view=diff
==============================================================================
--- trunk/gtk/ChangeLog (original)
+++ trunk/gtk/ChangeLog Thu May 8 04:31:36 2008
@@ -14,6 +14,9 @@
Also replaced the usage of integers for Repositories and Versions for
an actual pointer.
+ * src/YGPackageSelector.cc: added support for links in package
+ descriptions.
+
2008-05-07 Michael Meeks
* src/YGDialog.cc (class YGWindow): only set 'fullscreen' on the main
Modified: trunk/gtk/src/YGPackageSelector.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGPackageSelector.cc?rev=47372&r1=47371&r2=47372&view=diff
==============================================================================
--- trunk/gtk/src/YGPackageSelector.cc (original)
+++ trunk/gtk/src/YGPackageSelector.cc Thu May 8 04:31:36 2008
@@ -221,6 +221,7 @@
virtual void setModel (GtkTreeModel *model) = 0;
virtual GList *getSelectedPaths (GtkTreeModel **model) = 0;
virtual void selectAll() = 0;
+ virtual void unselectAll() = 0;
virtual void ensureVisible (GtkTreePath *path) = 0;
virtual int countSelected()
@@ -437,6 +438,9 @@
virtual void selectAll()
{ gtk_tree_selection_select_all (getTreeSelection()); }
+ virtual void unselectAll()
+ { gtk_tree_selection_unselect_all (getTreeSelection()); }
+
virtual int countSelected()
{ return gtk_tree_selection_count_selected_rows (getTreeSelection()); }
@@ -546,6 +550,8 @@
virtual void selectAll()
{ gtk_icon_view_select_all (GTK_ICON_VIEW (m_widget)); }
+ virtual void unselectAll()
+ { gtk_icon_view_unselect_all (GTK_ICON_VIEW (m_widget)); }
static void packages_selected_cb (GtkIconView *view, View *pThis)
{ pThis->signalSelected(); }
@@ -649,6 +655,9 @@
PkgList getSelected()
{ return m_view->getSelected(); }
+ void unselectAll()
+ { m_view->unselectAll(); }
+
private:
GtkWidget *create_toggle_button (const char **xpm, const char *tooltip, GtkWidget *member)
{
@@ -1773,6 +1782,12 @@
class PackageDetails
{
+public:
+ struct Listener {
+ virtual void goToPackage (Ypp::Package *package) = 0;
+ };
+
+private:
struct TextExpander {
GtkWidget *expander, *text;
@@ -1836,18 +1851,25 @@
GtkWidget *m_widget, *m_description, *m_icon, *m_icon_frame;
TextExpander *m_filelist, *m_changelog, *m_authors;
DepExpander *m_dependencies;
+Listener *m_listener;
public:
+ void setListener (Listener *listener)
+ { m_listener = listener; }
+
GtkWidget *getWidget()
{ return m_widget; }
PackageDetails (bool update_mode)
+ : m_listener (NULL)
{
GtkWidget *vbox;
m_widget = createWhiteViewPort (&vbox);
GtkWidget *hbox = gtk_hbox_new (FALSE, 6);
m_description = ygtk_html_wrap_new();
+ ygtk_html_wrap_connect_link_clicked (m_description,
+ G_CALLBACK (description_pressed_cb), this);
gtk_box_pack_start (GTK_BOX (hbox), m_description, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), createIconWidget (&m_icon, &m_icon_frame),
FALSE, TRUE, 0);
@@ -1925,6 +1947,28 @@
static void path_pressed_cb (GtkWidget *text, const gchar *link)
{ FILEMANAGER_LAUNCH (link); }
+ static void description_pressed_cb (GtkWidget *text, const gchar *link,
+ PackageDetails *pThis)
+ {
+ if (!strncmp (link, "pkg://", 6)) {
+ const gchar *pkg_name = link + 6;
+ yuiMilestone() << "Hyperlinking to package \"" << pkg_name << "\"" << endl;
+ Ypp::Package *pkg = Ypp::get()->findPackage (Ypp::Package::PACKAGE_TYPE, pkg_name);
+ if (pThis->m_listener && pkg)
+ pThis->m_listener->goToPackage (pkg);
+ else {
+ GtkWidget *dialog = gtk_message_dialog_new (YGDialog::currentWindow(),
+ GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK, _("Package '%s' was not found."), pkg_name);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
+ }
+ else
+ yuiError() << "Protocol not supported - can't follow hyperlink \""
+ << link << "\"" << endl;
+ }
+
void scrollTop()
{
GtkScrolledWindow *scroll = GTK_SCROLLED_WINDOW (m_widget);
@@ -2178,7 +2222,8 @@
}
};
-class PackageSelector : public Filters::Listener, public PackagesView::Listener
+class PackageSelector : public Filters::Listener, public PackagesView::Listener,
+ public PackageDetails::Listener
{
PackagesView *m_packages;
Filters *m_filters;
@@ -2202,6 +2247,7 @@
m_changes = new ChangesPane (updateMode);
m_packages->setListener (this);
m_filters->setListener (this);
+ m_details->setListener (this);
GtkWidget *filter_box = gtk_hbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (filter_box), gtk_label_new (_("Filters:")), FALSE, TRUE, 0);
@@ -2270,6 +2316,15 @@
gtk_widget_show (m_details_box);
}
+ virtual void goToPackage (Ypp::Package *package)
+ {
+ m_packages->unselectAll();
+ PkgList list;
+ list.push (package);
+ m_details->setPackages (list);
+ m_control->setPackages (list);
+ }
+
void packageModified (Ypp::Package *package)
{
m_control->packageModified (package);
Modified: trunk/gtk/src/YGUtils.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUtils.cc?rev=47372&r1=47371&r2=47372&view=diff
==============================================================================
--- trunk/gtk/src/YGUtils.cc (original)
+++ trunk/gtk/src/YGUtils.cc Thu May 8 04:31:36 2008
@@ -119,7 +119,8 @@
else
mark = gtk_text_buffer_create_mark (buffer, "scroll", &iter, FALSE);
gtk_text_view_scroll_mark_onscreen (view, mark);
-// gtk_widget_redraw .... // FIXME: package selector change bug
+ // GTK 2.12.9 suffers from glitches otherwise:
+ gtk_widget_queue_draw (GTK_WIDGET (view));
}
void ygutils_scrollAdj (GtkAdjustment *vadj, gboolean top)
Modified: trunk/gtk/src/yzyppwrapper.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/yzyppwrapper.cc?rev=47372&r1=47371&r2=47372&view=diff
==============================================================================
--- trunk/gtk/src/yzyppwrapper.cc (original)
+++ trunk/gtk/src/yzyppwrapper.cc Thu May 8 04:31:36 2008
@@ -143,6 +143,7 @@
const Repository *getRepository (int nb);
const Repository *getRepository (const std::string &zyppId);
+ zypp::RepoInfo getRepoInfo (const Repository *repo);
Disk *getDisk();
// for Packages
@@ -165,6 +166,7 @@
StringTree *categories [Package::TOTAL_TYPES];
GSList *repos;
const Repository *favoriteRepo;
+ int favoriteRepoPriority;
Disk *disk;
Interface *interface;
GSList *pkg_listeners;
@@ -928,9 +930,12 @@
const Ypp::Package::Version *version = package->getAvailableVersion (i);
if (version->repo == *it) {
// filter if available isn't upgrade
- if (package->isInstalled() && hasUpgrade.defined && hasUpgrade.value)
+ if (package->isInstalled() && hasUpgrade.defined && hasUpgrade.value) {
if (version->cmp > 0)
match = true;
+ }
+ else
+ match = true;
break;
}
}
@@ -1305,6 +1310,17 @@
const Ypp::Disk::Partition *Ypp::Disk::getPartition (int nb)
{ return impl->getPartition (nb); }
+Ypp::Package *Ypp::findPackage (Ypp::Package::Type type, const std::string &name)
+{
+ GSList *pool = ypp->impl->getPackages (type);
+ for (GSList *i = pool; i; i = i->next) {
+ Package *pkg = (Package *) i->data;
+ if (pkg->name() == name)
+ return pkg;
+ }
+ return NULL;
+}
+
Ypp::Node *Ypp::getFirstCategory (Ypp::Package::Type type)
{
if (!impl->getPackages (type))
@@ -1434,6 +1450,19 @@
return NULL; /*error*/
}
+zypp::RepoInfo Ypp::Impl::getRepoInfo (const Repository *repo)
+{
+ zypp::RepoManager manager;
+ std::list zypp::RepoInfo zrepos = manager.knownRepositories();
+ for (std::list zypp::RepoInfo::const_iterator it = zrepos.begin();
+ it != zrepos.end(); it++)
+ if (repo->alias == it->alias())
+ return *it;
+ // error
+ zypp::RepoInfo i;
+ return i;
+}
+
Ypp::Disk *Ypp::Impl::getDisk()
{
if (!disk)
@@ -1681,6 +1710,7 @@
Ypp::~Ypp()
{
+ setFavoriteRepository (NULL);
delete impl;
}
@@ -1688,7 +1718,20 @@
{ return impl->getRepository (nb); }
void Ypp::setFavoriteRepository (const Ypp::Repository *repo)
-{ impl->favoriteRepo = repo; }
+{
+ if (impl->favoriteRepo) {
+ zypp::RepoInfo info = impl->getRepoInfo (impl->favoriteRepo);
+ info.setPriority (impl->favoriteRepoPriority);
+ }
+
+ impl->favoriteRepo = repo;
+
+ if (repo) {
+ zypp::RepoInfo info = impl->getRepoInfo (repo);
+ impl->favoriteRepoPriority = info.priority();
+ info.setPriority (1);
+ }
+}
const Ypp::Repository *Ypp::favoriteRepository()
{ return impl->favoriteRepo; }
@@ -1718,16 +1761,6 @@
void Ypp::finishTransactions()
{ impl->finishTransactions(); }
-static Ypp::Package *findPackage (GSList *list, std::string name)
-{
- for (GSList *i = list; i; i = i->next) {
- Ypp::Package *pkg = (Ypp::Package *) i->data;
- if (pkg->impl->zyppSel->name() == name)
- return pkg;
- }
- return NULL;
-}
-
#include <fstream>
#include
@@ -1743,13 +1776,12 @@
it != reader.end(); it++) {
std::string kind = it->kind(), name = it->name();
- GSList *list = 0;
- if (kind == "package")
- list = impl->getPackages (Ypp::Package::PACKAGE_TYPE);
- else if (kind == "pattern")
- list = impl->getPackages (Ypp::Package::PATTERN_TYPE);
+ Package::Type type = Ypp::Package::PACKAGE_TYPE;
+// if (kind == "package")
+ if (kind == "pattern")
+ type = Ypp::Package::PATTERN_TYPE;
- Ypp::Package *pkg = findPackage (list, name);
+ Ypp::Package *pkg = findPackage (type, name);
if (pkg && !pkg->isInstalled())
pkg->install (0);
}
Modified: trunk/gtk/src/yzyppwrapper.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/yzyppwrapper.h?rev=47372&r1=47371&r2=47372&view=diff
==============================================================================
--- trunk/gtk/src/yzyppwrapper.h (original)
+++ trunk/gtk/src/yzyppwrapper.h Thu May 8 04:31:36 2008
@@ -221,6 +221,8 @@
const Repository *favoriteRepository();
// Misc
+ Package *findPackage (Package::Type type, const std::string &name);
+
Node *getFirstCategory (Package::Type type);
struct Disk
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org