summaryrefslogtreecommitdiff
path: root/lib/leftpanel/fsbrowser.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/leftpanel/fsbrowser.tcl')
-rw-r--r--[-rwxr-xr-x]lib/leftpanel/fsbrowser.tcl158
1 files changed, 89 insertions, 69 deletions
diff --git a/lib/leftpanel/fsbrowser.tcl b/lib/leftpanel/fsbrowser.tcl
index 0a28d82..631eb3e 100755..100644
--- a/lib/leftpanel/fsbrowser.tcl
+++ b/lib/leftpanel/fsbrowser.tcl
@@ -2,7 +2,7 @@
# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
############################################################################
-# Copyright (C) 2007-2009 by Martin Ošmera #
+# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 by Martin Ošmera #
# martin.osmera@gmail.com #
# #
# This program is free software; you can redistribute it and#or modify #
@@ -21,6 +21,11 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _FSBROWSER_TCL ] } {
+set _FSBROWSER_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements file system browser for the left panel
@@ -28,7 +33,7 @@
class FSBrowser {
- # Definition of popup menu for filesystem browser, part: configure
+ # Definition of popup menu for file system browser, part: configure
common FSMENU_CONFIGURE {
{cascade "Sorting" 0 "" .sorting false 1 {
{radiobutton "By Name" "" {::KIFSD::FSD::config(sorting)}
@@ -53,7 +58,7 @@ class FSBrowser {
{filelist_fsb_reload} "Show / Ignore files starting with dot"}
}
- # Definition of popup menu for filesystem browser, part: listbox
+ # Definition of popup menu for file system browser, part: listbox
common FSMENU_LISTBOX {
{command {Up} {} 0 "filelist_fsb_up" {up}
"Go to parent folder"}
@@ -65,7 +70,7 @@ class FSBrowser {
{command {Home} {} 0 "filelist_fsb_gohome" {gohome}
"Go to your home folder"}
{command {Reload} {} 1 "filelist_fsb_reload" {reload}
- "Reload filelist"}
+ "Reload file list"}
{separator}
{command {Rename} {} 0 "filelist_fsb_rename" {edit}
"Rename file"}
@@ -80,7 +85,7 @@ class FSBrowser {
"Show file properties"}
}
- # Definition of popup menu for filesystem browser, part: bookmarks
+ # Definition of popup menu for file system browser, part: bookmarks
common FSMENU_BOOKMARKS {
{command {Add bookmark} {} 0 "filelist_fsb_add_bookmark"
{bookmark_add} "Bookmark the current folder"}
@@ -90,29 +95,29 @@ class FSBrowser {
}
## PRIVATE
- private variable fs_browser_selected_item {} ;# Item selected by popup menu for filesystem browser
+ private variable fs_browser_selected_item {} ;# Item selected by popup menu for file system browser
private variable fs_browser_selection_in_P 0 ;# Procedure "filelist_fsb_select" in progress
- private variable fs_browser_listbox_top_frame ;# Top frame of filesystem browser
- private variable forward_history {} ;# List of forward history (filesystem browser)
- private variable back_history {} ;# List of backward history (filesystem browser)
- private variable fs_browser_current_dir ;# Current directory (filesystem browser)
- private variable fs_browser_conf_menu ;# ID of filesystem browser configuration menu
+ private variable fs_browser_listbox_top_frame ;# Top frame of file system browser
+ private variable forward_history {} ;# List of forward history (file system browser)
+ private variable back_history {} ;# List of backward history (file system browser)
+ private variable fs_browser_current_dir ;# Current directory (file system browser)
+ private variable fs_browser_conf_menu ;# ID of files ystem browser configuration menu
private variable fs_browser_dir_ok ;# Button: Confirm location
- private variable fs_browser_listbox_menu ;# ID of popup menu for filesystem browser
- private variable fs_browser_bm_menu ;# ID of bookmarks popup menu (filesystem browser)
- private variable fs_browser_toolbar ;# ID of filesystem browser toolbar
+ private variable fs_browser_listbox_menu ;# ID of popup menu for file system browser
+ private variable fs_browser_bm_menu ;# ID of bookmarks popup menu (file system browser)
+ private variable fs_browser_toolbar ;# ID of file system browser toolbar
private variable fs_browser_dir ;# ComboBox: Current directory
private variable fs_browser_listbox ;# ListBox: Files & Directories
- private variable fs_browser_listbox_v_scrollbar ;# Vertical scrollbar for filesystem browser
- private variable fs_browser_listbox_h_scrollbar ;# Horizontal scrollbar for filesystem browser
+ private variable fs_browser_listbox_v_scrollbar ;# Vertical scrollbar for file system browser
+ private variable fs_browser_listbox_h_scrollbar ;# Horizontal scrollbar for file system browser
private variable fs_browser_filter ;# ComboBox: Filter
private variable item_menu_invoked 0 ;# Bool: Item menu request
- # Current GLOB filter for filesystem browser
+ # Current GLOB filter for file system browser
private variable fs_browser_current_mask ${::CONFIG(FS_BROWSER_MASK)}
# Variables related to object initialization
private variable parent
- private variable gui_initialized 0
+ private variable fsb_gui_initialized 0
constructor {} {
# Configure local ttk styles
@@ -130,14 +135,14 @@ class FSBrowser {
# @return void
public method PrepareFSBrowser {_parent} {
set parent $_parent
- set gui_initialized 0
+ set fsb_gui_initialized 0
}
## Create GUI of tab "File system browser"
# @return void
public method CreateFSBrowserGUI {} {
- if {$gui_initialized} {return}
- set gui_initialized 1
+ if {$fsb_gui_initialized} {return}
+ set fsb_gui_initialized 1
set fs_browser_current_dir [$this cget -projectPath]
@@ -157,8 +162,8 @@ class FSBrowser {
{current "Current document folder" {next} {filelist_fsb_current_doc_folder}
"Go to directory containing the current document"}
{configure "Configure" {configure} {filelist_fsb_popup_config_menu}
- "Filesystem browser configuration menu"}
- }
+ "File system browser configuration menu"}
+ } [namespace current]
${fs_browser_toolbar}forward configure -state disabled
${fs_browser_toolbar}back configure -state disabled
@@ -240,7 +245,7 @@ class FSBrowser {
bind $fs_browser_filter <Return> [list $this filelist_fsb_filter_ok]
bind $fs_browser_filter <KP_Enter> [list $this filelist_fsb_filter_ok]
bind $fs_browser_filter <<ComboboxSelected>> [list $this filelist_fsb_filter_ok]
- DynamicHelp::add $fs_browser_filter -text [mc "Filter"]
+ DynamicHelp::add $fs_browser_filter -text [mc "Filter"]
setStatusTip -widget $fs_browser_filter \
-text [mc "File filter"]
set val [lsearch -exact -ascii {{*.asm} {*.inc} {*.c} {*.h} {*}} $fs_browser_current_mask]
@@ -250,7 +255,7 @@ class FSBrowser {
$fs_browser_filter current $val
pack $fs_browser_filter -fill x -expand 1 -side left
- # Pack componets of filesystem browser
+ # Pack componets of file system browser
pack $fs_browser_toolbar -anchor w
pack $fs_browser_dir_frame -fill x -pady 3
pack $fs_browser_listbox_frame -fill both -expand 1
@@ -262,12 +267,12 @@ class FSBrowser {
set fs_browser_bm_menu $parent.bm_menu
filelist_fsb_makePopupMenu
- # Initialize filesystem browser
+ # Initialize file system browser
filelist_fsb_change_dir $fs_browser_current_dir
filelist_fsb_refresh_bookmarks
}
- ## Popup bookmarks menu for filesystem browser
+ ## Popup bookmarks menu for file system browser
# @return void
public method filelist_fsb_popup_bm_menu {} {
set x [winfo rootx ${fs_browser_toolbar}bookmark]
@@ -277,7 +282,7 @@ class FSBrowser {
tk_popup $fs_browser_bm_menu $x $y
}
- ## Popup configuration menu for filesystem browser
+ ## Popup configuration menu for file system browser
# @return void
public method filelist_fsb_popup_config_menu {} {
set x [winfo rootx ${fs_browser_toolbar}configure]
@@ -287,7 +292,7 @@ class FSBrowser {
tk_popup $fs_browser_conf_menu $x $y
}
- ## Popup filesystem browser listbox menu
+ ## Popup file system browser listbox menu
# @parm Int x - Relative horizontal position of mouse pointer
# @parm Int y - Relative vertical position of mouse pointer
# @return void
@@ -306,7 +311,7 @@ class FSBrowser {
tk_popup $fs_browser_listbox_menu $x $y
}
- ## Popup filesystem browser listbox menu
+ ## Popup file system browser listbox menu
# @parm Int x - Relative horizontal position of mouse pointer
# @parm Int y - Relative vertical position of mouse pointer
# @parm String item - Selected item (file of directory)
@@ -325,11 +330,11 @@ class FSBrowser {
tk_popup $fs_browser_listbox_menu $x $y
}
- ## Change current directory in filesystem browser
+ ## Change current directory in file system browser
# @parm String dir - New directory location
# @return void
public method filelist_fsb_change_dir {dir} {
- if {!$gui_initialized} {CreateFSBrowserGUI}
+ if {!$fsb_gui_initialized} {CreateFSBrowserGUI}
if {$::MICROSOFT_WINDOWS} {
# Transform for instance "C:" to "C:/"
@@ -340,14 +345,16 @@ class FSBrowser {
# Check if the given directory is valid
if {![file exists $dir] || ![file isdirectory $dir]} {
- tk_messageBox -parent . \
+ tk_messageBox
+ -parent . \
-title [mc "Invalid directory"] \
- -type ok -icon warning \
+ -type ok \
+ -icon warning \
-message [mc "The specified directory does not exist:\n%s" $dir]
return
}
- # Normalize path and configure toolbar (history control)
+ # Normalize path and configure toolbar (history controll)
set dir [file normalize $dir]
if {$dir != $fs_browser_current_dir} {
lappend back_history $fs_browser_current_dir
@@ -399,7 +406,7 @@ class FSBrowser {
if {$dir == [file separator]} {
$fs_browser_listbox_menu entryconfigure [::mc "Up"] -state disabled
${fs_browser_toolbar}up configure -state disabled
- } {
+ } else {
$fs_browser_listbox_menu entryconfigure [::mc "Up"] -state normal
${fs_browser_toolbar}up configure -state normal
}
@@ -407,7 +414,7 @@ class FSBrowser {
# Fill directory location combobox
set values {}
set folder $dir
- while 1 {
+ while {1} {
lappend values $folder
if {$folder == [file separator]} {break}
if {$::MICROSOFT_WINDOWS} {
@@ -444,7 +451,7 @@ class FSBrowser {
-parent . \
-icon info \
-type ok \
- -title [mc "Unable to compile"] \
+ -title [mc "Unable to comply"] \
-message [mc "Unable to open source file while simulator is engaged."]
return
}
@@ -491,7 +498,7 @@ class FSBrowser {
}
# Open directory
- } {
+ } else {
filelist_fsb_change_dir \
[file join $fs_browser_current_dir [lindex $file 1]]
}
@@ -512,7 +519,7 @@ class FSBrowser {
# This method shoul be called after FSD close
# @return void
public method filelist_fsb_refresh_bookmarks {} {
- if {!$gui_initialized} {CreateFSBrowserGUI}
+ if {!$fsb_gui_initialized} {CreateFSBrowserGUI}
# Clear current bookmarks entries
if {[$fs_browser_bm_menu index end] > 2} {
@@ -555,15 +562,15 @@ class FSBrowser {
set fs_browser_current_dir $tmp
# File selected -> bookmark current directory
- } {
+ } else {
filelist_fsb_add_bookmark
}
}
- ## Reload filesystem browser contents
+ ## Reload file system browser contents
# @return void
public method filelist_fsb_reload {} {
- if {!$gui_initialized} {CreateFSBrowserGUI}
+ if {!$fsb_gui_initialized} {CreateFSBrowserGUI}
filelist_fsb_change_dir $fs_browser_current_dir
}
@@ -599,7 +606,7 @@ class FSBrowser {
if {![llength $back_history]} {
${fs_browser_toolbar}back configure -state disabled
$fs_browser_listbox_menu entryconfigure [::mc "Back"] -state disabled
- } {
+ } else {
${fs_browser_toolbar}back configure -state normal
$fs_browser_listbox_menu entryconfigure [::mc "Back"] -state normal
}
@@ -633,7 +640,7 @@ class FSBrowser {
if {![llength $forward_history]} {
${fs_browser_toolbar}forward configure -state disabled
$fs_browser_listbox_menu entryconfigure [::mc "Forward"] -state disabled
- } {
+ } else {
${fs_browser_toolbar}forward configure -state normal
$fs_browser_listbox_menu entryconfigure [::mc "Forward"] -state normal
}
@@ -648,7 +655,7 @@ class FSBrowser {
set file [$this editor_procedure {} getFileName {}]
if {[lindex $file 0] != {}} {
set dir [lindex $file 0]
- } {
+ } else {
set dir $projectPath
}
# Change current directory
@@ -697,7 +704,7 @@ class FSBrowser {
-message [mc "Do you really want to delete file:\n%s" $filename]]
==
{yes}
- } {
+ } then {
if {[catch {file delete -force -- [file join $fs_browser_current_dir $filename]}]} {
tk_messageBox \
-parent . \
@@ -714,7 +721,7 @@ class FSBrowser {
# @return void
public method filelist_fsb_new_folder {} {
# Create dialog window
- set dialog [toplevel .new_dir_dialog -class {New folder} -bg {#EEEEEE}]
+ set dialog [toplevel .new_dir_dialog -class {New folder} -bg ${::COMMON_BG_COLOR}]
# Create header
pack [label $dialog.header \
@@ -774,7 +781,7 @@ class FSBrowser {
# Local variables
set dialog .new_dir_dialog ;# ID of dialog window
set folder [$dialog.entry get] ;# Name of folder to create
- set error 0 ;# Bool: error occured
+ set error 0 ;# Bool: error occurred
# Check for folder name validity
if {$folder == {}} {
@@ -783,10 +790,13 @@ class FSBrowser {
# Create new folder
if {$error || [catch {file mkdir [file join $fs_browser_current_dir $folder]}]} {
- tk_messageBox -parent $dialog -icon warning -type ok \
+ tk_messageBox \
+ -parent $dialog \
+ -icon warning \
+ -type ok \
-title [mc "Unable to create folder"] \
-message [mc "Unable to create the specified folder"]
- } {
+ } else {
# Remove dialog and reload browser
grab release $dialog
destroy $dialog
@@ -809,7 +819,7 @@ class FSBrowser {
if {[lindex $name 0] == {}} {
set name [lindex $name 1]
set type [mc "Directory"]
- } {
+ } else {
set name [lindex $name 0]
set type [mc "File"]
}
@@ -842,8 +852,8 @@ class FSBrowser {
# Create dialog window componets
- set dialog [toplevel .properties_dialog -class {File properties} -bg {#EEEEEE}] ;# Toplevel window itself
- set nb [NoteBook $dialog.nb -bg {#EEEEEE}] ;# NoteBook
+ set dialog [toplevel .properties_dialog -class {File properties} -bg ${::COMMON_BG_COLOR}] ;# Toplevel window itself
+ set nb [ModernNoteBook $dialog.nb] ;# NoteBook
set bottom_frame [frame $dialog.bottom_frame] ;# Button frame
# Create tabs in NoteBook
@@ -953,7 +963,7 @@ class FSBrowser {
]
# Pack NoteBook and bottom frame
- pack $nb -fill both -expand 1 -padx 10 -pady 5
+ pack [$nb get_nb] -fill both -expand 1 -padx 10 -pady 5
pack $bottom_frame -anchor e -after $nb -padx 10 -pady 5
# Configure dialog window
@@ -987,7 +997,10 @@ class FSBrowser {
# Change permissions
if {[catch {file attributes $file -permissions "0[format {%o} $perm]"}]} {
set error 1
- tk_messageBox -type ok -icon warning -parent $dialog \
+ tk_messageBox \
+ -type ok \
+ -icon warning \
+ -parent $dialog \
-title [mc "Permission denied"] \
-message [mc "Unable to change permissions for file:\n%s" [file tail $file]]
}
@@ -1000,16 +1013,19 @@ class FSBrowser {
file rename -force -- \
$file [file join $dir \
${::KIFSD::FSD::item_properties(name)}]}]
- } {
+ } then {
set error 1
- tk_messageBox -type ok -icon warning -parent $dialog \
+ tk_messageBox \
+ -type ok \
+ -icon warning \
+ -parent $dialog \
-title [mc "Permission denied"] \
-message [mc "Unable to rename file:\n%s\n\t=>\n%s" [file tail $file] ${::KIFSD::FSD::item_properties(name)}]
}
filelist_fsb_reload
}
- # If no error occured, close dialog
+ # If no error occurred, close dialog
if {!$error} {
grab release $dialog
destroy $dialog
@@ -1048,7 +1064,7 @@ class FSBrowser {
# Fill directory location combobox
set folder $content
set values {}
- while 1 {
+ while {1} {
lappend values $folder
if {$folder == [file separator]} {break}
if {$::MICROSOFT_WINDOWS} {
@@ -1068,7 +1084,7 @@ class FSBrowser {
}
}
$fs_browser_dir configure -values $values
- } {
+ } else {
$fs_browser_dir_ok configure -state disabled
$fs_browser_dir configure -style FSBrowser_RedBg.TCombobox
}
@@ -1082,7 +1098,7 @@ class FSBrowser {
filelist_fsb_change_dir [$fs_browser_dir get]
}
- ## Verticaly scroll FileSystem browser ListBox
+ ## Verticaly scroll File System browser ListBox
# @parm Float frac0 - Fraction of top visible area
# @parm Float frac1 - Fraction of bottom visible area
# @return void
@@ -1095,7 +1111,7 @@ class FSBrowser {
}
# Otherwise -> create scrollbar
- } {
+ } else {
if {![winfo ismapped $fs_browser_listbox_v_scrollbar]} {
pack $fs_browser_listbox_v_scrollbar \
-after $fs_browser_listbox \
@@ -1106,7 +1122,7 @@ class FSBrowser {
}
}
- ## Horizontaly scroll FileSystem browser ListBox
+ ## Horizontaly scroll File System browser ListBox
# @parm Float frac0 - Fraction of top visible area
# @parm Float frac1 - Fraction of bottom visible area
# @return void
@@ -1119,7 +1135,7 @@ class FSBrowser {
}
# Otherwise -> create scrollbar
- } {
+ } else {
if {![winfo ismapped $fs_browser_listbox_h_scrollbar]} {
pack $fs_browser_listbox_h_scrollbar \
-after $fs_browser_listbox_top_frame \
@@ -1133,7 +1149,7 @@ class FSBrowser {
## Recreate popup menus
# @return void
public method filelist_fsb_makePopupMenu {} {
- if {!$gui_initialized} {return}
+ if {!$fsb_gui_initialized} {return}
if {[winfo exists $fs_browser_conf_menu]} {
destroy $fs_browser_conf_menu
}
@@ -1144,9 +1160,9 @@ class FSBrowser {
destroy $fs_browser_bm_menu
}
- menuFactory $FSMENU_CONFIGURE $fs_browser_conf_menu 0 "$this " 0 {}
- menuFactory $FSMENU_LISTBOX $fs_browser_listbox_menu 0 "$this " 0 {}
- menuFactory $FSMENU_BOOKMARKS $fs_browser_bm_menu 0 "$this " 0 {}
+ menuFactory $FSMENU_CONFIGURE $fs_browser_conf_menu 0 "$this " 0 {} [namespace current]
+ menuFactory $FSMENU_LISTBOX $fs_browser_listbox_menu 0 "$this " 0 {} [namespace current]
+ menuFactory $FSMENU_BOOKMARKS $fs_browser_bm_menu 0 "$this " 0 {} [namespace current]
if {![llength $back_history]} {
$fs_browser_listbox_menu entryconfigure [::mc "Back"] -state disabled
@@ -1162,3 +1178,7 @@ class FSBrowser {
return $fs_browser_current_mask
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard