Commit f7ec771f authored by Nalin x GNU's avatar Nalin x GNU

Configuration folder made hidden, path macros renamed

parent 00b21bf9
......@@ -132,7 +132,7 @@ class BasicTextView(text_view.TextView):
def open(self):
open_file = file_chooser.FileChooserDialog(_("Select the file to open"),
file_chooser.FileChooserDialog.OPEN,
macros.supported_text_formats,macros.home_dir)
macros.supported_text_formats,macros.user_home_path)
response = open_file.run()
if response == file_chooser.FileChooserDialog.ACCEPT:
to_open = read_text_from_file(open_file.get_filename())
......@@ -223,7 +223,7 @@ class BasicTextView(text_view.TextView):
def export_text_cleaner_list(self,*data):
open_file = file_chooser.FileChooserDialog(_("Filename please"),
file_chooser.FileChooserDialog.SAVE,
macros.supported_text_formats,macros.home_dir)
macros.supported_text_formats,macros.user_home_path)
open_file.set_current_name(".txt")
response = open_file.run()
if response == file_chooser.FileChooserDialog.ACCEPT:
......@@ -233,11 +233,11 @@ class BasicTextView(text_view.TextView):
def import_text_cleaner_list(self,*data):
open_file = file_chooser.FileChooserDialog(_("Select the file to import"),
file_chooser.FileChooserDialog.OPEN,
"*",macros.home_dir)
"*",macros.user_home_path)
response = open_file.run()
if response == file_chooser.FileChooserDialog.ACCEPT:
self.set_text_cleaner_list_from_file(open_file.get_filename())
self.save_text_cleaner_list_to_file(macros.local_text_cleaner_list_file);
self.save_text_cleaner_list_to_file(macros.local_text_cleaner_list_file_path);
open_file.destroy()
def open_text_cleaner(self,*data):
......@@ -259,14 +259,14 @@ class BasicTextView(text_view.TextView):
if (response == dialog.Dialog.BUTTON_ID_1):
treeview.append((entry_match.get_text(),entry_replace.get_text()))
self.text_cleaner_list = treeview.get_list()
self.save_text_cleaner_list_to_file(macros.local_text_cleaner_list_file);
self.save_text_cleaner_list_to_file(macros.local_text_cleaner_list_file_path);
dlg.destroy()
def remove_clicked(*data):
index = treeview.get_selected_row_index()
treeview.remove(index)
self.text_cleaner_list = treeview.get_list()
self.save_text_cleaner_list_to_file(macros.local_text_cleaner_list_file);
self.save_text_cleaner_list_to_file(macros.local_text_cleaner_list_file_path);
def export_list(*data):
self.export_text_cleaner_list()
......@@ -274,21 +274,21 @@ class BasicTextView(text_view.TextView):
def import_list(*data):
self.import_text_cleaner_list()
treeview.set_list(self.text_cleaner_list)
self.save_text_cleaner_list_to_file(macros.local_text_cleaner_list_file);
self.save_text_cleaner_list_to_file(macros.local_text_cleaner_list_file_path);
def restore(*data):
self.set_text_cleaner_list_from_file(macros.default_text_cleaner_list_file)
self.set_text_cleaner_list_from_file(macros.default_text_cleaner_list_file_path)
treeview.set_list(self.text_cleaner_list)
self.save_text_cleaner_list_to_file(macros.local_text_cleaner_list_file);
self.save_text_cleaner_list_to_file(macros.local_text_cleaner_list_file_path);
def clear(*data):
self.text_cleaner_list = []
treeview.set_list(self.text_cleaner_list)
self.save_text_cleaner_list_to_file(macros.local_text_cleaner_list_file);
self.save_text_cleaner_list_to_file(macros.local_text_cleaner_list_file_path);
def list_updated(*data):
self.text_cleaner_list = treeview.get_list()
self.save_text_cleaner_list_to_file(macros.local_text_cleaner_list_file);
self.save_text_cleaner_list_to_file(macros.local_text_cleaner_list_file_path);
def close(*data):
window_text_cleaner.close()
......@@ -483,7 +483,7 @@ class BasicTextView(text_view.TextView):
def import_bookmarks_from_file(self,*data):
open_file = file_chooser.FileChooserDialog(_("Select the bookmark file to import"),
file_chooser.FileChooserDialog.OPEN,
macros.supported_text_formats,macros.home_dir)
macros.supported_text_formats,macros.user_home_path)
response = open_file.run()
if response == file_chooser.FileChooserDialog.ACCEPT:
with open(open_file.get_filename()) as file:
......@@ -807,7 +807,7 @@ class BasicTextView(text_view.TextView):
split = spinbutton_split.get_value()
voice = combobox.get_active_text()
output_format = combobox_format.get_active()
save_file = file_chooser.FileChooserDialog(_("Save"),file_chooser.FileChooserDialog.SAVE,["wav","mp3"],macros.home_dir)
save_file = file_chooser.FileChooserDialog(_("Save"),file_chooser.FileChooserDialog.SAVE,["wav","mp3"],macros.user_home_path)
response = save_file.run()
if response == file_chooser.FileChooserDialog.ACCEPT:
converter = text_to_audio_converter(text,volume,voice,split,pitch,speed)
......@@ -836,7 +836,7 @@ class BasicTextView(text_view.TextView):
def print_to_pdf(self,*data):
save_file = file_chooser.FileChooserDialog(_("Enter the file name"),
file_chooser.FileChooserDialog.SAVE,macros.supported_pdf_formats,macros.home_dir)
file_chooser.FileChooserDialog.SAVE,macros.supported_pdf_formats,macros.user_home_path)
response = save_file.run()
if response == file_chooser.FileChooserDialog.ACCEPT:
if (self.has_selection()):
......
......@@ -23,19 +23,21 @@ import itertools
def get_list_of_mixed_case_combinations(list_items):
return list(itertools.chain.from_iterable([[''.join(a) for a in itertools.product(*zip(s.upper(), s.lower()))] for s in list_items]))
home_dir = os.environ['HOME']
user_home_path = os.environ['HOME']
config_dir = user_home_path+"/.lios"
tmp_dir = "/tmp/Lios/"
bookmarks_dir = home_dir+"/lios/bookmarks/"
bookmarks_dir = config_dir+"/bookmarks/"
local_text_cleaner_list_file = home_dir+"/lios/text_cleaner_list.text"
local_text_cleaner_list_file_path = config_dir+"/text_cleaner_list.text"
default_text_cleaner_list_file = "/usr/share/lios/text_cleaner_list.text"
default_text_cleaner_list_file_path = "/usr/share/lios/text_cleaner_list.text"
preferences_file_path = home_dir+"/lios/lios_preferences"
preferences_file_path = config_dir+"/preferences.cfg"
recent_file_path = home_dir+"/lios/lios_recent"
recent_file_path = config_dir+"/recent.text"
supported_image_formats = get_list_of_mixed_case_combinations(["png","pnm","jpg","jpeg","tif","tiff","bmp","pbm","ppm"])
......@@ -51,7 +53,7 @@ icon_dir = "/usr/share/lios/icons/"
readme_file = "/usr/share/lios/readme.text"
default_text_cleaner_list_file = "/usr/share/lios/text_cleaner_list.text"
default_text_cleaner_list_file_path = "/usr/share/lios/text_cleaner_list.text"
app_name = "Linux-intelligent-ocr-solution"
......
......@@ -58,7 +58,7 @@ class linux_intelligent_ocr_solution():
pass
try:
os.mkdir(macros.home_dir+"/lios")
os.mkdir(macros.config_dir)
except:
pass
......@@ -161,9 +161,9 @@ class linux_intelligent_ocr_solution():
box_editor.add(scroll_box_editor)
#Load TextCleaner List
if(not self.textview.set_text_cleaner_list_from_file(macros.local_text_cleaner_list_file)):
self.textview.set_text_cleaner_list_from_file(macros.default_text_cleaner_list_file)
self.textview.save_text_cleaner_list_to_file(macros.local_text_cleaner_list_file)
if(not self.textview.set_text_cleaner_list_from_file(macros.local_text_cleaner_list_file_path)):
self.textview.set_text_cleaner_list_from_file(macros.default_text_cleaner_list_file_path)
self.textview.save_text_cleaner_list_to_file(macros.local_text_cleaner_list_file_path)
......@@ -1257,7 +1257,7 @@ class linux_intelligent_ocr_solution():
elif (len(item_list) == 1):
dlg = FileChooserDialog(_("Filename please"),
FileChooserDialog.SAVE,macros.supported_image_formats,
macros.home_dir);
macros.user_home_path);
response = dlg.run()
if response == FileChooserDialog.ACCEPT:
shutil.copy(item_list[0],dlg.get_filename())
......@@ -1265,7 +1265,7 @@ class linux_intelligent_ocr_solution():
else:
dlg = FileChooserDialog(_("Select Folder to save images"),
FileChooserDialog.OPEN_FOLDER,macros.supported_image_formats,
macros.home_dir);
macros.user_home_path);
response = dlg.run()
if response == FileChooserDialog.ACCEPT:
directory = dlg.get_current_folder()
......@@ -1280,7 +1280,7 @@ class linux_intelligent_ocr_solution():
def save_selected_images_as_pdf(self,widget):
dlg = FileChooserDialog(_("Give pdf filename(with extention) to save images"),
FileChooserDialog.SAVE,macros.supported_pdf_formats,macros.home_dir)
FileChooserDialog.SAVE,macros.supported_pdf_formats,macros.user_home_path)
response = dlg.run()
if response == FileChooserDialog.ACCEPT:
file_name = dlg.get_filename()
......@@ -1386,7 +1386,7 @@ pacman -S aspell-fr"""))
def save_preferences(self,*data):
save_preferences_dlg = FileChooserDialog(_("Save preferences as "),
FileChooserDialog.SAVE,["cfg"],macros.home_dir)
FileChooserDialog.SAVE,["cfg"],macros.user_home_path)
response = save_preferences_dlg.run()
if response == FileChooserDialog.ACCEPT:
self.preferences.save_to_file(save_preferences_dlg.get_filename()+".cfg")
......@@ -1397,7 +1397,7 @@ pacman -S aspell-fr"""))
def load_preferences(self,*data):
load_preferences_dlg = FileChooserDialog(_("Select the image"),
FileChooserDialog.OPEN,["cfg"],macros.home_dir)
FileChooserDialog.OPEN,["cfg"],macros.user_home_path)
response = load_preferences_dlg.run()
if response == FileChooserDialog.ACCEPT:
self.preferences.set_from_file(load_preferences_dlg.get_filename())
......@@ -1430,8 +1430,8 @@ pacman -S aspell-fr"""))
file_chooser_open_files = FileChooserDialog(_("Select files to open"),
FileChooserDialog.OPEN,macros.supported_image_formats+
macros.supported_text_formats+macros.supported_pdf_formats,
macros.home_dir)
file_chooser_open_files.set_current_folder(macros.home_dir)
macros.user_home_path)
file_chooser_open_files.set_current_folder(macros.user_home_path)
file_chooser_open_files.set_select_multiple(True)
response = file_chooser_open_files.run()
if response == FileChooserDialog.ACCEPT:
......
......@@ -205,7 +205,7 @@ Please make sure following exicutables are installed
#Dictionary Editor
notebook_dicts = containers.NoteBook()
self.dictionary_objects = []
for item in DICT_LIST+[macros.home_dir+"/lios/user-words"]:
for item in DICT_LIST+[macros.user_home_path+"/lios/user-words"]:
dict_object = Dictionary(item)
notebook_dicts.add_page(item.split("/")[-1],dict_object)
self.dictionary_objects.append(dict_object)
......@@ -386,8 +386,8 @@ Please make sure following exicutables are installed
def button_ambiguous_import_clicked(self,*data):
file_chooser_open_files = FileChooserDialog(_("Select files to import"),
FileChooserDialog.OPEN,"*",
macros.home_dir)
file_chooser_open_files.set_current_folder(macros.home_dir)
macros.user_home_path)
file_chooser_open_files.set_current_folder(macros.user_home_path)
response = file_chooser_open_files.run()
if response == FileChooserDialog.ACCEPT:
filename = file_chooser_open_files.get_filename()
......@@ -441,7 +441,7 @@ Please make sure following exicutables are installed
def button_select_input_text_clicked(*data):
file_chooser = FileChooserDialog(_("Select input file"),
FileChooserDialog.OPEN,macros.supported_text_formats,macros.home_dir)
FileChooserDialog.OPEN,macros.supported_text_formats,macros.user_home_path)
response = file_chooser.run()
if response == FileChooserDialog.ACCEPT:
input_file = file_chooser.get_filename()
......@@ -601,7 +601,7 @@ Please make sure following exicutables are installed
save_file = file_chooser.FileChooserDialog(_("Save filename"),file_chooser.FileChooserDialog.SAVE,["traineddata"]);
save_file.set_do_overwrite_confirmation(True);
save_file.set_current_name(self.language+".traineddata")
save_file.set_current_folder(macros.home_dir)
save_file.set_current_folder(macros.user_home_path)
response = save_file.run()
if response == file_chooser.FileChooserDialog.ACCEPT:
command = "cp {0}/{1}.traineddata {2}".format(self.tessdata_dir,self.language, save_file.get_filename())
......@@ -660,8 +660,8 @@ Please make sure following exicutables are installed
f.close()
# Create user dictionary if not exist
if not os.path.isfile(macros.home_dir+"/lios/user-words.txt"):
f = open(macros.home_dir+"/lios/user-words.txt","w")
if not os.path.isfile(macros.user_home_path+"/lios/user-words.txt"):
f = open(macros.user_home_path+"/lios/user-words.txt","w")
f.close()
# Loading each dictionarys
......@@ -679,8 +679,8 @@ Please make sure following exicutables are installed
def button_add_image_box_pair_clicked(self,*data):
file_chooser = FileChooserDialog(_("Select images to import"),
FileChooserDialog.OPEN,["tif"],
macros.home_dir)
file_chooser.set_current_folder(macros.home_dir)
macros.user_home_path)
file_chooser.set_current_folder(macros.user_home_path)
file_chooser.set_select_multiple(True)
response = file_chooser.run()
if response == FileChooserDialog.ACCEPT:
......@@ -1081,7 +1081,7 @@ class BoxEditor(containers.Box):
def load_boxes_dialog(self,*data):
open_file = file_chooser.FileChooserDialog(_("Select the file to open"),
file_chooser.FileChooserDialog.OPEN,
"*",macros.home_dir)
"*",macros.user_home_path)
response = open_file.run()
if response == file_chooser.FileChooserDialog.ACCEPT:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment