Commit ffe2c35d authored by Avi Wadhwa's avatar Avi Wadhwa
Browse files

use Gio instead of Python OS to find mimetype, add more comments, relabel categories

parent 60d252a8
No preview for this file type
# ninja log v5
1 14 1549384279 src/organizer.gresource 78c4809cb7171ed0
0 410 1549384279 data/avi.wad.Organizer.desktop a2a1ec259a33d056
1 412 1549384279 data/avi.wad.Organizer.appdata.xml ffc6c7d4f5f0d94e
0 865 0 meson-install 9bd7faa9472bf40f
0 1054 0 meson-install 9bd7faa9472bf40f
0 854 0 meson-install 9bd7faa9472bf40f
0 25 1549385485 src/organizer.gresource 78c4809cb7171ed0
0 1308 0 meson-install 9bd7faa9472bf40f
0 15 1549385498 src/organizer.gresource 78c4809cb7171ed0
0 913 0 meson-install 9bd7faa9472bf40f
0 15 1549385533 src/organizer.gresource 78c4809cb7171ed0
0 923 0 meson-install 9bd7faa9472bf40f
0 15 1549385619 src/organizer.gresource 78c4809cb7171ed0
0 942 0 meson-install 9bd7faa9472bf40f
1 17 1549385889 src/organizer.gresource 78c4809cb7171ed0
0 863 0 meson-install 9bd7faa9472bf40f
0 899 0 meson-install 9bd7faa9472bf40f
0 866 0 meson-install 9bd7faa9472bf40f
0 847 0 meson-install 9bd7faa9472bf40f
0 929 0 meson-install 9bd7faa9472bf40f
1 867 0 meson-install 9bd7faa9472bf40f
0 868 0 meson-install 9bd7faa9472bf40f
0 896 0 meson-install 9bd7faa9472bf40f
0 840 0 meson-install 9bd7faa9472bf40f
0 824 0 meson-install 9bd7faa9472bf40f
0 860 0 meson-install 9bd7faa9472bf40f
0 868 0 meson-install 9bd7faa9472bf40f
0 870 0 meson-install 9bd7faa9472bf40f
1 895 0 meson-install 9bd7faa9472bf40f
0 870 0 meson-install 9bd7faa9472bf40f
0 880 0 meson-install 9bd7faa9472bf40f
0 890 0 meson-install 9bd7faa9472bf40f
0 842 0 meson-install 9bd7faa9472bf40f
0 964 0 meson-install 9bd7faa9472bf40f
0 894 0 meson-install 9bd7faa9472bf40f
0 876 0 meson-install 9bd7faa9472bf40f
0 902 0 meson-install 9bd7faa9472bf40f
0 1116 0 meson-install 9bd7faa9472bf40f
0 988 0 meson-install 9bd7faa9472bf40f
0 35 1549446199 src/organizer.gresource 78c4809cb7171ed0
0 410 1549384279 data/avi.wad.Organizer.desktop a2a1ec259a33d056
0 892 0 meson-install 9bd7faa9472bf40f
1 865 0 meson-install 9bd7faa9472bf40f
0 872 0 meson-install 9bd7faa9472bf40f
0 834 0 meson-install 9bd7faa9472bf40f
0 851 0 meson-install 9bd7faa9472bf40f
0 844 0 meson-install 9bd7faa9472bf40f
0 898 0 meson-install 9bd7faa9472bf40f
0 937 0 meson-install 9bd7faa9472bf40f
0 987 0 meson-install 9bd7faa9472bf40f
1 987 0 meson-install 9bd7faa9472bf40f
0 1172 0 meson-install 9bd7faa9472bf40f
0 921 0 meson-install 9bd7faa9472bf40f
0 982 0 meson-install 9bd7faa9472bf40f
1 968 0 meson-install 9bd7faa9472bf40f
0 1082 0 meson-install 9bd7faa9472bf40f
0 888 0 meson-install 9bd7faa9472bf40f
0 910 0 meson-install 9bd7faa9472bf40f
0 870 0 meson-install 9bd7faa9472bf40f
0 915 0 meson-install 9bd7faa9472bf40f
0 876 0 meson-install 9bd7faa9472bf40f
0 862 0 meson-install 9bd7faa9472bf40f
0 922 0 meson-install 9bd7faa9472bf40f
0 962 0 meson-install 9bd7faa9472bf40f
0 920 0 meson-install 9bd7faa9472bf40f
0 898 0 meson-install 9bd7faa9472bf40f
0 1788 0 meson-install 9bd7faa9472bf40f
0 996 0 meson-install 9bd7faa9472bf40f
0 972 0 meson-install 9bd7faa9472bf40f
0 835 0 meson-install 9bd7faa9472bf40f
0 886 0 meson-install 9bd7faa9472bf40f
0 876 0 meson-install 9bd7faa9472bf40f
0 964 0 meson-install 9bd7faa9472bf40f
0 940 0 meson-install 9bd7faa9472bf40f
0 910 0 meson-install 9bd7faa9472bf40f
0 960 0 meson-install 9bd7faa9472bf40f
0 17 1549446386 src/organizer.gresource 78c4809cb7171ed0
0 843 0 meson-install 9bd7faa9472bf40f
0 856 0 meson-install 9bd7faa9472bf40f
0 875 0 meson-install 9bd7faa9472bf40f
0 909 0 meson-install 9bd7faa9472bf40f
0 939 0 meson-install 9bd7faa9472bf40f
0 878 0 meson-install 9bd7faa9472bf40f
0 910 0 meson-install 9bd7faa9472bf40f
0 835 0 meson-install 9bd7faa9472bf40f
0 946 0 meson-install 9bd7faa9472bf40f
0 817 0 meson-install 9bd7faa9472bf40f
0 1192 0 meson-install 9bd7faa9472bf40f
0 830 0 meson-install 9bd7faa9472bf40f
0 872 0 meson-install 9bd7faa9472bf40f
1 812 0 meson-install 9bd7faa9472bf40f
0 925 0 meson-install 9bd7faa9472bf40f
0 899 0 meson-install 9bd7faa9472bf40f
0 1024 0 meson-install 9bd7faa9472bf40f
0 916 0 meson-install 9bd7faa9472bf40f
1 892 0 meson-install 9bd7faa9472bf40f
0 953 0 meson-install 9bd7faa9472bf40f
0 851 0 meson-install 9bd7faa9472bf40f
0 904 0 meson-install 9bd7faa9472bf40f
0 936 0 meson-install 9bd7faa9472bf40f
0 944 0 meson-install 9bd7faa9472bf40f
0 818 0 meson-install 9bd7faa9472bf40f
0 853 0 meson-install 9bd7faa9472bf40f
0 814 0 meson-install 9bd7faa9472bf40f
0 872 0 meson-install 9bd7faa9472bf40f
0 24 1549539685 src/organizer.gresource 78c4809cb7171ed0
0 942 0 meson-install 9bd7faa9472bf40f
0 895 0 meson-install 9bd7faa9472bf40f
0 891 0 meson-install 9bd7faa9472bf40f
0 919 0 meson-install 9bd7faa9472bf40f
0 884 0 meson-install 9bd7faa9472bf40f
0 1292 0 meson-install 9bd7faa9472bf40f
0 899 0 meson-install 9bd7faa9472bf40f
0 1324 0 meson-install 9bd7faa9472bf40f
0 933 0 meson-install 9bd7faa9472bf40f
0 1042 0 meson-install 9bd7faa9472bf40f
0 1372 0 meson-install 9bd7faa9472bf40f
0 112 1549604954 src/organizer.gresource 78c4809cb7171ed0
0 1559 0 meson-install 9bd7faa9472bf40f
0 856 0 meson-install 9bd7faa9472bf40f
0 901 0 meson-install 9bd7faa9472bf40f
0 954 0 meson-install 9bd7faa9472bf40f
0 853 0 meson-install 9bd7faa9472bf40f
0 829 0 meson-install 9bd7faa9472bf40f
0 900 0 meson-install 9bd7faa9472bf40f
0 867 0 meson-install 9bd7faa9472bf40f
0 843 0 meson-install 9bd7faa9472bf40f
......@@ -51,7 +51,6 @@
}
]
},
"python3-python-magic.json",
{
"name" : "organizer",
"buildsystem" : "meson",
......
{
"name": "python3-python-magic",
"buildsystem": "simple",
"build-commands": [
"pip3 install --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} python-magic"
],
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/84/30/80932401906eaf787f2e9bd86dc458f1d2e75b064b4c187341f29516945c/python-magic-0.4.15.tar.gz",
"sha256": "f3765c0f582d2dfc72c15f3b5a82aecfae9498bd29ca840d72f37d7bd38bfcd5"
}
]
}
\ No newline at end of file
......@@ -14,9 +14,8 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from gi.repository import Gtk, GLib, Handy
from gi.repository import Gtk, GLib, Handy, Gio
from .gi_composites import GtkTemplate
import magic
import sys
import os
import threading
......@@ -43,34 +42,59 @@ class OrganizerWindow(Gtk.ApplicationWindow):
stack_2 = GtkTemplate.Child()
go_back = GtkTemplate.Child()
start_screen = GtkTemplate.Child()
all_location_list = GtkTemplate.Child()
header_bar = GtkTemplate.Child()
sidebar = GtkTemplate.Child()
scrolled_start_screen = GtkTemplate.Child()
spinner = Gtk.Spinner()
application_list = GtkTemplate.Child()
audio_list = GtkTemplate.Child()
font_list = GtkTemplate.Child()
image_list = GtkTemplate.Child()
text_list = GtkTemplate.Child()
video_list = GtkTemplate.Child()
other_list = GtkTemplate.Child()
__gtype_name__ = 'OrganizerWindow'
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.init_template()
# test function for threading
# files function separated, for threading
def print_mimes(self, directory):
files = []
for entry in os.scandir(directory):
if entry.is_file() and entry.name.startswith('.') == False:
#TODO move files to different categories
files.append(entry)
# instantiate Gio directory
Gio_directory = Gio.File.new_for_path(directory).enumerate_children("*", Gio.FileQueryInfoFlags(1), None)
# loop through FileInfo objects
for entry in Gio_directory:
# print file name for debugging purposes
print(entry.get_name())
mimetype = entry.get_content_type()
first_mimetype = mimetype.split("/")[0]
name = entry.get_name()
# hide folders, hidden files and desktop files
if first_mimetype != "inode" and name.startswith('.') == False and name.endswith('.desktop') == False:
row = Gtk.Builder()
print(magic.from_file(entry.path, mime=True))
#print(str(entry.path)+" is "+str(mimetypes.guess_type(entry.name,strict=False)[0]))
# print mimetype for debugging purposes
print(mimetype)
# add GtkListBoxRow for each file in respective stack/category
row.add_objects_from_resource("/avi/wad/Organizer/row.ui", ("file_row", "filename_label"))
file_row = row.get_object("file_row")
filename_label = row.get_object("filename_label")
filename_label.set_text(entry.name)
GLib.idle_add(self.all_location_list.add, file_row)
print(len(files))
filename_label.set_text(entry.get_name())
#TODO if is application, use Nautilus table and Gnome archive to move to document/archive/other categories
try:
GLib.idle_add(eval("self."+first_mimetype+"_list").add, file_row)
except:
print(mimetype)
GLib.idle_add(self.other_list.add, file_row)
Gio_directory.close()
# Hide the spinner from start screen
GLib.idle_add(self.gtk_stack.set_visible_child, self.stack_2)
GLib.idle_add(self.spinner.destroy)
# Back Button
......@@ -78,15 +102,11 @@ class OrganizerWindow(Gtk.ApplicationWindow):
# if is folded (mobile mode) and leaflet model is 2nd (on content), then make child 1 (go to sidebar). otherwise actual back to startscreen
if self.stack_2.get_fold().value_name == "HDY_FOLD_FOLDED" and self.stack_2.get_visible_child().get_name() == "GtkStack":
# make the child 1
self.stack_2.set_visible_child(self.sidebar)
else:
#TODO map this to Alt+left keyboard shortcut
# hide the back button and go to start screen
#TODO if child visible is File Sorting, then go back to page, otherwise start screen
#self.spinner.destroy()
self.go_back.hide()
self.spinner.destroy()
self.header_bar.set_subtitle("")
self.gtk_stack.set_visible_child(self.scrolled_start_screen)
......@@ -109,19 +129,20 @@ class OrganizerWindow(Gtk.ApplicationWindow):
dialog.set_website('https://gitlab.gnome.org/aviwad/organizer')
dialog.run()
dialog.destroy()
def sidebar_clicked(self, widget, eventbutton):
self.stack_2.set_visible_child(widget.get_stack())
# When any location is clicked on homescreen
def row_activated(self, widget, row):
#TODO loop and delete all listboxrows
# loop and delete all previous file ListBoxRows
children = self.all_location_list.get_children()
children_length = len(children)
for entry in range (0, children_length):
self.all_location_list.remove(children[entry])
#children = self.all_location_list.get_children()
#children_length = len(children)
#for entry in range (0, children_length):
# self.all_location_list.remove(children[entry])
row_index = row.get_index()
......
This diff is collapsed.
This diff is collapsed.
Supports Markdown
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