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

Daniel Burrows dburrows@costa.debian.org
Tue, 07 Jun 2005 18:25:08 +0000


Author: dburrows
Date: Tue Jun  7 18:25:05 2005
New Revision: 3378

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/ui.cc
   branches/aptitude-0.3/aptitude/src/ui.h
Log:
Update the core UI code for styles.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Tue Jun  7 18:25:05 2005
@@ -1,5 +1,9 @@
 2005-06-07  Daniel Burrows  <dburrows@debian.org>
 
+	* src/ui.cc, src/ui.h:
+
+	Update the core UI code for styles.
+
 	* src/trust.cc:
 
 	Update the trust dialog for styles.

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 Jun  7 18:25:05 2005
@@ -205,9 +205,6 @@
 
   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,
@@ -216,7 +213,7 @@
   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"));
+  return vs_dialog_ok(t, NULL, _("Ok"), get_style("Error"));
 }
 
 // blah, I hate C++
@@ -525,7 +522,7 @@
 					   0, 0, 1, 1,
 					   vs_table::ALIGN_CENTER | vs_table::EXPAND | vs_table::FILL | vs_table::SHRINK,
 					   vs_table::ALIGN_CENTER,
-					   get_color("ScreenHeaderColor"),
+					   get_style("Header"),
 					   "",
 					   "",
 					   true));
@@ -533,7 +530,7 @@
   basic_format.push_back(package_view_item("main", 1, 0, 1, 1,
 					   vs_table::EXPAND | vs_table::FILL | vs_table::SHRINK,
 					   vs_table::EXPAND | vs_table::FILL | vs_table::SHRINK,
-					   get_color("DefaultWidgetBackground"),
+					   style(),
 					   true));
 
   basic_format.push_back(package_view_item("static2",
@@ -544,14 +541,14 @@
 					   2, 0, 1, 1,
 					   vs_table::ALIGN_CENTER | vs_table::EXPAND | vs_table::FILL | vs_table::SHRINK,
 					   vs_table::ALIGN_CENTER,
-					   get_color("ScreenStatusColor"),
+					   get_style("Status"),
 					   "", "",
 					   true));
 
   basic_format.push_back(package_view_item("desc", 3, 0, 1, 1,
 					   vs_table::EXPAND | vs_table::FILL | vs_table::SHRINK,
 					   vs_table::EXPAND | vs_table::FILL | vs_table::SHRINK,
-					   get_color("DefaultWidgetBackground"),
+					   style(),
 					   "ShowHideDescription", "",
 					   allow_visible_desc && aptcfg->FindB(PACKAGE "::UI::Description-Visible-By-Default", true)));
 
@@ -664,7 +661,7 @@
 
 static void do_help_about()
 {
-  fragment *f=fragf(_("%AAptitude %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."), get_color("DefaultWidgetBackground")|A_REVERSE, VERSION);
+  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));
   w->show_all();
@@ -800,7 +797,7 @@
 						       _("Really Continue"),
 						       NULL,
 						       _("Abort Installation"),
-						       get_color("Error"),
+						       get_style("Error"),
 						       true,
 						       false),
 				       true);
@@ -906,14 +903,14 @@
     {
       show_message(_("No solution to these dependency problems exists!"),
 		   NULL,
-		   get_color("Error"));
+		   get_style("Error"));
     }
   catch(NoMoreTime)
     {
-      show_message(attr_fragment(fragf(_("Ran out of time while trying to resolver dependencies (press \"%s\" to try harder)"),
-				       global_bindings.readable_keyname("NextSolution").c_str()),
-				 get_color("Error")),
-		   NULL);
+      show_message(fragf(_("Ran out of time while trying to resolve dependencies (press \"%s\" to try harder)"),
+			 global_bindings.readable_keyname("NextSolution").c_str()),
+		   NULL,
+		   get_style("Error")));
     }
 
   if(!undo->empty())
@@ -956,17 +953,17 @@
 	    check_package_trust();
 	  else
 	    {
-	      popup_widget(vs_dialog_yesno(wrapbox(text_fragment(_("Installing/removing packages requires administrative privileges, which you currently do not have.  Would you like to change to the root account?"), get_color("Error"))),
+	      popup_widget(vs_dialog_yesno(wrapbox(text_fragment(_("Installing/removing packages requires administrative privileges, which you currently do not have.  Would you like to change to the root account?"))),
 					   arg(sigc::bind(sigc::ptr_fun(&do_su_to_root),
 						      "-i")),
 					   _("Become root"),
 					   arg(sigc::ptr_fun(&check_package_trust)),
 					   _("Don't become root"),
-					   get_color("Error")));
+					   get_style("Error")));
 	    }
 	}
       else
-	show_message(_("A package-list update or install run is already taking place."), NULL, get_color("Error"));
+	show_message(_("A package-list update or install run is already taking place."), NULL, get_style("Error"));
     }
 }
 
@@ -1071,18 +1068,17 @@
 	really_do_update_lists();
       else
 	{
-	  popup_widget(vs_dialog_yesno(wrapbox(text_fragment(_("Updating the package lists requires administrative privileges, which you currently do not have.  Would you like to change to the root account?"),
-							     get_color("Error"))),
+	  popup_widget(vs_dialog_yesno(wrapbox(text_fragment(_("Updating the package lists requires administrative privileges, which you currently do not have.  Would you like to change to the root account?"))),
 				       arg(sigc::bind(sigc::ptr_fun(&do_su_to_root),
 						      "-u")),
 				       _("Become root"),
 				       arg(sigc::ptr_fun(&really_do_update_lists)),
 				       _("Don't become root"),
-				       get_color("Error")));
+				       get_style("Error")));
 	}
     }
   else
-    show_message(_("A package-list update or install run is already taking place."), NULL, get_color("Error"));
+    show_message(_("A package-list update or install run is already taking place."), NULL, get_style("Error"));
 }
 
 static void do_sweep()
@@ -1276,13 +1272,13 @@
 	{
 	  show_message(_("Unable to find a solution to apply."),
 		       NULL,
-		       get_color("Error"));
+		       get_style("Error"));
 	}
       catch(NoMoreTime)
 	{
 	  show_message(_("Ran out of time while trying to find a solution."),
 		       NULL,
-		       get_color("Error"));
+		       get_style("Error"));
 	}
 
       if(!undo->empty())
@@ -1572,8 +1568,7 @@
   if(item && item->get_description().size()>0)
     {
       label->show();
-      label->set_text(wrapbox(text_fragment(item->get_description(),
-					    label->get_bg())));
+      label->set_text(wrapbox(text_fragment(item->get_description())));
     }
   else
     {
@@ -1624,7 +1619,7 @@
 class help_bar:public vs_label
 {
 public:
-  help_bar(string txt, int attr):vs_label(txt, attr)
+  help_bar(string txt, const style &st):vs_label(txt, st)
   {
     set_visibility();
   }
@@ -1652,7 +1647,6 @@
   load_options(PACKAGE "::UI", false);
 
   vs_label *menu_description=new vs_label("");
-  menu_description->set_bg(get_color("ScreenStatusColor"));
 
   main_menu=new vs_menubar(!aptcfg->FindB(PACKAGE "::UI::Menubar-Autohide", false));
 
@@ -1738,7 +1732,7 @@
 	   update_key.c_str(),
 	   install_key.c_str());
 
-  help_bar *help_label=new help_bar(buf, get_color("ScreenStatusColor"));
+  help_bar *help_label=new help_bar(buf, get_style("Header"));
   main_table->add_widget_opts(help_label, 0, 0, 1, 1,
 			      vs_table::EXPAND | vs_table::FILL | vs_table::SHRINK,
 			      vs_table::ALIGN_CENTER);
@@ -1756,6 +1750,7 @@
 			      vs_table::ALIGN_CENTER);
 
   main_status_multiplex=new vs_multiplex;
+  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,
 			      vs_table::ALIGN_CENTER);
@@ -2005,7 +2000,6 @@
       string yesnostring=deflt?yesstring+nostring:nostring+yesstring;
 
       vs_statuschoice *c=new vs_statuschoice(prompt, yesnostring.c_str());
-      c->set_bg(get_color("ScreenStatusColor"));
       c->chosen.connect(sigc::bind(sigc::ptr_fun(&do_prompt_yesno),
 				   deflt,
 				   yesslot,
@@ -2023,12 +2017,14 @@
 }
 
 void show_message(fragment *msg,
-		  slot0arg okslot)
+		  slot0arg okslot,
+		  const style &st)
 {
+  msg=wrapbox(msg);
   if(aptcfg->FindB(PACKAGE "::UI::Minibuf-Prompts"))
     {
       vs_text_layout *l=new vs_text_layout(msg);
-      l->set_bg(get_color("ScreenStatusColor"));
+      l->set_bg_style(get_style("Status")+st);
       if(okslot)
 	l->destroyed.connect(*okslot);
 
@@ -2036,21 +2032,12 @@
       main_table->focus_widget(main_status_multiplex);
     }
   else
-    main_stacked->add_visible_widget(vs_dialog_ok(msg, okslot), true);
+    main_stacked->add_visible_widget(vs_dialog_ok(msg, okslot, st), true);
 }
 
 void show_message(const std::string &msg,
 		  slot0arg okslot,
-		  int attr)
-{
-  show_message(wrapbox(text_fragment(msg, attr)), okslot);
-}
-
-void show_message(const std::string &msg,
-		  slot0arg okslot)
+		  const style &st)
 {
-  if(aptcfg->FindB(PACKAGE "::UI::Minibuf-Prompts"))
-    show_message(msg, okslot, get_color("ScreenStatusColor"));
-  else
-    show_message(msg, okslot, get_color("DefaultWidgetBackground")|A_REVERSE);
+  show_message(text_fragment(msg), okslot, st);
 }

Modified: branches/aptitude-0.3/aptitude/src/ui.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/ui.h	(original)
+++ branches/aptitude-0.3/aptitude/src/ui.h	Tue Jun  7 18:25:05 2005
@@ -191,20 +191,19 @@
 /** Display the given message, either in a popup dialog box or as a
  *  "transient" message at the bottom of the screen.  The message
  *  should be expected to be relatively short (ie, short enough to not
- *  need a scrollbar on a 'reasonable' terminal).
+ *  need a scrollbar on a 'reasonable' terminal).  For convenience, a
+ *  wrapbox is implicitly placed around the message.
  *
  *  \param msg the message to display
  *  \param okslot an optional slot to be called when the message is dismissed
  */
 void show_message(fragment *msg,
-		  slot0arg okslot);
-
-void show_message(const std::string &msg,
 		  slot0arg okslot,
-		  int attr);
+		  const style &st=style());
 
 void show_message(const std::string &msg,
-		  slot0arg okslot=NULL);
+		  slot0arg okslot=NULL,
+		  const style &st=style());
 
 // Can be used to manually pop up an error dialog, if necessary.
 void check_apt_errors();