Skip to content

Commit

Permalink
Fallback to text-x-generic-symbolic if no symbolic
Browse files Browse the repository at this point in the history
  • Loading branch information
kra-mo committed Dec 22, 2023
1 parent e831d6f commit 3f78c10
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions hyperplane/file_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
"application/x-sharedlib",
"application/x-executable",
"application/x-pie-executable",
"inode/symlink",
}
19 changes: 18 additions & 1 deletion hyperplane/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,15 @@ def bind(self) -> None:
self.file_info = self.item.get_item()

self.gfile = self.file_info.get_attribute_object("standard::file")
self.gicon = self.file_info.get_symbolic_icon()
gicon = self.file_info.get_symbolic_icon()

for icon_name in gicon.get_names():
if icon_name.endswith("-symbolic") and icon_name in shared.icon_names:
break
else:
gicon = Gio.Icon.new_for_string("text-x-generic-symbolic")

self.gicon = gicon
self.content_type = self.file_info.get_content_type()
self.color = get_color_for_content_type(self.content_type, self.gicon)
self.edit_name = self.file_info.get_edit_name()
Expand Down Expand Up @@ -212,6 +220,15 @@ def next_files_cb(
files.next_files_async(1, GLib.PRIORITY_DEFAULT, None, next_files_cb, index)

if gicon := file_info.get_symbolic_icon():
for icon_name in gicon.get_names():
if (
icon_name.endswith("-symbolic")
and icon_name in shared.icon_names
):
break
else:
gicon = Gio.Icon.new_for_string("text-x-generic-symbolic")

idle_add(thumbnail.get_child().set_from_gicon, gicon)

if content_type == "inode/directory":
Expand Down
9 changes: 9 additions & 0 deletions hyperplane/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ def __init__(self, gfile: Gio.File, **kwargs) -> None:
)

elif gicon:
for icon_name in gicon.get_names():
if (
icon_name.endswith("-symbolic")
and icon_name in shared.icon_names
):
break
else:
gicon = Gio.Icon.new_for_string("text-x-generic-symbolic")

icon_group.add(image := Gtk.Image(gicon=gicon, halign=Gtk.Align.CENTER))
image.set_icon_size(Gtk.IconSize.LARGE)

Expand Down
2 changes: 2 additions & 0 deletions hyperplane/shared.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,5 @@ if (
recent_manager = Gtk.RecentManager(filename=str(path))
else:
recent_manager = Gtk.RecentManager.get_default()

icon_names = Gtk.IconTheme.get_for_display(Gdk.Display.get_default()).get_icon_names()

0 comments on commit 3f78c10

Please sign in to comment.