mirror of
https://github.com/alexkay/spek.git
synced 2025-04-22 19:30:27 +03:00
Custom info bar
This commit is contained in:
parent
02893f9a42
commit
668c8a7c3c
@ -100,7 +100,32 @@ SpekWindow::SpekWindow(const wxString& path) :
|
||||
);
|
||||
toolbar->Realize();
|
||||
|
||||
wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
// wxInfoBar is too limited, construct a custom one.
|
||||
wxPanel *info_bar = new wxPanel(this);
|
||||
info_bar->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_INFOTEXT));
|
||||
info_bar->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_INFOBK));
|
||||
wxSizer *info_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxStaticText *label = new wxStaticText(
|
||||
info_bar, -1, _("A new version of Spek is available, click to download."));
|
||||
label->SetCursor(*new wxCursor(wxCURSOR_HAND));
|
||||
label->Connect(wxEVT_LEFT_DOWN, wxCommandEventHandler(SpekWindow::on_visit));
|
||||
// This second Connect() handles clicks on the border
|
||||
info_bar->Connect(wxEVT_LEFT_DOWN, wxCommandEventHandler(SpekWindow::on_visit));
|
||||
info_sizer->Add(label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 6);
|
||||
// TODO: gtk-close won't work on win/osx
|
||||
wxBitmapButton *button = new wxBitmapButton(
|
||||
info_bar, -1, wxArtProvider::GetBitmap(wxT("gtk-close")),
|
||||
wxDefaultPosition, wxDefaultSize, wxNO_BORDER);
|
||||
button->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(SpekWindow::on_close));
|
||||
info_sizer->Add(button, 0, 0);
|
||||
info_bar->SetSizer(info_sizer);
|
||||
sizer->Add(info_bar, 0, wxEXPAND);
|
||||
|
||||
this->spectrogram = new SpekSpectrogram(this);
|
||||
sizer->Add(this->spectrogram, 1, wxEXPAND);
|
||||
|
||||
this->cur_dir = wxGetHomeDir();
|
||||
|
||||
if (!path.IsEmpty()) {
|
||||
@ -108,6 +133,8 @@ SpekWindow::SpekWindow(const wxString& path) :
|
||||
}
|
||||
|
||||
SetDropTarget(new SpekDropTarget(this));
|
||||
|
||||
SetSizer(sizer);
|
||||
}
|
||||
|
||||
void SpekWindow::open(const wxString& path)
|
||||
@ -266,3 +293,15 @@ void SpekWindow::on_about(wxCommandEvent& event)
|
||||
#endif
|
||||
wxAboutBox(info);
|
||||
}
|
||||
|
||||
void SpekWindow::on_visit(wxCommandEvent& event)
|
||||
{
|
||||
wxLaunchDefaultBrowser(wxT("http://spek-project.org"));
|
||||
}
|
||||
|
||||
void SpekWindow::on_close(wxCommandEvent& event)
|
||||
{
|
||||
wxWindow *self = ((wxWindow *)event.GetEventObject())->GetGrandParent();
|
||||
self->GetSizer()->Hide((size_t)0);
|
||||
self->Layout();
|
||||
}
|
||||
|
@ -35,6 +35,8 @@ private:
|
||||
void on_exit(wxCommandEvent& event);
|
||||
void on_preferences(wxCommandEvent& event);
|
||||
void on_about(wxCommandEvent& event);
|
||||
void on_visit(wxCommandEvent& event);
|
||||
void on_close(wxCommandEvent& event);
|
||||
|
||||
SpekSpectrogram *spectrogram;
|
||||
wxString path;
|
||||
|
@ -22,41 +22,7 @@ using Gtk;
|
||||
namespace Spek {
|
||||
public class Window : Gtk.Window {
|
||||
|
||||
private UIManager ui;
|
||||
private InfoBar info_bar;
|
||||
private Spectrogram spectrogram;
|
||||
private string description;
|
||||
private string cur_dir;
|
||||
private FileFilter filter_all;
|
||||
private FileFilter filter_audio;
|
||||
private FileFilter filter_png;
|
||||
|
||||
|
||||
private const Gtk.TargetEntry[] DEST_TARGET_ENTRIES = {
|
||||
{ "text/uri-list", 0, 0 }
|
||||
};
|
||||
|
||||
public Window (string? file_name) {
|
||||
info_bar = new InfoBar.with_buttons (Stock.OK, ResponseType.OK);
|
||||
var label = new Label (null);
|
||||
label.use_markup = true;
|
||||
label.set_markup (_("A new version of Spek is available on <a href=\"http://www.spek-project.org\">www.spek-project.org</a>"));
|
||||
label.ellipsize = Pango.EllipsizeMode.END;
|
||||
label.xalign = 0f;
|
||||
label.activate_link.connect (uri => { Platform.show_uri (uri); return true; });
|
||||
label.show();
|
||||
var content_area = (Container) info_bar.get_content_area();
|
||||
content_area.add(label);
|
||||
info_bar.message_type = MessageType.INFO;
|
||||
info_bar.response.connect(() => info_bar.hide());
|
||||
|
||||
var vbox = new VBox (false, 0);
|
||||
vbox.pack_start (info_bar, false, true, 0);
|
||||
add (vbox);
|
||||
vbox.show ();
|
||||
|
||||
show ();
|
||||
|
||||
try {
|
||||
Thread.create<void*> (check_version, false);
|
||||
} catch (ThreadError e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user