summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-01-09 20:05:06 +0000
committerDavid Robillard <d@drobilla.net>2015-01-09 20:05:06 +0000
commit4067bd81444736ddd7047210e2afdaaf9eaeaf40 (patch)
tree5cd70895cc5f4247996c321e044dfec7d063e9c7
parent1dff3fea90f2dc43a8bfc782eb88512344c1b5ae (diff)
downloadpatchage-4067bd81444736ddd7047210e2afdaaf9eaeaf40.tar.gz
patchage-4067bd81444736ddd7047210e2afdaaf9eaeaf40.tar.bz2
patchage-4067bd81444736ddd7047210e2afdaaf9eaeaf40.zip
Fix OSX integration.
git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@5504 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--osx/Info.plist.in8
-rwxr-xr-xosx/bundleify.sh25
-rw-r--r--osx/fonts.conf150
-rw-r--r--osx/gtkrc275
-rw-r--r--osx/pango.modules4
-rw-r--r--src/Patchage.cpp10
-rw-r--r--src/UIFile.hpp7
-rw-r--r--src/binary_location.h19
-rw-r--r--src/main.cpp38
-rw-r--r--wscript12
10 files changed, 280 insertions, 268 deletions
diff --git a/osx/Info.plist.in b/osx/Info.plist.in
index 2c98497..9fb93c4 100644
--- a/osx/Info.plist.in
+++ b/osx/Info.plist.in
@@ -26,6 +26,14 @@
<dict>
<key>DYLD_LIBRARY_PATH</key>
<string>lib</string>
+ <key>GTK_PATH</key>
+ <string>lib</string>
+ <key>FONTCONFIG_FILE</key>
+ <string>Resources/fonts.conf</string>
+ <key>PANGO_RC_FILE</key>
+ <string>Resources/pangorc</string>
+ <key>GTK2_RC_FILES</key>
+ <string>Resources/gtkrc</string>
</dict>
</dict>
</plist>
diff --git a/osx/bundleify.sh b/osx/bundleify.sh
index 220eb78..75bb030 100755
--- a/osx/bundleify.sh
+++ b/osx/bundleify.sh
@@ -1,18 +1,27 @@
#!/bin/sh
-bundle=$1
-exe=$2
+if [ "$#" != 3 ]; then
+ echo "USAGE: $0 LIB_PREFIX BUNDLE EXE";
+ exit 1;
+fi
+
+prefix=$1
+bundle=$2
+exe=$3
mkdir -p "$bundle/Contents/lib"
-mkdir -p "$bundle/Contents/lib/engines"
-mkdir -p "$bundle/Contents/lib/modules"
# Replace Control with Command in key bindings
sed -i '' 's/GDK_CONTROL_MASK/GDK_META_MASK/' $bundle/Contents/patchage.ui
+# Copy font configuration files
+cp $prefix/etc/fonts/fonts.conf $bundle/Contents/Resources
+
# Copy GTK and pango modules to bundle
-cp /usr/local/lib/gtk-2.0/2.10.0/engines/libquartz.so $bundle/Contents/lib/engines
-cp /opt/local/lib/pango/1.6.0/modules/*basic*.so $bundle/Contents/lib/modules
+mkdir -p "$bundle/Contents/lib/modules"
+mkdir -p "$bundle/Contents/lib/gtk-2.0/engines"
+cp $prefix/lib/gtk-2.0/2.10.0/engines/libquartz.so $bundle/Contents/lib/gtk-2.0/engines
+cp $prefix/lib/pango/1.8.0/modules/*basic*.so $bundle/Contents/lib/modules
# Copy libraries depended on by the executable to bundle
libs="`otool -L $exe | grep '\.dylib\|\.so' | grep '/User\|/opt/local\|/usr/local' | sed 's/(.*//'`"
@@ -21,13 +30,13 @@ for l in $libs; do
done
# Add libraries depended on by those libraries
-reclibs="`otool -L $bundle/Contents/lib/* $bundle/Contents/lib/engines/* $bundle/Contents/lib/modules/* | grep '\.dylib\|\.so' | grep '/User\|/opt/local\|/usr/local' | sed 's/(.*//'`"
+reclibs="`otool -L $bundle/Contents/lib/* $bundle/Contents/lib/gtk-2.0/engines/* $bundle/Contents/lib/modules/* | grep '\.dylib\|\.so' | grep \"$prefix\|/User\|/opt/local\|/usr/local\" | sed 's/(.*//'`"
for l in $reclibs; do
cp $l $bundle/Contents/lib
done
# ... and libraries depended on by those libraries (yes, this should be done more sanely)
-recreclibs="`otool -L $bundle/Contents/lib/* $bundle/Contents/lib/engines/* $bundle/Contents/lib/modules/* | grep '\.dylib\|\.so' | grep '/User\|/opt/local\|/usr/local' | sed 's/(.*//'`"
+recreclibs="`otool -L $bundle/Contents/lib/* $bundle/Contents/lib/gtk-2.0/engines/* $bundle/Contents/lib/modules/* | grep '\.dylib\|\.so' | grep \"$prefix\|/User\|/opt/local\|/usr/local\" | sed 's/(.*//'`"
for l in $recreclibs; do
cp $l $bundle/Contents/lib
done
diff --git a/osx/fonts.conf b/osx/fonts.conf
deleted file mode 100644
index 766e742..0000000
--- a/osx/fonts.conf
+++ /dev/null
@@ -1,150 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
-<!-- /etc/fonts/fonts.conf file to configure system font access -->
-<fontconfig>
-
-<!--
- DO NOT EDIT THIS FILE.
- IT WILL BE REPLACED WHEN FONTCONFIG IS UPDATED.
- LOCAL CHANGES BELONG IN 'local.conf'.
-
- The intent of this standard configuration file is to be adequate for
- most environments. If you have a reasonably normal environment and
- have found problems with this configuration, they are probably
- things that others will also want fixed. Please submit any
- problems to the fontconfig bugzilla system located at fontconfig.org
-
- Note that the normal 'make install' procedure for fontconfig is to
- replace any existing fonts.conf file with the new version. Place
- any local customizations in local.conf which this file references.
-
- Keith Packard
--->
-
-<!-- Font directory list -->
-
- <dir>~/Library/Fonts</dir>
- <dir>~/.fonts</dir>
- <dir>/Library/Fonts</dir>
- <dir>/System/Library/Fonts</dir>
-
-<!-- Font cache directory list -->
-
- <cachedir>~/.fontconfig</cachedir>
-
-<!--
- Accept deprecated 'mono' alias, replacing it with 'monospace'
--->
- <match target="pattern">
- <test qual="any" name="family">
- <string>mono</string>
- </test>
- <edit name="family" mode="assign">
- <string>monospace</string>
- </edit>
- </match>
-
-<!--
- Accept alternate 'sans serif' spelling, replacing it with 'sans-serif'
--->
- <match target="pattern">
- <test qual="any" name="family">
- <string>sans serif</string>
- </test>
- <edit name="family" mode="assign">
- <string>sans-serif</string>
- </edit>
- </match>
-
-<!--
- Accept deprecated 'sans' alias, replacing it with 'sans-serif'
--->
- <match target="pattern">
- <test qual="any" name="family">
- <string>sans</string>
- </test>
- <edit name="family" mode="assign">
- <string>sans-serif</string>
- </edit>
- </match>
-
-<!--
- Load local system customization file
--->
- <include ignore_missing="yes">conf.d</include>
-
- <config>
-<!--
- These are the default Unicode chars that are expected to be blank
- in fonts. All other blank chars are assumed to be broken and
- won't appear in the resulting charsets
- -->
- <blank>
- <int>0x0020</int> <!-- SPACE -->
- <int>0x00A0</int> <!-- NO-BREAK SPACE -->
- <int>0x00AD</int> <!-- SOFT HYPHEN -->
- <int>0x034F</int> <!-- COMBINING GRAPHEME JOINER -->
- <int>0x0600</int> <!-- ARABIC NUMBER SIGN -->
- <int>0x0601</int> <!-- ARABIC SIGN SANAH -->
- <int>0x0602</int> <!-- ARABIC FOOTNOTE MARKER -->
- <int>0x0603</int> <!-- ARABIC SIGN SAFHA -->
- <int>0x06DD</int> <!-- ARABIC END OF AYAH -->
- <int>0x070F</int> <!-- SYRIAC ABBREVIATION MARK -->
- <int>0x115F</int> <!-- HANGUL CHOSEONG FILLER -->
- <int>0x1160</int> <!-- HANGUL JUNGSEONG FILLER -->
- <int>0x1680</int> <!-- OGHAM SPACE MARK -->
- <int>0x17B4</int> <!-- KHMER VOWEL INHERENT AQ -->
- <int>0x17B5</int> <!-- KHMER VOWEL INHERENT AA -->
- <int>0x180E</int> <!-- MONGOLIAN VOWEL SEPARATOR -->
- <int>0x2000</int> <!-- EN QUAD -->
- <int>0x2001</int> <!-- EM QUAD -->
- <int>0x2002</int> <!-- EN SPACE -->
- <int>0x2003</int> <!-- EM SPACE -->
- <int>0x2004</int> <!-- THREE-PER-EM SPACE -->
- <int>0x2005</int> <!-- FOUR-PER-EM SPACE -->
- <int>0x2006</int> <!-- SIX-PER-EM SPACE -->
- <int>0x2007</int> <!-- FIGURE SPACE -->
- <int>0x2008</int> <!-- PUNCTUATION SPACE -->
- <int>0x2009</int> <!-- THIN SPACE -->
- <int>0x200A</int> <!-- HAIR SPACE -->
- <int>0x200B</int> <!-- ZERO WIDTH SPACE -->
- <int>0x200C</int> <!-- ZERO WIDTH NON-JOINER -->
- <int>0x200D</int> <!-- ZERO WIDTH JOINER -->
- <int>0x200E</int> <!-- LEFT-TO-RIGHT MARK -->
- <int>0x200F</int> <!-- RIGHT-TO-LEFT MARK -->
- <int>0x2028</int> <!-- LINE SEPARATOR -->
- <int>0x2029</int> <!-- PARAGRAPH SEPARATOR -->
- <int>0x202A</int> <!-- LEFT-TO-RIGHT EMBEDDING -->
- <int>0x202B</int> <!-- RIGHT-TO-LEFT EMBEDDING -->
- <int>0x202C</int> <!-- POP DIRECTIONAL FORMATTING -->
- <int>0x202D</int> <!-- LEFT-TO-RIGHT OVERRIDE -->
- <int>0x202E</int> <!-- RIGHT-TO-LEFT OVERRIDE -->
- <int>0x202F</int> <!-- NARROW NO-BREAK SPACE -->
- <int>0x205F</int> <!-- MEDIUM MATHEMATICAL SPACE -->
- <int>0x2060</int> <!-- WORD JOINER -->
- <int>0x2061</int> <!-- FUNCTION APPLICATION -->
- <int>0x2062</int> <!-- INVISIBLE TIMES -->
- <int>0x2063</int> <!-- INVISIBLE SEPARATOR -->
- <int>0x206A</int> <!-- INHIBIT SYMMETRIC SWAPPING -->
- <int>0x206B</int> <!-- ACTIVATE SYMMETRIC SWAPPING -->
- <int>0x206C</int> <!-- INHIBIT ARABIC FORM SHAPING -->
- <int>0x206D</int> <!-- ACTIVATE ARABIC FORM SHAPING -->
- <int>0x206E</int> <!-- NATIONAL DIGIT SHAPES -->
- <int>0x206F</int> <!-- NOMINAL DIGIT SHAPES -->
- <int>0x3000</int> <!-- IDEOGRAPHIC SPACE -->
- <int>0x3164</int> <!-- HANGUL FILLER -->
- <int>0xFEFF</int> <!-- ZERO WIDTH NO-BREAK SPACE -->
- <int>0xFFA0</int> <!-- HALFWIDTH HANGUL FILLER -->
- <int>0xFFF9</int> <!-- INTERLINEAR ANNOTATION ANCHOR -->
- <int>0xFFFA</int> <!-- INTERLINEAR ANNOTATION SEPARATOR -->
- <int>0xFFFB</int> <!-- INTERLINEAR ANNOTATION TERMINATOR -->
- </blank>
-<!--
- Rescan configuration every 30 seconds when FcFontSetList is called
- -->
- <rescan>
- <int>30</int>
- </rescan>
- </config>
-
-</fontconfig>
diff --git a/osx/gtkrc b/osx/gtkrc
index ba7477b..d3ae142 100644
--- a/osx/gtkrc
+++ b/osx/gtkrc
@@ -1,75 +1,248 @@
-# FIXME: What sizes should we have?
-gtk-icon-sizes = "gtk-menu=16,16:gtk-small-toolbar=16,16:gtk-large-toolbar=24,24:gtk-dnd=32,32"
-gtk-toolbar-icon-size = small-toolbar
+gtk-color-scheme =
+"bg_color: #f5f5f5
+fg_color: #000
+base_color: #fff
+text_color: #000
+selected_bg_color: #0066FF
+selected_fg_color: #fff
+tooltip_bg_color: #fafaba
+tooltip_fg_color: #000"
+
+gtk-button-images = 0
+gtk-menu-images = 0
+gtk-toolbar-style = 0
+gtk-enable-mnemonics = 0
+gtk-icon-sizes = "gtk-small-toolbar=16,16:gtk-large-toolbar=22,22"
+gtk-toolbar-icon-size = large-toolbar
+gtk-error-bell = 0
+gtk-show-input-method-menu = 0
+
+style "default"
+{
+ bg[NORMAL] = @bg_color
+ bg[PRELIGHT] = @bg_color
+ bg[SELECTED] = @selected_bg_color
+ bg[INSENSITIVE] = @bg_color
+ bg[ACTIVE] = @bg_color
+
+ fg[NORMAL] = @fg_color
+ fg[PRELIGHT] = @fg_color
+ fg[SELECTED] = @selected_fg_color
+ fg[INSENSITIVE] = darker (@bg_color)
+ fg[ACTIVE] = @fg_color
+
+ text[NORMAL] = @text_color
+ text[PRELIGHT] = @text_color
+ text[SELECTED] = @selected_fg_color
+ text[INSENSITIVE] = darker (@bg_color)
+ text[ACTIVE] = @text_color
+
+ base[NORMAL] = @base_color
+ base[PRELIGHT] = @selected_bg_color
+ base[SELECTED] = @selected_bg_color
+ base[INSENSITIVE] = @bg_color
+ base[ACTIVE] = shade (1.3, @selected_bg_color)
+
+ GtkWidget::interior-focus = 1
+ GtkWidget::new-tooltip-style = 1
+ GtkWidget::focus-line-width = 0
+ GtkWidget::focus-padding = 0
+ GtkButton::default-border = { 1, 1, 1, 1 }
+ GtkButton::default-outside-border = { 1, 1, 1, 1 }
+ GtkButton::child-displacement-x = 0
+ GtkButton::child-displacement-y = 0
+ GtkCheckButton::indicator-spacing = 3
+ GtkSpinButton::shadow-type = out
+ GtkButtonBox::child-min-width = 70
+ GtkButtonBox::child-min-height = 22
+ GtkComboBox::appears-as-list = 0
+ GtkComboBox::focus-on-click = 0
+ GtkNotebook::tab-curvature = 4
+ GtkNotebook::tab-overlap = 0
+ GtkTreeView::allow-rules = 1
+ GtkTreeView::expander-size = 14
+ GtkToolbar::internal-padding = 3
+ GtkExpander::expander-size = 14
+ GtkScrolledWindow::scrollbar-spacing = 0
+ GtkMenuItem::horizontal-padding = 8
+ GtkMenu::vertical-padding = 4
+ GtkMenuItem::horizontal-padding = 9
+ GtkMenuItem::toggle-spacing = 0
+ GtkSeparatorMenuItem::horizontal-padding = 2
+ GtkSeparatorMenuItem::horizontal-padding = 2
+ GtkScrollbar::min-slider-length = 10
+ GtkScrollbar::has-forward-stepper = 1
+ GtkScrollbar::has-backward-stepper = 0
+ GtkScrollbar::has-secondary-forward-stepper = 0
+ GtkScrollbar::has-secondary-backward-stepper = 1
+ GtkRange::trough-border = 0
+ GtkRange::stepper-spacing = 0
+ GtkRange::stepper-size = 14
+ GtkRange::trough-under-steppers = 1
+
+ engine "quartz"
+ {
+ buttontype = "aqua"
+ }
+}
+
+style "wider"
+{
+ xthickness = 3
+ ythickness = 3
+}
+
+style "scrolled-window"
+{
+ xthickness = 1
+ ythickness = 1
+}
+
+style "menu"
+{
+ xthickness = 0
+ ythickness = 0
+ font_name = "Lucida Grande 14"
+
+ bg[PRELIGHT] = @selected_fg_color
+ fg[PRELIGHT] = @selected_fg_color
+ text[PRELIGHT] = @selected_fg_color
+}
+
+style "menu-item" = "menu"
+{
+ ythickness = 2
+ GtkWidget::draw-border = { 0, 0, 0, 2 }
+}
+
+style "menu-separator" = "menu-item"
+{
+ ythickness = 3
+}
+
+style "menu-bar"
+{
+ ythickness = 0
+ xthickness = 0
+}
+
+style "treeview"
+{
+ GtkTreeView::odd-row-color = "#f5f5f5"
+
+ base[SELECTED] = "#2b5dcd"
+ base[ACTIVE] = "#cacaca"
+ text[SELECTED] = "#FFF"
+ text[ACTIVE] = "#000"
+
+ font_name = "Lucida Grande 12"
-gtk_color_scheme = "fg_color:#000\nbg_color:ededed\nbase_color:#fff\ntext_color:#1A1A1A\nselected_bg_color:#86ABD9\nselected_fg_color:#fff\ntooltip_bg_color:#F5F5B5\ntooltip_fg_color:#000"
+ GtkWidget::focus-line-width = 0
+ GtkWidget::draw-border = { 1, 1, 1, 1 }
+ GtkButton::inner-border = { 3, 3, 1, 3 }
+}
-gtk-button-images = 0
-gtk-menu-images = 0
-gtk-enable-mnemonics = 0
+style "tree-header"
+{
+ ythickness = 0
+ bg[NORMAL] = "#f2f2f2"
-style "quartz-default"
+ font_name = "Lucida Grande 11"
+}
+
+style "tooltip"
{
- xthickness = 0
- ythickness = 0
+ xthickness = 5
+ ythickness = 5
- GtkWidget::interior-focus = 1
- GtkWidget::focus-line-width = 0
- GtkWidget::focus-padding = 0
+ fg[NORMAL] = @tooltip_fg_color
+ bg[NORMAL] = @tooltip_bg_color
+}
- GtkButton::default-border = { 0, 0, 0, 0 }
- GtkButton::default-outside-border = { 0, 0, 0, 0 }
- GtkButton::child-displacement-x = 0
- GtkButton::child-displacement-y = 0
+style "scrollbar"
+{
+ GtkScrollbar::has-forward-stepper = 0
+ GtkScrollbar::has-backward-stepper = 0
+ GtkRange::slider-width = 15
+ GtkRange::trough-border = 0
+ GtkRange::trough-side-details = 0
+}
- GtkCheckButton::indicator-spacing = 3
+style "button"
+{
+ xthickness = 2
+ ythickness = 2
- #GtkOptionMenu::indicator-size = { 9, 5 }
- #GtkOptionMenu::indicator-spacing = { 7, 5, 2, 2 }
+ bg[NORMAL] = @bg_color
+ bg[PRELIGHT] = shade(1.1, @bg_color)
+ bg[ACTIVE] = @bg_color
+ bg[INSENSITIVE] = @bg_color
- # We have to set a shadow to get the whole box exposed
- GtkSpinButton::shadow-type = out
+ GtkWidget::draw-border = { 2, 2, 2, 2 }
+ GtkWidget::focus-line-width = 1
+}
- GtkComboBox::appears-as-list = 0
- GtkComboBox::focus-on-click = 0
+style "combo-box"
+{
+ fg[NORMAL] = "#616161"
+ #xthickness = 2
+ #ythickness = 2
+}
- GtkNotebook::tab-curvature = 4
- GtkNotebook::tab-overlap = 0
-
- GtkTreeView::allow-rules = 1
- GtkTreeView::expander-size = 14
- GtkToolbar::internal-padding = 3
- GtkExpander::expander-size = 14
+style "combo-box-button"
+{
+ xthickness = 6
+ ythickness = 2
- GtkScrolledWindow::scrollbar-spacing = 0
+ bg[NORMAL] = @base_color
+ bg[PRELIGHT] = shade(1.1, @base_color)
+ bg[ACTIVE] = @base_color
+ bg[INSENSITIVE] = @base_color
- #GtkMenuItem::toggle-spacing = ...
- GtkMenuItem::horizontal-padding = 8
- GtkSeparatorMenuItem::horizontal-padding = 2
+ GtkWidget::focus-padding = 0
+}
- engine "quartz"
- {
- }
+style "combo-box-label" = "combo-box"
+{
+ fg[NORMAL] = "#595959"
}
-class "*" style "quartz-default"
-style "quartz-toolbar"
+style "small-font"
{
- xthickness = 3
- ythickness = 3
+ font_name = "Lucida Grande 11"
}
-widget_class "*Toolbar*" style "quartz-toolbar"
-style "quartz-frame"
+style "mini-font"
{
- xthickness = 2
- ythickness = 2
+ font_name = "Lucida Grande 9"
}
-widget_class "*.<GtkFrame>" style "quartz-frame"
-style "quartz-scrolled-window"
+style "entry"
{
- xthickness = 2
- ythickness = 2
+ xthickness = 2
+ ythickness = 2
+ GtkEntry::inner-border = { 2, 2, 2, 2 }
+ base[INSENSITIVE] = shade(1.02, @bg_color)
}
-widget_class "*.<GtkScrolledWindow>" style "quartz-scrolled-window"
+
+class "GtkWidget" style "default"
+class "GtkMenuBar" style "menu-bar"
+class "GtkScrolledWindow" style "scrolled-window"
+class "GtkFrame" style "wider"
+class "GtkScrollbar" style "scrollbar"
+class "GtkEntry" style "entry"
+class "GtkButton" style "button"
+
+widget "gtk-tooltip*" style "tooltip"
+widget "*small-font*" style "small-font"
+widget "*mini-font*" style "mini-font"
+
+widget_class "*<GtkMenu>*" style "menu"
+widget_class "*<GtkMenuItem>*" style "menu-item"
+widget_class "*<GtkSeparatorMenuItem>" style "menu-separator"
+/*widget "*.gtk-combobox-popup-menu*" style "combo-box-menu"*/
+widget_class "*.<GtkTreeView>*" style "treeview"
+widget_class "*.GtkTreeView.GtkButton" style "tree-header"
+widget_class "*.<GtkComboBox>.*" style "combo-box"
+widget_class "*.<GtkComboBoxText>.<GtkToggleButton>" style "combo-box-button"
+widget_class "*.<GtkComboBoxEntry>.<GtkToggleButton>" style "combo-box-button"
diff --git a/osx/pango.modules b/osx/pango.modules
index 108291e..d981ee2 100644
--- a/osx/pango.modules
+++ b/osx/pango.modules
@@ -1,2 +1,2 @@
-lib/modules/pango-basic-atsui.so BasicScriptEngineATSUI PangoEngineShape PangoRenderATSUI common:
-lib/modules/pango-basic-fc.so BasicScriptEngineFc PangoEngineShape PangoRenderFc latin:* cyrillic:* greek:* armenian:* georgian:* runic:* ogham:* bopomofo:* cherokee:* coptic:* deseret:* ethiopic:* gothic:* han:* hiragana:* katakana:* old-italic:* canadian-aboriginal:* yi:* braille:* cypriot:* limbu:* osmanya:* shavian:* linear-b:* ugaritic:* glagolitic:* cuneiform:* phoenician:* common:
+lib/modules/pango-basic-coretext.so BasicScriptEngineCoreText PangoEngineShape PangoRenderCoreText common:
+lib/modules/pango-basic-fc.so BasicScriptEngineFc PangoEngineShape PangoRenderFc common:
diff --git a/src/Patchage.cpp b/src/Patchage.cpp
index 85a3bdf..d561feb 100644
--- a/src/Patchage.cpp
+++ b/src/Patchage.cpp
@@ -295,15 +295,15 @@ Patchage::Patchage(int argc, char** argv)
#ifdef PATCHAGE_GTK_OSX
// Set up Mac menu bar
- GtkOSXApplication* osxapp;
- gtk_osxapplication_ready(osxapp);
-
+ GtkosxApplication* osxapp = (GtkosxApplication*)g_object_new(
+ GTKOSX_TYPE_APPLICATION, NULL);
_menubar->hide();
- gtk_osxapplication_set_menu_bar(osxapp, GTK_MENU_SHELL(_menubar->gobj()));
- gtk_osxapplication_insert_app_menu_item(
+ gtkosx_application_set_menu_bar(osxapp, GTK_MENU_SHELL(_menubar->gobj()));
+ gtkosx_application_insert_app_menu_item(
osxapp, GTK_WIDGET(_menu_help_about->gobj()), 0);
g_signal_connect(_menubar->gobj(), "can-activate-accel",
G_CALLBACK(can_activate_cb), NULL);
+ gtkosx_application_ready(osxapp);
#endif
}
diff --git a/src/UIFile.hpp b/src/UIFile.hpp
index a9ff0d5..561cb0f 100644
--- a/src/UIFile.hpp
+++ b/src/UIFile.hpp
@@ -40,14 +40,11 @@ public:
static Glib::RefPtr<Gtk::Builder> open(const std::string& base_name) {
std::string ui_filename;
- char* loc = NULL;
#ifdef PATCHAGE_BINLOC
- loc = binary_location();
- if (loc) {
- std::string bundle = loc;
+ std::string bundle = binary_location();
+ if (!bundle.empty()) {
bundle = bundle.substr(0, bundle.find_last_of("/"));
ui_filename = bundle + "/" + base_name + ".ui";
- free(loc);
if (is_readable(ui_filename)) {
std::cout << "Loading UI file " << ui_filename << std::endl;
return Gtk::Builder::create_from_file(ui_filename);
diff --git a/src/binary_location.h b/src/binary_location.h
index 995f17f..91e8b29 100644
--- a/src/binary_location.h
+++ b/src/binary_location.h
@@ -23,20 +23,21 @@
#include <stdlib.h>
#include <dlfcn.h>
-/** Return the absolute path of the binary.
- * Returned value must be freed by caller.
- */
-static char*
+#include <string>
+
+/** Return the absolute path of the binary. */
+static std::string
binary_location()
{
- Dl_info dli;
+ Dl_info dli;
+ std::string loc;
const int ret = dladdr((void*)&binary_location, &dli);
if (ret) {
char* const bin_loc = (char*)calloc(PATH_MAX, 1);
- if (!realpath(dli.dli_fname, bin_loc)) {
- return NULL;
+ if (realpath(dli.dli_fname, bin_loc)) {
+ loc = bin_loc;
}
- return bin_loc;
+ free(bin_loc);
}
- return NULL;
+ return loc;
}
diff --git a/src/main.cpp b/src/main.cpp
index b9e0bb3..0e870b9 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -28,42 +28,16 @@
#include "Patchage.hpp"
-#ifdef __APPLE__
-void
-set_bundle_environment()
-{
- char* binloc_c = binary_location();
- std::string binloc(binloc_c);
- free(binloc_c);
-
- const std::string bundle_path = binloc.substr(0, binloc.find_last_of('/'));
-
- const std::string lib_path(bundle_path + "/lib");
- setenv("GTK_PATH", lib_path.c_str(), 1);
- setenv("DYLD_LIBRARY_PATH", lib_path.c_str(), 1);
-
- chdir(bundle_path.c_str());
- const std::string pangorc_path(bundle_path + "/Resources/pangorc");
- setenv("PANGO_RC_FILE", pangorc_path.c_str(), 1);
-
- const std::string fonts_conf_path(bundle_path + "/Resources/fonts.conf");
- setenv("FONTCONFIG_FILE", fonts_conf_path.c_str(), 1);
-
- const char* path_c = getenv("PATH");
- std::string path = "/opt/local/bin";
- if (path_c)
- path += std::string(":") + path_c;
- setenv("PATH", path.c_str(), 1);
-
- gtk_rc_parse((bundle_path + "/Resources/gtkrc").c_str());
-}
-#endif
-
int
main(int argc, char** argv)
{
#ifdef __APPLE__
- set_bundle_environment();
+ const std::string binary = binary_location();
+ const std::string bundle = binary.substr(0, binary.find_last_of('/'));
+ const std::string gtkrc_path = bundle + "/Resources/gtkrc";
+ if (Glib::file_test(gtkrc_path, Glib::FILE_TEST_EXISTS)) {
+ gtk_rc_parse(gtkrc_path.c_str());
+ }
#endif
try {
diff --git a/wscript b/wscript
index 5e38fda..dd20921 100644
--- a/wscript
+++ b/wscript
@@ -62,7 +62,7 @@ def configure(conf):
if conf.env.DEST_OS == 'darwin':
autowaf.check_pkg(conf, 'gtk-mac-integration', uselib_store='GTK_OSX',
- atleast_version='1.0.0', mandatory=True)
+ atleast_version='1.0.0', mandatory=False)
if conf.env.HAVE_GTK_OSX:
autowaf.define(conf, 'PATCHAGE_GTK_OSX', 1)
@@ -99,10 +99,10 @@ def configure(conf):
autowaf.define(conf, 'PATCHAGE_BINLOC', 1)
# Boost headers
- autowaf.check_header(conf, 'cxx', 'boost/format.hpp')
- autowaf.check_header(conf, 'cxx', 'boost/shared_ptr.hpp')
- autowaf.check_header(conf, 'cxx', 'boost/utility.hpp')
- autowaf.check_header(conf, 'cxx', 'boost/weak_ptr.hpp')
+ conf.check_cxx(header_name='boost/format.hpp')
+ conf.check_cxx(header_name='boost/shared_ptr.hpp')
+ conf.check_cxx(header_name='boost/utility.hpp')
+ conf.check_cxx(header_name='boost/weak_ptr.hpp')
conf.env.PATCHAGE_VERSION = PATCHAGE_VERSION
@@ -187,7 +187,7 @@ def build(bld):
target = out_base + 'Resources/Patchage.icns')
# Gtk/Pango/etc configuration files
- for i in ['pangorc', 'pango.modules', 'gtkrc', 'fonts.conf']:
+ for i in ['pangorc', 'pango.modules', 'gtkrc']:
bld(rule = 'cp ${SRC} ${TGT}',
source = 'osx/' + i,
target = out_base + 'Resources/' + i)