]> khamidou — GitHub mirrors - electron.git/commitdiff
Add libgio loader
authorCheng Zhao <zcbenz@gmail.com>
Tue, 21 Oct 2014 10:50:50 +0000 (18:50 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 21 Oct 2014 10:50:50 +0000 (18:50 +0800)
atom.gyp
atom/browser/atom_browser_main_parts.cc
atom/browser/atom_browser_main_parts.h
chromium_src/library_loaders/libgio.h [new file with mode: 0644]
chromium_src/library_loaders/libgio_loader.cc [new file with mode: 0644]
chromium_src/library_loaders/libspeechd.h [new file with mode: 0644]

index 63f7e711cfe98a82a0c57518fa3547babde37dd3..7b439cbbfe15717ac75fbaf7cd5bb5d0dac81ad0 100644 (file)
--- a/atom.gyp
+++ b/atom.gyp
@@ -96,6 +96,7 @@
       'atom/browser/atom_browser_context.h',
       'atom/browser/atom_browser_main_parts.cc',
       'atom/browser/atom_browser_main_parts.h',
+      'atom/browser/atom_browser_main_parts_linux.cc',
       'atom/browser/atom_browser_main_parts_mac.mm',
       'atom/browser/atom_javascript_dialog_manager.cc',
       'atom/browser/atom_javascript_dialog_manager.h',
       'chromium_src/chrome/renderer/printing/print_web_view_helper.h',
       'chromium_src/chrome/renderer/tts_dispatcher.cc',
       'chromium_src/chrome/renderer/tts_dispatcher.h',
+      'chromium_src/library_loaders/libgio_loader.cc',
+      'chromium_src/library_loaders/libgio.h',
       'chromium_src/library_loaders/libspeechd_loader.cc',
+      'chromium_src/library_loaders/libspeechd.h',
       '<@(native_mate_files)',
     ],
     'framework_sources': [
index b0f08cd32fa0c04db46b2332339731873c9b1754..ed04751303e89561eaaa0a7a5b0aab01e5aa3b88 100644 (file)
@@ -50,6 +50,10 @@ brightray::BrowserContext* AtomBrowserMainParts::CreateBrowserContext() {
 void AtomBrowserMainParts::PostEarlyInitialization() {
   brightray::BrowserMainParts::PostEarlyInitialization();
 
+#if defined(USE_X11)
+  SetDPIFromGSettings();
+#endif
+
   // The ProxyResolverV8 has setup a complete V8 environment, in order to avoid
   // conflicts we only initialize our V8 environment after that.
   js_env_.reset(new JavascriptEnvironment);
index 4ad0185c4350507c570c7bf84c2eeca38b29d62f..82f270aa1b21bba12d6193d1fb0ea5443f8dadb8 100644 (file)
@@ -38,6 +38,10 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
 #endif
 
  private:
+#if defined(USE_X11)
+  void SetDPIFromGSettings();
+#endif
+
   scoped_ptr<Browser> browser_;
   scoped_ptr<JavascriptEnvironment> js_env_;
   scoped_ptr<NodeBindings> node_bindings_;
diff --git a/chromium_src/library_loaders/libgio.h b/chromium_src/library_loaders/libgio.h
new file mode 100644 (file)
index 0000000..f2ab880
--- /dev/null
@@ -0,0 +1,46 @@
+// This is generated file. Do not modify directly.
+// Path to the code generator: tools/generate_library_loader/generate_library_loader.py .
+
+#ifndef LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H
+#define LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H
+
+#include <gio/gio.h>
+#define LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN
+
+
+#include <string>
+
+class LibGioLoader {
+ public:
+  LibGioLoader();
+  ~LibGioLoader();
+
+  bool Load(const std::string& library_name)
+      __attribute__((warn_unused_result));
+
+  bool loaded() const { return loaded_; }
+
+  typeof(&::g_settings_new) g_settings_new;
+  typeof(&::g_settings_get_child) g_settings_get_child;
+  typeof(&::g_settings_get_string) g_settings_get_string;
+  typeof(&::g_settings_get_boolean) g_settings_get_boolean;
+  typeof(&::g_settings_get_int) g_settings_get_int;
+  typeof(&::g_settings_get_strv) g_settings_get_strv;
+  typeof(&::g_settings_list_schemas) g_settings_list_schemas;
+
+
+ private:
+  void CleanUp(bool unload);
+
+#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN)
+  void* library_;
+#endif
+
+  bool loaded_;
+
+  // Disallow copy constructor and assignment operator.
+  LibGioLoader(const LibGioLoader&);
+  void operator=(const LibGioLoader&);
+};
+
+#endif  // LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H
diff --git a/chromium_src/library_loaders/libgio_loader.cc b/chromium_src/library_loaders/libgio_loader.cc
new file mode 100644 (file)
index 0000000..e7f5085
--- /dev/null
@@ -0,0 +1,147 @@
+// This is generated file. Do not modify directly.
+// Path to the code generator: tools/generate_library_loader/generate_library_loader.py .
+
+#include "library_loaders/libgio.h"
+
+#include <dlfcn.h>
+
+// Put these sanity checks here so that they fire at most once
+// (to avoid cluttering the build output).
+#if !defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN) && !defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED)
+#error neither LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN nor LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED defined
+#endif
+#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN) && defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED)
+#error both LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN and LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED defined
+#endif
+
+LibGioLoader::LibGioLoader() : loaded_(false) {
+}
+
+LibGioLoader::~LibGioLoader() {
+  CleanUp(loaded_);
+}
+
+bool LibGioLoader::Load(const std::string& library_name) {
+  if (loaded_)
+    return false;
+
+#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN)
+  library_ = dlopen(library_name.c_str(), RTLD_LAZY);
+  if (!library_)
+    return false;
+#endif
+
+
+#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN)
+  g_settings_new =
+      reinterpret_cast<typeof(this->g_settings_new)>(
+          dlsym(library_, "g_settings_new"));
+#endif
+#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED)
+  g_settings_new = &::g_settings_new;
+#endif
+  if (!g_settings_new) {
+    CleanUp(true);
+    return false;
+  }
+
+#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN)
+  g_settings_get_child =
+      reinterpret_cast<typeof(this->g_settings_get_child)>(
+          dlsym(library_, "g_settings_get_child"));
+#endif
+#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED)
+  g_settings_get_child = &::g_settings_get_child;
+#endif
+  if (!g_settings_get_child) {
+    CleanUp(true);
+    return false;
+  }
+
+#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN)
+  g_settings_get_string =
+      reinterpret_cast<typeof(this->g_settings_get_string)>(
+          dlsym(library_, "g_settings_get_string"));
+#endif
+#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED)
+  g_settings_get_string = &::g_settings_get_string;
+#endif
+  if (!g_settings_get_string) {
+    CleanUp(true);
+    return false;
+  }
+
+#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN)
+  g_settings_get_boolean =
+      reinterpret_cast<typeof(this->g_settings_get_boolean)>(
+          dlsym(library_, "g_settings_get_boolean"));
+#endif
+#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED)
+  g_settings_get_boolean = &::g_settings_get_boolean;
+#endif
+  if (!g_settings_get_boolean) {
+    CleanUp(true);
+    return false;
+  }
+
+#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN)
+  g_settings_get_int =
+      reinterpret_cast<typeof(this->g_settings_get_int)>(
+          dlsym(library_, "g_settings_get_int"));
+#endif
+#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED)
+  g_settings_get_int = &::g_settings_get_int;
+#endif
+  if (!g_settings_get_int) {
+    CleanUp(true);
+    return false;
+  }
+
+#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN)
+  g_settings_get_strv =
+      reinterpret_cast<typeof(this->g_settings_get_strv)>(
+          dlsym(library_, "g_settings_get_strv"));
+#endif
+#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED)
+  g_settings_get_strv = &::g_settings_get_strv;
+#endif
+  if (!g_settings_get_strv) {
+    CleanUp(true);
+    return false;
+  }
+
+#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN)
+  g_settings_list_schemas =
+      reinterpret_cast<typeof(this->g_settings_list_schemas)>(
+          dlsym(library_, "g_settings_list_schemas"));
+#endif
+#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED)
+  g_settings_list_schemas = &::g_settings_list_schemas;
+#endif
+  if (!g_settings_list_schemas) {
+    CleanUp(true);
+    return false;
+  }
+
+
+  loaded_ = true;
+  return true;
+}
+
+void LibGioLoader::CleanUp(bool unload) {
+#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN)
+  if (unload) {
+    dlclose(library_);
+    library_ = NULL;
+  }
+#endif
+  loaded_ = false;
+  g_settings_new = NULL;
+  g_settings_get_child = NULL;
+  g_settings_get_string = NULL;
+  g_settings_get_boolean = NULL;
+  g_settings_get_int = NULL;
+  g_settings_get_strv = NULL;
+  g_settings_list_schemas = NULL;
+
+}
diff --git a/chromium_src/library_loaders/libspeechd.h b/chromium_src/library_loaders/libspeechd.h
new file mode 100644 (file)
index 0000000..11afa33
--- /dev/null
@@ -0,0 +1,52 @@
+// This is generated file. Do not modify directly.
+// Path to the code generator: tools/generate_library_loader/generate_library_loader.py .
+
+#ifndef LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H
+#define LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H
+
+#include "third_party/speech-dispatcher/libspeechd.h"
+#define LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN
+
+
+#include <string>
+
+class LibSpeechdLoader {
+ public:
+  LibSpeechdLoader();
+  ~LibSpeechdLoader();
+
+  bool Load(const std::string& library_name)
+      __attribute__((warn_unused_result));
+
+  bool loaded() const { return loaded_; }
+
+  typeof(&::spd_open) spd_open;
+  typeof(&::spd_say) spd_say;
+  typeof(&::spd_stop) spd_stop;
+  typeof(&::spd_close) spd_close;
+  typeof(&::spd_pause) spd_pause;
+  typeof(&::spd_resume) spd_resume;
+  typeof(&::spd_set_notification_on) spd_set_notification_on;
+  typeof(&::spd_set_voice_rate) spd_set_voice_rate;
+  typeof(&::spd_set_voice_pitch) spd_set_voice_pitch;
+  typeof(&::spd_list_synthesis_voices) spd_list_synthesis_voices;
+  typeof(&::spd_set_synthesis_voice) spd_set_synthesis_voice;
+  typeof(&::spd_list_modules) spd_list_modules;
+  typeof(&::spd_set_output_module) spd_set_output_module;
+
+
+ private:
+  void CleanUp(bool unload);
+
+#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
+  void* library_;
+#endif
+
+  bool loaded_;
+
+  // Disallow copy constructor and assignment operator.
+  LibSpeechdLoader(const LibSpeechdLoader&);
+  void operator=(const LibSpeechdLoader&);
+};
+
+#endif  // LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H