spek

Acoustic spectrum analyser
git clone http://git.hanabi.in/repos/spek.git
Log | Files | Refs | README

commit 44cb6f587d72ba148678d3e68a320669e602c303
parent d9ed0de8abe3bdab88f5e75ceaf6ded22a6c80e7
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date:   Fri, 10 Aug 2012 19:22:50 -0700

SpekPlatform::CanChangeLanguage() + spek_audio_init()

Diffstat:
Msrc/Makefile.am | 1+
Msrc/spek-platform.c | 57---------------------------------------------------------
Msrc/spek-platform.cc | 9+++++++++
Msrc/spek-platform.hh | 4++++
Msrc/spek.cc | 2++
Dsrc/spek.vala | 40----------------------------------------
6 files changed, 16 insertions(+), 97 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am @@ -24,6 +24,7 @@ spek_CFLAGS = \ @CFLAGS@ spek_CXXFLAGS = \ + $(SPEK_CFLAGS) \ @CXXFLAGS@ spek_LDADD = \ diff --git a/src/spek-platform.c b/src/spek-platform.c @@ -32,55 +32,6 @@ #include "spek-platform.h" -gchar *spek_platform_locale_dir () { - static gchar *locale_dir = NULL; - - if (!locale_dir) { -#ifdef G_OS_WIN32 - gchar *win32_dir; - - win32_dir = g_win32_get_package_installation_directory_of_module (NULL); - locale_dir = g_build_filename (win32_dir, "share", "locale", NULL); - - g_free (win32_dir); -#else -#ifdef G_OS_DARWIN - GtkOSXApplication *app = NULL; - const gchar *res_dir; - - app = g_object_new (GTK_TYPE_OSX_APPLICATION, NULL); - res_dir = gtk_osxapplication_get_resource_path (app); - locale_dir = g_build_filename (res_dir, "share", "locale", NULL); -#else - locale_dir = LOCALEDIR; -#endif -#endif - } - - return locale_dir; -} - -void spek_platform_show_uri (const gchar *uri) { -#ifdef G_OS_WIN32 - /* gtk_show_uri doesn't work on Windows... */ - ShellExecuteA (NULL, "open", uri, "", NULL, SW_SHOWNORMAL); -#else -#ifdef G_OS_DARWIN - /* ...or on OS X */ - CFStringRef str = NULL; - CFURLRef url = NULL; - - str = CFStringCreateWithCString (NULL, uri, kCFStringEncodingASCII); - url = CFURLCreateWithString (NULL, str, NULL); - LSOpenCFURLRef (url, NULL); - CFRelease (url); - CFRelease (str); -#else - gtk_show_uri (NULL, uri, gtk_get_current_event_time (), NULL); -#endif -#endif -} - gchar *spek_platform_read_line (const gchar *uri) { #ifdef G_OS_DARWIN /* GIO doesn't work on OS X */ @@ -123,11 +74,3 @@ gchar *spek_platform_read_line (const gchar *uri) { return line; #endif } - -gdouble spek_platform_get_font_scale () { -#ifdef G_OS_DARWIN - /* Pango/Quartz fonts are smaller than on X. */ - return 1.4; -#endif - return 1.0; -} diff --git a/src/spek-platform.cc b/src/spek-platform.cc @@ -37,6 +37,15 @@ wxString SpekPlatform::ConfigPath(const wxString& app_name) return file_name.GetFullPath(); } +bool SpekPlatform::CanChangeLanguage() +{ +#ifdef OS_UNIX + return false; +#else + return true; +#endif +} + char * spek_platform_short_path(const char *path) { #ifdef OS_WIN diff --git a/src/spek-platform.hh b/src/spek-platform.hh @@ -27,6 +27,10 @@ class SpekPlatform public: // Not quite XDG-compatible, but close enough. static wxString ConfigPath(const wxString& app_name); + + // Setting non-default locale under GTK+ is tricky (see e.g. how FileZilla does it). We will + // just disable the language setting for GTK+ users and will always use the system locale. + static bool CanChangeLanguage(); }; extern "C" { diff --git a/src/spek.cc b/src/spek.cc @@ -19,6 +19,7 @@ #include <wx/cmdline.h> #include <wx/log.h> +#include "spek-audio.h" #include "spek-preferences.hh" #include "spek-window.hh" @@ -36,6 +37,7 @@ IMPLEMENT_APP(Spek) bool Spek::OnInit() { SpekPreferences::Get().Init(); + spek_audio_init(); if (!wxApp::OnInit()) { return false; diff --git a/src/spek.vala b/src/spek.vala @@ -1,39 +0,0 @@ -/* spek.vala - * - * Copyright (C) 2010-2011 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/>. - */ - -namespace Spek { - bool version = false; - [CCode (array_length = false, array_null_terminated = true)] - string[] files = null; - - int main (string[] args) { - if (Preferences.instance.language.length > 0) { - Environment.set_variable ("LANGUAGE", Preferences.instance.language, true); - } - - Audio.init (); - var file_name = files == null ? null : files[0]; - if (file_name != null && file_name.has_prefix ("file://")) { - try { - file_name = Filename.from_uri (file_name); - } catch (ConvertError e) { - } - } - return 0; - } -} -\ No newline at end of file