Skip to content

Commit

Permalink
image: is_loading is only useful for booru images
Browse files Browse the repository at this point in the history
  • Loading branch information
ahodesuka committed Dec 3, 2017
1 parent 54993bc commit 159ed7b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/archive/image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Archive::Image::Image(const std::string &path, const Archive &archive)
m_ArchiveFilePath(path),
m_Archive(archive)
{
m_Loading = true;

}

std::string Archive::Image::get_filename() const
Expand Down Expand Up @@ -39,7 +39,6 @@ void Archive::Image::load_pixbuf()
std::lock_guard<std::mutex> lock(m_Mutex);
m_Pixbuf = p;
}
m_Loading = false;
m_SignalPixbufChanged();
}
}
Expand Down
11 changes: 5 additions & 6 deletions src/booru/image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ Image::Image(const std::string &path, const std::string &url,
if (!m_isWebM)
m_Curler.signal_write().connect(sigc::mem_fun(*this, &Image::on_write));

if (m_isWebM && !Glib::file_test(m_Path, Glib::FILE_TEST_EXISTS))
m_Loading = true;

m_Curler.set_referer(m_PostUrl);
m_Curler.signal_progress().connect(sigc::mem_fun(*this, &Image::on_progress));
m_Curler.signal_finished().connect(sigc::mem_fun(*this, &Image::on_finished));
Expand All @@ -41,6 +38,11 @@ Image::~Image()
cancel_download();
}

bool Image::is_loading() const
{
return (m_isWebM && !Glib::file_test(m_Path, Glib::FILE_TEST_EXISTS)) || m_Curler.is_active();
}

std::string Image::get_filename() const
{
return Glib::build_filename(m_Page.get_site()->get_name(), Glib::path_get_basename(m_Path));
Expand Down Expand Up @@ -156,7 +158,6 @@ bool Image::start_download()
if (!m_Curler.is_active())
{
m_Page.get_image_fetcher().add_handle(&m_Curler);
m_Loading = true;

if (!m_isWebM)
{
Expand Down Expand Up @@ -213,8 +214,6 @@ void Image::on_finished()
m_Loader.reset();
}

m_Loading = false;

m_SignalPixbufChanged();
m_DownloadCond.notify_one();
}
Expand Down
1 change: 1 addition & 0 deletions src/booru/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace AhoViewer
std::string get_url() const { return m_Url; }
std::string get_post_url() const { return m_PostUrl; }

virtual bool is_loading() const override;
virtual std::string get_filename() const override;
virtual const Glib::RefPtr<Gdk::Pixbuf>& get_thumbnail() override;

Expand Down
3 changes: 1 addition & 2 deletions src/image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ const Glib::RefPtr<Gdk::Pixbuf>& Image::get_missing_pixbuf()
}

Image::Image(const std::string &path)
: m_Loading(false),
m_isWebM(Image::is_webm(path)),
: m_isWebM(Image::is_webm(path)),
m_Path(path)
{

Expand Down
5 changes: 3 additions & 2 deletions src/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ namespace AhoViewer
static const Glib::RefPtr<Gdk::Pixbuf>& get_missing_pixbuf();

const std::string get_path() const { return m_Path; }
bool is_loading() const { return m_Loading; }
bool is_webm() const { return m_isWebM; }

// This is only used in Booru::Image
virtual bool is_loading() const { return false; }
virtual std::string get_filename() const;
virtual const Glib::RefPtr<Gdk::PixbufAnimation>& get_pixbuf();
virtual const Glib::RefPtr<Gdk::Pixbuf>& get_thumbnail();
Expand All @@ -46,7 +47,7 @@ namespace AhoViewer
Glib::RefPtr<Gdk::Pixbuf> create_pixbuf_at_size(const std::string &path,
const int w, const int h) const;

bool m_Loading, m_isWebM;
bool m_isWebM;
std::string m_Path, m_ThumbnailPath;

Glib::RefPtr<Gdk::Pixbuf> m_ThumbnailPixbuf;
Expand Down

0 comments on commit 159ed7b

Please sign in to comment.