Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Oct 2001 16:25:28 -0400
From:      The Anarcat <anarcat@anarcat.dyndns.org>
To:        The Anarcat <anarcat@anarcat.dyndns.org>
Subject:   basic label editor stub
Message-ID:  <20011007162528.A28881@shall.anarcat.dyndns.org>

next in thread | raw e-mail | index | archive | help

--aM3YZ0Iwxop3KEKx
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi.

In my ongoing work on what I call the "label editor", here is a patch to
release/diskedit/fdisk.tcl that creates a simple "Edit Partitions"
button and a stub to call a unimplemented "disklabel" procedure.

I also include a stub disklabel.tcl file that must be added to the repo
in order for this change to not break anything.

I will keep on working on disklabel.tcl now.

A. 

--aM3YZ0Iwxop3KEKx
Content-Type: text/plain; charset=us-ascii
Content-Description: patch to fdisk.tcl
Content-Disposition: attachment; filename="patch-2001.10.07"

Index: fdisk.tcl
===================================================================
RCS file: /home/libh/cvs/libh/release/diskedit/fdisk.tcl,v
retrieving revision 1.6
diff -u -r1.6 fdisk.tcl
--- fdisk.tcl	2001/06/10 16:10:03	1.6
+++ fdisk.tcl	2001/10/07 20:21:58
@@ -3,6 +3,33 @@
 source sliceops.tcl
 source fdiskops.tcl
 
+proc edit_part_callback {hui button userdata} {
+
+    global activedisk
+    set listbox [$hui byName "sliceslistbox"]
+    set slice [$listbox select]
+    set slicename [$listbox text $slice]
+    
+    set chunk [[$activedisk chunks] part]
+    for {set index 0}\
+	{![H::is_null $chunk] && [expr $index < $slice]}\
+	{incr index} {
+            set chunk [$chunk next]
+        }
+
+    # from libdisk source, type returns 3 for FreeBSD partitions
+    # this (3) should be a variable
+    if {[$chunk type] != 3} {
+        # can't edit that
+        # FIXME: put a warning here
+        puts stderr "unimplemented: can't edit slice, not FreeBSD"
+    } else {
+        puts stderr "found good slice, launching disklabel editor"
+        source disklabel.tcl
+        disklabel [$chunk part]
+    }
+}
+
 proc update_slices {} {
     global slices
     global activedisk
@@ -122,6 +149,7 @@
     $vcont3 button "quit_button" "&Quit" {button_click_result QUIT}
     $vcont3 button "undo_button" "&Undo All Changes" {undo_all ""}
     $vcont3 button "write_button" "Write Changes" {write_changes ""}
+    $vcont3 button "edit_button" "Edit &Partitions" {edit_part_callback ""}
  
     update_slices
 

--aM3YZ0Iwxop3KEKx
Content-Type: text/plain; charset=us-ascii
Content-Description: new disklabel.tcl file
Content-Disposition: attachment; filename="disklabel.tcl"

proc disklabel {part} {
    puts stderr "unimplemented"
    global main_window
    global menubar
    global hui
    global slices
    global dialog
    global activedisk
    
    return
    # this is proc fdisk implementation, we'll use this as an example
    set activedisk [Disk $diskname]
    set disk $activedisk
    
    set dialog [$hui dialog $main_window [format "%sfdiskdialog" $diskname] \
		    $diskname "1 0" "75 18" "vertical"]
    
    set diskgeometrylabel [$dialog label "diskgeometrylabel" \
			       [format "Disk Geometry: %s" \
				    [disk_geometry_text [Disk $diskname]]]]
    $diskgeometrylabel resize "-1 1"
    
    set slices [$dialog listBox "sliceslistbox" {} -1 \
		    "Offset\tSize(ST)\tEnd\tName\tPType\tDesc\tSubtype\tFlags"]
    set hcont1 [$dialog container "hcont" "0 0" "horizontal"]
    $hcont1 resize "-1 8"

    set vcont1 [$hcont1 container "vcont1" "0 0" "vertical"]
    $vcont1 button "entire_button" "Use &Entire Disk" {entire_disk ""}
    $vcont1 button "create_button" "&Create Slice" {create_slice ""}
    $vcont1 button "delete_button" "&Delete Slice" {delete_slice ""}
    $vcont1 button "bootable_button" "Toggle &Bootable" {toggle_bootable ""}

    set vcont2 [$hcont1 container "vcont1" "0 0" "vertical"]
    $vcont2 button "changetype_button" "Change Type" {change_type ""}
    $vcont2 button "togglesize_button" "Toggle Size Units" {toggle_size ""}
    $vcont2 button "help_button" "Help" {fdisk_help ""}

    set vcont3 [$hcont1 container "vcont2" "0 0" "vertical"]
    $vcont3 button "quit_button" "&Quit" {button_click_result QUIT}
    $vcont3 button "undo_button" "&Undo All Changes" {undo_all ""}
    $vcont3 button "write_button" "Write Changes" {write_changes ""}
    $vcont3 button "edit_button" "Edit Partitions" {edit_part_callback ""}
 
    update_slices

    $dialog exec

}

--aM3YZ0Iwxop3KEKx--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-libh" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011007162528.A28881>