added diff compare on duplicate found

This commit is contained in:
itdominator 2022-01-29 22:11:03 -06:00
parent b0991cb776
commit ecfb586f53
3 changed files with 142 additions and 10 deletions

View File

@ -4,7 +4,7 @@ import os
# Lib imports # Lib imports
import gi import gi
gi.require_version('Gtk', '3.0') gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GObject, Gio from gi.repository import Gtk, GObject, GLib, Gio
# Application imports # Application imports
@ -244,7 +244,7 @@ class WidgetFileActionMixin:
def move_files(self, files, target): def move_files(self, files, target):
self.handle_files(files, "move", target) self.handle_files(files, "move", target)
# NOTE: Gtk recommends using fail flow than pre check existence which is more # NOTE: Gtk recommends using fail flow than pre check which is more
# race condition proof. They're right; but, they can't even delete # race condition proof. They're right; but, they can't even delete
# directories properly. So... f**k them. I'll do it my way. # directories properly. So... f**k them. I'll do it my way.
def handle_files(self, paths, action, _target_path=None): def handle_files(self, paths, action, _target_path=None):
@ -273,8 +273,7 @@ class WidgetFileActionMixin:
if _file.query_exists(): if _file.query_exists():
if not overwrite_all and not rename_auto_all: if not overwrite_all and not rename_auto_all:
self.exists_file_label.set_label(_file.get_basename()) self.setup_exists_data(file, _file)
self.exists_file_field.set_text(_file.get_basename())
response = self.show_exists_page() response = self.show_exists_page()
if response == "overwrite_all": if response == "overwrite_all":
@ -344,6 +343,45 @@ class WidgetFileActionMixin:
self.exists_file_rename_bttn.set_sensitive(False) self.exists_file_rename_bttn.set_sensitive(False)
def setup_exists_data(self, from_file, to_file):
from_info = from_file.query_info("standard::*,time::modified", 0, cancellable=None)
to_info = to_file.query_info("standard::*,time::modified", 0, cancellable=None)
exists_file_diff_from = self.builder.get_object("exists_file_diff_from")
exists_file_diff_to = self.builder.get_object("exists_file_diff_to")
exists_file_from = self.builder.get_object("exists_file_from")
exists_file_to = self.builder.get_object("exists_file_to")
from_date = from_info.get_modification_date_time()
to_date = to_info.get_modification_date_time()
from_size = from_info.get_size()
to_size = to_info.get_size()
exists_file_from.set_label(from_file.get_parent().get_path())
exists_file_to.set_label(to_file.get_parent().get_path())
self.exists_file_label.set_label(to_file.get_basename())
self.exists_file_field.set_text(to_file.get_basename())
# Returns: -1, 0 or 1 if dt1 is less than, equal to or greater than dt2.
age = GLib.DateTime.compare(from_date, to_date)
age_text = "( same time )"
if age == -1:
age_text = "older"
if age == 1:
age_text = "newer"
size_text = "( same size )"
if from_size < to_size:
size_text = "smaller"
if from_size > to_size:
size_text = "larger"
from_label_text = f"{age_text} & {size_text}"
if age_text != "( same time )" or size_text != "( same size )":
from_label_text = f"{from_date.format('%F %R')} {self.sizeof_fmt(from_size)} ( {from_size} bytes ) ( {age_text} & {size_text} )"
to_label_text = f"{to_date.format('%F %R')} {self.sizeof_fmt(to_size)} ( {to_size} bytes )"
exists_file_diff_from.set_text(from_label_text)
exists_file_diff_to.set_text(to_label_text)
def rename_proc(self, gio_file): def rename_proc(self, gio_file):
full_path = gio_file.get_path() full_path = gio_file.get_path()

Binary file not shown.

View File

@ -903,6 +903,103 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="margin-top">15</property>
<property name="margin-bottom">10</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Moving From:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="exists_file_from">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="exists_file_diff_from">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-top">20</property>
<property name="margin-bottom">10</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Moving To:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="exists_file_to">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="exists_file_diff_to">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-top">20</property>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
@ -930,12 +1027,9 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">1</property> <property name="position">5</property>
</packing> </packing>
</child> </child>
<child>
<placeholder/>
</child>
<child> <child>
<object class="GtkEntry" id="exists_file_field"> <object class="GtkEntry" id="exists_file_field">
<property name="visible">True</property> <property name="visible">True</property>
@ -945,7 +1039,7 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">3</property> <property name="position">6</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -1008,7 +1102,7 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">4</property> <property name="position">7</property>
</packing> </packing>
</child> </child>
</object> </object>