48
49
SetAcceptKeyNavFocusOnMouseDown(false);
49
50
SetAcceptKeyNavFocusOnMouseEnter(true);
51
std::string texture_prefix = PKGDATADIR"/";
52
std::string texture_prefix;
57
texture_prefix += "lockscreen";
58
texture_prefix = "lockscreen";
60
61
case Action::LOGOUT:
61
texture_prefix += "logout";
62
texture_prefix = "logout";
62
63
label = _("Log Out");
64
65
case Action::SUSPEND:
65
texture_prefix += "suspend";
66
texture_prefix = "suspend";
66
67
label = _("Suspend");
68
69
case Action::HIBERNATE:
69
texture_prefix += "hibernate";
70
texture_prefix = "hibernate";
70
71
label = _("Hibernate");
72
73
case Action::SHUTDOWN:
73
texture_prefix += "shutdown";
74
texture_prefix = "shutdown";
74
75
label = _("Shut Down");
76
77
case Action::REBOOT:
77
texture_prefix += "restart";
78
texture_prefix = "restart";
78
79
label = _("Restart");
94
95
image_view_->SetTexture(highlighted ? highlight_tex_ : normal_tex_);
98
theme::Settings::Get()->theme.changed.connect(sigc::hide(sigc::bind(sigc::mem_fun(this, &Button::UpdateTextures), texture_prefix)));
97
100
image_view_ = new IconTexture(normal_tex_);
98
101
image_view_->SetInputEventSensitivity(false);
99
102
main_layout->AddView(image_view_, 1, nux::MINOR_POSITION_CENTER);
128
131
void Button::UpdateTextures(std::string const& texture_prefix)
130
RawPixel const texture_size = GetDefaultMaxTextureSize(texture_prefix);
133
auto const& theme = theme::Settings::Get();
134
auto texture_path = theme->ThemedFilePath(texture_prefix, {PKGDATADIR});
135
RawPixel const texture_size = GetDefaultMaxTextureSize(texture_path);
136
normal_tex_.Adopt(nux::CreateTexture2DFromFile(texture_path.c_str(), texture_size.CP(scale), true));
132
normal_tex_.Adopt(nux::CreateTexture2DFromFile((texture_prefix + ".png").c_str(), texture_size.CP(scale), true));
133
highlight_tex_.Adopt(nux::CreateTexture2DFromFile((texture_prefix + "_highlight.png").c_str(), texture_size.CP(scale), true));
138
auto texture_highlight_path = theme->ThemedFilePath(texture_prefix + "_highlight", {PKGDATADIR});
139
RawPixel const texture_highlight_size = GetDefaultMaxTextureSize(texture_path);
140
highlight_tex_.Adopt(nux::CreateTexture2DFromFile(texture_highlight_path.c_str(), texture_highlight_size.CP(scale), true));
136
RawPixel Button::GetDefaultMaxTextureSize(std::string const& texture_prefix) const
143
RawPixel Button::GetDefaultMaxTextureSize(std::string const& texture_path) const
139
auto const& texture_name = (texture_prefix + ".png");
140
gdk_pixbuf_get_file_info(texture_name.c_str(), &size.width, &size.height);
146
gdk_pixbuf_get_file_info(texture_path.c_str(), &size.width, &size.height);
141
147
RawPixel max_size = std::max(size.width, size.height);