Skip to content

Commit

Permalink
Merge pull request #102 from nwg-piotr/fix_no_display
Browse files Browse the repository at this point in the history
Restore solution to #84 broken in #83
  • Loading branch information
nwg-piotr committed Sep 5, 2020
2 parents 90845b4 + 6729921 commit fe6afd8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions common/nwg_classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ struct DesktopEntry {
std::string icon;
std::string comment;
std::string mime_type;
// We need this field to mask unwanted .desktop entries by their copies in ./local/share/applications
// with the `NoDisplay=true` line added.
// See https://wiki.archlinux.org/index.php/desktop_entries#Hide_desktop_entries
bool no_display {false};
};

struct RGBA {
Expand Down
8 changes: 4 additions & 4 deletions grid/grid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@ int main(int argc, char *argv[]) {
auto& ab = window.emplace_box(std::move(de.name),
std::move(de.exec),
std::move(de.comment),
GridBox::Favorite,
GridBox::Favorite,
GridBox::Unpinned);

Gtk::Image* image = app_image(icon_theme_ref, de.icon);
ab.set_image_position(Gtk::POS_TOP);
ab.set_image(*image);
Expand All @@ -335,7 +335,7 @@ int main(int argc, char *argv[]) {
for (auto& entry : desktop_entries) {
// if it's empty, it was probably moved from during the previous steps
// there should be some better way, but it works
if (!entry.exec.empty()) {
if (!entry.exec.empty() && !entry.no_display) {
auto& ab = window.emplace_box(std::move(entry.name),
std::move(entry.exec),
std::move(entry.comment),
Expand All @@ -347,7 +347,7 @@ int main(int argc, char *argv[]) {
}
}


window.build_grids();

gettimeofday(&tp, NULL);
Expand Down
4 changes: 3 additions & 1 deletion grid/grid_tools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ std::optional<DesktopEntry> desktop_entry(std::string&& path, const std::string&
};
};
if (view == nodisplay) {
return std::nullopt;
// @Siborgium: return std::nullopt won't do the job, as we DO NEED this object.
// See https://wiki.archlinux.org/index.php/desktop_entries#Hide_desktop_entries
entry.no_display = true;
}
for (auto& [prefix, dest, tag] : matches) {
auto [ok, pos] = try_strip_prefix(prefix);
Expand Down

0 comments on commit fe6afd8

Please sign in to comment.