ACC SHELL

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

/**
 * File:	ep-loop.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-loop-dialogs.ycp";
    include "partitioning/ep-loop-lib.ycp";


    void EpContextMenuLoop(string device)
    {
	symbol widget = ContextMenu::Simple([ `item(`id(`edit), _("Edit")),
					      `item(`id(`delete), _("Delete")) ]);

	switch (widget)
	{
	    case `edit:
		EpEditLoop(device);
		break;

	    case `delete:
		EpDeleteLoop(device);
		break;
	}
    }


    term LoopButtonBox()
    {
	return `HBox(
	    // push button text
	    `PushButton(`id(`edit), `opt(`key_F4), _("Edit...")),
	    // push button text
	    `PushButton(`id(`delete), `opt(`key_F5), _("Delete..."))
	);
    }


    void HandleLoopButtons( string part_device, map event )
    {
	switch (Event::IsWidgetActivated(event))
	{
	    case `add:
		EpCreateLoop();
		break;

	    case `edit:
		EpEditLoop(part_device);
		break;

	    case `delete:
		EpDeleteLoop(part_device);
		break;
	}
    }


    void CreateLoopMainPanel(any user_data)
    {
	symbol Predicate(map disk, map partition)
	{
	    return StorageFields::PredicateDiskType(disk, partition, [`CT_LOOP]);
	}

	list<symbol> fields = StorageSettings::FilterTable([ `device, `size, `fs_type, `label, `mount_point ]);

	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(
				  `HStretch(),
				  // heading
				  `IconAndHeading(_("Crypt Files"), StorageIcons::loop_icon),
				  `Table(`id(`table), `opt(`keepSorting, `notify, `notifyContextMenu),
					 table_header, table_contents),
				  `HBox(
				      // push button text
				      `PushButton(`id(`add), `opt(`key_F3), _("Add Crypt File...")),
				      LoopButtonBox(),
				      `HStretch()
				      )
				  )
			      )
	    );

	// helptext
	string helptext = _("<p>This view shows all crypt files.</p>");

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


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

	HandleLoopButtons(device, event);

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

	UI::SetFocus(`id(`table));
    }


    void CreateLoopPanel(any user_data)
    {
	string part_device = (string) user_data;

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

	list<symbol> fields = StorageSettings::FilterOverview([ `heading_device, `device, `size, `file_path,
								`heading_filesystem, `fs_type, `mount_point ]);

	UI::ReplaceWidget(`tree_panel,
			  Greasemonkey::Transform(
			      `VBox(
				  // heading
				  `IconAndHeading(sformat(_("Crypt File: %1"), part_device), StorageIcons::loop_icon),
				  `HStretch(),
				  StorageFields::Overview(fields, target_map, part_device),
				  `HBox(
				      LoopButtonBox(),
				      `HStretch()
				      )
				  ))
	    );

	// helptext
	string helptext = _("<p>This view shows detailed information of the
selected crypt file.</p>");

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


    void HandleLoopPanel(any user_data, map event)
    {
	string part_device = (string) user_data;

	HandleLoopButtons( part_device, event );

	UI::SetFocus(`id(`text));
    }
}

ACC SHELL 2018