mirror of
https://github.com/alexkay/spek.git
synced 2025-04-19 09:57:41 +03:00
SpekPlatform::CanChangeLanguage() + spek_audio_init()
This commit is contained in:
parent
d9ed0de8ab
commit
44cb6f587d
@ -24,6 +24,7 @@ spek_CFLAGS = \
|
||||
@CFLAGS@
|
||||
|
||||
spek_CXXFLAGS = \
|
||||
$(SPEK_CFLAGS) \
|
||||
@CXXFLAGS@
|
||||
|
||||
spek_LDADD = \
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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" {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user