File: Icons.pm

package info (click to toggle)
clamtk 6.07-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,468 kB
  • sloc: perl: 4,510; python: 44; makefile: 23
file content (86 lines) | stat: -rw-r--r-- 3,305 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# ClamTk, copyright (C) 2004-2021 Dave M
#
# This file is part of ClamTk
# (https://gitlab.com/dave_m/clamtk-gtk3/).
#
# ClamTk is free software; you can redistribute it and/or modify it
# under the terms of either:
#
# a) the GNU General Public License as published by the Free Software
# Foundation; either version 1, or (at your option) any later version, or
#
# b) the "Artistic License".
package ClamTk::Icons;

# use strict;
# use warnings;
# $| = 1;

sub get_image() {
    my ( $self, $wanted ) = @_;

    my $use_image = '';

    my %table;

    # These need to be scrubbed again
    # The gtk-apply in the left column is because it works and
    # the newer names (e.g., emblem-ok) don't.
    $table{ 'system-run' }                 = 'gtk-apply';
    $table{ 'alarm' }                      = 'gtk-properties';
    $table{ 'document-new' }               = 'gtk-file';
    $table{ 'document-print' }             = 'gtk-print';
    $table{ 'document-properties' }        = 'document-properties';
    $table{ 'document-save' }              = 'gtk-apply';
    $table{ 'document-save-as' }           = 'gtk-save-as';
    $table{ 'document-send' }              = 'gtk-index';
    $table{ 'edit-delete' }                = 'gtk-delete';
    $table{ 'edit-find' }                  = 'gtk-find';
    $table{ 'edit-select' }                = 'gtk-find';
    $table{ 'edit-undo' }                  = 'gtk-undelete';
    $table{ 'emblem-important' }           = 'gtk-no';
    $table{ 'folder-documents' }           = 'gtk-directory';
    $table{ 'go-previous' }                = 'gtk-go-back';
    $table{ 'help-about' }                 = 'gtk-about';
    $table{ 'image-missing' }              = 'gtk-missing-image';
    $table{ 'list-add' }                   = 'gtk-add';
    $table{ 'list-remove' }                = 'gtk-remove';
    $table{ 'media-playback-start' }       = 'gtk-yes';
    $table{ 'preferences-system' }         = 'gtk-preferences';
    $table{ 'preferences-system-network' } = 'gtk-network';
    $table{ 'process-stop' }               = 'gtk-cancel';
    $table{ 'security-high' }              = 'gtk-new';
    $table{ 'software-update-available' }  = 'gtk-ok';
    $table{ 'system-help' }                = 'gtk-about';
    $table{ 'system-lock-screen' }         = 'gtk-refresh';
    $table{ 'system-search' }              = 'gtk-find';
    $table{ 'text-x-preview' }             = 'gtk-select-all';
    $table{ 'user-trash-full' }            = 'gtk-refresh';
    $table{ 'view-list' }                  = 'gtk-edit';
    $table{ 'window-close' }               = 'gtk-close';

    my $theme = Gtk3::IconTheme::get_default();

    if ( exists $table{ $wanted } ) {
        if ( $theme->has_icon( $wanted ) ) {
            $use_image = $wanted;
        } elsif ( $theme->has_icon( $table{ $wanted } ) ) {
            $use_image = $table{ $wanted };
        } else {
            if ( $theme->has_icon( 'image-missing' ) ) {
                $use_image = 'image-missing';
            } else {
                $use_image = $table{ 'image-missing' };
            }
        }
    } else {
        if ( $theme->has_icon( 'image-missing' ) ) {
            $use_image = 'image-missing';
        } else {
            $use_image = $table{ 'image-missing' };
        }
    }
    return $use_image;
}

1;