Mailinglist Archive: yast-commit (2114 mails)

< Previous Next >
[yast-commit] r58698 - in /trunk/gtk: ChangeLog src/YGPackageSelector.cc src/ygtkcellrendererbutton.c src/ygtkcellrendererbutton.h src/ygtkzyppview.cc src/ygtkzyppview.h src/yzyppwrapper.cc src/yzyppwrapper.h
  • From: rpmcruz@xxxxxxxxxxxxxxxx
  • Date: Tue, 22 Sep 2009 00:22:58 -0000
  • Message-id: <E1Mpt9m-00052v-CL@xxxxxxxxxxxxxxxx>
Author: rpmcruz
Date: Tue Sep 22 02:22:57 2009
New Revision: 58698

URL: http://svn.opensuse.org/viewcvs/yast?rev=58698&view=rev
Log:
* src/ygtkzyppview.h/cc: fix: make double-click working on
remove and undo tabs.

* src/ygtkzyppview.cc: fix: refresh version control on
package change.

* src/yzyppwrapper.h/cc: PkgList::add/removeListener()
now (fake) const.

Modified:
trunk/gtk/ChangeLog
trunk/gtk/src/YGPackageSelector.cc
trunk/gtk/src/ygtkcellrendererbutton.c
trunk/gtk/src/ygtkcellrendererbutton.h
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=58698&r1=58697&r2=58698&view=diff
==============================================================================
--- trunk/gtk/ChangeLog (original)
+++ trunk/gtk/ChangeLog Tue Sep 22 02:22:57 2009
@@ -1,3 +1,14 @@
+2009-09-22 Ricardo Cruz <rpmcruz@xxxxxxxxxxxxxxxxxxx>
+
+ * src/ygtkzyppview.h/cc: fix: make double-click working on
+ remove and undo tabs.
+
+ * src/ygtkzyppview.cc: fix: refresh version control on
+ package change.
+
+ * src/yzyppwrapper.h/cc: PkgList::add/removeListener()
+ now (fake) const.
+
2009-09-21 Ricardo Cruz <rpmcruz@xxxxxxxxxxxxxxxxxxx>

* tests/Layout-Truncated-Widget.ycp: uncovered difference

Modified: trunk/gtk/src/YGPackageSelector.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGPackageSelector.cc?rev=58698&r1=58697&r2=58698&view=diff
==============================================================================
--- trunk/gtk/src/YGPackageSelector.cc (original)
+++ trunk/gtk/src/YGPackageSelector.cc Tue Sep 22 02:22:57 2009
@@ -192,6 +192,7 @@
YGtkPackageView *view = ygtk_package_view_new (FALSE);
view->appendCheckColumn (checkCol);
view->appendTextColumn (NULL, ZyppModel::NAME_COLUMN,
-1, true);
+ view->setActivateAction (YGtkPackageView::UNDO_ACTION);
view->setList (list, NULL);
view->setListener (listener);
gtk_scrolled_window_set_shadow_type (

Modified: trunk/gtk/src/ygtkcellrendererbutton.c
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkcellrendererbutton.c?rev=58698&r1=58697&r2=58698&view=diff
==============================================================================
--- trunk/gtk/src/ygtkcellrendererbutton.c (original)
+++ trunk/gtk/src/ygtkcellrendererbutton.c Tue Sep 22 02:22:57 2009
@@ -144,9 +144,10 @@
}

GtkCellRenderer *ygtk_cell_renderer_button_new (void)
-{
- return g_object_new (YGTK_TYPE_CELL_RENDERER_BUTTON, NULL);
-}
+{ return g_object_new (YGTK_TYPE_CELL_RENDERER_BUTTON, NULL); }
+
+gboolean ygtk_cell_renderer_button_get_active (YGtkCellRendererButton *cell)
+{ return cell->active; }

static void ygtk_cell_renderer_button_class_init (YGtkCellRendererButtonClass
*class)
{

Modified: trunk/gtk/src/ygtkcellrendererbutton.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkcellrendererbutton.h?rev=58698&r1=58697&r2=58698&view=diff
==============================================================================
--- trunk/gtk/src/ygtkcellrendererbutton.h (original)
+++ trunk/gtk/src/ygtkcellrendererbutton.h Tue Sep 22 02:22:57 2009
@@ -41,6 +41,8 @@
GtkCellRenderer *ygtk_cell_renderer_button_new (void);
GType ygtk_cell_renderer_button_get_type (void) G_GNUC_CONST;

+gboolean ygtk_cell_renderer_button_get_active (YGtkCellRendererButton *cell);
+
G_END_DECLS
#endif /*YGTK_CELL_RENDERER_BUTTON_H*/


Modified: trunk/gtk/src/ygtkzyppview.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkzyppview.cc?rev=58698&r1=58697&r2=58698&view=diff
==============================================================================
--- trunk/gtk/src/ygtkzyppview.cc (original)
+++ trunk/gtk/src/ygtkzyppview.cc Tue Sep 22 02:22:57 2009
@@ -674,7 +674,7 @@
{
Impl (GtkWidget *scroll, bool descriptiveTooltip)
: m_listener (NULL), m_popup_hack (NULL), m_descriptiveTooltip
(descriptiveTooltip),
- m_model (NULL), m_modelId (0)
+ m_model (NULL), m_modelId (0), m_activate_action (NONE_ACTION)
{
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
@@ -717,6 +717,7 @@
bool m_descriptiveTooltip;
GtkTreeModel *m_model;
guint m_modelId;
+ Action m_activate_action;

// methods
void setList (Ypp::PkgList list, const char *applyAllLabel)
@@ -801,6 +802,20 @@
gtk_tree_view_append_column (view, column);
}

+ static Action columnAction (int col)
+ {
+ switch (col) {
+ case ZyppModel::TO_INSTALL_COLUMN:
+ case ZyppModel::TO_UPGRADE_COLUMN:
+ default:
+ return INSTALL_ACTION;
+ case ZyppModel::TO_REMOVE_COLUMN:
+ return REMOVE_ACTION;
+ case ZyppModel::TO_MODIFY_COLUMN:
+ return UNDO_ACTION;
+ }
+ }
+
void appendCheckColumn (int modelCol)
{
GtkTreeView *view = GTK_TREE_VIEW (m_view);
@@ -809,14 +824,19 @@
renderer, "active", modelCol, "visible",
ZyppModel::CHECK_VISIBLE_COLUMN,
"sensitive", ZyppModel::SENSITIVE_COLUMN,
"cell-background", ZyppModel::BACKGROUND_COLUMN, NULL);
- g_object_set_data (G_OBJECT (column), "status-tooltip",
GINT_TO_POINTER (1));
- g_object_set_data (G_OBJECT (renderer), "col", GINT_TO_POINTER
(modelCol));
g_signal_connect (G_OBJECT (renderer), "toggled",
G_CALLBACK (renderer_toggled_cb), this);
+
// it seems like GtkCellRendererToggle has no width at start,
so fixed doesn't work
gtk_tree_view_column_set_sizing (column,
GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_fixed_width (column, 25);
gtk_tree_view_append_column (view, column);
+
+ Action action = columnAction (modelCol);
+ g_object_set_data (G_OBJECT (renderer), "action",
GINT_TO_POINTER (action));
+ if (m_activate_action == NONE_ACTION)
+ m_activate_action = action;
+ g_object_set_data (G_OBJECT (column), "status-tooltip",
GINT_TO_POINTER (1));
}

void appendButtonColumn (const char *header, int modelCol)
@@ -835,19 +855,25 @@

GtkTreeView *view = GTK_TREE_VIEW (m_view);
GtkCellRenderer *renderer = ygtk_cell_renderer_button_new();
- GtkTreeViewColumn *column =
gtk_tree_view_column_new_with_attributes (header,
- renderer, "active", modelCol, "visible",
ZyppModel::CHECK_VISIBLE_COLUMN,
+ GtkTreeViewColumn *column =
gtk_tree_view_column_new_with_attributes (
+ header, renderer, "active", modelCol,
+ "visible", ZyppModel::CHECK_VISIBLE_COLUMN,
"sensitive", ZyppModel::SENSITIVE_COLUMN,
"cell-background", ZyppModel::BACKGROUND_COLUMN,
"text", labelCol, "stock-id", stockCol, NULL);
- g_object_set_data (G_OBJECT (column), "status-tooltip",
GINT_TO_POINTER (1));
- g_object_set_data (G_OBJECT (renderer), "col", GINT_TO_POINTER
(modelCol));
g_signal_connect (G_OBJECT (renderer), "toggled",
G_CALLBACK (renderer_toggled_cb), this);
+
// it seems like GtkCellRendererToggle has no width at start,
so fixed doesn't work
gtk_tree_view_column_set_sizing (column,
GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_fixed_width (column, 120);
gtk_tree_view_append_column (view, column);
+
+ Action action = columnAction (modelCol);
+ g_object_set_data (G_OBJECT (renderer), "action",
GINT_TO_POINTER (action));
+ if (m_activate_action == NONE_ACTION)
+ m_activate_action = action;
+ g_object_set_data (G_OBJECT (column), "status-tooltip",
GINT_TO_POINTER (1));
}

void appendTextColumn (const char *header, int col, int size, bool
identAuto)
@@ -1011,36 +1037,32 @@
return package != NULL;
}

- static void apply (Ypp::Package *package, int col, bool enable)
+ static void apply (Ypp::Package *package, Action action, bool enable)
{
if (enable)
- switch (col) {
- case ZyppModel::TO_INSTALL_COLUMN:
- case ZyppModel::TO_UPGRADE_COLUMN:
- package->install (0);
- break;
- case ZyppModel::TO_REMOVE_COLUMN:
- package->remove();
- break;
- default: break;
+ switch (action) {
+ case INSTALL_ACTION: package->install (0);
break;
+ case REMOVE_ACTION: package->remove(); break;
+ case UNDO_ACTION: package->undo(); break;
+ case NONE_ACTION: break;
}
else
package->undo();
}

static gboolean apply_iter_cb (GtkTreeModel *model,
- GtkTreePath *path, GtkTreeIter *iter, gpointer col)
+ GtkTreePath *path, GtkTreeIter *iter, gpointer action)
{
Ypp::Package *package;
gboolean enable;
enable = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (model),
"enable"));
gtk_tree_model_get (model, iter, ZyppModel::PTR_COLUMN,
&package, -1);
if (package)
- apply (package, GPOINTER_TO_INT (col), enable);
+ apply (package, (Action) GPOINTER_TO_INT (action),
enable);
return FALSE;
}

- static void renderer_toggled_cb (GtkCellRendererToggle *renderer, gchar
*path_str,
+ static void renderer_toggled_cb (GtkCellRenderer *renderer, gchar
*path_str,
Impl *pThis)
{
Ypp::Package *package = 0;
@@ -1052,18 +1074,18 @@

gboolean active;
if (GTK_IS_CELL_RENDERER_TOGGLE (renderer))
- active = gtk_cell_renderer_toggle_get_active (renderer);
-/* else
- active = ygtk_cell_renderer_toggle_get_active
(renderer);*/
-else active = FALSE; // FIXME
- int col = GPOINTER_TO_INT (g_object_get_data (G_OBJECT
(renderer), "col"));
+ active = gtk_cell_renderer_toggle_get_active
(GTK_CELL_RENDERER_TOGGLE (renderer));
+ else
+ active = ygtk_cell_renderer_button_get_active
(YGTK_CELL_RENDERER_BUTTON (renderer));
+
+ Action action = (Action) GPOINTER_TO_INT (g_object_get_data
(G_OBJECT (renderer), "action"));
if (package)
- apply (package, col, !active);
+ apply (package, action, !active);
else {
if (!gtk_tree_model_iter_next (model, &iter)) { // on
apply-all
g_object_set_data (G_OBJECT (model), "enable",
GINT_TO_POINTER (!active));
Ypp::get()->startTransactions();
- gtk_tree_model_foreach (model, apply_iter_cb,
GINT_TO_POINTER (col));
+ gtk_tree_model_foreach (model, apply_iter_cb,
GINT_TO_POINTER (action));
Ypp::get()->finishTransactions();
}
}
@@ -1073,8 +1095,12 @@
GtkTreeViewColumn *column, Impl
*pThis)
{
Ypp::PkgList packages = pThis->getSelected();
- if (packages.notInstalled() || packages.upgradable())
- packages.install();
+ switch (pThis->m_activate_action) {
+ case INSTALL_ACTION: packages.install(); break;
+ case REMOVE_ACTION: packages.remove(); break;
+ case UNDO_ACTION: packages.undo(); break;
+ case NONE_ACTION: break;
+ }
}

static gboolean query_tooltip_cb (GtkWidget *widget, gint x, gint y,
@@ -1204,6 +1230,9 @@
void YGtkPackageView::setRulesHint (bool hint)
{ impl->setRulesHint (hint); }

+void YGtkPackageView::setActivateAction (Action action)
+{ impl->m_activate_action = action; }
+
void YGtkPackageView::setListener (Listener *listener)
{ impl->m_listener = listener; }

@@ -1244,16 +1273,16 @@
gtk_box_pack_start (GTK_BOX (m_box), label, FALSE,
TRUE, 0);
gtk_box_pack_start (GTK_BOX (m_box), m_versions_box,
TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (m_box), button_box, FALSE,
TRUE, 0);
+
+ Ypp::get()->getPackages
(Ypp::Package::PACKAGE_TYPE).addListener (this);
}

~Versions()
- { m_packages.removeListener (this); }
+ { Ypp::get()->getPackages
(Ypp::Package::PACKAGE_TYPE).removeListener (this); }

void setPackages (Ypp::PkgList packages)
{
- m_packages.removeListener (this);
m_packages = packages;
- m_packages.addListener (this);

GList *children = gtk_container_get_children
(GTK_CONTAINER (m_versions_box));
for (GList *i = children; i; i = i->next)
@@ -1355,9 +1384,11 @@
}

private:
- virtual void entryChanged (const Ypp::PkgList list, int index,
Ypp::Package *package)
- { setPackages (m_packages); /* refresh */ }
-
+ virtual void entryChanged (const Ypp::PkgList list, int index,
Ypp::Package *package)
+ {
+ if (m_packages.contains (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) {}

Modified: trunk/gtk/src/ygtkzyppview.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkzyppview.h?rev=58698&r1=58697&r2=58698&view=diff
==============================================================================
--- trunk/gtk/src/ygtkzyppview.h (original)
+++ trunk/gtk/src/ygtkzyppview.h Tue Sep 22 02:22:57 2009
@@ -63,6 +63,8 @@
void appendTextColumn (const char *header, int col, int size = -1, bool
identAuto = false);
// (set all column headers to NULL in order to hide them.)
void setRulesHint (bool hint);
+ enum Action { NONE_ACTION, INSTALL_ACTION, REMOVE_ACTION, UNDO_ACTION };
+ void setActivateAction (Action action);

struct Listener {
virtual void packagesSelected (Ypp::PkgList packages) = 0;

Modified: trunk/gtk/src/yzyppwrapper.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/yzyppwrapper.cc?rev=58698&r1=58697&r2=58698&view=diff
==============================================================================
--- trunk/gtk/src/yzyppwrapper.cc (original)
+++ trunk/gtk/src/yzyppwrapper.cc Tue Sep 22 02:22:57 2009
@@ -1500,13 +1500,9 @@
_allCanRemove : 2;
int refcount;

-char id;
-
Impl (const Ypp::PkgList *lparent) : Listener()
, parent (NULL), inited (false), refcount (1)
{
- static int idN = 0;
- id = idN++;
if (lparent) {
parent = new PkgList (*lparent);
parent->addListener (this);
@@ -1538,7 +1534,9 @@
}

void addListener (Ypp::PkgList::Listener *listener)
- { listeners.push_back (listener); }
+ {
+ listeners.push_back (listener);
+ }

void removeListener (Ypp::PkgList::Listener *listener)
{ listeners.remove (listener); }
@@ -1802,11 +1800,11 @@
Ypp::get()->finishTransactions();
}

-void Ypp::PkgList::addListener (Ypp::PkgList::Listener *listener)
-{ impl->addListener (listener); }
+void Ypp::PkgList::addListener (Ypp::PkgList::Listener *listener) const
+{ const_cast <Impl *> (impl)->addListener (listener); }

-void Ypp::PkgList::removeListener (Ypp::PkgList::Listener *listener)
-{ impl->removeListener (listener); }
+void Ypp::PkgList::removeListener (Ypp::PkgList::Listener *listener) const
+{ const_cast <Impl *> (impl)->removeListener (listener); }

//** Query


Modified: trunk/gtk/src/yzyppwrapper.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/yzyppwrapper.h?rev=58698&r1=58697&r2=58698&view=diff
==============================================================================
--- trunk/gtk/src/yzyppwrapper.h (original)
+++ trunk/gtk/src/yzyppwrapper.h Tue Sep 22 02:22:57 2009
@@ -159,8 +159,8 @@
virtual void entryInserted (const PkgList list, int
index, Package *package) = 0;
virtual void entryDeleted (const PkgList list, int
index, Package *package) = 0;
};
- void addListener (Listener *listener);
- void removeListener (Listener *listener);
+ void addListener (Listener *listener) const;
+ void removeListener (Listener *listener) const;

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