ACC SHELL

Path : /usr/share/YaST2/include/partitioning/
File Upload :
Current File : //usr/share/YaST2/include/partitioning/ep-unused.ycp

/**
 * File:        ep-unused.ycp
 * Package:     yast2-storage
 * Summary:     Expert Partitioner
 * Authors:     Arvin Schnell <aschnell@suse.de>
 *
 * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
 */
{
    textdomain "storage";

    include "partitioning/ep-dialogs.ycp";


    void CreateUnusedPanel(any user_data)
    {
	symbol Predicate(map disk, map partition)
	{
	    symbol disk_type = disk["type"]:`CT_UNKNOWN;

	    if (partition == nil)
	    {
		if (isempty(disk["partitions"]:[]) &&
		    isempty(disk["used_by"]:[]))
		{
		    return `show;
		}

		return `follow;
	    }
	    else
	    {
		if (partition["type"]:`primary != `extended &&
		    isempty(partition["mount"]:"") &&
		    isempty(partition["used_by"]:[]))
		{
		    return `show;
		}

		return `ignore;
	    }
	}

	list<symbol> fields = StorageSettings::FilterTable([ `device, `udev_path, `udev_id, `size, `format,
							     `encrypted, `type, `fs_type, `label ]);

	map<string, map> target_map = Storage::GetTargetMap();

	term table_header = StorageFields::TableHeader(fields);
	list<term> table_contents = StorageFields::TableContents(fields, target_map, Predicate);

	UI::ReplaceWidget(`tree_panel,
			  Greasemonkey::Transform(
			      `VBox(
				  // heading
				  `IconAndHeading(_("Unused Devices"), StorageIcons::unused_icon),
				  `Table(`id(`table), `opt(`keepSorting, `notify, `notifyContextMenu),
					 table_header, table_contents),
				  `HBox(
				      // push button text
				      `PushButton(`id(`rescan), `opt(`key_F6), _("Rescan")),
				      `HStretch()
				  )
			      ))
	    );

	// helptext
	string helptext = _("<p>This view shows devices that have no mount
point assigned to them, disks that are unpartitioned and volume groups that
have no logical volumes.</p>");

	Wizard::RestoreHelp(helptext + StorageFields::TableHelptext(fields));
    }


    void HandleUnusedPanel(any user_data, map event)
    {
	string device = (string) UI::QueryWidget(`id(`table), `CurrentItem);

	switch (Event::IsWidgetContextMenuActivated(event))
	{
	    case `table:
		EpContextMenuDevice(device);
		break;
	}

	switch (Event::IsWidgetActivated(event))
	{
	    case `rescan:
		// popup message
		if (Popup::YesNo(_("Rescaning unused devices cancels
all current changes. Really rescan unused devices?")))
		{
		    RescanDisks();
		    Storage::CreateTargetBackup("expert-partitioner");

		    UpdateMainStatus();
		    UpdateNavigationTree(nil);
		    TreePanel::Create();
		}
	}
    }
}

ACC SHELL 2018