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

organize multiple 'application' files to special categories

parent ffe2c35d
No preview for this file type
# ninja log v5
1 412 1549384279 data/avi.wad.Organizer.appdata.xml ffc6c7d4f5f0d94e
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 835 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 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
1 20 1549626074 src/organizer.gresource 78c4809cb7171ed0
0 469 1549626074 data/avi.wad.Organizer.desktop a2a1ec259a33d056
0 472 1549626075 data/avi.wad.Organizer.appdata.xml ffc6c7d4f5f0d94e
0 921 0 meson-install 9bd7faa9472bf40f
0 966 0 meson-install 9bd7faa9472bf40f
0 967 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
0 890 0 meson-install 9bd7faa9472bf40f
0 869 0 meson-install 9bd7faa9472bf40f
0 823 0 meson-install 9bd7faa9472bf40f
0 18 1549685105 src/organizer.gresource 78c4809cb7171ed0
0 873 0 meson-install 9bd7faa9472bf40f
0 847 0 meson-install 9bd7faa9472bf40f
0 817 0 meson-install 9bd7faa9472bf40f
0 18 1549685622 src/organizer.gresource 78c4809cb7171ed0
0 817 0 meson-install 9bd7faa9472bf40f
0 861 0 meson-install 9bd7faa9472bf40f
0 18 1549685924 src/organizer.gresource 78c4809cb7171ed0
0 866 0 meson-install 9bd7faa9472bf40f
1 865 0 meson-install 9bd7faa9472bf40f
0 17 1549686153 src/organizer.gresource 78c4809cb7171ed0
0 876 0 meson-install 9bd7faa9472bf40f
0 863 0 meson-install 9bd7faa9472bf40f
1 877 0 meson-install 9bd7faa9472bf40f
0 833 0 meson-install 9bd7faa9472bf40f
0 18 1549686849 src/organizer.gresource 78c4809cb7171ed0
0 917 0 meson-install 9bd7faa9472bf40f
0 15 1549686863 src/organizer.gresource 78c4809cb7171ed0
0 849 0 meson-install 9bd7faa9472bf40f
0 858 0 meson-install 9bd7faa9472bf40f
0 22 1549687481 src/organizer.gresource 78c4809cb7171ed0
0 971 0 meson-install 9bd7faa9472bf40f
0 1006 0 meson-install 9bd7faa9472bf40f
0 1012 0 meson-install 9bd7faa9472bf40f
......@@ -54,7 +54,7 @@ build src/organizer.gresource: CUSTOM_COMMAND_DEP ../src/organizer.gresource.xml
description = Generating$ organizer_gresource$ with$ a$ custom$ command.
build meson-organizer-pot: CUSTOM_COMMAND
COMMAND = /usr/bin/meson --internal commandrunner /home/aviwad/Projects/Organizer /home/aviwad/Projects/Organizer/_build po /usr/bin/meson /usr/bin/meson --internal gettext pot --pkgname=organizer --extra-args=--keyword=N_@@--flag=g_dngettext:2:pass-c-format@@--keyword=g_dcgettext:2@@--keyword=C_:1c,2@@--flag=N_:1:pass-c-format@@--flag=g_string_printf:2:c-format@@--keyword=_@@--flag=g_string_append_printf:2:c-format@@--flag=g_error_new:3:c-format@@--keyword=g_dngettext:2,3@@--flag=NC_:2:pass-c-format@@--keyword=NC_:1c,2@@--keyword=g_dpgettext2:2c,3@@--flag=g_set_error:4:c-format@@--flag=C_:2:pass-c-format@@--from-code=UTF-8@@--flag=g_strdup_printf:1:c-format@@--add-comments
COMMAND = /usr/bin/meson --internal commandrunner /home/aviwad/Projects/Organizer /home/aviwad/Projects/Organizer/_build po /usr/bin/meson /usr/bin/meson --internal gettext pot --pkgname=organizer --extra-args=--flag=g_string_printf:2:c-format@@--from-code=UTF-8@@--keyword=g_dpgettext2:2c,3@@--flag=g_dngettext:2:pass-c-format@@--flag=N_:1:pass-c-format@@--keyword=C_:1c,2@@--keyword=g_dcgettext:2@@--flag=g_error_new:3:c-format@@--add-comments@@--flag=g_set_error:4:c-format@@--flag=g_strdup_printf:1:c-format@@--keyword=N_@@--keyword=g_dngettext:2,3@@--flag=C_:2:pass-c-format@@--flag=NC_:2:pass-c-format@@--keyword=NC_:1c,2@@--keyword=_@@--flag=g_string_append_printf:2:c-format
description = Running$ external$ command$ organizer-pot.
pool = console
......@@ -68,7 +68,7 @@ build meson-organizer-gmo: CUSTOM_COMMAND
build organizer-gmo: phony meson-organizer-gmo
build meson-organizer-update-po: CUSTOM_COMMAND
COMMAND = /usr/bin/meson --internal commandrunner /home/aviwad/Projects/Organizer /home/aviwad/Projects/Organizer/_build po /usr/bin/meson /usr/bin/meson --internal gettext update_po --pkgname=organizer --extra-args=--keyword=N_@@--flag=g_dngettext:2:pass-c-format@@--keyword=g_dcgettext:2@@--keyword=C_:1c,2@@--flag=N_:1:pass-c-format@@--flag=g_string_printf:2:c-format@@--keyword=_@@--flag=g_string_append_printf:2:c-format@@--flag=g_error_new:3:c-format@@--keyword=g_dngettext:2,3@@--flag=NC_:2:pass-c-format@@--keyword=NC_:1c,2@@--keyword=g_dpgettext2:2c,3@@--flag=g_set_error:4:c-format@@--flag=C_:2:pass-c-format@@--from-code=UTF-8@@--flag=g_strdup_printf:1:c-format@@--add-comments
COMMAND = /usr/bin/meson --internal commandrunner /home/aviwad/Projects/Organizer /home/aviwad/Projects/Organizer/_build po /usr/bin/meson /usr/bin/meson --internal gettext update_po --pkgname=organizer --extra-args=--flag=g_string_printf:2:c-format@@--from-code=UTF-8@@--keyword=g_dpgettext2:2c,3@@--flag=g_dngettext:2:pass-c-format@@--flag=N_:1:pass-c-format@@--keyword=C_:1c,2@@--keyword=g_dcgettext:2@@--flag=g_error_new:3:c-format@@--add-comments@@--flag=g_set_error:4:c-format@@--flag=g_strdup_printf:1:c-format@@--keyword=N_@@--keyword=g_dngettext:2,3@@--flag=C_:2:pass-c-format@@--flag=NC_:2:pass-c-format@@--keyword=NC_:1c,2@@--keyword=_@@--flag=g_string_append_printf:2:c-format
description = Running$ external$ command$ organizer-update-po.
pool = console
......
Build started at 2019-02-05T22:00:13.890846
Build started at 2019-02-08T17:11:07.480018
Main binary: /usr/bin/python3.7
Python system: Linux
The Meson build system
......
......@@ -21,6 +21,112 @@ import os
import threading
import time
# dict mapping the special categories for "application" mimetype files
# inspired by Nautilus, Gnome Autoar, and Calibre's tables
# https://gitlab.gnome.org/GNOME/nautilus/blob/master/src/nautilus-mime-actions.c#L91
# https://github.com/GNOME/gnome-autoar/blob/master/gnome-autoar/autoar-mime-types.c
# https://github.com/kovidgoyal/calibre/blob/master/resources/calibre-mimetypes.xml
application = { # DOCUMENTS
"rtf": "text",
"msword": "text",
"vnd.sun.xml.writer": "text",
"vnd.sun.xml.writer.global": "text",
"vnd.sun.xml.writer.template": "text",
"vnd.oasis.opendocument.text": "text",
"vnd.oasis.opendocument.text-template": "text",
"x-abiword": "text",
"x-applix-word": "text",
"x-mswrite": "text",
"docbook+xml": "text",
"x-kword": "text",
"x-kword-crypt": "text",
"x-lyx": "text",
"vnd.openxmlformats-officedocument.wordprocessingml.document": "text",
"pdf": "text",
"postscript": "text",
"x-dvi": "text",
# ARCHIVES
"x-7z-compressed": "archives",
"x-7z-compressed-tar": "archives",
"x-bzip": "archives",
"x-bzip-compressed-tar": "archives",
"x-compress": "archives",
"x-compressed-tar": "archives",
"x-cpio": "archives",
"x-gzip": "archives",
"x-lha": "archives",
"x-lzip": "archives",
"x-lzip-compressed-tar": "archives",
"x-lzma": "archives",
"x-lzma-compressed-tar": "archives",
"x-tar": "archives",
"x-tarz": "archives",
"x-xar": "archives",
"x-xz": "archives",
"x-xz-compressed-tar": "archives",
"zip": "archives",
"gzip": "archives",
"bzip2": "archives",
"vnd.rar": "archives",
# ILLUSTRATION
"illustrator": "illustration",
"vnd.corel-draw": "illustration",
"vnd.stardivision.draw": "illustration",
"vnd.oasis.opendocument.graphics": "illustration",
"x-dia-diagram": "illustration",
"x-karbon": "illustration",
"x-killustrator": "illustration",
"x-kivio": "illustration",
"x-kontour": "illustration",
"x-wpg": "illustration",
# MUSIC
"ogg" : "audio",
# IMAGES
"vnd.oasis.opendocument.image": "image",
"x-krita": "image",
# PRESENTATIONS
"vnd.ms-powerpoint": "presentations",
"vnd.sun.xml.impress": "presentations",
"vnd.oasis.opendocument.presentation": "presentations",
"x-magicpoint": "presentations",
"x-kpresenter": "presentations",
"vnd.openxmlformats-officedocument.presentationml.presentation": "presentations",
# SPREADSHEETS
"vnd.lotus-1-2-3": "spreadsheets",
"vnd.ms-excel": "spreadsheets",
"vnd.stardivision.calc": "spreadsheets",
"vnd.sun.xml.calc": "spreadsheets",
"vnd.oasis.opendocument.spreadsheet": "spreadsheets",
"x-applix-spreadsheet": "spreadsheets",
"x-gnumeric": "spreadsheets",
"x-kspread": "spreadsheets",
"x-kspread-crypt": "spreadsheets",
"x-quattropro": "spreadsheets",
"x-sc": "spreadsheets",
"x-siag": "spreadsheets",
"vnd.openxmlformats-officedocument.spreadsheetml.sheet": "spreadsheets",
# EBOOKS
"x-sony-bbeb": "ebooks",
"epub+zip": "ebooks",
"text/lrs": "ebooks",
"x-mobipocket-ebook": "ebooks",
"x-palm-database": "ebooks",
"x-topaz-ebook": "ebooks",
"x-kindle-application": "ebooks",
"x-mobipocket-subscription": "ebooks",
"x-mobipocket-ebook": "ebooks",
"x-mobipocket-subscription-magazine": "ebooks",
"x-mobi8-ebook": "ebooks"
#TODO add code category
}
# array mapping each xdg folder with the GtkList options 1-6
folders = [
GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP),
......@@ -52,13 +158,23 @@ class OrganizerWindow(Gtk.ApplicationWindow):
image_list = GtkTemplate.Child()
text_list = GtkTemplate.Child()
video_list = GtkTemplate.Child()
other_list = GtkTemplate.Child()
archives_list = GtkTemplate.Child()
illustrations_list = GtkTemplate.Child()
presentations_list = GtkTemplate.Child()
spreadsheets_list = GtkTemplate.Child()
ebooks_list = GtkTemplate.Child()
#TODO open popover with all ListBox's, see how Lollypop does it
#file_popover = Gtk.Builder().add_objects_from_resource("/avi/wad/Organizer/window.ui", "file_popover")
__gtype_name__ = 'OrganizerWindow'
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.init_template()
# testing 123
def activated (self, widget, row):
file_popover()
# files function separated, for threading
def print_mimes(self, directory):
......@@ -69,29 +185,31 @@ class OrganizerWindow(Gtk.ApplicationWindow):
# 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]
second_mimetype = mimetype.split("/")[1]
name = entry.get_name()
# hide folders, hidden files and desktop files
if first_mimetype != "inode" and name.startswith('.') == False and name.endswith('.desktop') == False:
if first_mimetype != "inode" and name.startswith('.') == False and name.endswith('.desktop') == False and name.endswith('~') == False:
row = Gtk.Builder()
# print mimetype for debugging purposes
print(mimetype)
# add GtkListBoxRow for each file in respective stack/category
#TODO get popover for GtkListBox to move files to different categories, etc
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.get_name())
#TODO if is application, use Nautilus table and Gnome archive to move to document/archive/other categories
try:
#TODO add to arrays and add that to list for sorting + future editing (moving)
if first_mimetype != "application":
GLib.idle_add(eval("self."+first_mimetype+"_list").add, file_row)
except:
print(mimetype)
GLib.idle_add(self.other_list.add, file_row)
else:
application_mimetype = application.get(second_mimetype)
if application_mimetype:
GLib.idle_add(eval("self."+application_mimetype+"_list").add, file_row)
else:
GLib.idle_add(eval("self."+first_mimetype+"_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)
......@@ -111,6 +229,7 @@ class OrganizerWindow(Gtk.ApplicationWindow):
self.gtk_stack.set_visible_child(self.scrolled_start_screen)
# About Menu
# TODO make about menu grey out the background app, see how Lollypop does it
def on_about_button_clicked(self, button):
dialog = Gtk.AboutDialog()
......@@ -174,7 +293,8 @@ class OrganizerWindow(Gtk.ApplicationWindow):
self.spinner.set_visible(True)
self.spinner.props.active = True
self.spinner.start()
#TODO make this work before the file intensive operation
# separate thread to not hang up the entire GUI, and to render the spinner at the same time
thread_testing = threading.Thread(target=self.print_mimes, args=(directory,))
thread_testing.start()
......@@ -183,5 +303,3 @@ class OrganizerWindow(Gtk.ApplicationWindow):
# Unhide the back button
self.go_back.show()
#self.print_mimes(directory)
#self.gtk_stack.set_visible_child(self.stack_2)
This diff is collapsed.
This diff is collapsed.
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