Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2bbf02f
Initial OSX support from the 1.8 version - definitely broken
Jun 21, 2015
34316a0
Add adwaita theme to OSX
Jun 22, 2015
da87c5c
Update readme for the master version.
Jun 28, 2015
f2996d7
Initial OSX support from the 1.8 version - definitely broken
Jun 21, 2015
e19618a
Add adwaita theme to OSX
Jun 22, 2015
6f3974a
Update readme for the master version.
Jun 28, 2015
c708c06
Update readme, build script
Jul 19, 2015
7ca54fa
Almost done packaging OSX for v3
Jul 19, 2015
a09885f
Merge branch 'master' of https://github.com/yousseb/meld
Jul 19, 2015
3956f65
Almost done packaging OSX for v3
Jul 19, 2015
1e199f2
OK, we have a package. Extremely hacky, time to cleanup
Jul 19, 2015
eda638a
We should let people test
Jul 19, 2015
40ef01b
Update build instructions
Jul 19, 2015
6d40e38
Poor man's solution to accel keys
Jul 20, 2015
554d525
We seem to be getting closer to releasing the OSX latest version.. :)
Jul 20, 2015
2c8e956
Hackish, but works..
Jul 20, 2015
966f285
Fix: Run from anywhere
Jul 20, 2015
6b19f98
Some intermediate state
yousseb Feb 13, 2016
77cbbef
We're getting close
yousseb Feb 13, 2016
988e64e
It finally workd
yousseb Feb 13, 2016
4dff479
Make README.md look pretty
yousseb Feb 13, 2016
21fe5c7
readme
yousseb Feb 13, 2016
9294240
Remove unneeded code
yousseb Feb 14, 2016
9db07b6
Merge remote-tracking branch 'upstream/master'
yousseb Feb 14, 2016
8de3597
Merge branch 'master' of https://github.com/yousseb/meld
yousseb Feb 14, 2016
2f75ce8
Readme: How to use the OSX build as git difftool
yousseb Feb 14, 2016
a970602
Update build to fix issue with crashes due to missing styles in OSX i…
yousseb Feb 19, 2016
a2fdbfe
Allow the user to set the GTK theme from enironment variable
yousseb Feb 19, 2016
eef5fea
Fix typos in the OS X README
dguo Feb 21, 2016
0934072
Merge pull request #8 from dguo/patch-1
yousseb Feb 21, 2016
8d29d11
Only DYLD_LIBRARY_PATH environment variable is missing to completely …
yousseb Feb 27, 2016
f559e61
Merge branch 'master' of https://github.com/yousseb/meld
yousseb Feb 27, 2016
913c0d5
We can build and run again... Switching to Python wrapper and back to…
yousseb Apr 22, 2016
89c54d3
Merge remote-tracking branch 'upstream/master'
yousseb Apr 22, 2016
3a9bab9
Update version string in our build, too
yousseb Apr 22, 2016
8584d37
Handle all args
yousseb Apr 22, 2016
2b1fa36
Bug fix to make paths relative to PWD in MacOS app
nickie Apr 23, 2016
f84697c
Merge pull request #16 from nickie/fix-rel-paths
yousseb Apr 23, 2016
6de1f4c
i18n for OSX prepared.. Need to include the mo files in the package now
yousseb Apr 23, 2016
417a58f
Merge remote-tracking branch 'upstream/master'
yousseb May 4, 2016
457c875
Upstream sync
yousseb May 4, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bin/meld
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ try:
libintl.bindtextdomain(locale_domain, locale_dir)
libintl.bind_textdomain_codeset(locale_domain, 'UTF-8')
del libintl
elif sys.platform == 'darwin':
gettext.install(locale_domain, locale_dir, names=["ngettext"])
gettext.textdomain(locale_domain)
gettext.bindtextdomain(locale_domain, locale_dir)
else:
locale.bindtextdomain(locale_domain, locale_dir)
locale.bind_textdomain_codeset(locale_domain, 'UTF-8')
Expand Down
3 changes: 3 additions & 0 deletions meld/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ def uninstalled():
data_dir = os.environ.get('XDG_DATA_DIRS', "/usr/local/share/:/usr/share/")
data_dir = ":".join((melddir, data_dir))
os.environ['XDG_DATA_DIRS'] = data_dir

def is_darwin():
return sys.platform == "darwin"
29 changes: 27 additions & 2 deletions meld/meldwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from .ui import notebooklabel

from .util.compat import string_types
from meld.conf import _
from meld.conf import _, is_darwin
from meld.recent import recent_comparisons
from meld.settings import interface_settings, settings

Expand Down Expand Up @@ -138,7 +138,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:
if not gtk_settings.props.gtk_shell_shows_app_menu or is_darwin():
from meldapp import app

def make_app_action(name):
Expand Down Expand Up @@ -246,6 +246,10 @@ 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():
self.osx_ready = False
self.widget.connect('window_state_event', self.osx_menu_setup)

# Set tooltip on map because the recentmenu is lazily created
rmenu = self.ui.get_widget('/Menubar/FileMenu/Recent').get_submenu()
rmenu.connect("map", self._on_recentmenu_map)
Expand All @@ -258,6 +262,27 @@ def app_action(*args):
# GtkShortcutsWindow is new in GTK+ 3.20
pass

def osx_menu_setup(self, widget, event, callback_data=None):
if self.osx_ready == False:
from gi.repository import GtkosxApplication as gtkosx_application
self.macapp = gtkosx_application.Application()
prefs_item =self.menubar.get_children()[1].get_submenu().get_children()[1]
about_item = self.menubar.get_children()[1].get_submenu().get_children()[3]
#self.menubar.get_children()[1].get_submenu().get_children()[2] #help
quit_item = self.menubar.get_children()[1].get_submenu().get_children()[4]

self.menubar.show()
self.menubar.remove(self.menubar.get_children()[1])
self.macapp.set_menu_bar(self.menubar)
self.menubar.hide()
self.menubar.get_children()[1].hide()
self.macapp.insert_app_menu_item(about_item, 0)
self.macapp.insert_app_menu_item(Gtk.SeparatorMenuItem(), 1)
self.macapp.insert_app_menu_item(prefs_item, 2)
self.macapp.insert_app_menu_item(Gtk.SeparatorMenuItem(), 3)
#self.macapp.ready()
self.osx_ready = True

def _on_recentmenu_map(self, recentmenu):
for imagemenuitem in recentmenu.get_children():
imagemenuitem.set_tooltip_text(imagemenuitem.get_label())
Expand Down
Binary file added osx/DS_Store
Binary file not shown.
48 changes: 48 additions & 0 deletions osx/Meld
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python

import sys
import os
import subprocess
import locale

def getScriptPath():
return os.path.dirname(os.path.realpath(sys.argv[0]))

def fix_abspath(path):
if not os.path.isabs(path):
cwd = os.environ['PWD']
path = os.path.join(cwd, path)
return os.path.normpath(path)

arglist = []
for arg in sys.argv[1:]:
if arg.startswith('--output'):
filename = arg.split('=')[1]
newArg = '--output=' + fix_abspath(filename)
elif arg.startswith('-'):
newArg = arg
else:
newArg = fix_abspath(arg)
arglist.append(newArg)

MELDPATH = os.path.join(getScriptPath(), "Meld-bin")
APPPATH = fix_abspath(os.path.join(getScriptPath(), '..'))

LANG="C"
#try:
# LANG= ".".join(locale.getdefaultlocale()[0], "UTF-8")
#except:
# pass

environment = dict(os.environ, **{
"DYLD_LIBRARY_PATH": ":".join([
os.path.join(APPPATH, "Resources", "lib"),
os.path.join(APPPATH, "Frameworks")
]),
"LANG": LANG,
"LC_ALL": LANG,
"LC_CTYPE": LANG
})

status = subprocess.call([MELDPATH] + arglist, env=environment)
exit(status)
107 changes: 107 additions & 0 deletions osx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
Meld for OS X
===========

This README should help you build Meld for OS X.

> :bulb:**Tip:** A lot of people are asking how to use this package as a git difftool.
> Once installed, edit your ```~/.gitconfig```, and add the following lines
> ```
[diff]
tool = meld
[difftool]
prompt = false
[difftool "meld"]
trustExitCode = true
cmd = /Applications/Meld.app/Contents/MacOS/Meld \"$LOCAL\" \"$PWD/$REMOTE\"
```

### Preparing JHBuild Environment ###

JHBuild is the build system that we will be using to build Meld. This step should really be done once and further builds should not require updating the build environment unless there have been some updates to the libraries that you'd like to do.

---
#### Preparation ####

To ensure that we don't hit some issue with python not able to determine locales on OSX, let's do the following
```
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
```

> :bulb:**Tip:** Renaming /opt/local (MacPorts) during the initial build of the the build
environment proved to reduce collisions later on. You might want to consider doing this..

#### Initial Phase ####

1. Download the setup script
```
cd ~
curl -O https://git.gnome.org/browse/gtk-osx/plain/gtk-osx-build-setup.sh
```

2. Run the setup script
```
sh gtk-osx-build-setup.sh
~/.local/bin/jhbuild shell
```
You can exit the shell once you determine that it works properly

3. Prepare paths and build the bootstrap
```
export PATH="~/.local/bin/:$PATH"
jhbuild bootstrap
```

4. Checkout meld and start the initial phase
```
git clone https://github.com/yousseb/meld.git
cd meld
cd osx/
ln -sf $PWD/jhbuildrc-custom ~/.jhbuildrc-custom
cd ..
```

#### 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
```
or
```
jhbuild shell
chmod +x osx/build_app.sh
./osx/build_app.sh
```

#### Output ####

> :bulb:**Output:** Find the output dmg file in osx/Archives after you're done building.

#### FAQ ####

1. Can't run jhbuild bootstrap - gives an error related to bash not being found.
```
mkdir -p $HOME/gtk/inst/bin;
ln -sf /bin/bash $HOME/gtk/inst/bin/bash
```
153 changes: 153 additions & 0 deletions osx/build_app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
#!/bin/sh

APP="$PWD/dist/Meld.app"
MAIN="$APP/"
RES="$MAIN/Contents/Resources/"
FRAMEWORKS="$MAIN/Contents/Frameworks/"
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

# icon themes
mkdir -p $RES/share/icons
rsync -r -t --ignore-existing $INSTROOT/share/icons/Adwaita $RES/share/icons
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
rsync -r -t $INSTROOT/share/GConf/gsettings $RES/share/GConf

# pango
mkdir -p $RES/etc/pango
pango-querymodules |perl -i -pe 's/^[^#].*\///' > $RES/etc/pango/pango.modules
echo "[Pango]\nModuleFiles=./etc/pango/pango.modules\n" > $RES/etc/pango/pangorc

# gdk-pixbuf
rsync -r -t $INSTROOT/lib/gdk-pixbuf-2.0 $RES/lib
gdk-pixbuf-query-loaders |perl -i -pe 's/^[^#].*\/(lib\/.*")$/"..\/Resources\/$1/' > $RES/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache

# GTK themes
mkdir -p $RES/share/themes
rsync -r -t $INSTROOT/share/themes/Default/ $RES/share/themes/Default
rsync -r -t $INSTROOT/share/themes/Mac/ $RES/share/themes/Mac
rsync -r -t $INSTROOT/share/gtksourceview-3.0 $RES/share

# meld specific resources
mkdir $RES/share/meld
rsync -r -t data/icons/* $RES/share/icons
rsync -r -t data/meld.css $RES/share/meld
rsync -r -t data/styles/meld-dark.xml $RES/share/gtksourceview-3.0/styles
rsync -r -t data/styles/meld-base.xml $RES/share/gtksourceview-3.0/styles

# update icon cache for Adwaita
pushd .
cd $RES/share/icons/Adwaita
gtk-update-icon-cache -f .
popd

# update icon cache for hicolor
pushd .
cd $RES/share/icons/hicolor
gtk-update-icon-cache -f .
popd

# DIRTY HACK FOR NOW
#pushd .
#cd $MAIN/Contents/MacOS
#ln -s ../Resources/share .
#popd

# copy main libraries
mkdir -p $RES/lib
rsync -r -t $INSTROOT/lib/gtk-3.0 $RES/lib
rsync -r -t $INSTROOT/lib/girepository-1.0 $RES/lib
rsync -r -t $INSTROOT/lib/gobject-introspection $RES/lib

# copy some libraries that py2app misses
mkdir -p $FRAMEWORKS
rsync -t $INSTROOT/lib/libglib-2.0.0.dylib $FRAMEWORKS/libglib-2.0.0.dylib
rsync -t $INSTROOT/lib/libcairo-gobject.2.dylib $FRAMEWORKS/libcairo-gobject.2.dylib
rsync -t $INSTROOT/lib/libcairo-script-interpreter.2.dylib $FRAMEWORKS/libcairo-script-interpreter.2.dylib
rsync -t $INSTROOT/lib/libcairo.2.dylib $FRAMEWORKS/libcairo.2.dylib
rsync -t $INSTROOT/lib/libpangocairo-1.0.0.dylib $FRAMEWORKS/libpangocairo-1.0.0.dylib
rsync -t $INSTROOT/lib/libatk-1.0.0.dylib $FRAMEWORKS/libatk-1.0.0.dylib
rsync -t $INSTROOT/lib/libgio-2.0.0.dylib $FRAMEWORKS/libgio-2.0.0.dylib
rsync -t $INSTROOT/lib/libgobject-2.0.0.dylib $FRAMEWORKS/libgobject-2.0.0.dylib
rsync -t $INSTROOT/lib/libpango-1.0.0.dylib $FRAMEWORKS/libpango-1.0.0.dylib
rsync -t $INSTROOT/lib/libpangoft2-1.0.0.dylib $FRAMEWORKS/libpangoft2-1.0.0.dylib
rsync -t $INSTROOT/lib/libgtk-3.0.dylib $FRAMEWORKS/libgtk-3.0.dylib
rsync -t $INSTROOT/lib/libgtksourceview-3.0.1.dylib $FRAMEWORKS/libgtksourceview-3.0.1.dylib
rsync -t $INSTROOT/lib/libgtkmacintegration-gtk3.2.dylib $FRAMEWORKS/libgtkmacintegration-gtk3.2.dylib

# rename script, use wrapper
mv $MAIN/Contents/MacOS/Meld $MAIN/Contents/MacOS/Meld-bin
rsync -t osx/Meld $MAIN/Contents/MacOS/meld_wrapper
mv $MAIN/Contents/MacOS/meld_wrapper $MAIN/Contents/MacOS/Meld
chmod +x $MAIN/Contents/MacOS/Meld
chmod +x $MAIN/Contents/MacOS/Meld-bin

# unroot the library path
pushd .
cd $MAIN/Contents/
# Original from
# https://github.com/apocalyptech/eschalon_utils/blob/master/make-osx-apps.sh
#
# Modify library paths in the modules manually with install_name_tool
# Modified from tegaki create_app_bundle.sh
# Keep looping as long as we added more libraries
newlibs=1
while [ $newlibs -gt 0 ]; do
newlibs=0
for dylib in $(find . -name "*.so" -o -name "*.dylib"); do
echo "Modifying library references in $dylib"
changes=""
for lib in `otool -L $dylib | egrep "($INSTROOT|libs/)" | awk '{print $1}'` ; do
base=`basename $lib`
changes="$changes -change $lib @executable_path/../Frameworks/$base"
# Copy the library in if necessary
if [ ! -f "$FRAMEWORKS/$base" ]; then
echo "Copying in $lib"
cp $lib $FRAMEWORKS
# Loop again so we can pick up this library's dependencies
newlibs=1
fi
done
if test "x$changes" != x ; then
if ! install_name_tool $changes $dylib ; then
echo "Error for $dylib"
fi
install_name_tool -id @executable_path/../$dylib $dylib
fi
done
done

#for dylib in $(find . -name "*.dylib"); do
# echo "Adding @executable_path/../Frameworks/$dylib to Meld"
# install_name_tool -add_rpath "@executable_path/../Frameworks/$dylib" $MAIN/Contents/MacOS/Meld
#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"
popd

# Compress the dmg file..
cp osx/DS_Store /Volumes/Meld\ Merge/.DS_Store
hdiutil detach $DEV
hdiutil convert myimg.dmg -format UDZO -o meldmerge.dmg

# Cleanup
mkdir -p osx/Archives
mv meldmerge.dmg osx/Archives
#rm -f myimg.dmg
Loading