Mailinglist Archive: yast-commit (819 mails)

< Previous Next >
[yast-commit] r55054 - in /branches/SuSE-Code-11-Branch/gtk: ./ src/
  • From: rpmcruz@xxxxxxxxxxxxxxxx
  • Date: Mon, 26 Jan 2009 17:26:42 -0000
  • Message-id: <E1LRVEQ-0003kE-9K@xxxxxxxxxxxxxxxx>
Author: rpmcruz
Date: Mon Jan 26 18:26:41 2009
New Revision: 55054

URL: http://svn.opensuse.org/viewcvs/yast?rev=55054&view=rev
Log:
Sync with HEAD.

Modified:
branches/SuSE-Code-11-Branch/gtk/ChangeLog
branches/SuSE-Code-11-Branch/gtk/src/YGComboBox.cc
branches/SuSE-Code-11-Branch/gtk/src/YGDialog.cc
branches/SuSE-Code-11-Branch/gtk/src/YGDialog.h
branches/SuSE-Code-11-Branch/gtk/src/YGPackageSelector.cc
branches/SuSE-Code-11-Branch/gtk/src/YGProgressBar.cc
branches/SuSE-Code-11-Branch/gtk/src/YGSelectionModel.h
branches/SuSE-Code-11-Branch/gtk/src/YGTable.cc
branches/SuSE-Code-11-Branch/gtk/src/YGText.cc
branches/SuSE-Code-11-Branch/gtk/src/YGUtils.cc
branches/SuSE-Code-11-Branch/gtk/src/ygtkscrolledwindow.c
branches/SuSE-Code-11-Branch/gtk/src/ygtkscrolledwindow.h
branches/SuSE-Code-11-Branch/gtk/src/ygtkzyppwrapper.cc
branches/SuSE-Code-11-Branch/gtk/src/ygtkzyppwrapper.h

Modified: branches/SuSE-Code-11-Branch/gtk/ChangeLog
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/gtk/ChangeLog?rev=55054&r1=55053&r2=55054&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/gtk/ChangeLog (original)
+++ branches/SuSE-Code-11-Branch/gtk/ChangeLog Mon Jan 26 18:26:41 2009
@@ -1,6 +1,21 @@
-2009-01-21 Ricardo Cruz <rpmcruz@xxxxxxxxxxxxxxxxxxx>
+2009-01-26 Ricardo Cruz <rpmcruz@xxxxxxxxxxxxxxxxxxx>

- * src/YGPushButton.cc: bug fix 446440: re-enable treat icon code.
+ * src/YGSelectionModel.h: decoupled doSelectItem(NULL) into
+ doUnselectAllItem().
+
+ * src/YGTable.cc: bug fix 468974: selection was broken. Also
+ fixed YTree's double click crash, and YMultiSelectionBox
+ check boxes default values.
+
+2009-01-21 Ricardo Cruz <rpmcruz@xxxxxxxxxxxxxxxxxxx>
+
+ * src/YGProgressBar.cc (YGDownloadProgress): bug fix 460106:
+ set size units translatable.
+
+2009-01-19 Ricardo Cruz <rpmcruz@xxxxxxxxxxxxxxxxxxx>
+
+ * src/YGPackageSelector (PackageSelector): a couple of mockups
+ (change PKG_SELECTOR_FACE to enable).

2009-01-17 Ricardo Cruz <rpmcruz@xxxxxxxxxxxxxxxxxxx>

@@ -12,8 +27,22 @@
* src/pkg-selector-help.h: bug fix 448192 & 459457: improved
pkg selector help a bit.

- * src/YGLayout.cc: looks odd when adjusting menu buttons to the same
- height as the other buttons.
+ * src/YGLayout.cc: bug fix 464904: looks odd when adjusting menu
+ buttons to the same height as the other buttons.
+
+ * src/YGDialog.h/cc: methods to retrive function key widget and
+ and list of widgets from a given class.
+
+ * src/YGPackageSelector.cc & src/ygtkscrolledwindow.h/c: moved
+ right-click tree hack from the pkg selector to its own widget.
+
+ * src/YGTable.cc: implemented Martin Vidner suggestion on function
+ keys: http://mvidner.blogspot.com/2009/01/yast-ui-table-usability.html
+
+ * src/ygtkzyppwrapper.h/cc: exposed a couple new data columns.
+
+ * src/YGPackageSelector.cc (PackagesView): added CheckView for
+ mockup purposes.

2009-01-08 Ricardo Cruz <rpmcruz@xxxxxxxxxxxxxxxxxxx>


Modified: branches/SuSE-Code-11-Branch/gtk/src/YGComboBox.cc
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/gtk/src/YGComboBox.cc?rev=55054&r1=55053&r2=55054&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/gtk/src/YGComboBox.cc (original)
+++ branches/SuSE-Code-11-Branch/gtk/src/YGComboBox.cc Mon Jan 26 18:26:41 2009
@@ -82,11 +82,10 @@

virtual void setText (const string &value)
{
- IMPL
BlockEvents block (this);
- GtkTreeIter iter;
- if (findByText (value, &iter))
- doSelectItem (&iter);
+ GtkTreeIter iter;
+ if (findByText (value, &iter))
+ doSelectItem (&iter);
else
gtk_entry_set_text (getEntry(), value.c_str());
}
@@ -95,12 +94,16 @@
virtual void doSelectItem (GtkTreeIter *iter)
{
BlockEvents block (this);
- if (iter)
- gtk_combo_box_set_active_iter (getComboBox(), iter);
- else
- gtk_combo_box_set_active (getComboBox(), -1);
+ gtk_combo_box_set_active_iter (getComboBox(), iter);
}

+ virtual void doUnselectAll()
+ {
+ BlockEvents block (this);
+ gtk_combo_box_set_active (getComboBox(), -1);
+ }
+
+
virtual YItem *doSelectedItem()
{
GtkTreeIter iter;

Modified: branches/SuSE-Code-11-Branch/gtk/src/YGDialog.cc
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/gtk/src/YGDialog.cc?rev=55054&r1=55053&r2=55054&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/gtk/src/YGDialog.cc (original)
+++ branches/SuSE-Code-11-Branch/gtk/src/YGDialog.cc Mon Jan 26 18:26:41 2009
@@ -11,6 +11,7 @@
#endif
#include <gdk/gdkkeysyms.h>
#include <math.h> // easter
+#include <string.h>

/* In the main dialog case, it doesn't necessarly have a window of its own. If
there is already a main window, it should replace its content -- and when
closed,
@@ -529,6 +530,38 @@
}
}

+typedef bool (*FindWidgetsCb) (YWidget *widget, void *data) ;
+
+static void findWidgets (
+ std::list <YWidget *> *widgets, YWidget *widget, FindWidgetsCb find_cb,
void *cb_data)
+{
+ if (find_cb (widget, cb_data))
+ widgets->push_back (widget);
+ for (YWidgetListConstIterator it = widget->childrenBegin();
+ it != widget->childrenEnd(); it++)
+ findWidgets (widgets, *it, find_cb, cb_data);
+}
+
+static bool IsFunctionWidget (YWidget *widget, void *data)
+{ return widget->functionKey() == GPOINTER_TO_INT (data); }
+
+YWidget *YGDialog::getFunctionWidget (int key)
+{
+ std::list <YWidget *> widgets;
+ findWidgets (&widgets, this, IsFunctionWidget, GINT_TO_POINTER (key));
+ return widgets.empty() ? NULL : widgets.front();
+}
+
+static bool IsClassWidget (YWidget *widget, void *data)
+{ return !strcmp (widget->widgetClass(), (char *) data); }
+
+std::list <YWidget *> YGDialog::getClassWidgets (const char *className)
+{
+ std::list <YWidget *> widgets;
+ findWidgets (&widgets, this, IsClassWidget, (void *) className);
+ return widgets;
+}
+
YDialog *YGWidgetFactory::createDialog (YDialogType dialogType,
YDialogColorMode colorMode)
{
IMPL

Modified: branches/SuSE-Code-11-Branch/gtk/src/YGDialog.h
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/gtk/src/YGDialog.h?rev=55054&r1=55053&r2=55054&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/gtk/src/YGDialog.h (original)
+++ branches/SuSE-Code-11-Branch/gtk/src/YGDialog.h Mon Jan 26 18:26:41 2009
@@ -45,6 +45,9 @@
void setTitle (const std::string &title, bool sticky = false);
void setIcon (const std::string &icon);

+ YWidget *getFunctionWidget (int key);
+ std::list <YWidget *> getClassWidgets (const char *className);
+
YGWIDGET_IMPL_CONTAINER (YDialog)
};


Modified: branches/SuSE-Code-11-Branch/gtk/src/YGPackageSelector.cc
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/gtk/src/YGPackageSelector.cc?rev=55054&r1=55053&r2=55054&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/gtk/src/YGPackageSelector.cc (original)
+++ branches/SuSE-Code-11-Branch/gtk/src/YGPackageSelector.cc Mon Jan 26
18:26:41 2009
@@ -415,44 +415,17 @@
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL,
NULL, button, event_time);
gtk_widget_show_all (menu);
}
-
- static gboolean popup_key_cb (GtkWidget *widget, View *pThis)
- { pThis->signalPopup (0, gtk_get_current_event_time()); return
TRUE; }
};
- struct ListView : public View
+ // TreeView: base class for ListView and CheckView (see append*Col
methods)
+ struct TreeView : public View
{
bool m_isTree, m_descriptiveTooltip;
- ListView (bool isTree, bool descriptiveTooltip, bool editable,
PackagesView *parent)
+ TreeView (bool isTree, bool descriptiveTooltip, bool editable,
PackagesView *parent)
: View (parent), m_isTree (isTree), m_descriptiveTooltip
(descriptiveTooltip)
{
- GtkTreeView *view = GTK_TREE_VIEW (m_widget =
gtk_tree_view_new());
+ GtkTreeView *view = GTK_TREE_VIEW (m_widget =
ygtk_tree_view_new());
gtk_tree_view_set_headers_visible (view, FALSE);
gtk_tree_view_set_search_column (view,
YGtkZyppModel::NAME_COLUMN);
- GtkTreeViewColumn *column;
- GtkCellRenderer *renderer;
- renderer = gtk_cell_renderer_pixbuf_new();
- column = gtk_tree_view_column_new_with_attributes ("",
renderer,
- "pixbuf", YGtkZyppModel::ICON_COLUMN, NULL);
- gtk_tree_view_column_set_sizing (column,
GTK_TREE_VIEW_COLUMN_FIXED);
- gtk_tree_view_column_set_fixed_width (column, 38);
- gtk_tree_view_append_column (view, column);
- renderer = gtk_cell_renderer_text_new();
- if (isTree) {
- int height = MAX (34, YGUtils::getCharsHeight
(m_widget, 2));
- gtk_cell_renderer_set_fixed_size (renderer, -1,
height);
- }
- g_object_set (G_OBJECT (renderer), "ellipsize",
PANGO_ELLIPSIZE_END, NULL);
- gboolean reverse = gtk_widget_get_default_direction()
== GTK_TEXT_DIR_RTL;
- if (reverse) { // work-around: Pango ignored alignment
flag on RTL
- gtk_widget_set_direction (m_widget,
GTK_TEXT_DIR_LTR);
- g_object_set (renderer, "alignment",
PANGO_ALIGN_RIGHT, NULL);
- }
- column = gtk_tree_view_column_new_with_attributes ("",
renderer,
- "markup",
YGtkZyppModel::NAME_DESCRIPTION_COLUMN, NULL);
- gtk_tree_view_column_set_sizing (column,
GTK_TREE_VIEW_COLUMN_FIXED);
- gtk_tree_view_column_set_fixed_width (column, 50 /* it
will expand */);
- gtk_tree_view_column_set_expand (column, TRUE);
- gtk_tree_view_insert_column (view, column, reverse ? 0
: -1);
gtk_tree_view_set_fixed_height_mode (view, TRUE);
gtk_tree_view_set_show_expanders (view, FALSE); /*
would conflict with icons */

@@ -467,10 +440,8 @@
if (editable) {
g_signal_connect (G_OBJECT (m_widget),
"row-activated",
G_CALLBACK
(package_activated_cb), this);
- g_signal_connect (G_OBJECT (m_widget),
"popup-menu",
- G_CALLBACK
(popup_key_cb), this);
- g_signal_connect (G_OBJECT (m_widget),
"button-press-event",
- G_CALLBACK
(popup_button_cb), this);
+ g_signal_connect (G_OBJECT (m_widget),
"right-click",
+ G_CALLBACK
(popup_menu_cb), this);
}
gtk_widget_set_has_tooltip (m_widget, TRUE);
g_signal_connect (G_OBJECT (m_widget), "query-tooltip",
@@ -478,6 +449,54 @@
ensure_view_visible_hook (m_widget);
}

+ void appendIconCol()
+ {
+ GtkTreeView *view = GTK_TREE_VIEW (m_widget);
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer =
gtk_cell_renderer_pixbuf_new();
+ if (m_isTree) {
+ int height = MAX (34, YGUtils::getCharsHeight
(m_widget, 2));
+ gtk_cell_renderer_set_fixed_size (renderer, -1,
height);
+ }
+ column = gtk_tree_view_column_new_with_attributes (
+ "", renderer, "pixbuf",
YGtkZyppModel::ICON_COLUMN, NULL);
+ gtk_tree_view_column_set_sizing (column,
GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_fixed_width (column, 38);
+ gtk_tree_view_append_column (view, column);
+ }
+ void appendTextCol (int modelCol)
+ {
+ GtkTreeView *view = GTK_TREE_VIEW (m_widget);
+ GtkCellRenderer *renderer =
gtk_cell_renderer_text_new();
+ g_object_set (G_OBJECT (renderer), "ellipsize",
PANGO_ELLIPSIZE_END, NULL);
+ gboolean reverse = gtk_widget_get_default_direction()
== GTK_TEXT_DIR_RTL;
+ if (reverse) { // work-around: Pango ignored alignment
flag on RTL
+ gtk_widget_set_direction (m_widget,
GTK_TEXT_DIR_LTR);
+ g_object_set (renderer, "alignment",
PANGO_ALIGN_RIGHT, NULL);
+ }
+ GtkTreeViewColumn *column;
+ column = gtk_tree_view_column_new_with_attributes (
+ "", renderer, "markup", modelCol, NULL);
+ gtk_tree_view_column_set_sizing (column,
GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_fixed_width (column, 50 /* it
will expand */);
+ gtk_tree_view_column_set_expand (column, TRUE);
+ gtk_tree_view_insert_column (view, column, reverse ? 0
: -1);
+ }
+ void appendCheckCol()
+ {
+ GtkTreeView *view = GTK_TREE_VIEW (m_widget);
+ GtkCellRenderer *renderer =
gtk_cell_renderer_toggle_new();
+ GtkTreeViewColumn *column;
+ column = gtk_tree_view_column_new_with_attributes (
+ "", renderer, "active",
YGtkZyppModel::IS_INSTALLED_COLUMN, NULL);
+ gtk_tree_view_column_set_sizing (column,
GTK_TREE_VIEW_COLUMN_FIXED);
+ // it seems like GtkCellRendererToggle has no width at
start, so fixed doesn't work
+ gtk_tree_view_column_set_fixed_width (column, 25);
+ gtk_tree_view_append_column (view, column);
+ g_signal_connect (G_OBJECT (renderer), "toggled",
+ G_CALLBACK (toggled_cb), this);
+ }
+
virtual void setModel (GtkTreeModel *model)
{
GtkTreeView *view = GTK_TREE_VIEW (m_widget);
@@ -514,26 +533,26 @@
packages.install();
}

- static gboolean popup_button_cb (GtkWidget *widget,
GdkEventButton *event, View *pThis)
+ static void toggled_cb (GtkCellRendererToggle *renderer, gchar
*path_str,
+ TreeView *pThis)
{
- // workaround (based on gedit): we want the tree view
to receive this press in order
- // to select the row, but we can't use connect_after,
so we throw a dummy mouse press
- if (event->type == GDK_BUTTON_PRESS && event->button ==
3) {
- static bool safeguard = false;
- if (safeguard) return false;
- safeguard = true;
- if (pThis->countSelected() <= 1) { // if there
is a selection, let it be
- event->button = 1;
- if (!gtk_widget_event (widget,
(GdkEvent *) event))
- return FALSE;
- }
- pThis->signalPopup (3, event->time);
- safeguard = false;
- return TRUE;
- }
- return FALSE;
+ Ypp::Package *package = 0;
+ GtkTreeIter iter;
+ GtkTreeView *view = GTK_TREE_VIEW (pThis->m_widget);
+ GtkTreeModel *model = gtk_tree_view_get_model (view);
+ gtk_tree_model_get_iter_from_string (model, &iter,
path_str);
+ gtk_tree_model_get (model, &iter,
YGtkZyppModel::PTR_COLUMN, &package, -1);
+ if (package->toModify())
+ package->undo();
+ else if (package->isInstalled())
+ package->remove();
+ else
+ package->install (0);
}

+ static void popup_menu_cb (YGtkTreeView *view, gboolean
outreach, View *pThis)
+ { if (!outreach) pThis->signalPopup(3,
gtk_get_current_event_time()); }
+
static gboolean can_select_row_cb (GtkTreeSelection *selection,
GtkTreeModel *model,
GtkTreePath *path, gboolean path_currently_selected,
gpointer data)
{
@@ -545,7 +564,7 @@
}

static gboolean query_tooltip_cb (GtkWidget *widget, gint x,
gint y,
- gboolean keyboard_mode, GtkTooltip *tooltip, ListView
*pThis)
+ gboolean keyboard_mode, GtkTooltip *tooltip, TreeView
*pThis)
{
GtkTreeView *view = GTK_TREE_VIEW (widget);
GtkTreeModel *model;
@@ -624,13 +643,31 @@
return FALSE;
}
};
+ struct ListView : public TreeView
+ {
+ ListView (bool isTree, bool descriptiveTooltip, bool editable,
PackagesView *parent)
+ : TreeView (isTree, descriptiveTooltip, editable, parent)
+ {
+ appendIconCol();
+ appendTextCol (YGtkZyppModel::NAME_DESCRIPTION_COLUMN);
+ }
+ };
+ struct CheckView : public TreeView
+ {
+ CheckView (PackagesView *parent)
+ : TreeView (false, false, true, parent)
+ {
+ appendCheckCol();
+ appendTextCol (YGtkZyppModel::NAME_COLUMN);
+ }
+ };
struct IconView : public View
{
IconView (bool editable, PackagesView *parent)
: View (parent)
{
GtkIconView *view = GTK_ICON_VIEW (m_widget =
gtk_icon_view_new());
- gtk_icon_view_set_text_column (view,
YGtkZyppModel::NAME_COLUMN);
+ gtk_icon_view_set_text_column (view,
YGtkZyppModel::NAME_TRUNCATE_COLUMN);
gtk_icon_view_set_pixbuf_column (view,
YGtkZyppModel::ICON_COLUMN);
gtk_icon_view_set_selection_mode (view,
GTK_SELECTION_MULTIPLE);
g_signal_connect (G_OBJECT (m_widget),
"selection-changed",
@@ -681,6 +718,8 @@
pThis->signalPopup (3, event->time);
return FALSE;
}
+ static gboolean popup_key_cb (GtkWidget *widget, View *pThis)
+ { pThis->signalPopup (0, gtk_get_current_event_time()); return
TRUE; }
};

GtkWidget *m_bin;
@@ -721,7 +760,7 @@
}

enum ViewMode {
- LIST_MODE, ICON_MODE
+ LIST_MODE, ICON_MODE, CHECK_MODE
};
void setMode (ViewMode mode, bool editable)
{
@@ -729,10 +768,17 @@
if (m_view)
gtk_container_remove (GTK_CONTAINER (m_bin),
m_view->m_widget);
delete m_view;
- if (mode == LIST_MODE)
- m_view = new ListView (m_isTree, m_descriptiveTooltip,
editable, this);
- else // if (mode == ICON_MODE)
- m_view = new IconView (editable, this);
+ switch (mode) {
+ case LIST_MODE:
+ m_view = new ListView (m_isTree,
m_descriptiveTooltip, editable, this);
+ break;
+ case ICON_MODE:
+ m_view = new IconView (editable, this);
+ break;
+ case CHECK_MODE:
+ m_view = new CheckView (this);
+ break;
+ }
gtk_container_add (GTK_CONTAINER (m_bin), m_view->m_widget);
if (m_model)
m_view->setModel (m_model);
@@ -2549,6 +2595,9 @@
}
};

+// mockup experiments
+#define PKG_SELECTOR_FACE 0
+
class PackageSelector : public Filters::Listener, public
PackagesView::Listener,
public PackageDetails::Listener
{
@@ -2577,6 +2626,7 @@
m_filters->setListener (this);
m_details->setListener (this);

+#if (PKG_SELECTOR_FACE == 0)
GtkWidget *categories_box = gtk_vbox_new (FALSE, 4);
gtk_box_pack_start (GTK_BOX (categories_box),
m_filters->getTypeWidget(), FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (categories_box),
m_filters->getCollectionWidget(),
@@ -2613,6 +2663,103 @@
gtk_box_pack_start (GTK_BOX (m_box),
m_filters->getStatusesWidget(),
FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (m_box), details_pane, TRUE, TRUE,
0);
+#endif
+#if (PKG_SELECTOR_FACE == 1)
+ // based on KPorts:
http://kde-apps.org/content/show.php/KPorts?content=24579
+ GtkWidget *type_combo = gtk_combo_box_new_text();
+ gtk_combo_box_append_text (GTK_COMBO_BOX (type_combo),
"Search");
+ gtk_combo_box_append_text (GTK_COMBO_BOX (type_combo),
"Groups");
+ gtk_combo_box_append_text (GTK_COMBO_BOX (type_combo),
"Changed");
+ gtk_combo_box_set_active (GTK_COMBO_BOX (type_combo), 0);
+
+ GtkWidget *pkg_box = gtk_vbox_new (FALSE, 6);
+ //gtk_box_pack_start (GTK_BOX (pkg_box),
m_filters->getTypeWidget(), FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (pkg_box), type_combo, FALSE, TRUE,
0);
+ gtk_box_pack_start (GTK_BOX (pkg_box),
m_filters->getNameWidget(), FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (pkg_box), m_packages->getWidget(),
TRUE, TRUE, 0);
+ m_packages->setMode (PackagesView::CHECK_MODE, true);
+
+ GtkWidget *control_align = gtk_alignment_new (0, 0, 0, 1);
+ gtk_container_add (GTK_CONTAINER (control_align),
m_control->getWidget());
+
+ m_details_box = gtk_vbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (m_details_box),
m_details->getWidget(), TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (m_details_box), control_align,
FALSE, TRUE, 0);
+
+ m_box = gtk_hpaned_new();
+ gtk_paned_pack1 (GTK_PANED (m_box), pkg_box, TRUE, FALSE);
+ gtk_paned_pack2 (GTK_PANED (m_box), m_details_box, TRUE, FALSE);
+ gtk_paned_set_position (GTK_PANED (m_box), 250);
+#endif
+#if (PKG_SELECTOR_FACE == 2)
+ struct inner {
+ static void install_button_clicked_cb (GtkButton
*button, PackagesView *view)
+ {
+ PkgList pkgs = view->getSelected();
+ pkgs.install();
+ }
+ static void remove_button_clicked_cb (GtkButton
*button, PackagesView *view)
+ {
+ PkgList pkgs = view->getSelected();
+ pkgs.remove();
+ }
+ static void undo_button_clicked_cb (GtkButton *button,
PackagesView *view)
+ {
+ PkgList pkgs = view->getSelected();
+ pkgs.undo();
+ }
+ };
+
+ Ypp::QueryPool::Query *query = new Ypp::QueryPool::Query();
+ query->setToModify (true);
+ PackagesView *changes = new PackagesView (true, false, false,
true, true);
+ changes->setQuery (query);
+
+ GtkWidget *install_btn = gtk_button_new_with_label (" install
");
+ GtkWidget *undo_btn = gtk_button_new_with_label (" < undo ");
+ g_signal_connect (G_OBJECT (install_btn), "clicked",
+ G_CALLBACK
(inner::install_button_clicked_cb), m_packages);
+ g_signal_connect (G_OBJECT (undo_btn), "clicked",
+ G_CALLBACK (inner::undo_button_clicked_cb),
changes);
+ //gtk_widget_set_sensitive (undo_btn, FALSE);
+
+ m_details_box = gtk_vbox_new (FALSE, 18);
+ //gtk_box_pack_start (GTK_BOX (m_details_box),
m_control->getWidget(), FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (m_details_box), gtk_label_new
(""), TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (m_details_box), install_btn,
FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (m_details_box), undo_btn, FALSE,
TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (m_details_box), gtk_label_new
(""), TRUE, TRUE, 0);
+
+ GtkWidget *type_combo = gtk_combo_box_new_text();
+ gtk_combo_box_append_text (GTK_COMBO_BOX (type_combo),
"Available");
+ gtk_combo_box_append_text (GTK_COMBO_BOX (type_combo),
"Upgrades");
+ gtk_combo_box_append_text (GTK_COMBO_BOX (type_combo),
"Installed");
+ gtk_combo_box_set_active (GTK_COMBO_BOX (type_combo), 0);
+
+ GtkWidget *find_align = gtk_alignment_new (0, 0, 0, 1);
+ gtk_container_add (GTK_CONTAINER (find_align),
m_filters->getNameWidget());
+
+ GtkWidget *packages_box = gtk_vbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (packages_box), type_combo, FALSE,
TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (packages_box),
m_packages->getWidget(), TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (packages_box), find_align, FALSE,
TRUE, 0);
+
+ GtkWidget *changes_label = gtk_label_new ("Changes:");
+ gtk_misc_set_alignment (GTK_MISC (changes_label), 0, 0.5);
+ GtkWidget *changes_box = gtk_vbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (changes_box), changes_label,
FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (changes_box),
changes->getWidget(), TRUE, TRUE, 0);
+
+ GtkSizeGroup *labels_group = gtk_size_group_new
(GTK_SIZE_GROUP_VERTICAL);
+ gtk_size_group_add_widget (labels_group, type_combo); //
type_combo is acting as a label
+ gtk_size_group_add_widget (labels_group, changes_label);
+ g_object_unref (G_OBJECT (labels_group));
+
+ m_box = gtk_hbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (m_box), packages_box, TRUE, TRUE,
0);
+ gtk_box_pack_start (GTK_BOX (m_box), m_details_box, FALSE,
TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (m_box), changes_box, TRUE, TRUE,
0);
+#endif

gtk_widget_show_all (m_box);
m_changes->startHack();
@@ -2631,6 +2778,10 @@

virtual void doQuery (Ypp::QueryPool::Query *query)
{
+#if (PKG_SELECTOR_FACE == 1)
+query = new Ypp::QueryPool::Query();
+query->addType (Ypp::Package::PACKAGE_TYPE);
+#endif
m_packages->setQuery (query);
}

@@ -2703,8 +2854,10 @@
ygtk_wizard_set_child (YGTK_WIZARD (wizard),
m_package_selector->getWidget());

createToolsButton();
+#if (PKG_SELECTOR_FACE == 0)
ygtk_wizard_set_information_widget (YGTK_WIZARD (wizard),
m_package_selector->m_changes->getWidget(), FALSE);
+#endif

Ypp::get()->setInterface (this);
Ypp::get()->addPkgListener (this);

Modified: branches/SuSE-Code-11-Branch/gtk/src/YGProgressBar.cc
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/gtk/src/YGProgressBar.cc?rev=55054&r1=55053&r2=55054&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/gtk/src/YGProgressBar.cc (original)
+++ branches/SuSE-Code-11-Branch/gtk/src/YGProgressBar.cc Mon Jan 26 18:26:41
2009
@@ -11,6 +11,30 @@
#include "YGWidget.h"
#include "YGi18n.h"

+std::string size_stdform (YFileSize_t size)
+{
+ long double mantissa = size;
+ int unit = 0;
+ for (; mantissa/1024 > 1; unit++)
+ mantissa /= 1024;
+
+ const char *unit_str = "";
+ switch (unit) {
+ // translator: byte shorthand
+ case 0: unit_str = _("B"); break;
+ case 1: unit_str = _("KB"); break;
+ case 2: unit_str = _("MB"); break;
+ case 3: unit_str = _("GB"); break;
+ case 4: unit_str = _("TB"); break;
+ default: mantissa = 0; break;
+ }
+
+ gchar *text = g_strdup_printf ("%.1f %s", (float) mantissa, unit_str);
+ std::string str (text);
+ g_free (text);
+ return str;
+}
+
#include "YProgressBar.h"

class YGProgressBar : public YProgressBar, public YGLabeledWidget
@@ -82,42 +106,13 @@
YGDownloadProgress *pThis = (YGDownloadProgress*) pData;
GtkProgressBar *bar = GTK_PROGRESS_BAR (pThis->getWidget());

- double current, total;
- int unit = 0;
- for (current = pThis->currentFileSize(), total =
pThis->expectedSize(); total/1024>1; unit++) {
- current /= 1024;
- total /= 1024;
+ gtk_progress_bar_set_fraction (bar, pThis->currentPercent() /
100.0);
+ if (pThis->expectedSize() > 0) {
+ std::string current (size_stdform
(pThis->currentFileSize()));
+ std::string total (size_stdform
(pThis->expectedSize()));
+ std::string text = current + " " + _("of") + " " +
total;
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR (bar),
text.c_str());
}
- float fraction = 0;
- if (total)
- fraction = MIN ((float) current / total, 1);
-
- gtk_progress_bar_set_fraction (bar, fraction);
- const char *unit_str;
- switch (unit) {
- case 0:
- unit_str = "B";
- break;
- case 1:
- unit_str = "KB";
- break;
- case 2:
- unit_str = "MB";
- break;
- case 3:
- unit_str = "GB";
- break;
- default:
- unit_str = "";
- break;
- }
- char *text;
- if (total)
- text = g_strdup_printf ("%.1f %s %s %.1f %s", current,
unit_str, _("of"), total, unit_str);
- else
- text = g_strdup_printf ("%.1f %s", current, unit_str);
- gtk_progress_bar_set_text (GTK_PROGRESS_BAR (bar), text);
- g_free (text);
return TRUE;
}


Modified: branches/SuSE-Code-11-Branch/gtk/src/YGSelectionModel.h
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/gtk/src/YGSelectionModel.h?rev=55054&r1=55053&r2=55054&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/gtk/src/YGSelectionModel.h (original)
+++ branches/SuSE-Code-11-Branch/gtk/src/YGSelectionModel.h Mon Jan 26 18:26:41
2009
@@ -29,7 +29,8 @@
virtual void doAddItem (YItem *item);
virtual void doDeleteAllItems();
virtual YItem *doSelectedItem() = 0;
- virtual void doSelectItem (GtkTreeIter *iter) = 0; // NULL to unselect
all
+ virtual void doSelectItem (GtkTreeIter *iter) = 0;
+ virtual void doUnselectAll() = 0;

YItemConstIterator itemsBegin() { return ywidget->itemsBegin(); }
YItemConstIterator itemsEnd() { return ywidget->itemsEnd(); }
@@ -79,7 +80,7 @@
} \
virtual void deselectAllItems() { \
ParentClass::deselectAllItems(); \
- doSelectItem (NULL); \
+ doUnselectAll(); \
} \
virtual YItem *selectedItem() { \
return doSelectedItem(); \

Modified: branches/SuSE-Code-11-Branch/gtk/src/YGTable.cc
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/gtk/src/YGTable.cc?rev=55054&r1=55053&r2=55054&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/gtk/src/YGTable.cc (original)
+++ branches/SuSE-Code-11-Branch/gtk/src/YGTable.cc Mon Jan 26 18:26:41 2009
@@ -9,23 +9,25 @@
#include "YSelectionWidget.h"
#include "YGSelectionModel.h"
#include "ygtkcellrenderertextpixbuf.h"
+#include "ygtkscrolledwindow.h"
+#include <time.h>

/* A generic widget for table related widgets. */
class YGTableView : public YGScrolledWidget, public YGSelectionModel
{
protected:
int m_colsNb;
- bool m_blockSelected; // GtkTreeSelection signals act weird
+ time_t m_blockTime; // GtkTreeSelection signals act weird

public:
YGTableView (YWidget *ywidget, YWidget *parent, const string &label,
bool ordinaryModel, bool isTree)
: YGScrolledWidget (ywidget, parent, label, YD_VERT,
- GTK_TYPE_TREE_VIEW, NULL)
+ YGTK_TYPE_TREE_VIEW, NULL)
, YGSelectionModel ((YSelectionWidget *) ywidget, ordinaryModel, isTree)
{
IMPL
- m_blockSelected = false;
+ m_blockTime = time (NULL);
if (ordinaryModel) {
appendIconTextColumn ("", YAlignUnchanged,
YGSelectionModel::ICON_COLUMN,
YGSelectionModel::LABEL_COLUMN);
@@ -81,7 +83,6 @@

void appendCheckColumn (string header, int bool_col)
{
- IMPL
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;

@@ -99,7 +100,6 @@

void appendDumbColumn()
{
- IMPL
gtk_tree_view_append_column (getView(),
gtk_tree_view_column_new());
}

@@ -109,20 +109,28 @@
virtual bool immediateEvent() { return true; }

// YGSelectionModel
+
virtual void doSelectItem (GtkTreeIter *iter)
{
- m_blockSelected = true;
- if (iter) {
+ if (!gtk_tree_selection_iter_is_selected (getSelection(),
iter)) {
+ m_blockTime = time (NULL);
GtkTreePath *path = gtk_tree_model_get_path
(getModel(), iter);
gtk_tree_view_expand_to_path (getView(), path);

- gtk_tree_selection_select_iter (getSelection(), iter);
if (gtk_tree_selection_get_mode (getSelection()) !=
GTK_SELECTION_MULTIPLE)
gtk_tree_view_scroll_to_cell (getView(), path,
NULL, TRUE, 0.5, 0);
gtk_tree_path_free (path);
+
+ gtk_tree_selection_select_iter (getSelection(), iter);
}
- else
+ }
+
+ virtual void doUnselectAll()
+ {
+ if (gtk_tree_selection_count_selected_rows (getSelection())) {
+ m_blockTime = time (NULL);
gtk_tree_selection_unselect_all (getSelection());
+ }
}

virtual YItem *doSelectedItem()
@@ -167,10 +175,8 @@

static void selection_changed_cb (GtkTreeSelection *selection,
YGTableView *pThis)
{
- if (pThis->m_blockSelected) {
- pThis->m_blockSelected = false;
+ if (time (NULL) - pThis->m_blockTime <= 2)
return;
- }
if (!pThis->toggleMode()) {
GtkTreeSelection *selection = pThis->getSelection();
for (YItemConstIterator it = pThis->itemsBegin(); it !=
pThis->itemsEnd(); it++) {
@@ -203,6 +209,8 @@
};

#include "YTable.h"
+#include "YGDialog.h"
+#include <gdk/gdkkeysyms.h>

class YGTable : public YTable, public YGTableView
{
@@ -243,6 +251,8 @@

connect (getWidget(), "row-activated", G_CALLBACK
(activated_cb), (YGTableView *) this);
connect (getSelection(), "changed", G_CALLBACK
(selection_changed_cb), (YGTableView *) this);
+ connect (getWidget(), "right-click", G_CALLBACK
(right_click_cb), this);
+ connect (getWidget(), "key-press-event", G_CALLBACK
(key_press_event_cb), this);
}

virtual void setKeepSorting (bool keepSorting)
@@ -322,6 +332,65 @@
}

YGSELECTION_WIDGET_IMPL (YTable)
+
+ // callbacks
+
+ // hack up a popup menu and honor the delete key as suggested at:
+ // http://mvidner.blogspot.com/2009/01/yast-ui-table-usability.html
+ static void activateButton (YWidget *button)
+ {
+ YWidgetEvent *event = new YWidgetEvent (button,
YEvent::Activated);
+ YGUI::ui()->sendEvent (event);
+ }
+
+ static void right_click_cb (YGtkTreeView *view, gboolean outreach,
YGTable *pThis)
+ {
+ if (!YGDialog::currentDialog()->getFunctionWidget (5) ||
+ // undetermined case -- more than one table exists
+ YGDialog::currentDialog()->getClassWidgets
("YTable").size() > 1) {
+ gtk_widget_error_bell (GTK_WIDGET (view));
+ return;
+ }
+
+ struct inner {
+ static void key_activate_cb (GtkMenuItem *item, YWidget
*button)
+ { activateButton (button); }
+ static void appendItem (GtkWidget *menu, const gchar
*stock, int key)
+ {
+ YWidget *button =
YGDialog::currentDialog()->getFunctionWidget (key);
+ if (button) {
+ GtkWidget *item;
+ item =
gtk_image_menu_item_new_from_stock (stock, NULL);
+ gtk_menu_shell_append (GTK_MENU_SHELL
(menu), item);
+ g_signal_connect (G_OBJECT (item),
"activate",
+
G_CALLBACK (key_activate_cb), button);
+ }
+ }
+ };
+
+ GtkWidget *menu = gtk_menu_new();
+ if (outreach)
+ inner::appendItem (menu, GTK_STOCK_ADD, 3);
+ else {
+ inner::appendItem (menu, GTK_STOCK_EDIT, 4);
+ inner::appendItem (menu, GTK_STOCK_DELETE, 5);
+ }
+ ygtk_tree_view_popup_menu (view, menu);
+ }
+
+ static gboolean key_press_event_cb (GtkWidget *widget, GdkEventKey
*event, YGTable *pThis)
+ {
+ if (event->keyval == GDK_Delete) {
+ YWidget *button =
YGDialog::currentDialog()->getFunctionWidget (5);
+ if (button)
+ activateButton (button);
+ else
+ gtk_widget_error_bell (widget);
+ return TRUE;
+ }
+ return FALSE;
+ }
+
};

#if YAST2_VERSION >= 2017005
@@ -386,8 +455,8 @@
}

// YMultiSelectionBox
- virtual void doAddItem (YItem *item)
- {
+ virtual void doAddItem (YItem *item)
+ {
GtkTreeIter iter;
addRow (&iter, item, false);
setCellToggle (&iter, 0, item->selected());
@@ -395,20 +464,6 @@
setCellLabel (&iter, 2, item->label());
}

- virtual void doSelectItem (YItem *item)
- {
- GtkTreeIter iter;
- if (getIter (item, &iter))
- setCellToggle (&iter, 0, item->selected());
- else { // unselect all
- if (gtk_tree_model_get_iter_first (getModel(), &iter)) {
- do {
- setCellToggle (&iter, 0, false);
- } while (gtk_tree_model_iter_next (getModel(),
&iter));
- }
- }
- }
-
virtual YItem *currentItem()
{ return doSelectedItem(); }

@@ -426,13 +481,28 @@
// Events
static void multi_activated_cb (GtkTreeView *tree_view, GtkTreePath
*path,
GtkTreeViewColumn *column,
YGMultiSelectionBox* pThis)
+ { pThis->toggle (path, 0); }
+
+ // YGSelectionModel
+
+ virtual void doSelectItem (GtkTreeIter *iter)
{
- IMPL
- pThis->toggle (path, 0);
+ setCellToggle (iter, 0, true);
}

- virtual bool isShrinkable() { return shrinkable(); }
+ virtual void doUnselectAll()
+ {
+ GtkTreeIter iter;
+ if (gtk_tree_model_get_iter_first (getModel(), &iter)) {
+ do {
+ setCellToggle (&iter, 0, false);
+ } while (gtk_tree_model_iter_next (getModel(), &iter));
+ }
+ }

+ // YGWidget
+
+ virtual bool isShrinkable() { return shrinkable(); }
YGWIDGET_IMPL_COMMON (YMultiSelectionBox)
YGSELECTION_WIDGET_IMPL (YMultiSelectionBox)
};
@@ -454,10 +524,10 @@
: YTree (NULL, label)
, YGTableView (this, parent, label, true, true)
{
- connect (getWidget(), "row-activated", G_CALLBACK
(activated_cb), this);
- connect (getWidget(), "cursor-changed", G_CALLBACK
(row_selected_cb), this);
connect (getWidget(), "row-collapsed", G_CALLBACK
(row_collapsed_cb), this);
connect (getWidget(), "row-expanded", G_CALLBACK
(row_expanded_cb), this);
+ connect (getWidget(), "cursor-changed", G_CALLBACK
(row_selected_cb), this);
+ connect (getWidget(), "row-activated", G_CALLBACK
(activated_cb), (YGTableView *) this);
}

// YTree
@@ -519,6 +589,7 @@
}
}
}
+
static void row_selected_cb (GtkTreeView *view, YGTree *pThis)
{
// expand selected row

Modified: branches/SuSE-Code-11-Branch/gtk/src/YGText.cc
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/gtk/src/YGText.cc?rev=55054&r1=55053&r2=55054&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/gtk/src/YGText.cc (original)
+++ branches/SuSE-Code-11-Branch/gtk/src/YGText.cc Mon Jan 26 18:26:41 2009
@@ -187,11 +187,14 @@
ygtk_html_wrap_set_text (getWidget(), text.c_str(), TRUE);
}

- void setRichText (const string &_text)
+ void setRichText (const string &text)
{
+#if 0 // current done at the XHTML treatment level, we may want to enable
+ // this code so that we replace the entity for all widgets
string text (_text);
std::string productName = YUI::app()->productName();
YGUtils::replace (text, "&product;", 9, productName.c_str());
+#endif
ygtk_html_wrap_set_text (getWidget(), text.c_str(), FALSE);
}


Modified: branches/SuSE-Code-11-Branch/gtk/src/YGUtils.cc
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/gtk/src/YGUtils.cc?rev=55054&r1=55053&r2=55054&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/gtk/src/YGUtils.cc (original)
+++ branches/SuSE-Code-11-Branch/gtk/src/YGUtils.cc Mon Jan 26 18:26:41 2009
@@ -100,6 +100,7 @@

static const EntityMap entities[] = {
{ "nbsp", " " },
+ { "product", 0 }, // dynamic
};

static const EntityMap *lookup_entity (const char *html)
@@ -238,7 +239,10 @@
else if (instr[i] == '&') { // Entity
const EntityMap *entity = lookup_entity (instr+i);
if (entity) {
- g_string_append (outp, entity->text);
+ if (!strcmp (entity->html, "product"))
+ g_string_append (outp,
YUI::app()->productName().c_str());
+ else
+ g_string_append (outp, entity->text);
i += strlen (entity->html);
if (instr[i+1] == ';') i++;
}
@@ -303,7 +307,7 @@
if (!*j) {
// not valid text
g_signal_stop_emission_by_name
(editable, "insert_text");
- gdk_beep();
+ gtk_widget_error_bell
(GTK_WIDGET (editable));
return;
}
}

Modified: branches/SuSE-Code-11-Branch/gtk/src/ygtkscrolledwindow.c
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/gtk/src/ygtkscrolledwindow.c?rev=55054&r1=55053&r2=55054&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/gtk/src/ygtkscrolledwindow.c (original)
+++ branches/SuSE-Code-11-Branch/gtk/src/ygtkscrolledwindow.c Mon Jan 26
18:26:41 2009
@@ -97,3 +97,82 @@
gtkobject_class->destroy = ygtk_scrolled_window_destroy;
}

+/* YGtkTreeView widget */
+// check the header file for information about this widget
+
+static guint right_click_signal = 0;
+
+G_DEFINE_TYPE (YGtkTreeView, ygtk_tree_view, GTK_TYPE_TREE_VIEW)
+
+static void ygtk_tree_view_init (YGtkTreeView *view)
+{
+}
+
+static void _gtk_widget_destroy (gpointer widget)
+{ gtk_widget_destroy (GTK_WIDGET (widget)); }
+
+void ygtk_tree_view_popup_menu (YGtkTreeView *view, GtkWidget *menu)
+{
+ GtkWidget *widget = GTK_WIDGET (view);
+ // popup hack -- we can't destroy the menu at hide because it may not
have
+ // emitted signals yet -- destroy it when replaced or the widget
destroyed
+ g_object_set_data_full (G_OBJECT (view), "popup", menu,
_gtk_widget_destroy);
+
+ guint32 time = gtk_get_current_event_time();
+ gtk_menu_attach_to_widget (GTK_MENU (menu), widget, NULL);
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 3, time);
+ gtk_widget_show_all (menu);
+}
+
+static gboolean ygtk_tree_view_button_press_event (GtkWidget *widget,
GdkEventButton *event)
+{
+ // workaround (based on gedit): we want the tree view to receive this
press in order
+ // to select the row, but we can't use connect_after, so we throw a
dummy mouse press
+ if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
+ static gboolean safeguard = FALSE;
+ if (safeguard) return FALSE;
+ safeguard = TRUE;
+
+ GtkTreeView *view = GTK_TREE_VIEW (widget);
+ GtkTreeSelection *selection = gtk_tree_view_get_selection
(view);
+
+ gboolean outreach;
+ outreach = !gtk_tree_view_get_path_at_pos (view, event->x,
event->y, 0, 0, 0, 0);
+ if (gtk_tree_selection_count_selected_rows (selection) <= 1) {
+ // if there is a selection, let it be
+ event->button = 1;
+ if (!gtk_widget_event (widget, (GdkEvent *) event))
+ return FALSE;
+ }
+ g_signal_emit (widget, right_click_signal, 0, outreach);
+ safeguard = FALSE;
+ return TRUE;
+ }
+ return GTK_WIDGET_CLASS
(ygtk_tree_view_parent_class)->button_press_event (widget, event);
+}
+
+static gboolean _ygtk_tree_view_popup_menu (GtkWidget *widget)
+{
+ GtkTreeView *view = GTK_TREE_VIEW (widget);
+ GtkTreeSelection *selection = gtk_tree_view_get_selection (view);
+ gboolean outreach = gtk_tree_selection_count_selected_rows (selection)
== 0;
+
+ g_signal_emit (widget, right_click_signal, 0, outreach);
+ return TRUE;
+}
+
+GtkWidget *ygtk_tree_view_new (void)
+{ return g_object_new (YGTK_TYPE_TREE_VIEW, NULL); }
+
+static void ygtk_tree_view_class_init (YGtkTreeViewClass *klass)
+{
+ GtkWidgetClass *gtkwidget_class = GTK_WIDGET_CLASS (klass);
+ gtkwidget_class->button_press_event = ygtk_tree_view_button_press_event;
+ gtkwidget_class->popup_menu = _ygtk_tree_view_popup_menu;
+
+ right_click_signal = g_signal_new ("right-click",
+ G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (YGtkTreeViewClass, right_click),
+ NULL, NULL, gtk_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1,
G_TYPE_BOOLEAN);
+}
+

Modified: branches/SuSE-Code-11-Branch/gtk/src/ygtkscrolledwindow.h
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/gtk/src/ygtkscrolledwindow.h?rev=55054&r1=55053&r2=55054&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/gtk/src/ygtkscrolledwindow.h (original)
+++ branches/SuSE-Code-11-Branch/gtk/src/ygtkscrolledwindow.h Mon Jan 26
18:26:41 2009
@@ -49,3 +49,45 @@
G_END_DECLS
#endif /*YGTK_SCROLLED_WINDOW_H*/

+/* YGtkTreeView hacks support for a right-click signal.
+*/
+
+#ifndef YGTK_TREE_VIEW_H
+#define YGTK_TREE_VIEW_H
+
+#include <gtk/gtktreeview.h>
+G_BEGIN_DECLS
+
+#define YGTK_TYPE_TREE_VIEW (ygtk_tree_view_get_type ())
+#define YGTK_TREE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ YGTK_TYPE_TREE_VIEW, YGtkScrolledWindow))
+#define YGTK_TREE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ YGTK_TYPE_TREE_VIEW, YGtkScrolledWindowClass))
+#define YGTK_IS_TREE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ YGTK_TYPE_TREE_VIEW))
+#define YGTK_IS_TREE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ YGTK_TYPE_TREE_VIEW))
+#define YGTK_TREE_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ YGTK_TYPE_TREE_VIEW, YGtkScrolledWindowClass))
+
+typedef struct _YGtkTreeView
+{
+ GtkTreeView parent;
+} YGtkTreeView;
+
+typedef struct _YGtkTreeViewClass
+{
+ GtkTreeViewClass parent_class;
+
+ // signals:
+ void (*right_click) (YGtkTreeView *view, gboolean outreach);
+} YGtkTreeViewClass;
+
+GtkWidget* ygtk_tree_view_new (void);
+GType ygtk_tree_view_get_type (void) G_GNUC_CONST;
+
+void ygtk_tree_view_popup_menu (YGtkTreeView *view, GtkWidget *menu);
+
+G_END_DECLS
+#endif /*YGTK_TREE_VIEW_H*/
+

Modified: branches/SuSE-Code-11-Branch/gtk/src/ygtkzyppwrapper.cc
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/gtk/src/ygtkzyppwrapper.cc?rev=55054&r1=55053&r2=55054&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/gtk/src/ygtkzyppwrapper.cc (original)
+++ branches/SuSE-Code-11-Branch/gtk/src/ygtkzyppwrapper.cc Mon Jan 26 18:26:41
2009
@@ -222,8 +222,11 @@
case YGtkZyppModel::ICON_COLUMN:
return GDK_TYPE_PIXBUF;
case YGtkZyppModel::NAME_COLUMN:
+ case YGtkZyppModel::NAME_TRUNCATE_COLUMN:
case YGtkZyppModel::NAME_DESCRIPTION_COLUMN:
return G_TYPE_STRING;
+ case YGtkZyppModel::IS_INSTALLED_COLUMN:
+ return G_TYPE_BOOLEAN;
case YGtkZyppModel::PTR_COLUMN:
return G_TYPE_POINTER;
}
@@ -315,8 +318,19 @@
}
case YGtkZyppModel::NAME_COLUMN:
{
- std::string name = YGUtils::truncate (package->name(),
15, 1);
- g_value_set_string (value, g_strdup (name.c_str()));
+ bool highlight = zmodel->pool->highlight (pool_iter);
+ std::string str (package->name());
+ if (highlight)
+ str = "<b>" + str + "</b>";
+ if (package->toModify())
+ str = "<i>" + str + "</i>";
+ g_value_set_string (value, g_strdup (str.c_str()));
+ break;
+ }
+ case YGtkZyppModel::NAME_TRUNCATE_COLUMN:
+ {
+ std::string str (YGUtils::truncate (package->name(),
15, 1));
+ g_value_set_string (value, g_strdup (str.c_str()));
break;
}
case YGtkZyppModel::NAME_DESCRIPTION_COLUMN:
@@ -335,6 +349,13 @@
g_value_set_string (value, g_strdup (str.c_str()));
break;
}
+ case YGtkZyppModel::IS_INSTALLED_COLUMN:
+ {
+ bool installed = package->toInstall() ||
+ (package->isInstalled() &&
!package->toRemove());
+ g_value_set_boolean (value, installed);
+ break;
+ }
case YGtkZyppModel::PTR_COLUMN:
{
void *ptr;

Modified: branches/SuSE-Code-11-Branch/gtk/src/ygtkzyppwrapper.h
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/gtk/src/ygtkzyppwrapper.h?rev=55054&r1=55053&r2=55054&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/gtk/src/ygtkzyppwrapper.h (original)
+++ branches/SuSE-Code-11-Branch/gtk/src/ygtkzyppwrapper.h Mon Jan 26 18:26:41
2009
@@ -26,8 +26,8 @@
GObject parent;

enum Columns {
- ICON_COLUMN, NAME_COLUMN, NAME_DESCRIPTION_COLUMN,
- PTR_COLUMN, TOTAL_COLUMNS
+ ICON_COLUMN, NAME_COLUMN, NAME_TRUNCATE_COLUMN,
NAME_DESCRIPTION_COLUMN,
+ IS_INSTALLED_COLUMN, PTR_COLUMN, TOTAL_COLUMNS
};

Ypp::Pool *pool;

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

< Previous Next >
This Thread
  • No further messages