Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fwsetup-ng.git;a=commitdiff;h=172e81da792dda29c95bf5d4f24328a13c1a6f12

commit 172e81da792dda29c95bf5d4f24328a13c1a6f12
Author: James Buren <[email protected]>
Date:   Tue Aug 28 14:29:48 2012 -0500

replace text formatting blocks with functions so they can be updated elsewhere

diff --git a/PartitionModule.cc b/PartitionModule.cc
index 6bce8b9..1455ba4 100644
--- a/PartitionModule.cc
+++ b/PartitionModule.cc
@@ -24,6 +24,20 @@ public:

};

+static string formatDeviceText(Device *device)
+{
+  stringstream buf;
+
+  buf << device->getPath();
+  buf << ": ";
+  buf << device->getLabelType();
+  buf << " label (";
+  buf << device->getSizeString();
+  buf << ")";
+
+  return buf.str();
+}
+
// FIXME: this function makes assumptions about text alignment padding.
static string formatPartitionText(Device *device,Partition *part)
{
@@ -46,6 +60,17 @@ static string formatPartitionText(Device *device,Partition 
*part)
return buf.str();
}

+static string formatSpaceText(Device *device)
+{
+  stringstream buf;
+
+  buf << "  Free space (";
+  buf << device->getUnusedSizeString();
+  buf << ")";
+
+  return buf.str();
+}
+
bool Item::getItems(vector <Device *> &devices,vector <Item *> 
&items,newtComponent &listbox)
{
devices = Device::probeAll();
@@ -61,8 +86,8 @@ bool Item::getItems(vector <Device *> &devices,vector <Item 
*> &items,newtCompon
{
Item *item = new Item();

-      item->text = device->getPath() + ": " + device->getLabelType() + " label 
(" + device->getSizeString() + ")";
-
+      item->text = formatDeviceText(device);
+
item->device = device;

items.push_back(item);
@@ -86,7 +111,7 @@ bool Item::getItems(vector <Device *> &devices,vector <Item 
*> &items,newtCompon
{
item = new Item();

-          item->text = "  Free Space (" + device->getUnusedSizeString() + ")";
+          item->text = formatSpaceText(device);

item->space = true;
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to