Class: Gtk::IconThemeExample

Inherits:
Box
  • Object
show all
Defined in:
lib/gtk_paradise/examples/gtk3/072_icon_theme_example.rb

Constant Summary collapse

DEFAULT_ICON_SIZE =
#

DEFAULT_ICON_SIZE

#
32

Instance Method Summary collapse

Methods inherited from Box

#add_space, #left_aligned_text, #text

Constructor Details

#initializeIconThemeExample

#

initialize

#


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
87
88
# File 'lib/gtk_paradise/examples/gtk3/072_icon_theme_example.rb', line 28

def initialize
  super(:horizontal)
  icon_theme = ::Gtk::IconTheme.default

  use_this_icon_name = 'folder-music'
  icon1 = icon_theme.load_icon(use_this_icon_name, DEFAULT_ICON_SIZE, 0)
  image1 = new_pixbuf_image(icon1) # Use the icon here.
  pack_start(image1, padding: 2)

  use_this_icon_name = 'dialog-password'
  icon2 = icon_theme.load_icon(use_this_icon_name, DEFAULT_ICON_SIZE, 0)
  image2 = new_pixbuf_image(icon2) # Use the icon here.
  pack_start(image2, padding: 2)

  use_this_icon_name = 'window-close'
  icon3 = icon_theme.load_icon(use_this_icon_name, DEFAULT_ICON_SIZE, 0) # Use the window-close example.
  image3 = new_pixbuf_image(icon3) # Use the icon here.
  pack_start(image3, padding: 2)

  use_this_icon_name = 'folder-download'
  icon4 = icon_theme.load_icon(use_this_icon_name, DEFAULT_ICON_SIZE, 0)
  image4 = new_pixbuf_image(icon4) # Use the icon here.
  pack_start(image4, padding: 2)

  begin # This icon is not always available.
    use_this_icon_name = 'audio-speakers'
    icon5 = icon_theme.load_icon(use_this_icon_name, DEFAULT_ICON_SIZE, 0)
    image5 = new_pixbuf_image(icon5) # Use the icon here.
    pack_start(image5, padding: 2)
  rescue Exception => error
    pp error
  end

  use_this_icon_name = 'emblem-readonly'
  icon6 = icon_theme.load_icon(use_this_icon_name, DEFAULT_ICON_SIZE, 0)
  image6 = new_pixbuf_image(icon6) # Use the icon here.
  pack_start(image6, padding: 2)

  use_this_icon_name = 'emblem-shared'
  icon7 = icon_theme.load_icon(use_this_icon_name, DEFAULT_ICON_SIZE, 0)
  image7 = new_pixbuf_image(icon7) # Use the icon here.
  pack_start(image7, padding: 2)

  use_this_icon_name = 'network-wired-symbolic.symbolic'
  icon8 = icon_theme.load_icon(use_this_icon_name, DEFAULT_ICON_SIZE, 0)
  image8 = new_pixbuf_image(icon8)
  image8.icon_size = 125
  pack_start(image8, padding: 2)

  use_this_icon_name = 'preferences-system-search-symbolic.symbolic'
  icon9 = icon_theme.load_icon(use_this_icon_name, DEFAULT_ICON_SIZE*2, 0)
  image9 = new_pixbuf_image(icon9)
  pack_start(image9, padding: 2)

  use_this_icon_name = 'open-menu-symbolic'
  icon10 = icon_theme.load_icon(use_this_icon_name, DEFAULT_ICON_SIZE*2, 0)
  image10 = new_pixbuf_image(icon10)
  pack_start(image10, padding: 2)

  reset
end

Instance Method Details

#new_pixbuf_image(icon) ⇒ Object

#

new_pixbuf_image

#


100
101
102
# File 'lib/gtk_paradise/examples/gtk3/072_icon_theme_example.rb', line 100

def new_pixbuf_image(icon)
  ::Gtk::Image.new(pixbuf: icon)
end

#resetObject

#

reset

#


93
94
95
# File 'lib/gtk_paradise/examples/gtk3/072_icon_theme_example.rb', line 93

def reset
  set_border_width(12)
end