|
| 1 | +#include "PropertiesDialog.h" |
| 2 | + |
| 3 | +#include "ModuleManager.h" |
| 4 | +#include <string> |
| 5 | + |
| 6 | +PropertiesDialog::PropertiesDialog(void* node, void* manager){ |
| 7 | + ModuleNode* nodeRef = (ModuleNode*) node; |
| 8 | + ModuleManager* mgr = (ModuleManager*) manager; |
| 9 | + |
| 10 | + // get the sizes |
| 11 | + auto sizes = mgr->getSizes(nodeRef); |
| 12 | + Glib::ustring decompSize = Glib::format_size(sizes.first); |
| 13 | + Glib::ustring compSize = Glib::format_size(sizes.second); |
| 14 | + |
| 15 | + set_title("Properties of " + nodeRef->name); |
| 16 | + set_size_request(400, 250); |
| 17 | + |
| 18 | + int r = 0; |
| 19 | + |
| 20 | + // fill the contents |
| 21 | + |
| 22 | + Gtk::Grid* mainGrid = Gtk::make_managed<Gtk::Grid>(); |
| 23 | + mainGrid->set_halign(Gtk::ALIGN_CENTER); |
| 24 | + mainGrid->set_margin_top(20); |
| 25 | + mainGrid->set_row_spacing(10); |
| 26 | + mainGrid->set_column_spacing(10); |
| 27 | + mainGrid->set_baseline_row(0); |
| 28 | + |
| 29 | + // Item name |
| 30 | + Gtk::Label* nameLabel = Gtk::make_managed<Gtk::Label>("Name: "); |
| 31 | + Gtk::Label* nameValueLabel = Gtk::make_managed<Gtk::Label>(nodeRef->name); |
| 32 | + mainGrid->attach(*nameLabel, 0, r); |
| 33 | + mainGrid->attach(*nameValueLabel, 1, r); |
| 34 | + nameLabel->set_halign(Gtk::ALIGN_START); |
| 35 | + nameValueLabel->set_halign(Gtk::ALIGN_START); |
| 36 | + nameLabel->show(); |
| 37 | + nameValueLabel->show(); |
| 38 | + r++; |
| 39 | + |
| 40 | + // Item name |
| 41 | + Gtk::Label* pathLabel = Gtk::make_managed<Gtk::Label>("Full Path: "); |
| 42 | + Gtk::Label* pathValueLabel = Gtk::make_managed<Gtk::Label>(nodeRef->path); |
| 43 | + mainGrid->attach(*pathLabel, 0, r); |
| 44 | + mainGrid->attach(*pathValueLabel, 1, r); |
| 45 | + pathLabel->set_halign(Gtk::ALIGN_START); |
| 46 | + pathValueLabel->set_halign(Gtk::ALIGN_START); |
| 47 | + pathLabel->show(); |
| 48 | + pathValueLabel->show(); |
| 49 | + r++; |
| 50 | + |
| 51 | + // using if since a folder may be in multiple modules and I'm too lazy to check that, so I'm just not displaying it for now |
| 52 | + if(nodeRef->type != NODE_TYPE_DIRECTORY){ |
| 53 | + // Module path |
| 54 | + Gtk::Label* moduleLabel = Gtk::make_managed<Gtk::Label>("Module: "); |
| 55 | + Gtk::Label* moduleValueLabel = Gtk::make_managed<Gtk::Label>(nodeRef->item->module->name); |
| 56 | + mainGrid->attach(*moduleLabel, 0, r); |
| 57 | + mainGrid->attach(*moduleValueLabel, 1, r); |
| 58 | + moduleLabel->set_halign(Gtk::ALIGN_START); |
| 59 | + moduleValueLabel->set_halign(Gtk::ALIGN_START); |
| 60 | + moduleLabel->show(); |
| 61 | + moduleValueLabel->show(); |
| 62 | + r++; |
| 63 | + } |
| 64 | + |
| 65 | + |
| 66 | + // Decompressed size |
| 67 | + Gtk::Label* decompLabel = Gtk::make_managed<Gtk::Label>("Decompressed Size: "); |
| 68 | + Gtk::Label* decompValueLabel = Gtk::make_managed<Gtk::Label>(decompSize + " (" + std::to_string(sizes.first) + " Bytes)"); |
| 69 | + mainGrid->attach(*decompLabel, 0, r); |
| 70 | + mainGrid->attach(*decompValueLabel, 1, r); |
| 71 | + decompLabel->set_halign(Gtk::ALIGN_START); |
| 72 | + decompValueLabel->set_halign(Gtk::ALIGN_START); |
| 73 | + decompLabel->show(); |
| 74 | + decompValueLabel->show(); |
| 75 | + r++; |
| 76 | + |
| 77 | + // Compressed size |
| 78 | + Gtk::Label* compLabel = Gtk::make_managed<Gtk::Label>("Compressed Size: "); |
| 79 | + Gtk::Label* compValueLabel = Gtk::make_managed<Gtk::Label>(compSize + " (" + std::to_string(sizes.second) + " Bytes)"); |
| 80 | + mainGrid->attach(*compLabel, 0, r); |
| 81 | + mainGrid->attach(*compValueLabel, 1, r); |
| 82 | + compLabel->set_halign(Gtk::ALIGN_START); |
| 83 | + compValueLabel->set_halign(Gtk::ALIGN_START); |
| 84 | + compLabel->show(); |
| 85 | + compValueLabel->show(); |
| 86 | + r++; |
| 87 | + |
| 88 | + ((Gtk::Box*)get_child())->add(*mainGrid); |
| 89 | + |
| 90 | + mainGrid->show(); |
| 91 | + show(); |
| 92 | +} |
0 commit comments