Mailinglist Archive: yast-commit (1809 mails)

< Previous Next >
[yast-commit] r58515 - in /trunk/gtk: ChangeLog src/YGPackageSelector.cc src/ygtkwizard.c src/ygtkzyppview.cc src/ygtkzyppview.h src/yzyppwrapper.cc src/yzyppwrapper.h
  • From: rpmcruz@xxxxxxxxxxxxxxxx
  • Date: Fri, 04 Sep 2009 06:27:04 -0000
  • Message-id: <E1MjSGG-0007Im-Rj@xxxxxxxxxxxxxxxx>
Author: rpmcruz
Date: Fri Sep 4 08:27:03 2009
New Revision: 58515

URL: http://svn.opensuse.org/viewcvs/yast?rev=58515&view=rev
Log:
* src/YGPackageSelector.cc: use a common pool for all tabs
so to make it a snap to change tabs.

* src/ygtkzyppview.h/cc: turned Package & Detail views into
GTK widgets so we don't have to bother with mem management.

* src/ygtkwizard.c: gtk_object_destroy() -> g_object_finalize();
not sure what the difference is, but latter seems more used.

* src/yzyppwrapper.h/cc: allow multiple listeners for PkgList.
bug fix: versions on the detail box now reflect any pkg changes.

Modified:
trunk/gtk/ChangeLog
trunk/gtk/src/YGPackageSelector.cc
trunk/gtk/src/ygtkwizard.c
trunk/gtk/src/ygtkzyppview.cc
trunk/gtk/src/ygtkzyppview.h
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=58515&r1=58514&r2=58515&view=diff
==============================================================================
--- trunk/gtk/ChangeLog (original)
+++ trunk/gtk/ChangeLog Fri Sep 4 08:27:03 2009
@@ -1,3 +1,17 @@
+2009-09-04 Ricardo Cruz <rpmcruz@xxxxxxxxxxxxxxxxxxx>
+
+ * src/YGPackageSelector.cc: use a common pool for all tabs
+ so to make it a snap to change tabs.
+
+ * src/ygtkzyppview.h/cc: turned Package & Detail views into
+ GTK widgets so we don't have to bother with mem management.
+
+ * src/ygtkwizard.c: gtk_object_destroy() -> g_object_finalize();
+ not sure what the difference is, but latter seems more used.
+
+ * src/yzyppwrapper.h/cc: allow multiple listeners for PkgList.
+ bug fix: versions on the detail box now reflect any pkg changes.
+
2009-09-03 Ricardo Cruz <rpmcruz@xxxxxxxxxxxxxxxxxxx>

* src/icons/pkg-tiles-mode.xpm & pkg-list-mode.xpm:

Modified: trunk/gtk/src/YGPackageSelector.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGPackageSelector.cc?rev=58515&r1=58514&r2=58515&view=diff
==============================================================================
--- trunk/gtk/src/YGPackageSelector.cc (original)
+++ trunk/gtk/src/YGPackageSelector.cc Fri Sep 4 08:27:03 2009
@@ -365,10 +365,10 @@
{ YGUI::ui()->sendEvent (new YMenuEvent ("repo_mgr")); }
};

-struct Collection : public QueryWidget, PackagesView::Listener
+struct Collection : public QueryWidget, YGtkPackageView::Listener
{
private:
- PackagesView * m_view;
+ YGtkPackageView *m_view;
GtkWidget *m_buttons_box, *m_box;

public:
@@ -377,15 +377,15 @@
Collection (Ypp::Package::Type type)
: QueryWidget()
{
- m_view = new PackagesView (true);
+ m_view = ygtk_package_view_new (TRUE);
m_view->appendIconColumn (NULL, ZyppModel::ICON_COLUMN);
m_view->appendTextColumn (NULL, ZyppModel::NAME_SUMMARY_COLUMN);
if (type == Ypp::Package::LANGUAGE_TYPE)
- m_view->setRows (Ypp::PkgQuery (type, NULL), NULL);
+ m_view->setList (Ypp::PkgQuery (type, NULL), NULL);
else
populateView (m_view, type);
m_view->setListener (this);
- m_view->setFrame (true);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW
(m_view), GTK_SHADOW_IN);

// control buttons
m_buttons_box = gtk_alignment_new (0, 0, 0, 0);
@@ -400,20 +400,17 @@

// layout
m_box = gtk_vbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (m_box), m_view->getWidget(), TRUE,
TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (m_box), GTK_WIDGET (m_view), TRUE,
TRUE, 0);
gtk_box_pack_start (GTK_BOX (m_box), m_buttons_box, FALSE,
TRUE, 0);
}

- virtual ~Collection()
- { delete m_view; }
-
- static void populateView (PackagesView *view, Ypp::Package::Type type)
+ static void populateView (YGtkPackageView *view, Ypp::Package::Type
type)
{ // list 1D categories intertwined with its constituent packages
Ypp::Node *category = Ypp::get()->getFirstCategory (type);
for (; category; category = category->next()) {
Ypp::PkgQuery::Query *query = new
Ypp::PkgQuery::Query();
query->addCategory (category);
- view->appendRows (category->name.c_str(), Ypp::PkgQuery
(type, query), NULL);
+ view->appendList (category->name.c_str(), Ypp::PkgQuery
(type, query), NULL);
}
}

@@ -549,7 +546,7 @@
GtkRadioButton *radiob = GTK_RADIO_BUTTON (m_radio[0]);
m_radio[1] = gtk_radio_button_new_with_label_from_widget
(radiob, _("Description"));
m_radio[2] = gtk_radio_button_new_with_label_from_widget
(radiob, _("File name"));
- gtk_widget_set_tooltip_markup (m_radio[2],
+ gtk_widget_set_tooltip_text (m_radio[2],
_("Only applicable to installed packages."));
if (m_onlineUpdate)
m_radio[3] = NULL;
@@ -774,7 +771,8 @@
private:
void set (GtkWidget *widget)
{
- gtk_container_remove (GTK_CONTAINER (m_bin), GTK_BIN
(m_bin)->child);
+ if (GTK_BIN (m_bin)->child)
+ gtk_container_remove (GTK_CONTAINER (m_bin), GTK_BIN
(m_bin)->child);
gtk_container_add (GTK_CONTAINER (m_bin), widget);
gtk_widget_show_all (m_bin);
}
@@ -890,7 +888,7 @@
public:
GtkWidget *getWidget() { return m_vbox; }

- UndoView (PackagesView::Listener *listener)
+ UndoView (YGtkPackageView::Listener *listener)
{
Ypp::PkgQuery::Query *query = new Ypp::PkgQuery::Query();
query->setToModify (true);
@@ -903,6 +901,7 @@
gtk_button_set_image (GTK_BUTTON (uncouple_button), icon);
GtkWidget *uncouple_align = gtk_alignment_new (1, .5, 0, 1);
gtk_container_add (GTK_CONTAINER (uncouple_align),
uncouple_button);
+ gtk_widget_set_tooltip_text (uncouple_button, _("Open in new
window"));
g_signal_connect (G_OBJECT (uncouple_button), "clicked",
G_CALLBACK (uncouple_clicked_cb), this);

@@ -918,7 +917,7 @@
{ g_object_unref (m_vbox); }

private:
- static GtkWidget *createView (const Ypp::PkgList changes,
PackagesView::Listener *listener)
+ static GtkWidget *createView (const Ypp::PkgList changes,
YGtkPackageView::Listener *listener)
{
GtkWidget *hbox = gtk_hbox_new (TRUE, 6);
for (int i = 0; i < 3; i++) {
@@ -957,18 +956,17 @@
label_box = gtk_hbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (label_box), icon, FALSE,
TRUE, 0);
gtk_box_pack_start (GTK_BOX (label_box), label, TRUE,
TRUE, 0);
- PackagesView *view = new PackagesView (true);
+ YGtkPackageView *view = ygtk_package_view_new (TRUE);
view->appendCheckColumn (checkCol);
view->appendTextColumn (NULL, ZyppModel::NAME_COLUMN);
- view->setRows (list, NULL);
- view->setFrame (true);
+ view->setList (list, NULL);
view->setListener (listener);
- // PackagesView is not a GtkWidget, we need to destroy
it:
- g_object_set_data_full (G_OBJECT (label_box), "view",
view, delete_pkgview);
+ gtk_scrolled_window_set_shadow_type (
+ GTK_SCROLLED_WINDOW (view), GTK_SHADOW_IN);

GtkWidget *box = gtk_vbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (box), label_box, FALSE,
TRUE, 0);
- gtk_box_pack_start (GTK_BOX (box), view->getWidget(),
TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (view),
TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), box, TRUE, TRUE, 0);
}
return hbox;
@@ -993,9 +991,6 @@
gtk_widget_show_all (dialog);
}

- static void delete_pkgview (gpointer data)
- { delete (PackagesView *) data; }
-
static gboolean uncouple_delete_event_cb (
GtkWidget *widget, GdkEvent *event, UndoView *pThis)
{
@@ -1010,38 +1005,35 @@
}
};

-class QueryNotebook : public QueryListener, PackagesView::Listener
+class QueryNotebook : public QueryListener, YGtkPackageView::Listener
{
GtkWidget *m_widget, *m_notebook;
bool m_onlineUpdate;
-PackagesView *m_view;
FilterCombo *m_combo;
-PackageDetails *m_details;
+YGtkDetailView *m_details;
FlexPane *m_pane;
GtkWidget *m_oldPage;
-UndoView *m_undoView;
guint m_timeout_id;
bool m_disabledTab, m_highlightTab;
+UndoView *m_undoView;
+Ypp::PkgList m_packages, m_pool;

public:
GtkWidget *getWidget() { return m_widget; }

QueryNotebook (bool onlineUpdate, bool repoMgrEnabled)
- : m_onlineUpdate (onlineUpdate), m_view (NULL), m_timeout_id (0),
- m_disabledTab (true), m_highlightTab (false)
+ : m_onlineUpdate (onlineUpdate), m_timeout_id (0), m_disabledTab
(true), m_highlightTab (false)
{
m_notebook = gtk_notebook_new();
- appendPage (m_notebook, _("_Install"), GTK_STOCK_ADD, 0, NULL);
+ appendPage (0, _("_Install"), GTK_STOCK_ADD);
if (!onlineUpdate)
- appendPage (m_notebook, _("_Upgrade"), GTK_STOCK_GO_UP,
1, NULL);
- appendPage (m_notebook, _("_Remove"), GTK_STOCK_REMOVE, 2,
NULL);
- if (!onlineUpdate) {
- m_undoView = new UndoView (this);
- appendPage (m_notebook, _("_Undo"), GTK_STOCK_UNDO, 3,
m_undoView->getWidget());
- }
+ appendPage (1, _("_Upgrade"), GTK_STOCK_GO_UP);
+ appendPage (2, _("_Remove"), GTK_STOCK_REMOVE);
+ if (!onlineUpdate)
+ appendPage (3, _("_Undo"), GTK_STOCK_UNDO);
gtk_widget_show (m_notebook);
- g_signal_connect_after (G_OBJECT (m_notebook), "switch-page",
- G_CALLBACK (switch_page_cb), this);
+ g_signal_connect (G_OBJECT (m_notebook), "switch-page",
+ G_CALLBACK (switch_page_cb), this);

#if 0 // test: put search entry as a new tab (since we can't make use of the
empty space...)
GtkWidget *entry = ygtk_find_entry_new();
@@ -1049,12 +1041,15 @@
GtkWidget *page = gtk_event_box_new();
gtk_widget_show (page);
gtk_notebook_append_page (GTK_NOTEBOOK (m_notebook), page,
entry);
+ gtk_notebook_set_tab_label_packing (
+ GTK_NOTEBOOK (m_notebook), page, TRUE, TRUE,
GTK_PACK_START);
+ g_object_set (G_OBJECT (m_notebook), "tab-vborder", 0, NULL);
#endif

- m_details = new PackageDetails (onlineUpdate);
+ m_details = YGTK_DETAIL_VIEW (ygtk_detail_view_new
(onlineUpdate));
m_pane = new FlexPane();
m_pane->pack (m_notebook, true, false);
- m_pane->pack (m_details->getWidget(), false, false);
+ m_pane->pack (GTK_WIDGET (m_details), false, false);
m_pane->setPosition (-175, -500);

m_combo = new FilterCombo (this, onlineUpdate, repoMgrEnabled);
@@ -1065,8 +1060,12 @@

m_widget = hpane;
gtk_widget_show_all (m_widget);
- gtk_widget_hide (m_details->getWidget());
- m_oldPage = gtk_notebook_get_nth_page (GTK_NOTEBOOK
(m_notebook), 0);
+ gtk_widget_hide (GTK_WIDGET (m_details));
+
+ Ypp::Package::Type type = Ypp::Package::PACKAGE_TYPE;
+ if (m_onlineUpdate)
+ type = Ypp::Package::PATCH_TYPE;
+ m_packages = Ypp::get()->getPackages (type);
queryNotify();
}

@@ -1074,11 +1073,9 @@
{
if (m_timeout_id)
g_source_remove (m_timeout_id);
- delete m_view;
+ delete m_undoView;
delete m_combo;
- delete m_details;
delete m_pane;
- delete m_undoView;
}

void setUndoPage()
@@ -1088,12 +1085,11 @@
}

private:
- static void appendPage (GtkWidget *notebook, const char *text, const
char *stock_icon,
- int nb, GtkWidget *child)
+ void appendPage (int nb, const char *text, const char *stock)
{
GtkWidget *hbox = gtk_hbox_new (FALSE, 6), *label, *icon;
- if (stock_icon) {
- icon = gtk_image_new_from_stock (stock_icon,
GTK_ICON_SIZE_MENU);
+ if (stock) {
+ icon = gtk_image_new_from_stock (stock,
GTK_ICON_SIZE_MENU);
gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, TRUE,
0);
}
label = gtk_label_new (text);
@@ -1102,12 +1098,42 @@
g_object_set_data (G_OBJECT (hbox), "label", label);
gtk_widget_show_all (hbox);

- GtkWidget *page = child;
- if (!page) page = gtk_event_box_new();
- gtk_widget_show (page);
- g_object_set_data (G_OBJECT (page), "nb", GINT_TO_POINTER (nb));
+ GtkWidget *page;
+ if (nb < 3) {
+ int col;
+ switch (nb) {
+ default:
+ case 0: col = ZyppModel::TO_INSTALL_COLUMN;
break;
+ case 1: col = ZyppModel::TO_UPGRADE_COLUMN;
break;
+ case 2: col = ZyppModel::TO_REMOVE_COLUMN;
break;
+ }
+ YGtkPackageView *view = ygtk_package_view_new (FALSE);
+ view->appendCheckColumn (col);
+ int nameSize = (col == ZyppModel::TO_UPGRADE_COLUMN) ?
-1 : 150;
+ view->appendTextColumn (_("Name"),
ZyppModel::NAME_COLUMN, nameSize);
+ if (col == ZyppModel::TO_UPGRADE_COLUMN) {
+ view->appendTextColumn (_("Installed"),
ZyppModel::INSTALLED_VERSION_COLUMN, 150);
+ view->appendTextColumn (_("Available"),
ZyppModel::AVAILABLE_VERSION_COLUMN, 150);
+ }
+ else
+ view->appendTextColumn (_("Summary"),
ZyppModel::SUMMARY_COLUMN);
+ view->setListener (this);
+ page = GTK_WIDGET (view);
+ }
+ else {
+ m_undoView = new UndoView (this);
+ page = m_undoView->getWidget();
+ }
+ gtk_notebook_append_page (GTK_NOTEBOOK (m_notebook), page,
hbox);
+ }

- gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, hbox);
+ void setTabLabelWeight (int page, PangoWeight weight)
+ {
+ GtkNotebook *notebook = GTK_NOTEBOOK (m_notebook);
+ GtkWidget *label = gtk_notebook_get_tab_label (notebook,
+ gtk_notebook_get_nth_page (notebook, page));
+ label = (GtkWidget *) g_object_get_data (G_OBJECT (label),
"label");
+ YGUtils::setWidgetFont (label, PANGO_STYLE_NORMAL, weight,
PANGO_SCALE_MEDIUM);
}

const char *getTooltip (int page)
@@ -1124,136 +1150,84 @@
return NULL;
}

- void clearPage()
+ void setEnabled (int page_nb, bool enabled, int new_page_nb = -1)
{
- if (m_oldPage)
- gtk_container_remove (GTK_CONTAINER (m_oldPage),
GTK_BIN (m_oldPage)->child);
- delete m_view;
- m_view = NULL;
- }
-
- static void switch_page_cb (GtkNotebook *notebook, GtkNotebookPage *,
- guint nb, QueryNotebook *pThis)
- {
- pThis->clearPage();
- pThis->m_oldPage = gtk_notebook_get_nth_page (notebook, nb);
- pThis->queryNotify();
- }
-
- int selectedPage()
- {
- int nb = gtk_notebook_get_current_page (GTK_NOTEBOOK
(m_notebook));
- GtkWidget *page = gtk_notebook_get_nth_page (GTK_NOTEBOOK
(m_notebook), nb);
- return GPOINTER_TO_INT (g_object_get_data (G_OBJECT (page),
"nb"));
- }
-
- Ypp::PkgQuery getQuery (int page)
- {
- Ypp::Package::Type type =
- m_onlineUpdate ? Ypp::Package::PATCH_TYPE :
Ypp::Package::PACKAGE_TYPE;
- Ypp::PkgList list (Ypp::get()->getPackages (type));
-
- Ypp::PkgQuery::Query *query = new Ypp::PkgQuery::Query();
- switch (page) {
- case 0: // available
- if (m_onlineUpdate)
- // special pane for patches upgrades
makes little sense, so
- // we instead list them together with
availables
- query->setHasUpgrade (true);
- query->setIsInstalled (false);
- break;
- case 1: // upgrades
- query->setHasUpgrade (true);
- break;
- case 2: // installed
- query->setIsInstalled (true);
- break;
- default: break;
+ GtkNotebook *notebook = GTK_NOTEBOOK (m_notebook);
+ GtkWidget *page = gtk_notebook_get_nth_page (notebook, page_nb);
+ if (page) {
+ GtkWidget *label = gtk_notebook_get_tab_label
(notebook, page);
+ gtk_widget_set_sensitive (label, enabled);
+ const char *tooltip = getTooltip (page_nb);
+ if (!enabled)
+ tooltip = _("Query only applicable to available
packages.");
+ gtk_widget_set_tooltip_text (label, tooltip);
+ if (!enabled && new_page_nb >= 0) {
+ GtkWidget *selected = gtk_notebook_get_nth_page
(notebook,
+ gtk_notebook_get_current_page
(notebook));
+ if (selected == page)
+ gtk_notebook_set_current_page
(notebook, new_page_nb);
+ }
}
-
- m_combo->writeQuery (query);
- return Ypp::PkgQuery (list, query);
}

virtual void queryNotify()
{
if (m_disabledTab) { // limit users to the tabs whose query is
applicable
m_disabledTab = false;
- GList *pages = gtk_container_get_children
(GTK_CONTAINER (m_notebook));
- int p = 0;
- for (GList *i = pages; i; i = i->next, p++) {
- GtkWidget *label, *page = (GtkWidget *) i->data;
- label = gtk_notebook_get_tab_label
(GTK_NOTEBOOK (m_notebook), page);
- gtk_widget_set_sensitive (label, TRUE);
- gtk_widget_set_tooltip_text (label, getTooltip
(p));
- }
- g_list_free (pages);
+ for (int i = 0; i < 4; i++)
+ setEnabled (i, true);
}
if (m_combo->availablePackagesOnly()) {
- int selected = gtk_notebook_get_current_page
(GTK_NOTEBOOK (m_notebook));
- if (selected > 0 && selected < 3) {
- gtk_notebook_set_current_page (GTK_NOTEBOOK
(m_notebook), 0);
- return;
- }
-
- GList *pages = gtk_container_get_children
(GTK_CONTAINER (m_notebook));
- for (GList *i = pages->next; i->next; i = i->next) {
- GtkWidget *label, *page = (GtkWidget *) i->data;
- label = gtk_notebook_get_tab_label
(GTK_NOTEBOOK (m_notebook), page);
- gtk_widget_set_sensitive (label, FALSE);
- gtk_widget_set_tooltip_text (label, _("Query
only applicable to available packages."));
- }
- g_list_free (pages);
+ setEnabled (1, false);
+ if (!m_onlineUpdate)
+ setEnabled (2, false, 0);
m_disabledTab = true;
}
else if (m_combo->installedPackagesOnly()) {
- int selected = gtk_notebook_get_current_page
(GTK_NOTEBOOK (m_notebook));
- if (selected == 0) {
- gtk_notebook_set_current_page (
- GTK_NOTEBOOK (m_notebook),
m_onlineUpdate ? 1 : 2);
- return;
- }
- GtkWidget *label, *page;
- page = gtk_notebook_get_nth_page (GTK_NOTEBOOK
(m_notebook), 0);
- label = gtk_notebook_get_tab_label (GTK_NOTEBOOK
(m_notebook), page);
- gtk_widget_set_sensitive (label, FALSE);
- gtk_widget_set_tooltip_text (label, _("Query only
applicable to installed packages."));
+ int new_page = m_onlineUpdate ? 1 : 2;
+ setEnabled (0, false, new_page);
m_disabledTab = true;
}

- int page = selectedPage();
- if (page == 3) {
- gtk_container_add (GTK_CONTAINER (m_oldPage),
m_undoView->getWidget());
- return;
+ GtkNotebook *notebook = GTK_NOTEBOOK (m_notebook);
+ for (int i = 0; i < 3; i++) {
+ GtkWidget *page = gtk_notebook_get_nth_page (notebook,
i);
+ if (page) YGTK_PACKAGE_VIEW (page)->clear();
}

- if (!m_view) {
- int col;
- switch (page) {
- default:
- case 0: col = ZyppModel::TO_INSTALL_COLUMN;
break;
- case 1: col = ZyppModel::TO_UPGRADE_COLUMN;
break;
- case 2: col = ZyppModel::TO_REMOVE_COLUMN;
break;
- }
- m_view = new PackagesView (false);
- m_view->appendCheckColumn (col);
- int nameSize = (col == ZyppModel::TO_UPGRADE_COLUMN) ?
-1 : 150;
- m_view->appendTextColumn (_("Name"),
ZyppModel::NAME_COLUMN, nameSize);
- if (col == ZyppModel::TO_UPGRADE_COLUMN) {
- m_view->appendTextColumn (_("Installed"),
ZyppModel::INSTALLED_VERSION_COLUMN, 150);
- m_view->appendTextColumn (_("Available"),
ZyppModel::AVAILABLE_VERSION_COLUMN, 150);
+ Ypp::PkgQuery::Query *query = new Ypp::PkgQuery::Query();
+ m_combo->writeQuery (query);
+ m_pool = Ypp::PkgQuery (m_packages, query);
+
+ for (int i = 0; i < 3; i++) {
+ GtkWidget *page = gtk_notebook_get_nth_page (notebook,
i);
+ if (page) {
+ YGtkPackageView *view = YGTK_PACKAGE_VIEW
(page);
+ Ypp::PkgQuery::Query *query = new
Ypp::PkgQuery::Query();
+ switch (i) {
+ case 0: // available
+ if (m_onlineUpdate)
+ // special pane for
patches upgrades makes little sense, so
+ // we instead list them
together with availables
+ query->setHasUpgrade
(true);
+ query->setIsInstalled (false);
+ break;
+ case 1: // upgrades
+ query->setHasUpgrade (true);
+ break;
+ case 2: // installed
+ query->setIsInstalled (true);
+ break;
+ default: break;
+ }
+ Ypp::PkgQuery list (m_pool, query);
+ const char *applyAll = NULL;
+ if (!m_onlineUpdate && i == 1)
+ applyAll = _("Upgrade All");
+ view->setList (list, applyAll);
}
- else
- m_view->appendTextColumn (_("Summary"),
ZyppModel::SUMMARY_COLUMN);
- m_view->setListener (this);
- gtk_container_add (GTK_CONTAINER (m_oldPage),
m_view->getWidget());
}

- // set query
- m_view->clear();
- const char *applyAll = page == 1 ? _("Upgrade All") : 0;
- m_view->setRows (getQuery (page), applyAll);
-
if (!m_onlineUpdate) {
// set tab label bold if there's a package there with
the name
if (m_highlightTab) {
@@ -1300,16 +1274,28 @@
{
m_details->setPackages (packages);
if (packages.size() > 0)
- gtk_widget_show (m_details->getWidget());
+ gtk_widget_show (GTK_WIDGET (m_details));
}

- void setTabLabelWeight (int page, PangoWeight weight)
- {
- GtkNotebook *notebook = GTK_NOTEBOOK (m_notebook);
- GtkWidget *label = gtk_notebook_get_tab_label (notebook,
- gtk_notebook_get_nth_page (notebook, page));
- label = (GtkWidget *) g_object_get_data (G_OBJECT (label),
"label");
- YGUtils::setWidgetFont (label, PANGO_STYLE_NORMAL, weight,
PANGO_SCALE_MEDIUM);
+ static void switch_page_cb (GtkNotebook *notebook, GtkNotebookPage *,
+ gint page_nb, QueryNotebook *pThis)
+ { // don't let user selected insensitive tab
+ GtkWidget *page = gtk_notebook_get_nth_page (notebook, page_nb);
+ GtkWidget *label = gtk_notebook_get_tab_label (notebook, page);
+ if (!GTK_WIDGET_IS_SENSITIVE (label)) { // change back to
current page
+ int page_nb = gtk_notebook_get_current_page (notebook);
+ // seems like GTK doesn't like changing current page
here
+ g_object_set_data (G_OBJECT (notebook), "to-page",
GINT_TO_POINTER (page_nb));
+ g_idle_add_full (G_PRIORITY_HIGH_IDLE,
change_page_idle_cb, notebook, NULL);
+ }
+ }
+
+ static gboolean change_page_idle_cb (gpointer data)
+ {
+ GtkNotebook *notebook = (GtkNotebook *) data;
+ int page_nb = GPOINTER_TO_INT (g_object_get_data (G_OBJECT
(notebook), "to-page"));
+ gtk_notebook_set_current_page (notebook, page_nb);
+ return FALSE;
}
};

@@ -1647,12 +1633,13 @@
gtk_window_set_default_size (GTK_WINDOW (dialog), -1, 480);
gtk_widget_show_all (dialog);

- PackagesView *view = new PackagesView (false);
+ YGtkPackageView *view = ygtk_package_view_new (TRUE);
view->appendCheckColumn (ZyppModel::TO_INSTALL_COLUMN);
view->appendTextColumn (_("Name"), ZyppModel::NAME_COLUMN, 150);
view->appendTextColumn (extraColTitle, extraCol);
- view->setRows (list, NULL);
- gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
view->getWidget());
+ view->setList (list, NULL);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (view),
GTK_SHADOW_IN);
+ gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
GTK_WIDGET (view));

bool confirm = (gtk_dialog_run (GTK_DIALOG (dialog)) ==
GTK_RESPONSE_YES);
gtk_widget_destroy (dialog);

Modified: trunk/gtk/src/ygtkwizard.c
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkwizard.c?rev=58515&r1=58514&r2=58515&view=diff
==============================================================================
--- trunk/gtk/src/ygtkwizard.c (original)
+++ trunk/gtk/src/ygtkwizard.c Fri Sep 4 08:27:03 2009
@@ -670,10 +670,8 @@
*hash = NULL;
}

-static void ygtk_wizard_destroy (GtkObject *object)
+static void ygtk_wizard_finalize (GObject *object)
{
- GTK_OBJECT_CLASS (ygtk_wizard_parent_class)->destroy (object);
-
YGtkWizard *wizard = YGTK_WIZARD (object);
wizard->help_button = NULL; // dialog unmap will try to access this
destroy_hash (&wizard->menu_ids, FALSE);
@@ -683,6 +681,7 @@
ygtk_help_text_destroy (wizard->m_help);
wizard->m_help = NULL;
}
+ G_OBJECT_CLASS (ygtk_wizard_parent_class)->finalize (object);
}

GtkWidget *ygtk_wizard_new (void)
@@ -1080,8 +1079,8 @@
widget_class->realize = ygtk_wizard_realize;
widget_class->map = ygtk_wizard_map;

- GtkObjectClass *gtkobject_class = GTK_OBJECT_CLASS (klass);
- gtkobject_class->destroy = ygtk_wizard_destroy;
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = ygtk_wizard_finalize;

action_triggered_signal = g_signal_new ("action-triggered",
G_TYPE_FROM_CLASS (G_OBJECT_CLASS (klass)), G_SIGNAL_RUN_LAST,

Modified: trunk/gtk/src/ygtkzyppview.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkzyppview.cc?rev=58515&r1=58514&r2=58515&view=diff
==============================================================================
--- trunk/gtk/src/ygtkzyppview.cc (original)
+++ trunk/gtk/src/ygtkzyppview.cc Fri Sep 4 08:27:03 2009
@@ -163,7 +163,7 @@
void append (const std::string &header, Ypp::PkgList list, const
std::string &applyAllLabel)
{
block.segments.push_back (Block::Segment (&block, header, list,
applyAllLabel));
- list.setListener (this);
+ list.addListener (this);
}

protected:
@@ -564,16 +564,14 @@

//** View

-struct PackagesView::Impl
+struct YGtkPackageView::Impl
{
- Impl (bool descriptiveTooltip)
+ Impl (GtkWidget *scroll, bool descriptiveTooltip)
: m_listener (NULL), m_popup_hack (NULL), m_descriptiveTooltip
(descriptiveTooltip),
m_model (NULL), m_modelId (0)
{
- m_scroll = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (m_scroll),
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- g_object_ref_sink (G_OBJECT (m_scroll));

GtkTreeView *view = GTK_TREE_VIEW (m_view =
ygtk_tree_view_new());
gtk_tree_view_set_search_column (view, ZyppModel::NAME_COLUMN);
@@ -595,28 +593,27 @@
g_signal_connect (G_OBJECT (m_view), "query-tooltip",
G_CALLBACK (query_tooltip_cb), this);

- gtk_container_add (GTK_CONTAINER (m_scroll), m_view);
- gtk_widget_show_all (m_scroll);
+ gtk_container_add (GTK_CONTAINER (scroll), m_view);
+ gtk_widget_show_all (scroll);
clear();
}

~Impl()
{
if (m_popup_hack) gtk_widget_destroy (m_popup_hack);
- g_object_unref (G_OBJECT (m_scroll));
if (m_model)
g_object_unref (G_OBJECT (m_model));
}

// data
- PackagesView::Listener *m_listener;
- GtkWidget *m_scroll, *m_view, *m_popup_hack;
+ YGtkPackageView::Listener *m_listener;
+ GtkWidget *m_view, *m_popup_hack;
bool m_descriptiveTooltip;
GtkTreeModel *m_model;
guint m_modelId;

// methods
- void setRows (Ypp::PkgList list, const char *applyAllLabel)
+ void setList (Ypp::PkgList list, const char *applyAllLabel)
{
std::string _applyAllLabel = applyAllLabel ? applyAllLabel : "";
if (m_model)
@@ -625,9 +622,11 @@
ygtk_zypp_model_append (m_model, std::string (""), list,
_applyAllLabel);
GtkTreeView *view = GTK_TREE_VIEW (m_view);
gtk_tree_view_set_model (view, m_model);
+ if (GTK_WIDGET_REALIZED (view))
+ gtk_tree_view_scroll_to_point (view, -1, 0);
}

- void appendRows (const char *header, Ypp::PkgList list, const char
*applyAllLabel)
+ void appendList (const char *header, Ypp::PkgList list, const char
*applyAllLabel)
{
std::string _header = header ? header : "";
std::string _applyAllLabel = applyAllLabel ? applyAllLabel : "";
@@ -1003,52 +1002,62 @@
}
};

-PackagesView::PackagesView (bool descriptiveTooltip)
-: impl (new Impl (descriptiveTooltip))
+G_DEFINE_TYPE (YGtkPackageView, ygtk_package_view, GTK_TYPE_SCROLLED_WINDOW)
+
+static void ygtk_package_view_init (YGtkPackageView *view)
{}

-PackagesView::~PackagesView()
-{ delete impl; }
+YGtkPackageView *ygtk_package_view_new (gboolean descriptiveTooltip)
+{
+ YGtkPackageView *view = (YGtkPackageView *) g_object_new
(YGTK_TYPE_PACKAGE_VIEW, NULL);
+ view->impl = new YGtkPackageView::Impl (GTK_WIDGET (view),
descriptiveTooltip);
+ return view;
+}

-GtkWidget *PackagesView::getWidget()
-{ return impl->m_scroll; }
+static void ygtk_package_view_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (ygtk_package_view_parent_class)->finalize (object);
+ YGtkPackageView *view = YGTK_PACKAGE_VIEW (object);
+ delete view->impl;
+ view->impl = NULL;
+}
+
+static void ygtk_package_view_class_init (YGtkPackageViewClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = ygtk_package_view_finalize;
+}

-void PackagesView::setRows (Ypp::PkgList list, const char *applyAllLabel)
-{ impl->setRows (list, applyAllLabel); }
+void YGtkPackageView::setList (Ypp::PkgList list, const char *applyAllLabel)
+{ impl->setList (list, applyAllLabel); }

-void PackagesView::appendRows (const char *header, Ypp::PkgList list, const
char *applyAllLabel)
-{ impl->appendRows (header, list, applyAllLabel); }
+void YGtkPackageView::appendList (const char *header, Ypp::PkgList list, const
char *applyAllLabel)
+{ impl->appendList (header, list, applyAllLabel); }

-void PackagesView::clear()
+void YGtkPackageView::clear()
{ impl->clear(); }

-void PackagesView::appendIconColumn (const char *header, int col)
+void YGtkPackageView::appendIconColumn (const char *header, int col)
{ impl->appendIconColumn (header, col); }

-void PackagesView::appendCheckColumn (int col)
+void YGtkPackageView::appendCheckColumn (int col)
{ impl->appendCheckColumn (col); }

-void PackagesView::appendTextColumn (const char *header, int col, int size)
+void YGtkPackageView::appendTextColumn (const char *header, int col, int size)
{ impl->appendTextColumn (header, col, size); }

-void PackagesView::setFrame (bool show)
-{
- GtkShadowType shadow = show ? GTK_SHADOW_IN : GTK_SHADOW_NONE;
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW
(impl->m_scroll), shadow);
-}
-
-void PackagesView::setListener (Listener *listener)
+void YGtkPackageView::setListener (Listener *listener)
{ impl->m_listener = listener; }

-Ypp::PkgList PackagesView::getSelected()
+Ypp::PkgList YGtkPackageView::getSelected()
{ return impl->getSelected(); }

//** Detail & control

-class PackageDetails::Impl
+class YGtkDetailView::Impl
{
private:
- struct Versions {
+ struct Versions : public Ypp::PkgList::Listener {
GtkWidget *m_box, *m_versions_box, *m_button, *m_undo_button;
Ypp::PkgList m_packages; // we keep a copy to test against
modified...

@@ -1066,6 +1075,7 @@
m_undo_button = gtk_button_new_with_label ("");
gtk_button_set_image (GTK_BUTTON (m_undo_button),
gtk_image_new_from_stock (GTK_STOCK_UNDO,
GTK_ICON_SIZE_BUTTON));
+ gtk_widget_set_tooltip_text (m_undo_button, _("Undo"));
g_signal_connect (G_OBJECT (m_undo_button), "clicked",
G_CALLBACK (undo_clicked_cb), this);
GtkWidget *button_box = gtk_hbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (button_box),
gtk_label_new(""), TRUE, TRUE, 0);
@@ -1078,10 +1088,15 @@
gtk_box_pack_start (GTK_BOX (m_box), button_box, FALSE,
TRUE, 0);
}

+ ~Versions()
+ { m_packages.removeListener (this); }
+
void setPackages (Ypp::PkgList packages)
{
+ m_packages.removeListener (this);
m_packages = packages;
m_packages.refreshProps();
+ m_packages.addListener (this);

GList *children = gtk_container_get_children
(GTK_CONTAINER (m_versions_box));
for (GList *i = children; i; i = i->next)
@@ -1183,6 +1198,13 @@
}

private:
+ virtual void entryChanged (const Ypp::PkgList list, int index,
Ypp::Package *package)
+ { setPackages (m_packages); /* refresh */ }
+
+ // won't happen:
+ virtual void entryInserted (const Ypp::PkgList list, int index,
Ypp::Package *package) {}
+ virtual void entryDeleted (const Ypp::PkgList list, int index,
Ypp::Package *package) {}
+
static gboolean draw_gray_cb (GtkWidget *widget, GdkEventExpose
*event, Versions *pThis)
{
GtkAllocation *alloc = &widget->allocation;
@@ -1308,41 +1330,26 @@
else if (pThis->m_packages.modified())
pThis->m_packages.undo();
}
- pThis->setPackages (pThis->m_packages); // refresh
}

static void undo_clicked_cb (GtkButton *button, Versions *pThis)
{
pThis->m_packages.undo();
- pThis->setPackages (pThis->m_packages); // refresh
- }
-
-#if 0
- void packageModified (Ypp::Package *package)
- {
- // GTK+ doesn't fire selection change when a selected
row changes, so we need
- // to re-load Versions in that occasions.
- if (m_packages.contains (package)) {
- m_packages.clearCache();
- setPackages (m_packages);
- }
}
-#endif
};

-GtkWidget *m_widget, *m_icon, *m_icon_frame, *m_description, *m_filelist,
*m_changelog,
+GtkWidget *m_scroll, *m_icon, *m_icon_frame, *m_description, *m_filelist,
*m_changelog,
*m_authors, *m_support, *m_requires, *m_provides;
Versions *m_versions;
-PackagesView *m_contents;
+YGtkPackageView *m_contents;

public:
- GtkWidget *getWidget() { return m_widget; }
-
- Impl (bool onlineUpdate)
+ Impl (GtkWidget *scroll, bool onlineUpdate)
{
+ m_scroll = scroll;
m_versions = new Versions();
GtkWidget *hbox = gtk_hbox_new (FALSE, 2);
- m_widget = createWhiteViewPort (hbox);
+ setupScrollAsWhite (scroll, hbox);

GtkWidget *versions_box = gtk_vbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (versions_box),
@@ -1377,10 +1384,10 @@
}
else {
m_filelist = m_changelog = m_authors = m_support =
m_requires = m_provides = NULL;
- m_contents = new PackagesView (false);
+ m_contents = ygtk_package_view_new (false);
m_contents->appendTextColumn (_("Name"),
ZyppModel::NAME_COLUMN, 150);
m_contents->appendTextColumn (_("Summary"),
ZyppModel::SUMMARY_COLUMN);
- appendExpander (vbox, _("Applies to"),
m_contents->getWidget());
+ appendExpander (vbox, _("Applies to"), GTK_WIDGET
(m_contents));
}

gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
@@ -1389,10 +1396,7 @@
}

~Impl()
- {
- delete m_contents;
- delete m_versions;
- }
+ { delete m_versions; }

void setPackages (Ypp::PkgList packages)
{
@@ -1430,8 +1434,7 @@
if (m_contents) { // patches -- "apply to"
Ypp::PkgQuery::Query *query = new
Ypp::PkgQuery::Query();
query->addCollection (package);
- m_contents->clear();
- m_contents->appendRows (0, Ypp::PkgQuery
(Ypp::Package::PACKAGE_TYPE, query), 0);
+ m_contents->setList (Ypp::PkgQuery
(Ypp::Package::PACKAGE_TYPE, query), 0);
}

gtk_image_clear (GTK_IMAGE (m_icon));
@@ -1461,7 +1464,8 @@
if (m_requires) setText (m_requires, "");
if (m_provides) setText (m_provides, "");
if (m_contents) {
- gtk_widget_hide (gtk_widget_get_ancestor
(m_contents->getWidget(), GTK_TYPE_EXPANDER));
+ gtk_widget_hide (gtk_widget_get_ancestor (
+ GTK_WIDGET (m_contents),
GTK_TYPE_EXPANDER));
m_contents->clear();
}
}
@@ -1480,7 +1484,7 @@
private:
void scrollTop()
{
- GtkScrolledWindow *scroll = GTK_SCROLLED_WINDOW (m_widget);
+ GtkScrolledWindow *scroll = GTK_SCROLLED_WINDOW (m_scroll);
YGUtils::scrollWidget (gtk_scrolled_window_get_vadjustment
(scroll), true);
}

@@ -1503,7 +1507,8 @@
*icon_frame = align;
return align;
}
- static GtkWidget *createWhiteViewPort (GtkWidget *box)
+
+ static void setupScrollAsWhite (GtkWidget *scroll, GtkWidget *box)
{
struct inner {
static gboolean expose_cb (GtkWidget *widget,
GdkEventExpose *event)
@@ -1521,12 +1526,11 @@

g_signal_connect (G_OBJECT (box), "expose-event",
G_CALLBACK (inner::expose_cb), NULL);
- GtkWidget *scroll = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW
(scroll), box);
- return scroll;
}
+
static void appendExpander (GtkWidget *box, const char *label,
GtkWidget *child)
{
std::string str = std::string ("<b>") + label + "</b>";
@@ -1535,6 +1539,7 @@
gtk_container_add (GTK_CONTAINER (expander), child);
gtk_box_pack_start (GTK_BOX (box), expander, FALSE, TRUE, 0);
}
+
static void setText (GtkWidget *text, const std::string &str)
{
ygtk_rich_text_set_text (YGTK_RICH_TEXT (text), str.c_str(),
FALSE);
@@ -1564,19 +1569,35 @@
}
};

-PackageDetails::PackageDetails (bool onlineUpdate)
-: impl (new Impl (onlineUpdate))
+G_DEFINE_TYPE (YGtkDetailView, ygtk_detail_view, GTK_TYPE_SCROLLED_WINDOW)
+
+static void ygtk_detail_view_init (YGtkDetailView *view)
{}

-PackageDetails::~PackageDetails()
-{ delete impl; }
+GtkWidget *ygtk_detail_view_new (gboolean onlineUpdate)
+{
+ YGtkDetailView *view = (YGtkDetailView *) g_object_new
(YGTK_TYPE_DETAIL_VIEW, NULL);
+ view->impl = new YGtkDetailView::Impl (GTK_WIDGET (view), onlineUpdate);
+ return GTK_WIDGET (view);
+}

-GtkWidget *PackageDetails::getWidget()
-{ return impl->getWidget(); }
+static void ygtk_detail_view_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (ygtk_detail_view_parent_class)->finalize (object);
+ YGtkDetailView *view = YGTK_DETAIL_VIEW (object);
+ delete view->impl;
+ view->impl = NULL;
+}
+
+static void ygtk_detail_view_class_init (YGtkDetailViewClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = ygtk_detail_view_finalize;
+}

-void PackageDetails::setPackages (Ypp::PkgList packages)
+void YGtkDetailView::setPackages (Ypp::PkgList packages)
{ impl->setPackages (packages); }

-void PackageDetails::setPackage (Ypp::Package *package)
+void YGtkDetailView::setPackage (Ypp::Package *package)
{ impl->setPackage (package); }


Modified: trunk/gtk/src/ygtkzyppview.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkzyppview.h?rev=58515&r1=58514&r2=58515&view=diff
==============================================================================
--- trunk/gtk/src/ygtkzyppview.h (original)
+++ trunk/gtk/src/ygtkzyppview.h Fri Sep 4 08:27:03 2009
@@ -9,6 +9,7 @@
#define YGTK_ZYPP_WRAPPER_H

#include "yzyppwrapper.h"
+#include <gtk/gtkscrolledwindow.h>

namespace ZyppModel {
enum Columns {
@@ -31,15 +32,28 @@
void ygtk_zypp_model_append (GtkTreeModel *model,
const char *header, Ypp::PkgList list, const char *applyAllLabel);

-struct PackagesView
-{
- PackagesView (bool descriptiveTooltip);
- ~PackagesView();
- GtkWidget *getWidget();
+// calls Ypp::finish() for cleaning, and it cleans our icon resources as well
+void ygtk_zypp_finish (void);
+
+#define YGTK_TYPE_PACKAGE_VIEW (ygtk_package_view_get_type ())
+#define YGTK_PACKAGE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ YGTK_TYPE_PACKAGE_VIEW, YGtkPackageView))
+#define YGTK_PACKAGE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ YGTK_TYPE_PACKAGE_VIEW, YGtkPackageViewClass))
+#define YGTK_IS_PACKAGE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ YGTK_TYPE_PACKAGE_VIEW))
+#define YGTK_IS_PACKAGE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ YGTK_TYPE_PACKAGE_VIEW))
+#define YGTK_PACKAGE_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ YGTK_TYPE_PACKAGE_VIEW, YGtkPackageViewClass))
+
+struct YGtkPackageView
+{ // use ygtk_package_view_new() to instance the object
+ GtkScrolledWindow parent;

- void setRows (Ypp::PkgList list, const char *applyAllLabel); // tiny
bit optimized
+ void setList (Ypp::PkgList list, const char *applyAllLabel); // tiny
bit optimized
// pack multiple lists:
- void appendRows (const char *header, Ypp::PkgList list, const char
*applyAllLabel);
+ void appendList (const char *header, Ypp::PkgList list, const char
*applyAllLabel);
void clear();

void appendCheckColumn (int col);
@@ -47,8 +61,6 @@
void appendTextColumn (const char *header, int col, int size = -1);
// (set all column headers to NULL in order to hide them.)

- void setFrame (bool show);
-
struct Listener {
virtual void packagesSelected (Ypp::PkgList packages) = 0;
};
@@ -59,11 +71,29 @@
Impl *impl;
};

-struct PackageDetails
+struct YGtkPackageViewClass
{
- PackageDetails (bool onlineUpdate);
- ~PackageDetails();
- GtkWidget *getWidget();
+ GtkScrolledWindowClass parent_class;
+};
+
+YGtkPackageView* ygtk_package_view_new (gboolean descriptiveTooltip);
+GType ygtk_package_view_get_type (void) G_GNUC_CONST;
+
+#define YGTK_TYPE_DETAIL_VIEW (ygtk_detail_view_get_type ())
+#define YGTK_DETAIL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ YGTK_TYPE_DETAIL_VIEW, YGtkDetailView))
+#define YGTK_DETAIL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ YGTK_TYPE_DETAIL_VIEW, YGtkDetailViewClass))
+#define YGTK_IS_DETAIL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ YGTK_TYPE_DETAIL_VIEW))
+#define YGTK_IS_DETAIL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ YGTK_TYPE_DETAIL_VIEW))
+#define YGTK_DETAIL_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ YGTK_TYPE_DETAIL_VIEW, YGtkDetailViewClass))
+
+struct YGtkDetailView
+{ // use ygtk_detail_view_new() to instance the object
+ GtkScrolledWindow parent;

void setPackages (Ypp::PkgList packages);
void setPackage (Ypp::Package *package); // convenience
@@ -72,8 +102,13 @@
Impl *impl;
};

-// calls Ypp::finish() for cleaning, and it cleans our stuff as well
-void ygtk_zypp_finish (void);
+struct YGtkDetailViewClass
+{
+ GtkScrolledWindowClass parent_class;
+};
+
+GtkWidget* ygtk_detail_view_new (gboolean onlineUpdate);
+GType ygtk_detail_view_get_type (void) G_GNUC_CONST;

#endif /*YGTK_ZYPP_WRAPPER_H*/


Modified: trunk/gtk/src/yzyppwrapper.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/yzyppwrapper.cc?rev=58515&r1=58514&r2=58515&view=diff
==============================================================================
--- trunk/gtk/src/yzyppwrapper.cc (original)
+++ trunk/gtk/src/yzyppwrapper.cc Fri Sep 4 08:27:03 2009
@@ -1424,29 +1424,19 @@

struct Ypp::PkgList::Impl : public Ypp::PkgListener
{
-PkgList::Listener *listener;
+std::list <PkgList::Listener *> listeners;
std::vector <Ypp::Package *> pool;
guint inited : 2, _allInstalled : 2, _allNotInstalled : 2, _allUpgradable : 2,
_allModified : 2, _allLocked : 2, _allUnlocked : 2, _allCanLock : 2,
_allCanRemove : 2;
int refcount;

-int _id; // DEBUG: TEMP
-
-char getId()
-{ return (_id + 'a' > 'z') ? (_id - ('z'-'a') + '0') : (_id + 'a'); }
-
Impl() : PkgListener()
- , listener (NULL), inited (false), refcount (1)
- {
-static int _idTotal = 0;
- _id = _idTotal++;
- Ypp::get()->addPkgListener (this);
- }
+ , inited (false), refcount (1)
+ { Ypp::get()->addPkgListener (this); }

~Impl()
- {
-Ypp::get()->removePkgListener (this); }
+ { Ypp::get()->removePkgListener (this); }

// implementations
int find (const Package *package) const
@@ -1505,40 +1495,57 @@
_allLocked = _allUnlocked = _allCanLock =
_allCanRemove = false;
}

+ void signalChanged (int index, Package *package)
+ {
+ PkgList list (this); refcount++;
+ for (std::list <PkgList::Listener *>::iterator it =
listeners.begin();
+ it != listeners.end(); it++)
+ (*it)->entryChanged (list, index, package);
+ }
+
+ void signalInserted (int index, Package *package)
+ {
+ PkgList list (this); refcount++;
+ for (std::list <PkgList::Listener *>::iterator it =
listeners.begin();
+ it != listeners.end(); it++)
+ (*it)->entryInserted (list, index, package);
+ }
+
+ void signalDeleted (int index, Package *package)
+ {
+ PkgList list (this); refcount++;
+ for (std::list <PkgList::Listener *>::iterator it =
listeners.begin();
+ it != listeners.end(); it++)
+ (*it)->entryDeleted (list, index, package);
+ }
+
// Ypp callback
virtual void packageModified (Package *package)
{
bool live = liveList();
- if (!live && !listener)
+ if (!live && listeners.empty())
return;

- PkgList list (this);
- refcount++;
bool match = this->match (package);
int index = find (package);
-
if (live) {
if (index >= 0) { // is on the pool
- if (match) { // modified
- if (listener)
- listener->entryChanged (list,
index, package);
- }
+ if (match) // modified
+ signalChanged (index, package);
else { // removed
- if (listener)
- listener->entryDeleted (list,
index, package);
+ signalDeleted (index, package);
remove (index);
}
}
else { // not on pool
if (match) { // inserted
pool.push_back (package);
- if (listener)
- listener->entryInserted (list,
pool.size()-1, package);
+ signalInserted (pool.size()-1, package);
}
}
}
else if (index >= 0)
- listener->entryChanged (list, index, package);
+ signalChanged (index, package);
}

// for sub-classes to implement live lists
@@ -1700,8 +1707,11 @@
Ypp::get()->finishTransactions();
}

-void Ypp::PkgList::setListener (Ypp::PkgList::Listener *listener)
-{ impl->listener = listener; }
+void Ypp::PkgList::addListener (Ypp::PkgList::Listener *listener)
+{ impl->listeners.push_back (listener); }
+
+void Ypp::PkgList::removeListener (Ypp::PkgList::Listener *listener)
+{ impl->listeners.remove (listener); }

//** Query

@@ -1778,8 +1788,6 @@
if (whole_string) {
if (case_sensitive)
return strcmp (str1, str2) == 0;
-if (strcasecmp (str1, str2) == 0)
- fprintf (stderr, "whole string: '%s' vs '%s'\n", str1, str2);
return strcasecmp (str1, str2) == 0;
}
if (case_sensitive)

Modified: trunk/gtk/src/yzyppwrapper.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/yzyppwrapper.h?rev=58515&r1=58514&r2=58515&view=diff
==============================================================================
--- trunk/gtk/src/yzyppwrapper.h (original)
+++ trunk/gtk/src/yzyppwrapper.h Fri Sep 4 08:27:03 2009
@@ -158,7 +158,8 @@
virtual void entryInserted (const PkgList list, int
index, Package *package) = 0;
virtual void entryDeleted (const PkgList list, int
index, Package *package) = 0;
};
- void setListener (Listener *listener);
+ void addListener (Listener *listener);
+ void removeListener (Listener *listener);

struct Impl;
Impl *impl;

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages