Author: rpmcruz
Date: Thu Jan 7 01:36:18 2010
New Revision: 60250
URL: http://svn.opensuse.org/viewcvs/yast?rev=60250&view=rev
Log:
* src/pkg/yzyppwrapper.h/cc: added API to read changes log.
* src/pkg/YGPackageSelector.cc: improved look of --undo-old-style.
* src/pkg/YGPackageSelector.cc: as requested by Atri,
added previous changes to the changes sidebar. See flag
--undo-log-all and --undo-log-changed.
* src/pkg/ygtkpackageview.cc: changed action button label/stock
behavior.
* src/pkg/ygtkpackageview.cc: as suggested by Atri, added
flag --action-col-label to allow disabling action button labels.
* src/pkg/ygtkpackageview.cc: added --colorful-rows.
Modified:
trunk/gtk/ChangeLog
trunk/gtk/src/YGPackageSelectorPluginStub.cc
trunk/gtk/src/pkg/YGPackageSelector.cc
trunk/gtk/src/pkg/ygtkpackageview.cc
trunk/gtk/src/pkg/yzyppwrapper.cc
trunk/gtk/src/pkg/yzyppwrapper.h
Modified: trunk/gtk/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=60250&r1=60249&r2=60250&view=diff
==============================================================================
--- trunk/gtk/ChangeLog (original)
+++ trunk/gtk/ChangeLog Thu Jan 7 01:36:18 2010
@@ -1,3 +1,21 @@
+2010-01-07 Ricardo Cruz
+
+ * src/pkg/yzyppwrapper.h/cc: added API to read changes log.
+
+ * src/pkg/YGPackageSelector.cc: improved look of --undo-old-style.
+
+ * src/pkg/YGPackageSelector.cc: as requested by Atri,
+ added previous changes to the changes sidebar. See flag
+ --undo-log-all and --undo-log-changed.
+
+ * src/pkg/ygtkpackageview.cc: changed action button label/stock
+ behavior.
+
+ * src/pkg/ygtkpackageview.cc: as suggested by Atri, added
+ flag --action-col-label to allow disabling action button labels.
+
+ * src/pkg/ygtkpackageview.cc: added --colorful-rows.
+
2009-12-29 Ricardo Cruz
* src/pkg/YGPackageSelector.cc: added --status-top
Modified: trunk/gtk/src/YGPackageSelectorPluginStub.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGPackageSelectorPluginStub.cc?rev=60250&r1=60249&r2=60250&view=diff
==============================================================================
--- trunk/gtk/src/YGPackageSelectorPluginStub.cc (original)
+++ trunk/gtk/src/YGPackageSelectorPluginStub.cc Thu Jan 7 01:36:18 2010
@@ -14,10 +14,12 @@
bool search_entry_side = true, search_entry_top = false, dynamic_sidebar = false,
categories_side = true, categories_top = false, status_side = false,
status_top = false, status_tabs = true, status_tabs_as_actions = false,
- undo_side = false, undo_tab = true, undo_old_style = false, status_col = false,
- action_col = true, action_col_as_button = true, action_col_as_check = false,
- version_col = true, single_line_rows = false, details_start_hide = true,
- toolbar_top = false, toolbar_yast = false, arrange_by = false;
+ undo_side = false, undo_tab = true, undo_old_style = false, undo_log_all = false,
+ undo_log_changed = false, status_col = false, action_col = true,
+ action_col_as_button = true, action_col_as_check = false, action_col_label = true,
+ version_col = true, single_line_rows = false, colorful_rows = false,
+ details_start_hide = true, toolbar_top = false, toolbar_yast = false,
+ arrange_by = false;
struct Arg {
const char *arg;
@@ -36,12 +38,16 @@
{ "undo-side", &undo_side },
{ "undo-tab", &undo_tab },
{ "undo-old-style", &undo_old_style },
+ { "undo-log-all", &undo_log_all },
+ { "undo-log-changed", &undo_log_changed },
{ "status-col", &status_col },
{ "action-col", &action_col },
{ "action-col-as-button", &action_col_as_button },
{ "action-col-as-check", &action_col_as_check },
+ { "action-col-label", &action_col_label },
{ "version-col", &version_col },
{ "single-line-rows", &single_line_rows },
+ { "colorful-rows", &colorful_rows },
{ "details-start-hide", &details_start_hide },
{ "toolbar-top", &toolbar_top },
{ "toolbar-yast", &toolbar_yast },
Modified: trunk/gtk/src/pkg/YGPackageSelector.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/pkg/YGPackageSelector.cc?rev=60250&r1=60249&r2=60250&view=diff
==============================================================================
--- trunk/gtk/src/pkg/YGPackageSelector.cc (original)
+++ trunk/gtk/src/pkg/YGPackageSelector.cc Thu Jan 7 01:36:18 2010
@@ -29,9 +29,9 @@
// experiments:
extern bool search_entry_side, search_entry_top, dynamic_sidebar, categories_side,
categories_top, status_side, status_top, status_tabs, status_tabs_as_actions,
- undo_side, undo_tab, undo_old_style, status_col, action_col, action_col_as_button,
- action_col_as_check, version_col, single_line_rows, details_start_hide,
- toolbar_top, toolbar_yast, arrange_by;
+ undo_side, undo_tab, undo_old_style, undo_log_all, undo_log_changed, status_col,
+ action_col, action_col_as_button, action_col_as_check, version_col,
+ single_line_rows, details_start_hide, toolbar_top, toolbar_yast, arrange_by;
//** UI components -- split up for re-usability, but mostly for readability
@@ -168,6 +168,43 @@
#endif
};
+static void small_button_style_set_cb (GtkWidget *button, GtkStyle *prev_style)
+{
+ // based on gedit
+ int width, height;
+ gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (button),
+ GTK_ICON_SIZE_MENU, &width, &height);
+ gtk_widget_set_size_request (button, width+2, height+2);
+}
+
+static GtkWidget *create_small_button (const char *stock_icon, const char *tooltip)
+{
+ static bool first_time = true;
+ if (first_time) {
+ first_time = false;
+ gtk_rc_parse_string (
+ "style \"small-button-style\"\n"
+ "{\n"
+ " GtkWidget::focus-padding = 0\n"
+ " GtkWidget::focus-line-width = 0\n"
+ " xthickness = 0\n"
+ " ythickness = 0\n"
+ "}\n"
+ "widget \"*.small-button\" style \"small-button-style\"");
+ }
+
+ GtkWidget *button = gtk_button_new();
+ gtk_widget_set_name (button, "small-button");
+ gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
+ gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+ gtk_widget_set_tooltip_text (button, tooltip);
+ GtkWidget *image = gtk_image_new_from_stock (stock_icon, GTK_ICON_SIZE_MENU);
+ gtk_button_set_image (GTK_BUTTON (button), image);
+ g_signal_connect (G_OBJECT (button), "style-set",
+ G_CALLBACK (small_button_style_set_cb), NULL);
+ return button;
+}
+
class ChangesPane : public Ypp::PkgList::Listener
{
struct Entry {
@@ -179,13 +216,10 @@
m_label = gtk_label_new ("");
gtk_misc_set_alignment (GTK_MISC (m_label), 0, 0.5);
gtk_label_set_ellipsize (GTK_LABEL (m_label), PANGO_ELLIPSIZE_END);
- m_button = gtk_button_new();
- gtk_widget_set_tooltip_text (m_button, _("Undo"));
- GtkWidget *undo_image = gtk_image_new_from_stock (GTK_STOCK_UNDO, GTK_ICON_SIZE_MENU);
- gtk_button_set_image (GTK_BUTTON (m_button), undo_image);
+ m_button = create_small_button (GTK_STOCK_UNDO, _("Undo"));
m_box = gtk_hbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (m_box), m_label, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (m_box), m_button, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (m_box), m_button, FALSE, TRUE, 0);
gtk_widget_show_all (m_box);
modified (package);
g_signal_connect (G_OBJECT (m_button), "clicked",
@@ -232,46 +266,120 @@
}
};
-GtkWidget *m_box, *m_entries_box;
+ struct LogEntry {
+ GtkWidget *m_box, *m_label, *m_button;
+ Ypp::Log::Entry::Action m_action;
+ GtkWidget *getWidget() { return m_box; }
+
+ LogEntry (Ypp::Package *package, Ypp::Log::Entry::Action action)
+ : m_action (action)
+ {
+ std::string label = action == Ypp::Log::Entry::INSTALL_ACTION ?
+ _("install") : _("remove");
+ label += " " + package->name();
+ m_label = gtk_label_new (label.c_str());
+ gtk_misc_set_alignment (GTK_MISC (m_label), 0, 0.5);
+ gtk_label_set_ellipsize (GTK_LABEL (m_label), PANGO_ELLIPSIZE_END);
+ if (canUndo (package, action)) {
+ m_button = create_small_button (GTK_STOCK_UNDO, _("Undo"));
+ m_box = gtk_hbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (m_box), m_label, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (m_box), m_button, FALSE, TRUE, 0);
+ g_signal_connect (G_OBJECT (m_button), "clicked",
+ G_CALLBACK (undo_clicked_cb), package);
+ }
+ else
+ m_box = m_label;
+ gtk_widget_show_all (m_box);
+ }
+
+ static void undo_clicked_cb (GtkButton *button, Ypp::Package *package)
+ {
+#if 0
+ if (m_action == Ypp::Log::Entry::INSTALL_ACTION)
+ package->remove();
+ else
+ package->install (0);
+#endif
+ if (package->isInstalled())
+ package->remove();
+ else
+ package->install (0);
+ gtk_widget_hide (GTK_WIDGET (button));
+ }
+
+ static bool canUndo (Ypp::Package *package, Ypp::Log::Entry::Action action)
+ {
+ return (action == Ypp::Log::Entry::INSTALL_ACTION && package->isInstalled())
+ || (action == Ypp::Log::Entry::REMOVE_ACTION && !package->isInstalled());
+ }
+ };
+
+GtkWidget *m_handle_box, *m_empty_label, *m_entries_box;
Ypp::PkgList m_pool;
GList *m_entries;
public:
GtkWidget *getWidget()
- { return m_box; }
+ { return m_handle_box; }
ChangesPane()
: m_entries (NULL)
{
- GtkWidget *heading = gtk_label_new (_("Changes:"));
+ GtkWidget *heading = gtk_label_new (_("To perform now:"));
YGUtils::setWidgetFont (heading, PANGO_STYLE_NORMAL, PANGO_WEIGHT_BOLD, PANGO_SCALE_MEDIUM);
gtk_misc_set_alignment (GTK_MISC (heading), 0, 0.5);
- m_entries_box = gtk_vbox_new (FALSE, 4);
+ m_entries_box = gtk_vbox_new (FALSE, 2);
+
+ m_empty_label = gtk_label_new (_("Package changes will\nbe listed here."));
+ YGUtils::setWidgetFont (m_empty_label, PANGO_STYLE_ITALIC, PANGO_WEIGHT_NORMAL, PANGO_SCALE_MEDIUM);
+ gtk_label_set_justify (GTK_LABEL (m_empty_label), GTK_JUSTIFY_CENTER);
+ gtk_misc_set_alignment (GTK_MISC (m_empty_label), 0.5, 0.5);
+
+ GtkWidget *vbox = gtk_vbox_new (FALSE, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
+ gtk_box_pack_start (GTK_BOX (vbox), heading, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), m_empty_label, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), m_entries_box, TRUE, TRUE, 0);
+
+ struct inner {
+ static gboolean expose_cb (GtkWidget *widget, GdkEventExpose *event)
+ {
+ cairo_t *cr = gdk_cairo_create (widget->window);
+ GdkColor color = { 0, 255 << 8, 255 << 8, 255 << 8 };
+ gdk_cairo_set_source_color (cr, &color);
+ cairo_rectangle (cr, event->area.x, event->area.y,
+ event->area.width, event->area.height);
+ cairo_fill (cr);
+ cairo_destroy (cr);
+ return FALSE;
+ }
+ };
+ g_signal_connect (G_OBJECT (vbox), "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_NEVER, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll),
- m_entries_box);
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll), vbox);
GtkWidget *port = gtk_bin_get_child (GTK_BIN (scroll));
gtk_viewport_set_shadow_type (GTK_VIEWPORT (port), GTK_SHADOW_NONE);
- GtkWidget *vbox = gtk_vbox_new (FALSE, 6);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
- gtk_box_pack_start (GTK_BOX (vbox), heading, FALSE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), scroll, TRUE, TRUE, 0);
-
+/*
ygtk_wizard_set_information_expose_hook (vbox, &vbox->allocation);
ygtk_wizard_set_information_expose_hook (m_entries_box, &m_entries_box->allocation);
-
+*/
int width = YGUtils::getCharsWidth (vbox, 32);
gtk_widget_set_size_request (vbox, width, -1);
gtk_widget_show_all (vbox);
- m_box = gtk_handle_box_new();
- gtk_container_add (GTK_CONTAINER (m_box), vbox);
- gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (m_box), GTK_POS_TOP);
- gtk_handle_box_set_snap_edge (GTK_HANDLE_BOX (m_box), GTK_POS_RIGHT);
+ GtkWidget *frame = gtk_frame_new (NULL);
+ gtk_container_add (GTK_CONTAINER (frame), scroll);
+
+ m_handle_box = gtk_handle_box_new();
+ gtk_container_add (GTK_CONTAINER (m_handle_box), frame);
+ gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (m_handle_box), GTK_POS_TOP);
+ gtk_handle_box_set_snap_edge (GTK_HANDLE_BOX (m_handle_box), GTK_POS_RIGHT);
Ypp::QueryBase *query = new Ypp::QueryProperty ("to-modify", true);
/* if (pkg_selector->onlineUpdateMode())
@@ -281,6 +389,25 @@
for (int i = 0; i < m_pool.size(); i++)
ChangesPane::entryInserted (m_pool, i, m_pool.get (i));
m_pool.addListener (this);
+
+ if (undo_log_all || undo_log_changed) {
+ GtkWidget *log_box = gtk_vbox_new (FALSE, 2);
+ GtkWidget *heading = gtk_label_new (_("Past changes:"));
+ YGUtils::setWidgetFont (heading, PANGO_STYLE_NORMAL, PANGO_WEIGHT_BOLD, PANGO_SCALE_MEDIUM);
+ gtk_misc_set_alignment (GTK_MISC (heading), 0, 0.5);
+ gtk_box_pack_start (GTK_BOX (vbox), heading, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), log_box, TRUE, TRUE, 0);
+
+ for (int i = 0; Ypp::get()->getLog()->getEntry (i); i++) {
+ Ypp::Log::Entry *entry = Ypp::get()->getLog()->getEntry (i);
+ if (entry->package)
+ if (undo_log_all || LogEntry::canUndo (entry->package, entry->action)) {
+ // FIXME: free these stuff
+ LogEntry *log_entry = new LogEntry (entry->package, entry->action);
+ gtk_box_pack_start (GTK_BOX (log_box), log_entry->getWidget(), FALSE, TRUE, 0);
+ }
+ }
+ }
}
~ChangesPane()
@@ -293,6 +420,7 @@
void startHack() // call after init, after you did a show_all in the dialog
{
UpdateVisible();
+
// ugly: signal modified for all entries to allow them to hide undo buttons
GList *i;
int index;
@@ -303,8 +431,10 @@
void UpdateVisible()
{
- if (details_start_hide)
- m_entries != NULL ? gtk_widget_show (m_box) : gtk_widget_hide (m_box);
+ if (details_start_hide && !(undo_log_all || undo_log_changed))
+ m_entries ? gtk_widget_show (m_handle_box) : gtk_widget_hide (m_handle_box);
+ if (m_entries)
+ gtk_widget_hide (m_empty_label);
}
virtual void entryInserted (const Ypp::PkgList list, int index, Ypp::Package *package)
@@ -3078,13 +3208,16 @@
GtkWidget *packages_pane = gtk_hpaned_new();
gtk_paned_pack1 (GTK_PANED (packages_pane), packages_button_box, TRUE, FALSE);
+ ChangesPane *changes_pane = 0;
GtkWidget *undo_widget;
if (undo_side) {
- if (undo_old_style)
- undo_widget = (new ChangesPane())->getWidget();
+ if (undo_old_style) {
+ changes_pane = new ChangesPane();
+ undo_widget = changes_pane->getWidget();
+ }
else
undo_widget = undo_view->createView (this, false);
- gtk_paned_pack2 (GTK_PANED (packages_pane), undo_widget, FALSE, FALSE);
+ gtk_paned_pack2 (GTK_PANED (packages_pane), undo_widget, FALSE, TRUE);
gtk_paned_set_position (GTK_PANED (packages_pane), 350);
}
@@ -3167,15 +3300,14 @@
m_widget = vbox;
gtk_widget_show_all (m_widget);
- if (details_start_hide) {
+ if (details_start_hide)
gtk_widget_hide (m_details->getWidget());
- if (undo_old_style)
- gtk_widget_hide (undo_widget);
- }
else
m_details->setPackage (NULL);
if (!categories_side && !search_entry_side && !status_side)
gtk_widget_hide (side_vbox);
+ if (changes_pane)
+ changes_pane->startHack();
}
~UI()
Modified: trunk/gtk/src/pkg/ygtkpackageview.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/pkg/ygtkpackageview.cc?rev=60250&r1=60249&r2=60250&view=diff
==============================================================================
--- trunk/gtk/src/pkg/ygtkpackageview.cc (original)
+++ trunk/gtk/src/pkg/ygtkpackageview.cc Thu Jan 7 01:36:18 2010
@@ -20,7 +20,7 @@
#include
extern bool status_col, action_col, action_col_as_button, action_col_as_check,
- version_col, single_line_rows;
+ action_col_label, version_col, colorful_rows, single_line_rows;
//** Icons resources
@@ -116,8 +116,8 @@
TO_INSTALL_PROP, TO_UPGRADE_PROP, TO_REMOVE_PROP, TO_MODIFY_PROP,
// internal
STYLE_PROP, WEIGHT_PROP, SENSITIVE_PROP, CHECK_VISIBLE_PROP,
- FOREGROUND_PROP, BACKGROUND_PROP, XPAD_PROP,
- INSTALL_LABEL_PROP, REMOVE_LABEL_PROP, INSTALL_STOCK_PROP, REMOVE_STOCK_PROP,
+ FOREGROUND_PROP, VERSION_FOREGROUND_PROP, BACKGROUND_PROP, XPAD_PROP,
+ ACTION_LABEL_PROP, ACTION_STOCK_PROP,
// misc
PTR_PROP, TOTAL_PROPS
};
@@ -136,11 +136,10 @@
case INSTALLED_VERSION_PROP:
case AVAILABLE_VERSION_PROP:
case FOREGROUND_PROP:
+ case VERSION_FOREGROUND_PROP:
case BACKGROUND_PROP:
- case INSTALL_LABEL_PROP:
- case REMOVE_LABEL_PROP:
- case INSTALL_STOCK_PROP:
- case REMOVE_STOCK_PROP:
+ case ACTION_LABEL_PROP:
+ case ACTION_STOCK_PROP:
return G_TYPE_STRING;
case TO_INSTALL_PROP:
case TO_UPGRADE_PROP:
@@ -173,13 +172,12 @@
case SIZE_PROP:
case INSTALLED_VERSION_PROP:
case AVAILABLE_VERSION_PROP:
- case INSTALL_LABEL_PROP:
- case REMOVE_LABEL_PROP:
- case INSTALL_STOCK_PROP:
- case REMOVE_STOCK_PROP:
+ case ACTION_LABEL_PROP:
+ case ACTION_STOCK_PROP:
g_value_set_string (value, g_strdup (""));
break;
case FOREGROUND_PROP:
+ case VERSION_FOREGROUND_PROP:
case BACKGROUND_PROP:
g_value_set_string (value, NULL);
break;
@@ -412,12 +410,10 @@
g_value_set_boolean (value, modified);
break;
}
- case INSTALL_LABEL_PROP:
- case REMOVE_LABEL_PROP:
+ case ACTION_LABEL_PROP:
g_value_set_string (value, g_strdup (_("All")));
break;
- case INSTALL_STOCK_PROP:
- case REMOVE_STOCK_PROP:
+ case ACTION_STOCK_PROP:
g_value_set_string (value, g_strdup (GTK_STOCK_SELECT_ALL));
break;
default:
@@ -516,15 +512,32 @@
g_value_set_boolean (value, sensitive);
break;
}
-/*
case STYLE_PROP: {
- PangoStyle style = PANGO_STYLE_NORMAL;
- if (package->isAuto())
- style = PANGO_STYLE_ITALIC;
- g_value_set_int (value, style);
+ if (colorful_rows) {
+ PangoStyle style = PANGO_STYLE_NORMAL;
+ if (package->isAuto())
+ style = PANGO_STYLE_ITALIC;
+ g_value_set_int (value, style);
+ }
+ else
+ _getValueDefault (col, value);
+ break;
+ }
+ case VERSION_FOREGROUND_PROP:
+ case FOREGROUND_PROP: {
+ if (colorful_rows) {
+ const char *color = NULL;
+ if (!package->isInstalled())
+ color = "darkgray";
+ if (col == VERSION_FOREGROUND_PROP)
+ if (package->hasUpgrade())
+ color = "blue";
+ g_value_set_string (value, color);
+ }
+ else
+ _getValueDefault (col, value);
break;
}
-*/
case WEIGHT_PROP: {
bool highlight = segment->list.highlight (package);
int weight = highlight ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL;
@@ -536,35 +549,25 @@
g_value_set_int (value, xpad);
break;
}
- case INSTALL_LABEL_PROP: {
- const char *label = _("Add");
-/* if (package->toModify())
+ case ACTION_LABEL_PROP: {
+ const char *label;
+ if (package->toModify())
label = _("Undo");
- else if (package->hasUpgrade())
- label = _("Upgrade");*/
- if (package->hasUpgrade())
- label = _("Upgrade");
- g_value_set_string (value, g_strdup (label));
- break;
- }
- case REMOVE_LABEL_PROP: {
- const char *label = _("Remove");
-/* if (package->toModify())
- label = _("Undo");*/
+ else if (package->isInstalled())
+ label = _("Remove");
+ else
+ label = _("Add");
g_value_set_string (value, g_strdup (label));
break;
}
- case INSTALL_STOCK_PROP: {
- const char *stock = GTK_STOCK_ADD;
-/* if (package->toModify())
- stock = GTK_STOCK_UNDO;*/
- g_value_set_string (value, g_strdup (stock));
- break;
- }
- case REMOVE_STOCK_PROP: {
- const char *stock = GTK_STOCK_REMOVE;
-/* if (package->toModify())
- stock = GTK_STOCK_UNDO;*/
+ case ACTION_STOCK_PROP: {
+ const char *stock;
+ if (package->toModify())
+ stock = GTK_STOCK_UNDO;
+ else if (package->isInstalled())
+ stock = GTK_STOCK_REMOVE;
+ else
+ stock = GTK_STOCK_ADD;
g_value_set_string (value, g_strdup (stock));
break;
}
@@ -891,49 +894,50 @@
void appendButtonColumn (const char *header, const std::string &prop)
{
- int modelCol = translateProperty (prop);
- int labelCol, stockCol;
- switch (modelCol) {
- case TO_INSTALL_PROP: case TO_UPGRADE_PROP: default:
- labelCol = INSTALL_LABEL_PROP;
- stockCol = INSTALL_STOCK_PROP;
- break;
- case TO_REMOVE_PROP:
- labelCol = REMOVE_LABEL_PROP;
- stockCol = REMOVE_STOCK_PROP;
- break;
- }
+ int labelCol = ACTION_LABEL_PROP, stockCol = ACTION_STOCK_PROP;
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,
+ header, renderer,// "active", modelCol,
"visible", CHECK_VISIBLE_PROP,
"sensitive", SENSITIVE_PROP,
"cell-background", BACKGROUND_PROP,
- "text", labelCol,
-// "stock-id", stockCol,
NULL);
+ if (action_col_label)
+ gtk_tree_view_column_add_attribute (column, renderer, "text", labelCol);
+ gboolean button_images;
+ g_object_get (G_OBJECT (gtk_settings_get_default()), "gtk-button-images", &button_images, NULL);
+ bool show_icon = !action_col_label || button_images;
+ if (show_icon)
+ gtk_tree_view_column_add_attribute (column, renderer, "stock-id", stockCol);
g_signal_connect (G_OBJECT (renderer), "toggled",
G_CALLBACK (renderer_toggled_cb), this);
PangoRectangle rect;
int width = 0;
- const char *text[] = { _("Add"), _("Remove") };
- for (int i = 0; i < 2; i++) {
- PangoLayout *layout = gtk_widget_create_pango_layout (m_view, text[i]);
- pango_layout_get_pixel_extents (layout, NULL, &rect);
- width = MAX (width, rect.width);
- g_object_unref (G_OBJECT (layout));
+ if (action_col_label) {
+ const char *text[] = { _("Add"), _("Remove") };
+ for (int i = 0; i < 2; i++) {
+ PangoLayout *layout = gtk_widget_create_pango_layout (m_view, text[i]);
+ pango_layout_get_pixel_extents (layout, NULL, &rect);
+ width = MAX (width, rect.width);
+ g_object_unref (G_OBJECT (layout));
+ }
}
width += 16;
-// width += 20; // icon
+ if (show_icon) {
+ int icon_width;
+ gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (m_view),
+ GTK_ICON_SIZE_MENU, &icon_width, NULL);
+ width += icon_width;
+ }
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_fixed_width (column, width);
gtk_tree_view_append_column (view, column);
- Action action = columnAction (modelCol);
+ Action action = columnAction (TO_INSTALL_PROP);
g_object_set_data (G_OBJECT (renderer), "action", GINT_TO_POINTER (action));
if (m_activate_action == NONE_ACTION)
m_activate_action = action;
@@ -967,9 +971,12 @@
"sensitive", SENSITIVE_PROP,
"style", STYLE_PROP,
"weight", WEIGHT_PROP,
- "foreground", FOREGROUND_PROP,
"cell-background", BACKGROUND_PROP,
NULL);
+ int foregroundCol = FOREGROUND_PROP;
+ if (col == AVAILABLE_VERSION_PROP)
+ foregroundCol = VERSION_FOREGROUND_PROP;
+ gtk_tree_view_column_add_attribute (column, renderer, "foreground", foregroundCol);
g_object_set_data_full (G_OBJECT (column), "property", g_strdup (prop.c_str()), g_free);
if (identAuto)
gtk_tree_view_column_add_attribute (column, renderer, "xpad", XPAD_PROP);
@@ -1166,15 +1173,18 @@
static void apply (Ypp::Package *package, Action action, bool enable)
{
- if (enable)
+ if (package->toModify())
+ package->undo();
+ else
+// if (enable)
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();
+/* else
+ package->undo();*/
}
static gboolean apply_iter_cb (GtkTreeModel *model,
Modified: trunk/gtk/src/pkg/yzyppwrapper.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/pkg/yzyppwrapper.cc?rev=60250&r1=60249&r2=60250&view=diff
==============================================================================
--- trunk/gtk/src/pkg/yzyppwrapper.cc (original)
+++ trunk/gtk/src/pkg/yzyppwrapper.cc Thu Jan 7 01:36:18 2010
@@ -1,10 +1,7 @@
/********************************************************************
* YaST2-GTK - http://en.opensuse.org/YaST2-GTK *
********************************************************************/
-
-/*
- Textdomain "yast2-gtk"
- */
+/* Textdomain "yast2-gtk" */
/* Ypp, zypp wrapper */
// check the header file for information about this wrapper
@@ -37,7 +34,6 @@
#include "YGUtils.h"
//** Zypp shortcuts
-
typedef zypp::ResPoolProxy ZyppPool;
inline ZyppPool zyppPool() { return zypp::getZYpp()->poolProxy(); }
typedef zypp::ui::Selectable::Ptr ZyppSelectable;
@@ -55,11 +51,10 @@
{ return zypp::dynamic_pointer_cast <const zypp::Pattern> (obj); }
//** Utilities
-
// converts a set of tree representation in a form of a strings to a tree structure.
// String tree representations are, for instance, filenames: /dir1/dir2/file
struct StringTree {
- typedef int (*Compare)(const char *, const char *);
+ typedef int (* Compare)(const char *, const char *);
Compare compare;
char delim;
const char *trans_domain;
@@ -208,7 +203,6 @@
std::vector repos;
const Repository *favoriteRepo;
int favoriteRepoPriority;
- Disk *disk;
Interface *interface;
GSList *pkg_listeners;
bool inTransaction;
@@ -2225,6 +2219,20 @@
}
};
+//** Disk
+
+static Ypp::Disk *_disk;
+
+Ypp::Disk *Ypp::getDisk()
+{
+ if (!_disk)
+ _disk = new Disk();
+ return _disk;
+}
+
+void finish_disk()
+{ delete _disk; _disk = 0; }
+
Ypp::Disk::Disk()
{ impl = new Impl(); }
Ypp::Disk::~Disk()
@@ -2244,6 +2252,8 @@
return NULL;
}
+//** Categories
+
Ypp::Node *Ypp::getFirstCategory2 (Ypp::Package::Type type)
{
impl->getPackages (type);
@@ -2325,7 +2335,7 @@
//** Ypp top methods & internal connections
Ypp::Impl::Impl()
-: favoriteRepo (NULL), disk (NULL), interface (NULL),
+: favoriteRepo (NULL), interface (NULL),
pkg_listeners (NULL), inTransaction (false), transactions (NULL)
{
for (int i = 0; i < Package::TOTAL_TYPES; i++) {
@@ -2355,7 +2365,6 @@
// don't delete pools as they don't actually belong to Ypp, just listeners
g_slist_free (pkg_listeners);
- delete disk;
}
const Ypp::Repository *Ypp::Impl::getRepository (int nb)
@@ -2424,13 +2433,6 @@
return i;
}
-Ypp::Disk *Ypp::Impl::getDisk()
-{
- if (!disk)
- disk = new Disk();
- return disk;
-}
-
bool Ypp::Impl::acceptLicense (Ypp::Package *package, const std::string &license)
{
if (interface)
@@ -2582,11 +2584,132 @@
g_slist_free (transactions);
transactions = NULL;
inTransaction = false;
- if (disk)
- disk->impl->packageModified();
+ if (_disk)
+ _disk->impl->packageModified();
interface->loading (1);
}
+//** Log
+
+#include
+typedef zypp::HistoryItem::Ptr ZyppHistoryItem;
+typedef zypp::HistoryItemInstall *ZyppHistoryItemInstall;
+typedef zypp::HistoryItemRemove *ZyppHistoryItemRemove;
+inline ZyppHistoryItemInstall tryCastToZyppHistoryItemInstall (ZyppHistoryItem item)
+{ return dynamic_cast (item.get()); }
+inline ZyppHistoryItemRemove tryCastToZyppHistoryItemRemove (ZyppHistoryItem item)
+{ return dynamic_cast (item.get()); }
+
+struct Ypp::Log::Impl
+{
+ std::vector entries;
+ Impl();
+ ~Impl();
+ void parse (const ZyppHistoryItem &item);
+};
+
+struct HistoryParseHandler {
+ Ypp::Log::Impl *log;
+ HistoryParseHandler (Ypp::Log::Impl *log) : log (log) {}
+
+ bool operator()(const ZyppHistoryItem &item) {
+ log->parse (item);
+ return true;
+ }
+};
+
+Ypp::Log::Impl::Impl()
+{
+ entries.reserve (512);
+ HistoryParseHandler handler (this);
+ const char *filename = "/var/log/zypp/history";
+ zypp::parser::HistoryLogReader reader (filename, boost::ref (handler));
+ try {
+ reader.readAll();
+ }
+ catch (const zypp::Exception &e) {
+ yuiWarning () << "Error: Could not load log file" << filename << ": "
+ << e.asUserHistory() << std::endl;
+ }
+}
+
+Ypp::Log::Impl::~Impl()
+{
+ for (std::vector ::iterator it = entries.begin();
+ it != entries.end(); it++)
+ delete *it;
+}
+
+void Ypp::Log::Impl::parse (const ZyppHistoryItem &item)
+{
+ Entry::Action action;
+ if (item->action.toEnum() == zypp::HistoryActionID::INSTALL_e)
+ action = Entry::INSTALL_ACTION;
+ else if (item->action.toEnum() == zypp::HistoryActionID::REMOVE_e)
+ action = Entry::REMOVE_ACTION;
+ else
+ return;
+
+ Entry *entry = new Entry();
+ entry->action = action;
+ entry->date = item->date;
+ if (action == Entry::INSTALL_ACTION) {
+ ZyppHistoryItemInstall _item = tryCastToZyppHistoryItemInstall (item);
+ if (_item) {
+ entry->package_str = _item->name;
+ entry->version_str = _item->edition.asString();
+ }
+ }
+ else {
+ ZyppHistoryItemRemove _item = tryCastToZyppHistoryItemRemove (item);
+ if (_item) {
+ entry->package_str = _item->name;
+ entry->version_str = _item->edition.asString();
+ }
+ }
+//fprintf (stderr, "parse: %s\n", entry->package_str.c_str());
+ entry->package = Ypp::get()->getPackages (Ypp::Package::PACKAGE_TYPE).find (entry->package_str);
+ entry->version = NULL;
+ if (entry->package) {
+ const Package::Version *version = entry->package->getInstalledVersion();
+ if (version && version->number == entry->version_str)
+ entry->version = version;
+ for (int i = 0; entry->package->getAvailableVersion (i); i++) {
+ version = entry->package->getAvailableVersion (i);
+ if (version->number == entry->version_str)
+ entry->version = version;
+ }
+ }
+ entries.push_back (entry);
+}
+
+Ypp::Log::Log()
+{ impl = new Impl(); }
+
+Ypp::Log::~Log()
+{ delete impl; }
+
+Ypp::Log::Entry *Ypp::Log::getEntry (int nb)
+{
+ if (nb >= (signed) impl->entries.size())
+ return NULL;
+ return impl->entries[impl->entries.size()-nb-1]; // reverse order
+}
+
+static Ypp::Log *_log = 0;
+
+Ypp::Log *Ypp::getLog()
+{
+ if (!_log)
+ _log = new Log();
+ return _log;
+}
+
+void finish_log()
+{ delete _log; _log = 0; }
+
+//** Top
+
Ypp::Ypp()
{
impl = new Impl();
@@ -2599,6 +2722,8 @@
{
setFavoriteRepository (NULL);
delete impl;
+ finish_log();
+ finish_disk();
}
const Ypp::Repository *Ypp::getRepository (int nb)
@@ -2623,9 +2748,6 @@
const Ypp::Repository *Ypp::favoriteRepository()
{ return impl->favoriteRepo; }
-Ypp::Disk *Ypp::getDisk()
-{ return impl->getDisk(); }
-
void Ypp::setInterface (Ypp::Interface *interface)
{
impl->interface = interface;
Modified: trunk/gtk/src/pkg/yzyppwrapper.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/pkg/yzyppwrapper.h?rev=60250&r1=60249&r2=60250&view=diff
==============================================================================
--- trunk/gtk/src/pkg/yzyppwrapper.h (original)
+++ trunk/gtk/src/pkg/yzyppwrapper.h Thu Jan 7 01:36:18 2010
@@ -258,6 +258,29 @@
void *impl;
};
+ // Log
+ struct Log {
+ struct Entry {
+ enum Action { INSTALL_ACTION, REMOVE_ACTION };
+ Action action;
+ std::string date;
+ std::string package_str;
+ std::string version_str;
+
+ // attemps to match the strings: could be null
+ Package *package;
+ const Package::Version *version; // only may be set for INSTALL
+ };
+
+ Entry *getEntry (int nb);
+
+ struct Impl;
+ Impl *impl;
+ Log();
+ ~Log();
+ };
+ Log *getLog();
+
// Module
static Ypp *get();
static void finish();
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org