[Aptitude-devel] r3160 - in branches/aptitude-0.3/aptitude: . src
Daniel Burrows
dburrows@costa.debian.org
Thu, 28 Apr 2005 01:00:30 +0000
Author: dburrows
Date: Thu Apr 28 01:00:26 2005
New Revision: 3160
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/ui.cc
Log:
Use the new text-layout-append support to handle errors gracefully
without opening lots&lots of error dialogs.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Thu Apr 28 01:00:26 2005
@@ -1,5 +1,11 @@
2005-04-27 Daniel Burrows <dburrows@debian.org>
+ * src/ui.cc:
+
+ Use the new support in vs_text_layout to not open tons of
+ extraneous error dialogs (instead we just reuse the existing
+ ones).
+
* src/vscreen/vs_text_layout.cc, src/vscreen/vs_text_layout.h:
Add a way to append text to a vs_text_layout 'after the fact'.
Modified: branches/aptitude-0.3/aptitude/src/ui.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/ui.cc (original)
+++ branches/aptitude-0.3/aptitude/src/ui.cc Thu Apr 28 01:00:26 2005
@@ -198,14 +198,49 @@
NULL);
}
+static vscreen_widget *make_error_dialog(vs_text_layout *layout)
+{
+ vs_table *t=new vs_table;
+
+ vs_scrollbar *s=new vs_scrollbar(vs_scrollbar::VERTICAL);
+
+ layout->set_bg(get_color("Error"));
+ s->set_bg(get_color("Error"));
+
+ t->add_widget(layout, 0, 0, 1, 1, true, true);
+ t->add_widget_opts(s, 0, 1, 1, 1,
+ vs_table::ALIGN_RIGHT,
+ vs_table::ALIGN_CENTER | vs_table::FILL);
+
+ layout->location_changed.connect(sigc::mem_fun(*s, &vs_scrollbar::set_slider));
+ s->scrollbar_interaction.connect(sigc::mem_fun(*layout, &vs_text_layout::scroll));
+
+ return vs_dialog_ok(t, NULL, _("Ok"), get_color("Error"));
+}
+
+// blah, I hate C++
+static void do_null_ptr(vs_text_layout **p)
+{
+ p=NULL;
+}
+
void check_apt_errors()
{
- if(!_error->empty())
- main_stacked->add_visible_widget(vs_dialog_ok(apt_error_fragment(),
- NULL, _("Ok"),
- get_color("Error"),
- true),
- true);
+ if(_error->empty())
+ return;
+
+ static vs_text_layout *error_dialog_layout=NULL;
+
+ if(!error_dialog_layout)
+ {
+ error_dialog_layout=new vs_text_layout(apt_error_fragment());
+ error_dialog_layout->destroyed.connect(sigc::bind(sigc::ptr_fun(do_null_ptr), &error_dialog_layout));
+
+ main_stacked->add_visible_widget(make_error_dialog(error_dialog_layout),
+ true);
+ }
+ else
+ error_dialog_layout->append_fragment(apt_error_fragment());
}
// Runs a sub-aptitude with the same selections that the user