From 4cd5654252f2c4aaab5b5e58c40797516ef9bfde Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 10 Sep 2015 08:55:29 +0200 Subject: [PATCH] Filenames without language support are now gray in the directory window. --- src/directories.cc | 22 +++++++++++++++++++++- src/directories.h | 3 +++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/directories.cc b/src/directories.cc index 52a31c7..5a761a4 100644 --- a/src/directories.cc +++ b/src/directories.cc @@ -29,6 +29,9 @@ Directories::Directories() : stop_update_thread(false) { tree_store = Gtk::TreeStore::create(column_record); tree_view.set_model(tree_store); tree_view.append_column("", column_record.name); + auto renderer=dynamic_cast(tree_view.get_column(0)->get_first_cell()); + tree_view.get_column(0)->add_attribute(renderer->property_foreground_rgba(), column_record.color); + tree_store->set_sort_column(column_record.id, Gtk::SortType::SORT_ASCENDING); tree_view.set_enable_search(true); //TODO: why does this not work in OS X? tree_view.set_search_column(column_record.name); @@ -67,6 +70,9 @@ Directories::Directories() : stop_update_thread(false) { } auto child=tree_store->append(iter->children()); child->set_value(column_record.name, std::string("(empty)")); + Gdk::RGBA rgba; + rgba.set_rgba(0.5, 0.5, 0.5); + child->set_value(column_record.color, rgba); } }); @@ -243,9 +249,20 @@ void Directories::add_path(const boost::filesystem::path& dir_path, const Gtk::T child->set_value(column_record.id, "a"+filename); auto grandchild=tree_store->append(child->children()); grandchild->set_value(column_record.name, std::string("(empty)")); + Gdk::RGBA rgba; + rgba.set_rgba(0.5, 0.5, 0.5); + grandchild->set_value(column_record.color, rgba); } - else + else { child->set_value(column_record.id, "b"+filename); + + auto language=Source::guess_language(it->path().filename()); + if(!language) { + Gdk::RGBA rgba; + rgba.set_rgba(0.5, 0.5, 0.5); + child->set_value(column_record.color, rgba); + } + } } } } @@ -261,5 +278,8 @@ void Directories::add_path(const boost::filesystem::path& dir_path, const Gtk::T if(!*children) { auto child=tree_store->append(*children); child->set_value(column_record.name, std::string("(empty)")); + Gdk::RGBA rgba; + rgba.set_rgba(0.5, 0.5, 0.5); + child->set_value(column_record.color, rgba); } } diff --git a/src/directories.h b/src/directories.h index c34e319..74878a7 100644 --- a/src/directories.h +++ b/src/directories.h @@ -24,10 +24,12 @@ public: add(id); add(name); add(path); + add(color); } Gtk::TreeModelColumn id; Gtk::TreeModelColumn name; Gtk::TreeModelColumn path; + Gtk::TreeModelColumn color; }; Directories(); @@ -46,6 +48,7 @@ private: Gtk::TreeView tree_view; Glib::RefPtr tree_store; ColumnRecord column_record; + std::unordered_map > last_write_times; std::mutex update_mutex; std::thread update_thread;