Move favorited places to the top of the list
This commit is contained in:
parent
a592b2dfc3
commit
3e13e77b6f
@ -106,9 +106,32 @@ void PlacesBrowser::refreshPlacesList ()
|
|||||||
{
|
{
|
||||||
placesModel->clear ();
|
placesModel->clear ();
|
||||||
|
|
||||||
|
// append favorites
|
||||||
|
for (size_t i = 0; i < options.favoriteDirs.size(); i++) {
|
||||||
|
Glib::RefPtr<Gio::File> fav = Gio::File::create_for_path (options.favoriteDirs[i]);
|
||||||
|
|
||||||
|
if (fav && fav->query_exists()) {
|
||||||
|
try {
|
||||||
|
if (auto info = fav->query_info ()) {
|
||||||
|
Gtk::TreeModel::Row newrow = *(placesModel->append());
|
||||||
|
newrow[placesColumns.label] = info->get_display_name ();
|
||||||
|
newrow[placesColumns.icon] = info->get_icon ();
|
||||||
|
newrow[placesColumns.root] = fav->get_parse_name ();
|
||||||
|
newrow[placesColumns.type] = 5;
|
||||||
|
newrow[placesColumns.rowSeparator] = false;
|
||||||
|
}
|
||||||
|
} catch(Gio::Error&) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// append home directory
|
// append home directory
|
||||||
Glib::RefPtr<Gio::File> hfile = Gio::File::create_for_path (userHomeDir()); // Will send back "My documents" on Windows now, which has no restricted access
|
Glib::RefPtr<Gio::File> hfile = Gio::File::create_for_path (userHomeDir()); // Will send back "My documents" on Windows now, which has no restricted access
|
||||||
|
|
||||||
|
if (!placesModel->children().empty()) {
|
||||||
|
Gtk::TreeModel::Row newrow = *(placesModel->append());
|
||||||
|
newrow[placesColumns.rowSeparator] = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (hfile && hfile->query_exists()) {
|
if (hfile && hfile->query_exists()) {
|
||||||
try {
|
try {
|
||||||
if (auto info = hfile->query_info ()) {
|
if (auto info = hfile->query_info ()) {
|
||||||
@ -223,29 +246,6 @@ void PlacesBrowser::refreshPlacesList ()
|
|||||||
newrow[placesColumns.rowSeparator] = false;
|
newrow[placesColumns.rowSeparator] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// append favorites
|
|
||||||
if (!placesModel->children().empty()) {
|
|
||||||
Gtk::TreeModel::Row newrow = *(placesModel->append());
|
|
||||||
newrow[placesColumns.rowSeparator] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < options.favoriteDirs.size(); i++) {
|
|
||||||
Glib::RefPtr<Gio::File> fav = Gio::File::create_for_path (options.favoriteDirs[i]);
|
|
||||||
|
|
||||||
if (fav && fav->query_exists()) {
|
|
||||||
try {
|
|
||||||
if (auto info = fav->query_info ()) {
|
|
||||||
Gtk::TreeModel::Row newrow = *(placesModel->append());
|
|
||||||
newrow[placesColumns.label] = info->get_display_name ();
|
|
||||||
newrow[placesColumns.icon] = info->get_icon ();
|
|
||||||
newrow[placesColumns.root] = fav->get_parse_name ();
|
|
||||||
newrow[placesColumns.type] = 5;
|
|
||||||
newrow[placesColumns.rowSeparator] = false;
|
|
||||||
}
|
|
||||||
} catch(Gio::Error&) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlacesBrowser::rowSeparatorFunc (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::iterator& iter)
|
bool PlacesBrowser::rowSeparatorFunc (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::iterator& iter)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user