commit a318529ecd77a4375cd02d093a4e7afac4ff0337
parent eb3b69f63f0621e88a4147c7a722ef78f87ef5c2
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date: Mon, 3 Sep 2012 20:14:47 -0700
Set window icon
Diffstat:
5 files changed, 105 insertions(+), 2 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
@@ -1,6 +1,8 @@
bin_PROGRAMS = spek
spek_SOURCES = \
+ spek-artwork.hh \
+ spek-artwork.cc \
spek-audio-desc.cc \
spek-audio-desc.hh \
spek-events.cc \
diff --git a/src/spek-artwork.cc b/src/spek-artwork.cc
@@ -0,0 +1,59 @@
+/* spek-artwork.cc
+ *
+ * Copyright (C) 2012 Alexander Kojevnikov <alexander@kojevnikov.com>
+ *
+ * Spek is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Spek is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Spek. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <wx/artprov.h>
+#include <wx/iconbndl.h>
+
+#include "spek-artwork.hh"
+
+class SpekArtProvider : public wxArtProvider
+{
+protected:
+ virtual wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client, const wxSize& size);
+#if ART_HAS_ICON_BUNDLES
+ virtual wxIconBundle CreateIconBundle(const wxArtID& id, const wxArtClient& client);
+#endif
+};
+
+wxBitmap SpekArtProvider::CreateBitmap(
+ const wxArtID& id, const wxArtClient& client, const wxSize& size)
+{
+ if (id == ART_SPEK) {
+#ifdef OS_UNIX
+ return wxArtProvider::GetBitmap(wxT("spek"), client, size);
+#endif
+ }
+ return wxNullBitmap;
+}
+
+#if ART_HAS_ICON_BUNDLES
+wxIconBundle SpekArtProvider::CreateIconBundle(const wxArtID& id, const wxArtClient& client)
+{
+ if (id == ART_SPEK) {
+#ifdef OS_UNIX
+ return wxArtProvider::GetIconBundle(wxT("spek"), client);
+#endif
+ }
+ return wxNullIconBundle;
+}
+#endif
+
+void spek_artwork_init()
+{
+ wxArtProvider::Push(new SpekArtProvider());
+}
diff --git a/src/spek-artwork.hh b/src/spek-artwork.hh
@@ -0,0 +1,34 @@
+/* spek-artwork.hh
+ *
+ * Copyright (C) 2012 Alexander Kojevnikov <alexander@kojevnikov.com>
+ *
+ * Spek is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Spek is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Spek. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SPEK_ARTWORK_HH_
+#define SPEK_ARTWORK_HH_
+
+#include <wx/string.h>
+
+#define ART_HAS_ICON_BUNDLES wxCHECK_VERSION(2, 9, 0)
+
+#define ART_SPEK wxT("art-spek")
+#define ART_OPEN wxT("art-open")
+#define ART_SAVE wxT("art-save")
+#define ART_ABOUT wxT("art-about")
+#define ART_CLOSE wxT("art-close")
+
+void spek_artwork_init();
+
+#endif
diff --git a/src/spek-window.cc b/src/spek-window.cc
@@ -30,6 +30,7 @@ extern "C" {
#include <spek-utils.h>
}
+#include "spek-artwork.hh"
#include "spek-preferences-dialog.hh"
#include "spek-preferences.hh"
#include "spek-spectrogram.hh"
@@ -74,8 +75,12 @@ SpekWindow::SpekWindow(const wxString& path) :
{
this->description = _("Spek - Acoustic Spectrum Analyser");
SetTitle(this->description);
- // TODO: test on all platforms
- //SetIcon(wxIcon(wxT("spek")));
+
+#if ART_HAS_ICON_BUNDLES
+ SetIcons(wxArtProvider::GetIconBundle(ART_SPEK));
+#else
+ SetIcon(wxArtProvider::GetIcon(ART_SPEK, wxART_OTHER, wxSize(48, 48)));
+#endif
wxMenuBar *menu = new wxMenuBar();
diff --git a/src/spek.cc b/src/spek.cc
@@ -24,6 +24,7 @@ extern "C" {
#include <spek-audio.h>
}
+#include "spek-artwork.hh"
#include "spek-platform.hh"
#include "spek-preferences.hh"
@@ -51,6 +52,8 @@ bool Spek::OnInit()
wxSocketBase::Initialize();
spek_audio_init();
+
+ spek_artwork_init();
spek_platform_init();
SpekPreferences::get().init();