[Aptitude-svn-commit] r3767 - in branches/aptitude-0.3/aptitude: . src

Daniel Burrows dburrows at costa.debian.org
Tue Aug 9 00:20:15 UTC 2005


Author: dburrows
Date: Tue Aug  9 00:20:12 2005
New Revision: 3767

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/ui.cc
Log:
Update the code in ui.cc to handle the brave new refcounted world.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Tue Aug  9 00:20:12 2005
@@ -1,5 +1,10 @@
 2005-08-08  Daniel Burrows  <dburrows at debian.org>
 
+	* src/ui.cc:
+
+	  Many updates to ui.cc to bring it in line with the new
+	  interfaces and conventions.
+
 	* src/dep_item.h:
 
 	  Update pkg_dep_screen for the reference-counting protocol.

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	Tue Aug  9 00:20:12 2005
@@ -61,6 +61,7 @@
 #include <vscreen/vs_editline.h>
 #include <vscreen/vs_frame.h>
 #include <vscreen/vs_label.h>
+#include <vscreen/vs_menu.h>
 #include <vscreen/vs_menubar.h>
 #include <vscreen/vs_multiplex.h>
 #include <vscreen/vs_pager.h>
@@ -96,21 +97,21 @@
 
 using namespace std;
 
-static vs_menubar *main_menu;
-static vs_menu *views_menu;
+static vs_menubar_ref main_menu;
+static vs_menu_ref views_menu;
 
-static vs_stacked *main_stacked;
+static vs_stacked_ref main_stacked;
 
 // Hmm, is this table the best idea?..
-static vs_table *main_table;
+static vs_table_ref main_table;
 
-static vs_multiplex *main_multiplex;
-static vs_multiplex *main_status_multiplex;
+static vs_multiplex_ref main_multiplex;
+static vs_multiplex_ref main_status_multiplex;
 
 // I think it's better to only have a single preview screen at once.  (note to
 // self: data-segment stuff initializes to 0 already..)
-static pkg_tree *active_preview_tree;
-static vscreen_widget *active_preview;
+static pkg_tree_ref active_preview_tree;
+static vs_widget_ref active_preview;
 
 // True if a download or package-list update is proceeding.  This hopefully will
 // avoid the nasty possibility of collisions between them.
@@ -120,7 +121,7 @@
 
 // While a status-widget download progress thingy is active, this will be
 // set to it.
-vscreen_widget *active_status_download;
+vs_widget_ref active_status_download;
 
 sigc::signal0<void> file_quit;
 sigc::signal0<void> package_states_changed;
@@ -182,41 +183,41 @@
 }
 
 // Handles "search" dialogs for pagers
-static void pager_search(vs_pager *p)
+static void pager_search(vs_pager &p)
 {
   prompt_string(transcode(_("Search for:")),
-		p->get_last_search(),
-		arg(sigc::mem_fun(*p, &vs_pager::search_for)),
+		p.get_last_search(),
+		arg(sigc::mem_fun(p, &vs_pager::search_for)),
 		NULL,
 		NULL,
 		NULL);
 }
 
 // similar
-static void pager_repeat_search(vs_pager *p)
+static void pager_repeat_search(vs_pager &p)
 {
-  p->search_for(L"");
+  p.search_for(L"");
 }
 
-static vscreen_widget *make_error_dialog(vs_text_layout *layout)
+static vs_widget_ref make_error_dialog(const vs_text_layout_ref &layout)
 {
-  vs_table *t=new vs_table;
+  vs_table_ref t=vs_table::create();
 
-  vs_scrollbar *s=new vs_scrollbar(vs_scrollbar::VERTICAL);
+  vs_scrollbar_ref s=vs_scrollbar::create(vs_scrollbar::VERTICAL);
 
   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));
+  layout->location_changed.connect(sigc::mem_fun(s.unsafe_get_ref(), &vs_scrollbar::set_slider));
+  s->scrollbar_interaction.connect(sigc::mem_fun(layout.unsafe_get_ref(), &vs_text_layout::scroll));
 
   return vs_dialog_ok(t, NULL, transcode(_("Ok")), get_style("Error"));
 }
 
 // blah, I hate C++
-static void do_null_ptr(vs_text_layout **p)
+static void do_null_ptr(vs_text_layout_ref *p)
 {
   *p=NULL;
 }
@@ -226,11 +227,11 @@
   if(_error->empty())
     return;
 
-  static vs_text_layout *error_dialog_layout=NULL;
+  static vs_text_layout_ref error_dialog_layout = NULL;
 
-  if(!error_dialog_layout)
+  if(!error_dialog_layout.valid())
     {
-      error_dialog_layout=new vs_text_layout(apt_error_fragment());
+      error_dialog_layout = vs_text_layout::create(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),
@@ -358,8 +359,8 @@
 	  check_apt_errors();
 	  // We have to clear these out or the cache won't reload properly (?)
 
-	  vs_progress *p = gen_progress_bar();
-	  apt_reload_cache(p, true);
+	  vs_progress_ref p = gen_progress_bar();
+	  apt_reload_cache(p.unsafe_get_ref(), true);
 	  p->destroy();
 	}
       else
@@ -379,13 +380,13 @@
 					       false));
 }
 
-vscreen_widget *reload_message;
+vs_widget_ref reload_message;
 static void do_show_reload_message()
 {
-  if(!reload_message)
+  if(!reload_message.valid())
     {
-      vscreen_widget *w=new vs_frame(new vs_label(_("Loading cache")));
-      reload_message=new vs_center(w);
+      vs_widget_ref w = vs_frame::create(vs_label::create(_("Loading cache")));
+      reload_message  = vs_center::create(w);
       reload_message->show_all();
       popup_widget(reload_message);
 
@@ -395,10 +396,10 @@
 
 static void do_hide_reload_message()
 {
-  if(reload_message)
+  if(reload_message.valid())
     {
       reload_message->destroy();
-      reload_message=NULL;
+      reload_message = NULL;
       vscreen_tryupdate();
     }
 }
@@ -413,7 +414,7 @@
 
 static void do_destroy_visible()
 {
-  if(active_status_download)
+  if(active_status_download.valid())
     {
       active_status_download->destroy();
       active_status_download=NULL;
@@ -423,8 +424,8 @@
     do_quit();
   else
     {
-      vscreen_widget *w=main_multiplex->visible_widget();
-      if(w)
+      vs_widget_ref w=main_multiplex->visible_widget();
+      if(w.valid())
 	w->destroy();
 
       // If all the screens are destroyed, we make the menu visible (so the
@@ -440,7 +441,7 @@
 
 static bool any_view_visible()
 {
-  return main_multiplex->visible_widget()!=NULL;
+  return main_multiplex->visible_widget().valid();
 }
 
 // These are necessary because main_multiplex isn't created until after
@@ -458,21 +459,21 @@
 
 static void do_show_ui_options_dlg()
 {
-  vscreen_widget *w=make_ui_options_dialog();
+  vs_widget_ref w = make_ui_options_dialog();
   main_stacked->add_visible_widget(w, true);
   w->show();
 }
 
 static void do_show_misc_options_dlg()
 {
-  vscreen_widget *w=make_misc_options_dialog();
+  vs_widget_ref w=make_misc_options_dialog();
   main_stacked->add_visible_widget(w, true);
   w->show();
 }
 
 static void do_show_dependency_options_dlg()
 {
-  vscreen_widget *w=make_dependency_options_dialog();
+  vs_widget_ref w=make_dependency_options_dialog();
   main_stacked->add_visible_widget(w, true);
   w->show();
 }
@@ -491,11 +492,11 @@
 	       NULL);
 }
 
-static vscreen_widget *make_default_view(pkg_menu_tree *mainwidget,
-					 pkg_signal *sig,
-					 desc_signal *desc_sig,
-					 bool allow_visible_desc=true,
-					 bool show_reason_first=false)
+static vs_widget_ref make_default_view(const pkg_menu_tree_ref &mainwidget,
+				       pkg_signal *sig,
+				       desc_signal *desc_sig,
+				       bool allow_visible_desc=true,
+				       bool show_reason_first=false)
 {
   if(aptcfg->Exists(PACKAGE "::UI::Default-Package-View"))
     {
@@ -503,12 +504,14 @@
 
       if(format)
 	{
-	  vscreen_widget *rval=make_package_view(*format, mainwidget,
-						 mainwidget, sig,
-						 desc_sig, show_reason_first);
+	  // The unsafe_get_ref is to convert mainwidget to be a
+	  // menu_redirect pointer.
+	  vs_widget_ref rval=make_package_view(*format, mainwidget,
+					       mainwidget.unsafe_get_ref(), sig,
+					       desc_sig, show_reason_first);
 	  delete format;
 
-	  if(rval)
+	  if(rval.valid())
 	    return rval;
 	}
     }
@@ -554,7 +557,9 @@
 					   "ShowHideDescription", "",
 					   allow_visible_desc && aptcfg->FindB(PACKAGE "::UI::Description-Visible-By-Default", true)));
 
-  return make_package_view(basic_format, mainwidget, mainwidget, sig, desc_sig,
+  return make_package_view(basic_format, mainwidget,
+			   mainwidget.unsafe_get_ref(),
+			   sig, desc_sig,
 			   show_reason_first);
 }
 
@@ -580,7 +585,7 @@
 	grp=new pkg_grouppolicy_task_factory(new pkg_grouppolicy_status_factory(new pkg_grouppolicy_section_factory(pkg_grouppolicy_section_factory::split_subdir,true,new pkg_grouppolicy_section_factory(pkg_grouppolicy_section_factory::split_topdir,false,new pkg_grouppolicy_end_factory()))));
     }
 
-  pkg_tree *tree=new pkg_tree(grpstr.c_str(), grp);
+  pkg_tree_ref tree=pkg_tree::create(grpstr.c_str(), grp);
 
   add_main_widget(make_default_view(tree,
 				    &tree->selected_signal,
@@ -595,17 +600,17 @@
 // For signal connections.
 static void do_new_package_view_with_new_bar()
 {
-  vs_progress *p=gen_progress_bar();
-  do_new_package_view(*p);
+  vs_progress_ref p = gen_progress_bar();
+  do_new_package_view(*p.unsafe_get_ref());
   p->destroy();
 }
 
 static void do_new_flat_view_with_new_bar()
 {
-  vs_progress *p = gen_progress_bar();
+  vs_progress_ref p = gen_progress_bar();
 
   pkg_grouppolicy_factory *grp = new pkg_grouppolicy_end_factory;
-  pkg_tree *tree = new pkg_tree("", grp);
+  pkg_tree_ref tree = pkg_tree::create("", grp);
   tree->set_limit(transcode("!~v"));
 
   add_main_widget(make_default_view(tree,
@@ -615,19 +620,19 @@
 		  _("View available packages and choose actions to perform"),
 		  _("Packages"));
 
-  tree->build_tree(*p);
+  tree->build_tree(*p.unsafe_get_ref());
   p->destroy();
 }
 
 static void do_new_tag_view_with_new_bar()
 {
-  vs_progress *p = gen_progress_bar();
+  vs_progress_ref p = gen_progress_bar();
 
   pkg_grouppolicy_factory *grp = NULL;
   string grpstr = "tag";
   grp = parse_grouppolicy(grpstr);
 
-  pkg_tree *tree = new pkg_tree(grpstr.c_str(), grp);
+  pkg_tree_ref tree = pkg_tree::create(grpstr.c_str(), grp);
 
   add_main_widget(make_default_view(tree,
 				    &tree->selected_signal,
@@ -636,7 +641,7 @@
 		  _("View available packages and choose actions to perform"),
 		  _("Packages"));
 
-  tree->build_tree(*p);
+  tree->build_tree(*p.unsafe_get_ref());
   p->destroy();
 }
 
@@ -648,7 +653,7 @@
   grpstr="hier";
   grp=parse_grouppolicy(grpstr);
 
-  pkg_tree *tree=new pkg_tree(grpstr.c_str(), grp);
+  pkg_tree_ref tree=pkg_tree::create(grpstr.c_str(), grp);
   tree->set_limit(transcode("!~v"));
   //tree->set_hierarchical(false);
 
@@ -664,48 +669,43 @@
 // For signal connections.
 static void do_new_hier_view_with_new_bar()
 {
-  vs_progress *p=gen_progress_bar();
-  do_new_hier_view(*p);
+  vs_progress_ref p=gen_progress_bar();
+  do_new_hier_view(*p.unsafe_get_ref());
   p->destroy();
 }
 
-vscreen_widget *make_info_screen(const pkgCache::PkgIterator &pkg,
-				 const pkgCache::VerIterator &ver)
+vs_widget_ref make_info_screen(const pkgCache::PkgIterator &pkg,
+			       const pkgCache::VerIterator &ver)
 {
-  pkg_info_screen *w=new pkg_info_screen(pkg, ver);
-  vscreen_widget *rval=make_default_view(w, w->get_sig(), w->get_desc_sig(), false);
+  pkg_info_screen_ref w = pkg_info_screen::create(pkg, ver);
+  vs_widget_ref rval    = make_default_view(w, w->get_sig(), w->get_desc_sig(), false);
   w->repeat_signal(); // force the status line in the view to update
   return rval;
 }
 
-vscreen_widget *make_dep_screen(const pkgCache::PkgIterator &pkg,
-				const pkgCache::VerIterator &ver,
-				bool reverse)
+vs_widget_ref make_dep_screen(const pkgCache::PkgIterator &pkg,
+			      const pkgCache::VerIterator &ver,
+			      bool reverse)
 {
-  pkg_dep_screen *w=new pkg_dep_screen(pkg, ver, reverse);
-  vscreen_widget *rval=make_default_view(w, w->get_sig(), w->get_desc_sig(), true);
+  pkg_dep_screen_ref w = pkg_dep_screen::create(pkg, ver, reverse);
+  vs_widget_ref rval   = make_default_view(w, w->get_sig(), w->get_desc_sig(), true);
   w->repeat_signal(); // force the status line in the view to update
   return rval;
 }
 
-vscreen_widget *make_ver_screen(const pkgCache::PkgIterator &pkg)
+vs_widget_ref make_ver_screen(const pkgCache::PkgIterator &pkg)
 {
-  pkg_ver_screen *w=new pkg_ver_screen(pkg);
-  vscreen_widget *rval=make_default_view(w, w->get_sig(), w->get_desc_sig(), true);
+  pkg_ver_screen_ref w = pkg_ver_screen::create(pkg);
+  vs_widget_ref rval   = make_default_view(w, w->get_sig(), w->get_desc_sig(), true);
   w->repeat_signal();
   return rval;
 }
 
-//static void silly_test_error(string s)
-//{
-//  _error->Error("%s", s.c_str());
-//}
-
 static void do_help_about()
 {
   fragment *f=fragf(_("Aptitude %s%n%nCopyright 2000-2005 Daniel Burrows.%n%naptitude comes with %BABSOLUTELY NO WARRANTY%b; for details see 'license' in the Help menu.  This is free software, and you are welcome to redistribute it under certain conditions; see 'license' for details."), VERSION);
 
-  vscreen_widget *w=vs_dialog_ok(wrapbox(f));
+  vs_widget_ref w=vs_dialog_ok(wrapbox(f));
   w->show_all();
 
   popup_widget(w);
@@ -713,10 +713,10 @@
 
 static void do_help_license()
 {
-  vscreen_widget *w=vs_dialog_fileview(HELPDIR "/COPYING",
-				       NULL,
-				       arg(sigc::ptr_fun(pager_search)),
-				       arg(sigc::ptr_fun(pager_repeat_search)));
+  vs_widget_ref w=vs_dialog_fileview(HELPDIR "/COPYING",
+				     NULL,
+				     arg(sigc::ptr_fun(pager_search)),
+				     arg(sigc::ptr_fun(pager_repeat_search)));
   w->show_all();
 
   popup_widget(w);
@@ -737,9 +737,9 @@
       encoding="UTF-8";
     }
 
-  vscreen_widget *w=vs_dialog_fileview(buf, NULL,
-				       arg(sigc::ptr_fun(pager_search)),
-				       arg(sigc::ptr_fun(pager_repeat_search)));
+  vs_widget_ref w=vs_dialog_fileview(buf, NULL,
+				     arg(sigc::ptr_fun(pager_search)),
+				     arg(sigc::ptr_fun(pager_repeat_search)));
   w->show_all();
 
   popup_widget(w);
@@ -760,19 +760,19 @@
       encoding="UTF-8";
     }
 
-  vscreen_widget *w=vs_dialog_fileview(buf, NULL,
-				       arg(sigc::ptr_fun(pager_search)),
-				       arg(sigc::ptr_fun(pager_repeat_search)),
-				       encoding);
+  vs_widget_ref w=vs_dialog_fileview(buf, NULL,
+				     arg(sigc::ptr_fun(pager_search)),
+				     arg(sigc::ptr_fun(pager_repeat_search)),
+				     encoding);
   w->show_all();
   popup_widget(w);
 }
 
 static void do_help_faq()
 {
-  vscreen_widget *w=vs_dialog_fileview(HELPDIR "/FAQ", NULL,
-				       arg(sigc::ptr_fun(pager_search)),
-				       arg(sigc::ptr_fun(pager_repeat_search)));
+  vs_widget_ref w=vs_dialog_fileview(HELPDIR "/FAQ", NULL,
+				     arg(sigc::ptr_fun(pager_search)),
+				     arg(sigc::ptr_fun(pager_repeat_search)));
   w->show_all();
 
   popup_widget(w);
@@ -781,9 +781,9 @@
 // news isn't translated since it's just a changelog.
 static void do_help_news()
 {
-  vscreen_widget *w=vs_dialog_fileview(HELPDIR "/NEWS", NULL,
-				       arg(sigc::ptr_fun(pager_search)),
-				       arg(sigc::ptr_fun(pager_repeat_search)));
+  vs_widget_ref w=vs_dialog_fileview(HELPDIR "/NEWS", NULL,
+				     arg(sigc::ptr_fun(pager_search)),
+				     arg(sigc::ptr_fun(pager_repeat_search)));
   w->show_all();
 
   popup_widget(w);
@@ -801,12 +801,12 @@
 {
   active_download=true;
 
-  if(active_preview_tree)
+  if(active_preview_tree.valid())
     active_preview_tree->destroy();
 
-  vs_progress *p=gen_progress_bar();
+  vs_progress_ref p=gen_progress_bar();
 
-  do_install_run(p, false, false);
+  do_install_run(p.unsafe_get_ref(), false, false);
 
   p->destroy();
 
@@ -879,7 +879,7 @@
 // view-customization stuff.
 static void do_show_preview()
 {
-  if(!active_preview_tree)
+  if(!active_preview_tree.valid())
     {
       pkg_grouppolicy_factory *grp=NULL;
       std::string grpstr;
@@ -903,9 +903,9 @@
 	}
 
       if(aptcfg->Exists(PACKAGE "::UI::Preview-Limit"))
-	active_preview_tree=new pkg_tree(grpstr.c_str(), grp, transcode(aptcfg->Find(PACKAGE "::UI::Preview-Limit").c_str()));
+	active_preview_tree=pkg_tree::create(grpstr.c_str(), grp, transcode(aptcfg->Find(PACKAGE "::UI::Preview-Limit").c_str()));
       else
-	active_preview_tree=new pkg_tree(grpstr.c_str(), grp);
+	active_preview_tree=pkg_tree::create(grpstr.c_str(), grp);
 
       active_preview=make_default_view(active_preview_tree,
 				       &active_preview_tree->selected_signal,
@@ -914,7 +914,7 @@
 				       true);
 
       active_preview->destroyed.connect(sigc::ptr_fun(reset_preview));
-      active_preview_tree->destroyed.connect(sigc::mem_fun(*active_preview, &vscreen_widget::destroy));
+      active_preview_tree->destroyed.connect(sigc::mem_fun(active_preview.unsafe_get_ref(), &vscreen_widget::destroy));
       active_preview_tree->connect_key("DoInstallRun",
 				       &global_bindings,
 				       sigc::ptr_fun(actually_do_package_run));
@@ -922,8 +922,8 @@
 		      _("View and/or adjust the actions that will be performed"),
 		      _("Preview"));
 
-      vs_progress *p=gen_progress_bar();
-      active_preview_tree->build_tree(*p);
+      vs_progress_ref p=gen_progress_bar();
+      active_preview_tree->build_tree(*p.unsafe_get_ref());
       p->destroy();
     }
   else
@@ -932,14 +932,14 @@
 
 static void fixer_dialog_done()
 {
-  if(active_preview_tree)
+  if(active_preview_tree.valid())
     active_preview_tree->build_tree();
   do_package_run_or_show_preview();
 }
 
 static void install_fixer_dialog()
 {
-  vscreen_widget *w=make_solution_dialog();
+  vs_widget_ref w=make_solution_dialog();
   w->destroyed.connect(sigc::ptr_fun(fixer_dialog_done));
   popup_widget(w, true);
 }
@@ -979,7 +979,7 @@
   else
     delete undo;
 
-  if(active_preview_tree)
+  if(active_preview_tree.valid())
     active_preview_tree->build_tree();
 }
 
@@ -1065,7 +1065,7 @@
 
   if(apt_cache_file)
     {
-      if(!active_preview_tree)
+      if(!active_preview_tree.valid())
 	{
 	  if(aptcfg->FindB(PACKAGE "::Display-Planned-Action", true))
 	    do_show_preview();
@@ -1091,7 +1091,7 @@
 {
   if(apt_cache_file)
     {
-      if(active_preview_tree && active_preview_tree->get_visible())
+      if(active_preview_tree.valid() && active_preview_tree->get_visible())
 	actually_do_package_run();
       else if((*apt_cache_file)->BrokenCount()>0)
 	{
@@ -1112,9 +1112,9 @@
 {
   active_download=true;
 
-  vs_progress *p=gen_progress_bar();
+  vs_progress_ref p=gen_progress_bar();
 
-  do_pkglist_update(p, false);
+  do_pkglist_update(p.unsafe_get_ref(), false);
 
   p->destroy();
 
@@ -1154,7 +1154,7 @@
     _error->Error(_("Cleaning while a download is in progress is not allowed"));
   else
     {
-      vscreen_widget *msg=new vs_center(new vs_frame(new vs_label(_("Deleting downloaded files"))));
+      vs_widget_ref msg=vs_center::create(vs_frame::create(vs_label::create(_("Deleting downloaded files"))));
       msg->show_all();
       popup_widget(msg);
       vscreen_tryupdate();
@@ -1207,7 +1207,7 @@
     _error->Error(_("Cleaning while a download is in progress is not allowed"));
   else
     {
-      vscreen_widget *msg=new vs_center(new vs_frame(new vs_label(_("Deleting obsolete downloaded files"))));
+      vs_widget_ref msg=vs_center::create(vs_frame::create(vs_label::create(_("Deleting obsolete downloaded files"))));
       msg->show_all();
       popup_widget(msg);
       vscreen_tryupdate();
@@ -1287,8 +1287,8 @@
 #ifdef WITH_RELOAD_CACHE
 static void do_reload_cache()
 {
-  vs_progress *p = gen_progress_bar();
-  apt_reload_cache(p, true);
+  vs_progress_ref p = gen_progress_bar();
+  apt_reload_cache(p.unsafe_get_ref(), true);
   p->destroy();
 }
 #endif
@@ -1635,7 +1635,7 @@
     }
 }
 
-static void do_show_menu_description(vs_menu_item *item, vs_label *label)
+static void do_show_menu_description(vs_menu_item *item, const vs_label_ref &label)
 {
   if(item && item->get_description().size()>0)
     {
@@ -1672,12 +1672,12 @@
   load_bindings(base+"::Keybindings::Tree", vs_tree::bindings, usetheme);
 }
 
-static vs_menu *add_menu(vs_menu_info *info, const std::string &name,
-			 vs_label *menu_description)
+static vs_menu_ref add_menu(vs_menu_info *info, const std::string &name,
+			    const vs_label_ref &menu_description)
 {
   munge_menu(info);
 
-  vs_menu *menu=new vs_menu(0, 0, 0, info);
+  vs_menu_ref menu=vs_menu::create(0, 0, 0, info);
 
   main_menu->append_item(transcode(name), menu);
 
@@ -1718,9 +1718,9 @@
 
   load_options(PACKAGE "::UI", false);
 
-  vs_label *menu_description=new vs_label("");
+  vs_label_ref menu_description=vs_label::create("");
 
-  main_menu=new vs_menubar(!aptcfg->FindB(PACKAGE "::UI::Menubar-Autohide", false));
+  main_menu=vs_menubar::create(!aptcfg->FindB(PACKAGE "::UI::Menubar-Autohide", false));
 
   aptcfg->connect(string(PACKAGE "::UI::Menubar-Autohide"),
 		  sigc::ptr_fun(update_menubar_autohide));
@@ -1739,7 +1739,7 @@
   views_menu=add_menu(views_menu_info, _("Views"), menu_description);
   add_menu(help_menu_info, _("Help"), menu_description);
 
-  main_stacked=new vs_stacked;
+  main_stacked=vs_stacked::create();
   main_menu->set_subwidget(main_stacked);
   main_stacked->show();
 
@@ -1785,7 +1785,7 @@
 				 &global_bindings,
 				 sigc::ptr_fun(do_dump_resolver));
 
-  main_table=new vs_table;
+  main_table=vs_table::create();
   main_stacked->add_widget(main_table);
   main_table->show();
 
@@ -1811,18 +1811,18 @@
   aptcfg->connect(string(PACKAGE "::UI::HelpBar"),
 		  sigc::mem_fun(*help_label, &help_bar::set_visibility));
 
-  main_multiplex=new vs_multiplex(true);
+  main_multiplex=vs_multiplex::create(true);
   main_table->add_widget_opts(main_multiplex, 1, 0, 1, 1,
 			      vs_table::EXPAND | vs_table::FILL | vs_table::SHRINK,
 			      vs_table::EXPAND | vs_table::FILL | vs_table::SHRINK);
   main_multiplex->show();
 
-  vscreen_widget *b=make_broken_indicator();
+  vs_widget_ref b=make_broken_indicator();
   main_table->add_widget_opts(b, 2, 0, 1, 1,
 			      vs_table::EXPAND | vs_table::FILL | vs_table::SHRINK,
 			      vs_table::ALIGN_CENTER);
 
-  main_status_multiplex=new vs_multiplex;
+  main_status_multiplex=vs_multiplex::create();
   main_status_multiplex->set_bg_style(get_style("Status"));
   main_table->add_widget_opts(main_status_multiplex, 3, 0, 1, 1,
 			      vs_table::EXPAND | vs_table::FILL | vs_table::SHRINK,
@@ -1860,15 +1860,15 @@
      (aptitudeDepCache *) (*apt_cache_file) &&
      apt_cache_file->is_locked())
     {
-      vs_progress *p=gen_progress_bar();
-      (*apt_cache_file)->save_selection_list(*p);
+      vs_progress_ref p=gen_progress_bar();
+      (*apt_cache_file)->save_selection_list(*p.unsafe_get_ref());
       p->destroy();
     }
 
   vscreen_shutdown();
 }
 
-void popup_widget(vscreen_widget *w, bool do_show_all)
+void popup_widget(const vs_widget_ref &w, bool do_show_all)
 {
   main_stacked->add_widget(w);
 
@@ -1878,15 +1878,15 @@
     w->show();
 }
 
-static void setup_main_widget(vscreen_widget *w, const std::wstring &menuref,
+static void setup_main_widget(const vs_widget_ref &w, const std::wstring &menuref,
 			      const std::wstring &menudesc)
 {
   vs_menu_item *menuentry=new vs_menu_item(menuref, "", menudesc);
 
   // FIXME: if w is removed from the multiplexer but not destroyed, this may
   //       break.  Fix for now: Don't Do That Then!
-  w->destroyed.connect(sigc::bind(sigc::mem_fun(*views_menu, &vs_menu::remove_item), menuentry));
-  menuentry->selected.connect(sigc::mem_fun(*w, &vscreen_widget::show));
+  w->destroyed.connect(sigc::bind(sigc::mem_fun(views_menu.unsafe_get_ref(), &vs_menu::remove_item), menuentry));
+  menuentry->selected.connect(sigc::mem_fun(w.unsafe_get_ref(), &vscreen_widget::show));
 
   views_menu->append_item(menuentry);
 }
@@ -1902,7 +1902,7 @@
     file_quit();
 }
 
-void add_main_widget(vscreen_widget *w, const std::wstring &menuref,
+void add_main_widget(const vs_widget_ref &w, const std::wstring &menuref,
 		     const std::wstring &menudesc,
 		     const std::wstring &tabdesc)
 {
@@ -1914,7 +1914,7 @@
   update_menubar_autohide();
 }
 
-void add_main_widget(vscreen_widget *w, const std::string &menuref,
+void add_main_widget(const vs_widget_ref &w, const std::string &menuref,
 		     const std::string &menudesc,
 		     const std::string &tabdesc)
 {
@@ -1922,7 +1922,7 @@
 		  transcode(tabdesc));
 }
 
-void insert_main_widget(vscreen_widget *w, const std::wstring &menuref,
+void insert_main_widget(const vs_widget_ref &w, const std::wstring &menuref,
 			const std::wstring &menudesc,
 			const std::wstring &tabdesc)
 {
@@ -1933,7 +1933,7 @@
   update_menubar_autohide();
 }
 
-void insert_main_widget(vscreen_widget *w, const std::string &menuref,
+void insert_main_widget(const vs_widget_ref &w, const std::string &menuref,
 			const std::string &menudesc,
 			const std::string &tabdesc)
 {
@@ -1941,14 +1941,14 @@
 		     transcode(menudesc), transcode(tabdesc));
 }
 
-vscreen_widget *active_main_widget()
+vs_widget_ref active_main_widget()
 {
   return main_multiplex->visible_widget();
 }
 
-vs_progress *gen_progress_bar()
+vs_progress_ref gen_progress_bar()
 {
-  vs_progress *rval=new vs_progress;
+  vs_progress_ref rval=vs_progress::create();
 
   main_status_multiplex->add_visible_widget(rval, true);
 
@@ -1975,37 +1975,53 @@
 					slot0arg abortslot)
 {
   download_manager *m=new download_manager;
-  download_list *w=NULL;
+  download_list_ref w=NULL;
 
   if(force_noninvasive ||
      aptcfg->FindB(PACKAGE "::UI::Minibuf-Download-Bar", false))
     {
-      w=new download_list(abortslot, false);
+      w=download_list::create(abortslot, false);
       main_status_multiplex->add_visible_widget(w, true);
       active_status_download=w;
       w->destroyed.connect(sigc::ptr_fun(&reset_status_download));
     }
   else
     {
-      w=new download_list(abortslot);
+      w=download_list::create(abortslot);
       add_main_widget(w, title, longtitle, tablabel);
     }
 
-  m->MediaChange_sig.connect(sigc::mem_fun(*w, &download_list::MediaChange));
-  m->IMSHit_sig.connect(sigc::mem_fun(*w, &download_list::IMSHit));
-  m->Fetch_sig.connect(sigc::mem_fun(*w, &download_list::Fetch));
-  m->Done_sig.connect(sigc::mem_fun(*w, &download_list::Done));
-  m->Fail_sig.connect(sigc::mem_fun(*w, &download_list::Fail));
-  m->Pulse_sig.connect(sigc::mem_fun(*w, &download_list::Pulse));
-  m->Start_sig.connect(sigc::mem_fun(*w, &download_list::Start));
-  m->Stop_sig.connect(sigc::mem_fun(*w, &download_list::Stop));
-  m->Complete_sig.connect(sigc::mem_fun(*w, &download_list::Complete));
+  m->MediaChange_sig.connect(sigc::mem_fun(w.unsafe_get_ref(),
+					   &download_list::MediaChange));
+  m->IMSHit_sig.connect(sigc::mem_fun(w.unsafe_get_ref(),
+				      &download_list::IMSHit));
+
+  m->Fetch_sig.connect(sigc::mem_fun(w.unsafe_get_ref(),
+				     &download_list::Fetch));
+
+  m->Done_sig.connect(sigc::mem_fun(w.unsafe_get_ref(),
+				    &download_list::Done));
+
+  m->Fail_sig.connect(sigc::mem_fun(w.unsafe_get_ref(),
+				    &download_list::Fail));
+
+  m->Pulse_sig.connect(sigc::mem_fun(w.unsafe_get_ref(),
+				     &download_list::Pulse));
+
+  m->Start_sig.connect(sigc::mem_fun(w.unsafe_get_ref(),
+				     &download_list::Start));
+
+  m->Stop_sig.connect(sigc::mem_fun(w.unsafe_get_ref(),
+				    &download_list::Stop));
+
+  m->Complete_sig.connect(sigc::mem_fun(w.unsafe_get_ref(),
+					&download_list::Complete));
 
   return m;
 }
 
 static void do_prompt_string(const wstring &s,
-			     vs_editline *e,
+			     const vs_editline_ref &e,
 			     sigc::slot0<void> realslot)
 {
   e->add_to_history(s);
@@ -2034,19 +2050,19 @@
 {
   if(aptcfg->FindB(PACKAGE "::UI::Minibuf-Prompts"))
     {
-      vs_editline *e=new vs_editline(prompt, text, history);
+      vs_editline_ref e=vs_editline::create(prompt, text, history);
       if(slot)
 	e->entered.connect(*slot);
 
       e->entered.connect(sigc::bind(sigc::ptr_fun(do_prompt_string),
 				    e,
-				    sigc::mem_fun(*e, &vscreen_widget::destroy)));
+				    sigc::mem_fun(e.unsafe_get_ref(), &vscreen_widget::destroy)));
       if(changed_slot)
 	e->text_changed.connect(*changed_slot);
 
       e->connect_key("Cancel",
 		     &global_bindings,
-		     sigc::mem_fun(*e, &vscreen_widget::destroy));
+		     sigc::mem_fun(e.unsafe_get_ref(), &vscreen_widget::destroy));
 
       if(cancel_slot)
 	e->connect_key("Cancel",
@@ -2112,7 +2128,7 @@
       nostring+=_("no_key")[0];
       string yesnostring=deflt?yesstring+nostring:nostring+yesstring;
 
-      vs_statuschoice *c=new vs_statuschoice(prompt, transcode(yesnostring));
+      vs_statuschoice_ref c=vs_statuschoice::create(prompt, transcode(yesnostring));
       c->chosen.connect(sigc::bind(sigc::ptr_fun(&do_prompt_yesno),
 				   deflt,
 				   yesslot,
@@ -2144,12 +2160,12 @@
   msg=wrapbox(msg);
   if(aptcfg->FindB(PACKAGE "::UI::Minibuf-Prompts"))
     {
-      vs_text_layout *l=new vs_text_layout(msg);
+      vs_text_layout_ref l=vs_text_layout::create(msg);
       l->set_bg_style(get_style("Status")+st);
       if(okslot)
 	l->destroyed.connect(*okslot);
 
-      main_status_multiplex->add_visible_widget(new vs_transient(l), true);
+      main_status_multiplex->add_visible_widget(vs_transient::create(l), true);
       main_table->focus_widget(main_status_multiplex);
     }
   else



More information about the Aptitude-svn-commit mailing list