Skip to content

Commit

Permalink
booru/browser: Prevent tagentry from becoming invisible
Browse files Browse the repository at this point in the history
This is an ugly hack for a problem I don't wish to investigate any
further, but it gets the job done.
  • Loading branch information
ahodesuka committed Jan 14, 2019
1 parent d047146 commit 54e44d9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/booru/browser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Browser::Browser(BaseObjectType *cobj, const Glib::RefPtr<Gtk::Builder> &bldr)
: Gtk::VPaned(cobj),
m_MinWidth(0),
m_ClosePage(false),
m_IconDownloaded(false),
m_LastSavePath(Settings.get_string("LastSavePath"))
{
bldr->get_widget("Booru::Browser::Notebook", m_Notebook);
Expand All @@ -22,6 +23,7 @@ Browser::Browser(BaseObjectType *cobj, const Glib::RefPtr<Gtk::Builder> &bldr)
bldr->get_widget_derived("Booru::Browser::TagEntry", m_TagEntry);
bldr->get_widget_derived("Booru::Browser::TagView", m_TagView);
bldr->get_widget_derived("StatusBar", m_StatusBar);
bldr->get_widget("MainWindow::HPaned", m_HPaned);

m_TagEntry->signal_key_press_event().connect(
sigc::mem_fun(*this, &Browser::on_entry_key_press_event), false);
Expand Down Expand Up @@ -82,7 +84,20 @@ void Browser::update_combobox_model()
{
Gtk::TreeIter it = m_ComboModel->append();
sigc::connection c = site->signal_icon_downloaded().connect([ &, site, it ]
{ it->set_value(m_ComboColumns.icon, site->get_icon_pixbuf()); });
{
it->set_value(m_ComboColumns.icon, site->get_icon_pixbuf());
// XXX: This is a terrible hack to fix an issue where the tagentry
// gets wrapped and becomes invisible after a site icon is downloaded
// and set. Normally this issue goes away after restarting the
// program, but for someone who opens ahoviewer for the first time
// and has this problem occur is quite undesirable.
if (!m_IconDownloaded)
{
m_IconDownloaded = true;
m_MinWidth += 2;
m_HPaned->set_position(m_MinWidth);
}
});
m_SiteIconConns.push_back(std::move(c));

it->set_value(m_ComboColumns.icon, site->get_icon_pixbuf());
Expand Down
3 changes: 2 additions & 1 deletion src/booru/browser.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ namespace AhoViewer
{ return Settings.get_sites()[m_ComboBox->get_active_row_number()]; }

StatusBar *m_StatusBar;
Gtk::HPaned *m_HPaned;

Gtk::ToolButton *m_NewTabButton,
*m_SaveImagesButton;
Expand All @@ -92,7 +93,7 @@ namespace AhoViewer
TagView *m_TagView;

int m_MinWidth;
bool m_ClosePage;
bool m_ClosePage, m_IconDownloaded;
std::string m_LastSavePath;

Glib::RefPtr<Gtk::UIManager> m_UIManager;
Expand Down

0 comments on commit 54e44d9

Please sign in to comment.