[niepce/gtk4: 5/10] gtk4: fix the workspace treeview display
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce/gtk4: 5/10] gtk4: fix the workspace treeview display
- Date: Mon, 21 Mar 2022 05:01:23 +0000 (UTC)
commit 25d92ff7bb3299d4d817eb82dc2b3a512b105678
Author: Hubert Figuière <hub figuiere net>
Date: Sun Mar 20 16:12:16 2022 -0400
gtk4: fix the workspace treeview display
- Need to set render and attributes manually
src/niepce/ui/workspacecontroller.cpp | 19 +++++++++++--------
src/niepce/ui/workspacecontroller.hpp | 12 ++++++------
2 files changed, 17 insertions(+), 14 deletions(-)
---
diff --git a/src/niepce/ui/workspacecontroller.cpp b/src/niepce/ui/workspacecontroller.cpp
index 7e28c9e..0ad70ad 100644
--- a/src/niepce/ui/workspacecontroller.cpp
+++ b/src/niepce/ui/workspacecontroller.cpp
@@ -63,14 +63,12 @@ WorkspaceController::WorkspaceController(const Glib::RefPtr<Gio::SimpleActionGro
{ 0, nullptr }
};
- Glib::RefPtr< Gtk::IconTheme > icon_theme(Application::app()->getIconTheme());
int i = 0;
- while(icons[i].icon_name) {
+ while (icons[i].icon_name) {
try {
- m_icons[icons[i].icon_id] = icon_theme->lookup_icon(
- Glib::ustring(icons[i].icon_name), 16, 1);
+ m_icons[icons[i].icon_id] = Gio::Icon::create(icons[i].icon_name);
}
- catch(const Gtk::IconThemeError & e)
+ catch (const std::exception& e)
{
ERR_OUT("Exception %s.", e.what());
}
@@ -369,7 +367,7 @@ void WorkspaceController::add_folder_item(const eng::LibFolder* f)
Gtk::TreeModel::iterator
WorkspaceController::add_item(const Glib::RefPtr<Gtk::TreeStore> &treestore,
const Gtk::TreeNodeChildren & childrens,
- const Glib::RefPtr<Gdk::Paintable> & icon,
+ const Glib::RefPtr<Gio::Icon> & icon,
const Glib::ustring & label,
eng::library_id_t id, int type) const
{
@@ -410,9 +408,14 @@ Gtk::Widget * WorkspaceController::buildWidget()
Glib::ustring(_("Keywords")), 0,
KEYWORDS_ITEM);
m_librarytree.set_headers_visible(false);
- m_librarytree.append_column("", m_librarycolumns.m_icon);
+
+ auto renderer = Gtk::manage(new Gtk::CellRendererPixbuf());
+ auto col = Gtk::manage(new Gtk::TreeViewColumn("", *renderer));
+ m_librarytree.append_column(*col);
+ col->add_attribute(*renderer, "gicon", m_librarycolumns.m_icon);
+
int num = m_librarytree.append_column("", m_librarycolumns.m_label);
- Gtk::TreeViewColumn * col = m_librarytree.get_column(num - 1);
+ col = m_librarytree.get_column(num - 1);
col->set_expand(true);
num = m_librarytree.append_column("", m_librarycolumns.m_count);
col = m_librarytree.get_column(num - 1);
diff --git a/src/niepce/ui/workspacecontroller.hpp b/src/niepce/ui/workspacecontroller.hpp
index e6dc1eb..0b414f9 100644
--- a/src/niepce/ui/workspacecontroller.hpp
+++ b/src/niepce/ui/workspacecontroller.hpp
@@ -63,7 +63,7 @@ public:
add(m_count);
add(m_count_n);
}
- Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Paintable> > m_icon;
+ Gtk::TreeModelColumn<Glib::RefPtr<Gio::Icon>> m_icon;
Gtk::TreeModelColumn<eng::library_id_t> m_id;
Gtk::TreeModelColumn<Glib::ustring> m_label;
Gtk::TreeModelColumn<int> m_type;
@@ -116,10 +116,10 @@ private:
* @param id the item id (in the database)
* @paran type the type of node
*/
- Gtk::TreeModel::iterator add_item(const Glib::RefPtr<Gtk::TreeStore> & treestore,
- const Gtk::TreeNodeChildren & childrens,
- const Glib::RefPtr<Gdk::Paintable>& icon,
- const Glib::ustring & label,
+ Gtk::TreeModel::iterator add_item(const Glib::RefPtr<Gtk::TreeStore>& treestore,
+ const Gtk::TreeNodeChildren& childrens,
+ const Glib::RefPtr<Gio::Icon>& icon,
+ const Glib::ustring& label,
eng::library_id_t id, int type) const;
void expand_from_cfg(const char* key, const Gtk::TreeModel::iterator& treenode);
@@ -135,7 +135,7 @@ private:
Glib::RefPtr<Gio::SimpleActionGroup> m_action_group;
- std::array<Glib::RefPtr<Gdk::Paintable>, _ICON_SIZE> m_icons;
+ std::array<Glib::RefPtr<Gio::Icon>, _ICON_SIZE> m_icons;
WorkspaceTreeColumns m_librarycolumns;
Gtk::Box m_vbox;
Gtk::Label m_label;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]