Skip to content

Commit

Permalink
Mojave support & jhbuild environment update
Browse files Browse the repository at this point in the history
  • Loading branch information
yousseb committed Dec 1, 2018
1 parent 75339a2 commit 13becf6
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 37 deletions.
14 changes: 14 additions & 0 deletions bin/meld
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@ if sys.executable.endswith("pythonw.exe") or sys.stdout is None:
# This allows skipping '__name__ == "main"' guard, but freezed case is special.
freeze_support()

# Auto dark theme support for Mac
gtk_theme= os.environ.get('GTK_THEME')
if gtk_theme is None:
try:
from Foundation import NSUserDefaults
standardUserDefaults = NSUserDefaults.standardUserDefaults()
if standardUserDefaults.stringForKey_("AppleInterfaceStyle") == 'Dark':
os.environ['GTK_THEME'] = "Adwaita:dark"
except:
pass
else:
os.environ['GTK_THEME'] = gtk_theme



def disable_stdout_buffering():

Expand Down
12 changes: 9 additions & 3 deletions meld/meldwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from gi.repository import Gtk

import meld.ui.util
from meld.conf import _, is_darwin
from meld.conf import _
from meld.dirdiff import DirDiff
from meld.filediff import FileDiff
from meld.filemerge import FileMerge
Expand All @@ -36,6 +36,12 @@
from meld.vcview import VcView
from meld.windowstate import SavedWindowState

is_native = False
try:
from Foundation import NSUserDefaults
is_native = True
except:
pass

class MeldWindow(Component):

Expand Down Expand Up @@ -138,7 +144,7 @@ def __init__(self):

# Manually handle shells that don't show an application menu
gtk_settings = Gtk.Settings.get_default()
if not gtk_settings.props.gtk_shell_shows_app_menu or is_darwin():
if not gtk_settings.props.gtk_shell_shows_app_menu or is_native:
from meld.meldapp import app

def make_app_action(name):
Expand Down Expand Up @@ -254,7 +260,7 @@ def app_action(*args):
self.widget.connect('focus_in_event', self.on_focus_change)
self.widget.connect('focus_out_event', self.on_focus_change)

if is_darwin():
if is_native:
self.osx_ready = False
self.widget.connect('window_state_event', self.osx_menu_setup)

Expand Down
26 changes: 3 additions & 23 deletions osx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ environment proved to reduce collisions later on. You might want to consider doi
```
You can exit the shell once you determine that it works properly

3. Prepare paths and build the bootstrap
3. Prepare build environment
```
export PATH="~/.local/bin/:$PATH"
jhbuild bootstrap
brew install ccache
(cd osx && ./build_env.sh)
```

4. Checkout meld and start the initial phase
Expand All @@ -62,27 +63,6 @@ environment proved to reduce collisions later on. You might want to consider doi
```

#### Building Meld ####

This can probably be done in the meld.modules file. Unfortunately I don't have
the time to fix the order/dependencies. So let's do it one by one. The following
is the list of the exact steps followed during the build to reduce conflicts

1. Build python - with libxml2 support
```
jhbuild -m osx/meld.modules build python-withxml2
```

2. Build graphics dependencies
```
jhbuild -m osx/meld.modules build graphics-dependencies
```

3. Build the rest of meld dependencies (rebuilding previous dependencies as well)
```
jhbuild -m osx/meld.modules build meld-deps -f
```

4. You're now ready to build Meld.
```
chmod +x osx/build_app.sh
jhbuild run osx/build_app.sh
Expand Down
10 changes: 6 additions & 4 deletions osx/build_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ INSTROOT="$HOME/gtk/inst/"
cp osx/conf.py meld/conf.py

glib-compile-schemas data
python setup_py2app.py build
python setup_py2app.py py2app
python3 setup_py2app.py build
python3 setup_py2app.py py2app

# py2app copies all Python framework to target..
# too busy to figure out how to solve this at the moment. Let's just
Expand All @@ -24,6 +24,8 @@ rsync -r -t --ignore-existing $INSTROOT/share/icons/hicolor $RES/share/icons

# glib schemas
rsync -r -t $INSTROOT/share/glib-2.0/schemas $RES/share/glib-2.0
cp data/org.gnome.meld.gschema.xml $RES/share/glib-2.0/schemas
(cd $RES/share/glib-2.0 && glib-compile-schemas schemas)
rsync -r -t $INSTROOT/share/GConf/gsettings $RES/share/GConf

# pango
Expand Down Expand Up @@ -136,15 +138,15 @@ done
#done
popd


# Create the dmg file..
hdiutil create -size 250m -fs HFS+ -volname "Meld Merge" myimg.dmg
hdiutil attach myimg.dmg
DEVS=$(hdiutil attach myimg.dmg | cut -f 1)
DEV=$(echo $DEVS | cut -f 1 -d ' ')
rsync -avzh $APP /Volumes/Meld\ Merge/
pushd .
cd /Volumes/Meld\ Merge/
ln -sf /Applications "Drag Meld Here"
(cd /Volumes/Meld\ Merge/ && ln -sf /Applications "Drag Meld Here")
popd

# Compress the dmg file..
Expand Down
7 changes: 0 additions & 7 deletions osx/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ def no_translation(gettext_string, *args):
_ = no_translation
ngettext = no_translation

def is_darwin():
return True

def frozen():
global DATADIR, LOCALEDIR, DATADIR_IS_UNINSTALLED

Expand All @@ -41,10 +38,6 @@ def frozen():
lib_path = os.path.join(resource_path , "lib")
share_path = os.path.join(resource_path , "share")

# Default to Adwaita GTK Theme or override with user's environment var
gtk_theme= os.environ.get('GTK_THEME', "Adwaita")
os.environ['GTK_THEME'] = gtk_theme

# Main libraries environment variables
#dyld_library_path = os.environ.get('DYLD_LIBRARY_PATH', '').split(':')
#dyld_library_path.insert(0, lib_path)
Expand Down

0 comments on commit 13becf6

Please sign in to comment.