Use own file type icons

This commit is contained in:
fiaxh 2019-08-06 16:47:06 +02:00
parent 08a5088c16
commit 5ebdbf8a8b
10 changed files with 92 additions and 18 deletions

View file

@ -24,6 +24,15 @@ set(RESOURCE_LIST
icons/im.dino.Dino-symbolic.svg icons/im.dino.Dino-symbolic.svg
icons/dino-tick-symbolic.svg icons/dino-tick-symbolic.svg
icons/dino-file-document-symbolic.svg
icons/dino-file-download-symbolic.svg
icons/dino-file-image-symbolic.svg
icons/dino-file-music-symbolic.svg
icons/dino-file-pdf-symbolic.svg
icons/dino-file-symbolic.svg
icons/dino-file-table-symbolic.svg
icons/dino-file-video-symbolic.svg
add_conversation/add_contact_dialog.ui add_conversation/add_contact_dialog.ui
add_conversation/add_groupchat_dialog.ui add_conversation/add_groupchat_dialog.ui
add_conversation/conference_details_fragment.ui add_conversation/conference_details_fragment.ui

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" viewBox="0 0 16 21" xmlns="http://www.w3.org/2000/svg">
<path d="m4 11v2h8v-2h-8"/>
<path d="m4 15v2h5v-2z"/>
<path d="m2 1.25c-1.2632 0-1.9836 0.78574-2 2v15.75c0 1.1966 0.68685 1.9999 2 2h12c1.2965 0 2-0.73406 2-2v-11.5c4.8e-4 -0.1991-0.07822-0.39022-0.21875-0.53125l-5.5-5.5c-0.14103-0.14053-0.33215-0.21923-0.53125-0.21875zm-0.5 1.5h7.75v4.75c2.7e-5 0.27613 0.22387 0.49997 0.5 0.5h4.75v11.5h-13z"/>
</svg>

After

Width:  |  Height:  |  Size: 475 B

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" viewBox="0 0 16 21" xmlns="http://www.w3.org/2000/svg">
<path d="m8 18-4-4h2.5v-3h3v3h2.5z"/>
<path d="m2 1.25c-1.2632 0-1.9836 0.78574-2 2v15.75c0 1.1966 0.68685 1.9999 2 2h12c1.2965 0 2-0.73406 2-2v-11.5c4.8e-4 -0.1991-0.07822-0.39022-0.21875-0.53125l-5.5-5.5c-0.14103-0.14053-0.33215-0.21923-0.53125-0.21875zm-0.5 1.5h7.75v4.75c2.7e-5 0.27613 0.22387 0.49997 0.5 0.5h4.75v11.5h-13z"/>
</svg>

After

Width:  |  Height:  |  Size: 457 B

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" viewBox="0 0 16 21" xmlns="http://www.w3.org/2000/svg">
<path d="m11.71 12 1.2899 1.8428v4.1572h-10l3.7101-5 2 2.0944"/>
<path d="m6.0629 9.4685a1.5315 1.5315 0 0 1 -1.5315 1.5315 1.5315 1.5315 0 0 1 -1.5315 -1.5315 1.5315 1.5315 0 0 1 1.5315 -1.5315 1.5315 1.5315 0 0 1 1.5315 1.5315z" stroke-width="1.021"/>
<path d="m2 1.25c-1.2632 0-1.9836 0.78574-2 2v15.75c0 1.1966 0.68685 1.9999 2 2h12c1.2965 0 2-0.73406 2-2v-11.5c4.8e-4 -0.1991-0.07822-0.39022-0.21875-0.53125l-5.5-5.5c-0.14103-0.14053-0.33215-0.21923-0.53125-0.21875zm-0.5 1.5h7.75v4.75c2.7e-5 0.27613 0.22387 0.49997 0.5 0.5h4.75v11.5h-13z"/>
</svg>

After

Width:  |  Height:  |  Size: 675 B

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" viewBox="0 0 16 21" xmlns="http://www.w3.org/2000/svg">
<path d="m2 1.25c-1.2632 0-1.9836 0.78574-2 2v15.75c0 1.1966 0.68685 1.9999 2 2h12c1.2965 0 2-0.73406 2-2v-11.5c4.8e-4 -0.1991-0.07822-0.39022-0.21875-0.53125l-5.5-5.5c-0.14103-0.14053-0.33215-0.21923-0.53125-0.21875zm-0.5 1.5h7.75v4.75c2.7e-5 0.27613 0.22387 0.49997 0.5 0.5h4.75v11.5h-13z"/>
<path d="m4.6934 13.773a1.3501 1.3501 0 0 0 -1.3301 1.3691v1.377a1.3506 1.3506 0 1 0 2.7012 0v-1.377a1.3501 1.3501 0 0 0 -1.3711 -1.3691z"/>
<path d="m11.115 13.773a1.3501 1.3501 0 0 0 -1.3281 1.3691v1.377a1.3501 1.3501 0 1 0 2.6992 0v-1.377a1.3501 1.3501 0 0 0 -1.3711 -1.3691z"/>
<path d="m7.9238 9.4824c-1.538 0-2.7575 0.64459-3.5059 1.6621-0.74838 1.0175-1.0547 2.347-1.0547 3.7617a0.65006 0.65006 0 1 0 1.2988 0c0-1.2218 0.27974-2.2792 0.80273-2.9902 0.52299-0.71108 1.2596-1.1348 2.459-1.1348 1.1288 0 1.8725 0.42826 2.4121 1.1504 0.53958 0.72213 0.8418 1.78 0.8418 2.9746a0.65039 0.65039 0 1 0 1.3008 0c0-1.4089-0.34141-2.7372-1.0996-3.752s-1.9667-1.6719-3.4551-1.6719z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" viewBox="0 0 16 21" xmlns="http://www.w3.org/2000/svg">
<path d="m2 1.25c-1.2632 0-1.9836 0.78574-2 2v15.75c0 1.1966 0.68685 1.9999 2 2h12c1.2965 0 2-0.73406 2-2v-11.5c4.8e-4 -0.1991-0.07822-0.39022-0.21875-0.53125l-5.5-5.5c-0.14103-0.14053-0.33215-0.21923-0.53125-0.21875zm-0.5 1.5h7.75v4.75c2.7e-5 0.27613 0.22387 0.49997 0.5 0.5h4.75v11.5h-13z"/>
</svg>

After

Width:  |  Height:  |  Size: 417 B

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" viewBox="0 0 16 21" xmlns="http://www.w3.org/2000/svg">
<path d="m6 12h-3v-2h3v2"/>
<path d="m10 12h-3v-2h3v2"/>
<path d="m6 15h-3v-2h3v2"/>
<path d="m10 15h-3v-2h3v2"/>
<path d="m6 18h-3v-2h3v2"/>
<path d="m10 18h-3v-2h3z"/>
<path d="m2 1.25c-1.2632 0-1.9836 0.78574-2 2v15.75c0 1.1966 0.68685 1.9999 2 2h12c1.2965 0 2-0.73406 2-2v-11.5c4.8e-4 -0.1991-0.07822-0.39022-0.21875-0.53125l-5.5-5.5c-0.14103-0.14053-0.33215-0.21923-0.53125-0.21875zm-0.5 1.5h7.75v4.75c2.7e-5 0.27613 0.22387 0.49997 0.5 0.5h4.75v11.5h-13z"/>
</svg>

After

Width:  |  Height:  |  Size: 599 B

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" viewBox="0 0 16 21" xmlns="http://www.w3.org/2000/svg">
<path d="m6.4377 10.018c-0.24578 0.01348-0.43806 0.21689-0.43771 0.46303v5.5564c8.196e-4 0.38151 0.43677 0.59842 0.74158 0.36898l4.074-2.7782c0.24595-0.18526 0.24595-0.55451 0-0.73977l-4.074-2.7782c-0.08725-0.0656-0.19487-0.09827-0.30387-0.09225z"/>
<path d="m2 1.25c-1.2632 0-1.9836 0.78574-2 2v15.75c0 1.1966 0.68685 1.9999 2 2h12c1.2965 0 2-0.73406 2-2v-11.5c4.8e-4 -0.1991-0.07822-0.39022-0.21875-0.53125l-5.5-5.5c-0.14103-0.14053-0.33215-0.21923-0.53125-0.21875zm-0.5 1.5h7.75v4.75c2.7e-5 0.27613 0.22387 0.49997 0.5 0.5h4.75v11.5h-13z"/>
</svg>

After

Width:  |  Height:  |  Size: 669 B

View file

@ -1,4 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<svg style="width:24px;height:24px" viewBox="0 0 24 24"> <svg version="1.1" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg">
<path fill="#000000" d="M3,11H5V13H3V11M11,5H13V9H11V5M9,11H13V15H11V13H9V11M15,11H17V13H19V11H21V13H19V15H21V19H19V21H17V19H13V21H11V17H15V15H17V13H15V11M19,19V15H17V19H19M15,3H21V9H15V3M17,5V7H19V5H17M3,3H9V9H3V3M5,5V7H7V5H5M3,15H9V21H3V15M5,17V19H7V17H5Z" /> <path d="m0 8h2v2h-2v-2"/>
<path d="m8 0h2v4h-2v-4"/>
<path d="m12 8v2 2h2 2v-2h-2v-2h-2z"/>
<path d="m16 10h2v-2h-2z"/>
<path d="m12 0v6h6v-6h-6zm2 2h2v2h-2v-2z"/>
<path d="m0 0v6h6v-6h-6zm2 2h2v2h-2v-2z"/>
<path d="m0 12v6h6v-6h-6zm2 2h2v2h-2v-2z"/>
<path d="m8 6v2h-2-2v2h2 2 2v-2-2h-2z"/>
<path d="m8 12v2h2 2v-2h-2-2z"/>
<path d="m8 16h2v2h-2v-2"/>
<path d="m12 14v2 2h2 2v-2h-2v-2h-2z"/>
<path d="m16 14h2v2h-2v-2"/>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 369 B

After

Width:  |  Height:  |  Size: 568 B

View file

@ -23,7 +23,6 @@ public class FileWidget : Box {
// default box // default box
private Box main_box; private Box main_box;
private string? icon_name;
private Image content_type_image; private Image content_type_image;
private Image download_image; private Image download_image;
private Spinner spinner; private Spinner spinner;
@ -135,10 +134,11 @@ public class FileWidget : Box {
} }
private Widget getDefaultWidget(FileTransfer file_transfer) { private Widget getDefaultWidget(FileTransfer file_transfer) {
main_box = new Box(Orientation.HORIZONTAL, 4) { halign=Align.FILL, hexpand=true, visible=true }; string icon_name = get_file_icon_name(file_transfer.mime_type);
icon_name = ContentType.get_generic_icon_name(file_transfer.mime_type ?? "application/octet-stream");
content_type_image = new Image.from_icon_name(icon_name + "-symbolic", IconSize.DND) { visible=true }; main_box = new Box(Orientation.HORIZONTAL, 10) { halign=Align.FILL, hexpand=true, visible=true };
download_image = new Image.from_icon_name("folder-download-symbolic", IconSize.MENU) { visible=true }; content_type_image = new Image.from_icon_name(icon_name, IconSize.DND) { opacity=0.5, visible=true };
download_image = new Image.from_icon_name("dino-file-download-symbolic", IconSize.DND) { opacity=0.7, visible=true };
spinner = new Spinner() { active=true, visible=true }; spinner = new Spinner() { active=true, visible=true };
EventBox stack_event_box = new EventBox() { visible=true }; EventBox stack_event_box = new EventBox() { visible=true };
@ -173,10 +173,9 @@ public class FileWidget : Box {
Timeout.add(20, () => { Timeout.add(20, () => {
if (pointer_inside) { if (pointer_inside) {
event.get_window().set_cursor(new Cursor.for_display(Gdk.Display.get_default(), CursorType.HAND2)); event.get_window().set_cursor(new Cursor.for_display(Gdk.Display.get_default(), CursorType.HAND2));
content_type_image.opacity = 0.7;
if (file_transfer.state == FileTransfer.State.NOT_STARTED) { if (file_transfer.state == FileTransfer.State.NOT_STARTED) {
image_stack.set_visible_child_name("download_image"); image_stack.set_visible_child_name("download_image");
} else if (file_transfer.state == FileTransfer.State.COMPLETE) {
content_type_image.opacity = 1;
} }
} }
return false; return false;
@ -191,10 +190,9 @@ public class FileWidget : Box {
Timeout.add(20, () => { Timeout.add(20, () => {
if (!pointer_inside) { if (!pointer_inside) {
event.get_window().set_cursor(new Cursor.for_display(Gdk.Display.get_default(), CursorType.XTERM)); event.get_window().set_cursor(new Cursor.for_display(Gdk.Display.get_default(), CursorType.XTERM));
content_type_image.opacity = 0.5;
if (file_transfer.state == FileTransfer.State.NOT_STARTED) { if (file_transfer.state == FileTransfer.State.NOT_STARTED) {
image_stack.set_visible_child_name("content_type_image"); image_stack.set_visible_child_name("content_type_image");
} else if (file_transfer.state == FileTransfer.State.COMPLETE) {
content_type_image.opacity = 0.5;
} }
} }
return false; return false;
@ -249,14 +247,11 @@ public class FileWidget : Box {
state = State.IMAGE; state = State.IMAGE;
} }
content_type_image.opacity = 0.5; string? mime_description = file_transfer.mime_type != null ? ContentType.get_description(file_transfer.mime_type) : null;
var mime_split = (file_transfer.mime_type ?? "").split("/");
var mime_caps = mime_split.length == 2 ? mime_split[1].up() : file_transfer.mime_type;
switch (file_transfer.state) { switch (file_transfer.state) {
case FileTransfer.State.COMPLETE: case FileTransfer.State.COMPLETE:
mime_label.label = "<span size='small'>" + _("%s file").printf(mime_caps) + "</span>"; mime_label.label = "<span size='small'>" + mime_description + "</span>";
image_stack.set_visible_child_name("content_type_image"); image_stack.set_visible_child_name("content_type_image");
break; break;
case FileTransfer.State.IN_PROGRESS: case FileTransfer.State.IN_PROGRESS:
@ -264,8 +259,8 @@ public class FileWidget : Box {
image_stack.set_visible_child_name("spinner"); image_stack.set_visible_child_name("spinner");
break; break;
case FileTransfer.State.NOT_STARTED: case FileTransfer.State.NOT_STARTED:
if (mime_caps != null) { if (mime_description != null) {
mime_label.label = "<span size='small'>" + _("%s file offered: %s").printf(mime_caps, get_size_string(file_transfer.size)) + "</span>"; mime_label.label = "<span size='small'>" + _("%s offered: %s").printf(mime_description, get_size_string(file_transfer.size)) + "</span>";
} else if (file_transfer.size != -1) { } else if (file_transfer.size != -1) {
mime_label.label = "<span size='small'>" + _("File offered: %s").printf(get_size_string(file_transfer.size)) + "</span>"; mime_label.label = "<span size='small'>" + _("File offered: %s").printf(get_size_string(file_transfer.size)) + "</span>";
} else { } else {
@ -280,6 +275,22 @@ public class FileWidget : Box {
} }
} }
private static string get_file_icon_name(string? mime_type) {
if (mime_type == null) return "dino-file-symbolic";
string generic_icon_name = ContentType.get_generic_icon_name(mime_type) ?? "";
switch (generic_icon_name) {
case "audio-x-generic": return "dino-file-music-symbolic";
case "image-x-generic": return "dino-file-image-symbolic";
case "text-x-generic": return "dino-file-document-symbolic";
case "text-x-generic-template": return "dino-file-document-symbolic";
case "video-x-generic": return "dino-file-video-symbolic";
case "x-office-document": return "dino-file-document-symbolic";
case "x-office-spreadsheet": return "dino-file-table-symbolic";
default: return "dino-file-symbolic";
}
}
private static string get_size_string(int size) { private static string get_size_string(int size) {
if (size < 1024) { if (size < 1024) {
return @"$(size) B"; return @"$(size) B";