Mailinglist Archive: yast-commit (195 mails)

< Previous Next >
[yast-commit] r63556 - in /trunk/storage/storage/src/include: ep-btrfs-dialogs.ycp ep-btrfs-lib.ycp ep-btrfs.ycp
Author: fehr
Date: Thu Mar 10 11:09:40 2011
New Revision: 63556

URL: http://svn.opensuse.org/viewcvs/yast?rev=63556&view=rev
Log:
add files for handling btrfs panel

Added:
trunk/storage/storage/src/include/ep-btrfs-dialogs.ycp
trunk/storage/storage/src/include/ep-btrfs-lib.ycp
trunk/storage/storage/src/include/ep-btrfs.ycp

Added: trunk/storage/storage/src/include/ep-btrfs-dialogs.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-btrfs-dialogs.ycp?rev=63556&view=auto
==============================================================================
--- trunk/storage/storage/src/include/ep-btrfs-dialogs.ycp (added)
+++ trunk/storage/storage/src/include/ep-btrfs-dialogs.ycp Thu Mar 10 11:09:40
2011
@@ -0,0 +1,36 @@
+/**
+ * File: ep-btrfs-dialogs.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Thomas Fehr <fehr@xxxxxxx>
+ *
+ * This file must only be included in other Expert Partitioner files
("ep-*.ycp").
+ */
+{
+ textdomain "storage";
+
+
+ boolean DlgEditBtrfsVolume(map<string, any> &data)
+ {
+ y2milestone( "DlgEditBtrfsVolume %1", data );
+ string device = data["device"]:"error";
+
+ map<string, any> aliases = $[
+ "FormatMount" : ``(MiniWorkflowStepFormatMount(data)),
+ "Password" : ``(MiniWorkflowStepPassword(data))
+ ];
+
+ map<string, any> sequence = $[
+ "FormatMount" : $[ `next : "Password",
+ `finish : `finish ],
+ "Password" : $[ `finish : `finish ]
+ ];
+
+ // dialog title
+ string title = sformat(_("Edit Btrfs %1"), data["uuid"]:"");
+
+ symbol widget = MiniWorkflow::Run(title, StorageIcons::lvm_lv_icon,
aliases, sequence, "FormatMount");
+
+ return widget == `finish;
+ }
+}

Added: trunk/storage/storage/src/include/ep-btrfs-lib.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-btrfs-lib.ycp?rev=63556&view=auto
==============================================================================
--- trunk/storage/storage/src/include/ep-btrfs-lib.ycp (added)
+++ trunk/storage/storage/src/include/ep-btrfs-lib.ycp Thu Mar 10 11:09:40 2011
@@ -0,0 +1,97 @@
+/**
+ * File: ep-btrfs-lib.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Thomas Fehr <fehr@xxxxxxx>
+ *
+ * This file must only be included in other Expert Partitioner files
("ep-*.ycp").
+ */
+{
+ textdomain "storage";
+
+
+ void EpEditBtrfsDevice(string device)
+ {
+ if (device == nil)
+ {
+ // error popup
+ Popup::Error(_("No BTRFS device selected."));
+ return;
+ }
+
+ map<string, map> target_map = Storage::GetTargetMap();
+ map<string, any> data = Storage::GetPartition(target_map, device);
+ y2milestone( "EpEditBtrfsDevice device:%1 data:%2", device, data );
+
+ if (Storage::IsUsedBy(data))
+ {
+ // error popup
+ Popup::Error(sformat(_("The Btrfs %1 is in use. It cannot be
+edited. To edit %1, make sure it is not used."), data["uuid"]:""));
+ return;
+ }
+
+ if (DlgEditBtrfsVolume(data))
+ {
+ Storage::ChangeVolumeProperties(data);
+
+ UpdateMainStatus();
+ UpdateNavigationTree(nil);
+ TreePanel::Create();
+ UpdateTableFocus(device);
+ }
+ }
+
+ void EpDeleteBtrfsDevice(string device)
+ {
+ if (device == nil)
+ {
+ // error popup
+ Popup::Error(_("No BTRFS device selected."));
+ return;
+ }
+
+ map<string, map> target_map = Storage::GetTargetMap();
+ map<string, any> data = Storage::GetPartition(target_map, device);
+ y2milestone( "EpDeletBtrfsDevice device:%1 data:%2", device, data );
+
+ if (!Storage::CanDelete(data, target_map["/dev/btrfs"]:$[], true))
+ return;
+
+ if (EpDeleteDevice(device))
+ {
+ any new_focus = nil;
+ if (UI::QueryWidget(`tree, `CurrentItem) == device)
+ new_focus = `md;
+ UpdateMainStatus();
+ UpdateNavigationTree(new_focus);
+ TreePanel::Create();
+ }
+
+ }
+
+ void EpResizeBtrfsDevice(string device)
+ {
+ if (device == nil)
+ {
+ // error popup
+ Popup::Error(_("No BTRFS device selected."));
+ return;
+ }
+
+ map<string, map> target_map = Storage::GetTargetMap();
+ map<string, any> data = Storage::GetPartition(target_map, device);
+ y2milestone( "EpResizetrfsDevice device:%1 data:%2", device, data );
+
+ if (true/*EpDeleteDevice(device)*/)
+ {
+ any new_focus = nil;
+ if (UI::QueryWidget(`tree, `CurrentItem) == device)
+ new_focus = `btrfs;
+ UpdateMainStatus();
+ UpdateNavigationTree(new_focus);
+ TreePanel::Create();
+ }
+
+ }
+}

Added: trunk/storage/storage/src/include/ep-btrfs.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-btrfs.ycp?rev=63556&view=auto
==============================================================================
--- trunk/storage/storage/src/include/ep-btrfs.ycp (added)
+++ trunk/storage/storage/src/include/ep-btrfs.ycp Thu Mar 10 11:09:40 2011
@@ -0,0 +1,229 @@
+/**
+ * File: ep-btrfs.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Thomas Fehr <fehr@xxxxxxx>
+ *
+ * This file must only be included in other Expert Partitioner files
("ep-*.ycp").
+ */
+{
+ textdomain "storage";
+
+ include "partitioning/ep-btrfs-dialogs.ycp";
+ include "partitioning/ep-btrfs-lib.ycp";
+
+
+ void EpContextMenuBtrfs(string device)
+ {
+ symbol widget = ContextMenu::Simple([ `item(`id(`edit), _("Edit")),
+ `item(`id(`delete),
_("Delete"))]);
+
+ switch (widget)
+ {
+ case `edit:
+ EpEditBtrfsDevice(device);
+ break;
+ case `delete:
+ EpDeleteBtrfsDevice(device);
+ break;
+ }
+ }
+
+ void HandleBtrfsButtons( any user_data, string device, map event )
+ {
+ y2milestone( "HandleBtrfsButtons device:%1 user_data:%2 event:%3",
+ device, event, user_data );
+ string disk_device = "";
+
+ if (user_data == nil)
+ {
+ map disk = nil;
+ map part = nil;
+
+ map<string, map> target_map = Storage::GetTargetMap();
+ SplitDevice(target_map, device, disk, part);
+ disk_device = (string) disk["device"]:"";
+ }
+ else
+ {
+ disk_device = (string) user_data;
+ }
+
+ switch (Event::IsWidgetActivated(event))
+ {
+ case `edit:
+ EpEditBtrfsDevice(device);
+ break;
+
+ case `resize:
+ EpResizeBtrfsDevice(device);
+ break;
+ }
+ }
+
+ void CreateBtrfsMainPanel(any user_data)
+ {
+ list<symbol> fields = StorageSettings::FilterTable([ `device, `size,
`format, `encrypted, `type,
+ `fs_type, `label,
`mount_point, `mount_by ]);
+
+ map<string, map> target_map = Storage::GetTargetMap();
+ term table_header = StorageFields::TableHeader(fields);
+ list<term> table_contents = StorageFields::TableContents(fields,
target_map, StorageFields::PredicateBtrfs);
+ UI::ReplaceWidget(`tree_panel,
+ Greasemonkey::Transform(
+ `VBox(
+ `HStretch(),
+ // heading
+ `IconAndHeading(_("Btrfs Volumes (BTRFS)"),
StorageIcons::dm_icon ),
+ `Table(`id(`table), `opt(`keepSorting,
`notify, `notifyContextMenu),
+ table_header, table_contents),
+ ArrangeButtons([ // push button text
+
`PushButton(`id(`edit),`opt(`key_F4), _("Edit...")),
+ // push button text
+
`PushButton(`id(`resize),`opt(`key_F8), _("Resize...")),
+ `HStretch() ])
+ )
+ ));
+
+ // helptext
+ string helptext = _("<p>This view shows all BTRFS volumes.</p>");
+
+ Wizard::RestoreHelp(helptext + StorageFields::TableHelptext(fields));
+ }
+
+ void HandleBtrfsMainPanel(any user_data, map event)
+ {
+ string device = (string) UI::QueryWidget(`id(`table), `CurrentItem);
+ HandleBtrfsButtons( user_data, device, event );
+ switch (Event::IsWidgetContextMenuActivated(event))
+ {
+ case `table:
+ EpContextMenuDevice(device);
+ break;
+ }
+ UI::SetFocus(`id(`table));
+ }
+
+
+ void CreateBtrfsOverviewTab(any user_data)
+ {
+ string device = (string) user_data;
+ y2milestone( "CreateBtrfsOverviewTab user_data:%1", user_data );
+
+ map<string, map> target_map = Storage::GetTargetMap();
+
+ list<symbol> fields = StorageSettings::FilterOverview([
`heading_device, `device, `size, `used_by,
+
`heading_filesystem, `fs_type, `mount_point,
+ `mount_by,
`uuid, `label ]);
+
+ UI::ReplaceWidget(`tab_panel,
+ Greasemonkey::Transform(
+ `VBox(
+ StorageFields::Overview(fields, target_map,
device),
+ `HBox(
+ // push button text
+ `PushButton(`id(`edit), _("Edit...")),
+ `HStretch()
+ )
+ )
+ )
+ );
+
+ // helptext
+ string helptext = _("<p>This view shows detailed information about the
+selected BTRFS volume.</p>");
+
+ Wizard::RestoreHelp(helptext + StorageFields::OverviewHelptext(fields));
+ }
+
+
+ void HandleBtrfsOverviewTab(any user_data, map event)
+ {
+ string device = (string) user_data;
+ y2milestone( "HandleBtrfsOverviewTab user_data:%1", user_data );
+
+ switch (Event::IsWidgetActivated(event))
+ {
+ case `edit:
+ EpEditBtrfsDevice(device);
+ break;
+ case `delete:
+ EpDeleteBtrfsDevice(device);
+ break;
+ case `resize:
+ EpResizeBtrfsDevice(device);
+ break;
+ }
+ }
+
+
+ void CreateBtrfsDevicesTab(any user_data)
+ {
+ string part_device = (string) user_data;
+ integer pos = search( part_device, "=" );
+ if( pos != nil )
+ part_device = substring( part_device, pos+1 );
+ y2milestone( "CreateBtrfsDevicesTab user_data:%1 part_device:%2",
user_data, part_device );
+
+ symbol Predicate(map disk, map partition)
+ {
+ return StorageFields::PredicateUsedByDevice(disk, partition, [
part_device ]);
+ }
+
+ list<symbol> fields = StorageSettings::FilterTable([ `device,
`udev_path, `udev_id, `size,
+ `format,
`encrypted, `type ]);
+
+ 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(`tab_panel,
+ `VBox(
+ `Table(`id(`table), `opt(`keepSorting, `notify),
+ table_header, table_contents)
+ )
+ );
+
+ // helptext
+ string helptext = _("<p>This view shows all devices used by the
+selected BTRFS volume.</p>");
+
+ Wizard::RestoreHelp(helptext + StorageFields::TableHelptext(fields));
+ }
+
+
+ void CreateBtrfsPanel(any user_data)
+ {
+ string device = (string) user_data;
+ y2milestone( "CreateBtrfsPanel user_data:%1 device:%2", user_data,
device );
+
+ map<symbol, map> data = $[ `overview : $[ `create :
CreateBtrfsOverviewTab, `handle : HandleBtrfsOverviewTab, `user_data :
user_data ],
+ `devices : $[ `create :
CreateBtrfsDevicesTab, `user_data : user_data ] ];
+
+ UI::ReplaceWidget(`tree_panel,
+ Greasemonkey::Transform(
+ `VBox(
+ // heading
+ `IconAndHeading(sformat(_("Btrfs Device:
%1"), device), StorageIcons::lvm_lv_icon),
+ `DumbTab(`id(`tab), [
+ // push button text
+ `item(`id(`overview),
_("&Overview")),
+ // push button text
+ `item(`id(`devices), _("&Used
Devices"))
+ ],
+ `ReplacePoint(`id(`tab_panel),
TabPanel::empty_panel)
+ )
+ )
+ )
+ );
+
+ TabPanel::Init(data, `overview);
+ }
+
+
+ void HandleBtrfsPanel(any user_data, map event)
+ {
+ TabPanel::Handle(event);
+ }
+}

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages