Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jabbalaci committed Jul 9, 2018
1 parent 9a70852 commit 8f2d9ab
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
9 changes: 9 additions & 0 deletions jive/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,21 @@ def has_something_to_commit(self):
return self.parent.imgList.has_something_to_commit()

def to_save(self):
"""
Number of images flagged to be saved.
"""
return self.parent.imgList.to_save()

def to_delete(self):
"""
Number of images flagged to be deleted.
"""
return self.parent.imgList.to_delete()

def to_wallpaper(self):
"""
Number of images flagged to be saved as wallpapers.
"""
return self.parent.imgList.to_wallpaper()

def _save_files(self, folder, lst, msg, method):
Expand Down
40 changes: 20 additions & 20 deletions jive/jive.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,17 @@ def has_something_to_commit(self):

return any([val1, val2, val3])

def mark_all_images_to_save(self):
for img in self._list_of_images:
img.to_save = True

def get_image_list(self):
"""
Return the path / URL of the images that are in the current list.
"""
result = [img.get_absolute_path_or_url() for img in self._list_of_images]
return result


######################
# #
Expand Down Expand Up @@ -1579,8 +1590,7 @@ def add_shortcuts(self):
self.shortcuts.register_window_shortcut(key, self.shortcutMarkAllToSave, self.mark_all_images_to_save)

def mark_all_images_to_save(self):
for img in self.imgList.get_list_of_images():
img.to_save = True
self.imgList.mark_all_images_to_save()
self.statusbar.flash_message(blue("all marked for save"))
self.redraw()

Expand Down Expand Up @@ -1718,6 +1728,9 @@ def important_files_and_folders(self):
def slideshow(self):
self.not_yet_implemented()

def not_yet_implemented(self):
self.statusbar.flash_message(red("not yet implemented"))

def reload_current_image(self):
if not self.imgList.get_curr_img():
self.statusbar.flash_message(red("no"))
Expand Down Expand Up @@ -1754,15 +1767,8 @@ def save_image(self):
else:
log.info(f"the file was NOT saved")

def get_image_list(self):
res = []
for img in self.imgList.get_list_of_images():
res.append(img.get_absolute_path_or_url())
#
return res

def export_image_list_to_clipboard(self):
lst = self.get_image_list()
lst = self.imgList.get_image_list()
if len(lst) == 0:
self.statusbar.flash_message(red("no"))
self.play_error_sound()
Expand All @@ -1774,7 +1780,7 @@ def export_image_list_to_clipboard(self):
self.statusbar.flash_message(blue("copied to clipboard"))

def save_image_list(self):
lst = self.get_image_list()
lst = self.imgList.get_image_list()
if len(lst) == 0:
self.statusbar.flash_message(red("no"))
self.play_error_sound()
Expand All @@ -1796,9 +1802,6 @@ def save_image_list(self):
log.info(f"image list was saved to {fname}")
self.statusbar.flash_message(blue("saved"))

def not_yet_implemented(self):
self.statusbar.flash_message(red("not yet implemented"))

def open_with_gimp(self):
if not self.imgList.get_curr_img():
self.statusbar.flash_message(red("no image"))
Expand Down Expand Up @@ -2193,20 +2196,17 @@ def closeEvent(self, event):
try:
# maybe it doesn't exist at all (the window was never opened), thus we'd refer to
# a non-existing attribute -> exception
if self.url_folding_window:
self.url_folding_window.close()
self.url_folding_window.close()
except:
pass
#
try:
if self.simple_scrape:
self.simple_scrape.close()
self.simple_scrape.close()
except:
pass
#
try:
if self.custom_url_list:
self.custom_url_list.close()
self.custom_url_list.close()
except:
pass
#
Expand Down

0 comments on commit 8f2d9ab

Please sign in to comment.