Skip to content

Commit

Permalink
osx stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
yousseb committed Dec 30, 2014
1 parent f171678 commit 90a8ae5
Show file tree
Hide file tree
Showing 14 changed files with 478 additions and 17 deletions.
1 change: 0 additions & 1 deletion data/ui/meldapp-ui.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<separator/>
<menuitem action="Recent" />
<menuitem action="Close" />
<menuitem action="Quit" />
</menu>
<menu action="EditMenu">
<menuitem action="Undo"/>
Expand Down
41 changes: 31 additions & 10 deletions meld/meldwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ def __init__(self):

actions = (
("FileMenu", None, _("_File")),
("New", gtk.STOCK_NEW, _("_New Comparison..."), "<control>N",
("New", gtk.STOCK_NEW, _("_New Comparison..."), "<Primary>N",
_("Start a new comparison"),
self.on_menu_file_new_activate),
("Save", gtk.STOCK_SAVE, None, None,
_("Save the current file"),
self.on_menu_save_activate),
("SaveAs", gtk.STOCK_SAVE_AS, _("Save As..."), "<control><shift>S",
("SaveAs", gtk.STOCK_SAVE_AS, _("Save As..."), "<Primary><shift>S",
_("Save the current file with a different name"),
self.on_menu_save_as_activate),
("Close", gtk.STOCK_CLOSE, None, None,
Expand All @@ -76,10 +76,10 @@ def __init__(self):
self.on_menu_quit_activate),

("EditMenu", None, _("_Edit")),
("Undo", gtk.STOCK_UNDO, None, "<control>Z",
("Undo", gtk.STOCK_UNDO, None, "<Primary>Z",
_("Undo the last action"),
self.on_menu_undo_activate),
("Redo", gtk.STOCK_REDO, None, "<control><shift>Z",
("Redo", gtk.STOCK_REDO, None, "<Primary><shift>Z",
_("Redo the last undone action"),
self.on_menu_redo_activate),
("Cut", gtk.STOCK_CUT, None, None, _("Cut the selection"),
Expand All @@ -90,14 +90,14 @@ def __init__(self):
self.on_menu_paste_activate),
("Find", gtk.STOCK_FIND, _("Find..."), None, _("Search for text"),
self.on_menu_find_activate),
("FindNext", None, _("Find Ne_xt"), "<control>G",
("FindNext", None, _("Find Ne_xt"), "<Primary>G",
_("Search forwards for the same text"),
self.on_menu_find_next_activate),
("FindPrevious", None, _("Find _Previous"), "<control><shift>G",
("FindPrevious", None, _("Find _Previous"), "<Primary><shift>G",
_("Search backwards for the same text"),
self.on_menu_find_previous_activate),
("Replace", gtk.STOCK_FIND_AND_REPLACE,
_("_Replace..."), "<control>H",
_("_Replace..."), "<Primary>H",
_("Find and replace text"),
self.on_menu_replace_activate),
("Preferences", gtk.STOCK_PREFERENCES, _("Prefere_nces"), None,
Expand All @@ -123,7 +123,7 @@ def __init__(self):
("Stop", gtk.STOCK_STOP, None, "Escape",
_("Stop the current action"),
self.on_toolbar_stop_clicked),
("Refresh", gtk.STOCK_REFRESH, None, "<control>R",
("Refresh", gtk.STOCK_REFRESH, None, "<Primary>R",
_("Refresh the view"),
self.on_menu_refresh_activate),

Expand Down Expand Up @@ -154,7 +154,7 @@ def __init__(self):
self.on_menu_about_activate),
)
toggleactions = (
("Fullscreen", None, _("Fullscreen"), "F11",
("Fullscreen", None, _("Fullscreen"), "<Ctrl><Primary>F",
_("View the comparison in fullscreen"),
self.on_action_fullscreen_toggled, False),
("ToolbarVisible", None, _("_Toolbar"), None,
Expand Down Expand Up @@ -205,7 +205,7 @@ def __init__(self):
self.actiongroup.get_action("Stop").set_sensitive(False)
self._update_page_action_sensitivity()

self.appvbox.pack_start(self.menubar, expand=False)
#self.appvbox.pack_start(self.menubar, expand=False)
self.appvbox.pack_start(self.toolbar, expand=False)
self._menu_context = self.statusbar.get_context_id("Tooltips")
self.widget.drag_dest_set(
Expand All @@ -229,6 +229,27 @@ def __init__(self):
self.widget.connect('focus_in_event', self.on_focus_change)
self.widget.connect('focus_out_event', self.on_focus_change)

try:
import gtkosx_application
self.macapp = gtkosx_application.gtkosx_application_get()
self.osx_menu_setup()
except ImportError:
QUARTZ_ENABLE = False
else:
QUARTZ_ENABLE = True

def osx_menu_setup(self):
about_item = self.ui.get_widget('/Menubar/HelpMenu/About')
prefs_item = self.ui.get_widget('/Menubar/EditMenu/Preferences')
self.menubar.show()
self.macapp.set_menu_bar(self.menubar)
self.menubar.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()

def on_focus_change(self, widget, event, callback_data=None):
for idx in range(self.notebook.get_n_pages()):
w = self.notebook.get_nth_page(idx)
Expand Down
19 changes: 13 additions & 6 deletions meld/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,34 @@
if not _help_dir: _help_dir = os.path.join(appdir,"help")
if not _share_dir: _share_dir = appdir

print os.name
if os.name == "posix":
from gtkosx_application import gtkosx_application_get_resource_path
_share_dir = os.path.join(gtkosx_application_get_resource_path(), "share")
_locale_dir = os.path.join(gtkosx_application_get_resource_path(), "share", "meld", "po")
_locale_dir = os.path.join(gtkosx_application_get_resource_path(), "share", "meld", "help")

def locale_dir(*args): # i18n files
return os.path.join(_locale_dir, *args)

def help_dir(*args): # help
return os.path.join(_help_dir, *args)

def share_dir(*args):
if os.path.exists(os.path.join(_share_dir, "data")):
return os.path.join(_share_dir, "data", *args)
if os.path.exists(os.path.join(_share_dir, "meld")):
return os.path.join(_share_dir, "meld", *args)
else:
return os.path.join(_share_dir, *args)

def ui_dir(*args):
if os.path.exists(os.path.join(_share_dir, "data")):
return os.path.join(_share_dir, "data", "ui", *args)
if os.path.exists(os.path.join(_share_dir, "meld", "ui")):
return os.path.join(_share_dir, "meld", "ui", *args)
else:
return os.path.join(_share_dir, "ui", *args)

def icon_dir(*args):
if os.path.exists(os.path.join(_share_dir, "data")):
return os.path.join(_share_dir, "data", "icons", *args)
if os.path.exists(os.path.join(_share_dir, "meld", "icons")):
return os.path.join(_share_dir, "meld", "icons", *args)
else:
return os.path.join(_share_dir, "icons", *args)

Binary file added osx/DS_Store
Binary file not shown.
79 changes: 79 additions & 0 deletions osx/Meld
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/sh

EXEC="exec"

name="`basename $0`"
if [[ "$0" == `pwd`* ]] || [[ "$0" == "//"* ]]; then
full_path="$0"
else
full_path="`pwd`/$0"
fi
tmp=`dirname "$full_path"`
tmp=`dirname "$tmp"`
bundle=`dirname "$tmp"`
bundle_contents="$bundle"/Contents
bundle_macos="$bundle_contents"/MacOS
bundle_res="$bundle_contents"/Resources
bundle_lib="$bundle_res"/lib:"$bundle_contents"/Frameworks
bundle_bin="$bundle_res"/bin
bundle_data="$bundle_res"/share
bundle_etc="$bundle_res"/etc

echo $bundle_lib
export DYLD_LIBRARY_PATH="$bundle_lib"
export XDG_CONFIG_DIRS="$bundle_etc"/xdg
export XDG_DATA_DIRS="$bundle_data"
export GTK_DATA_PREFIX="$bundle_res"
export GTK_EXE_PREFIX="$bundle_res"
export GTK_PATH="$bundle_res"

export GTK2_RC_FILES="$bundle_etc/gtk-2.0/gtkrc"
export GTK_IM_MODULE_FILE="$bundle_etc/gtk-2.0/gtk.immodules"
export GDK_PIXBUF_MODULE_FILE="$bundle_etc/gtk-2.0/gdk-pixbuf.loaders"
export PANGO_RC_FILE="$bundle_etc/pango/pangorc"
export PANGO_LIBDIR="$bundle_lib"
export PANGO_SYSCONFDIR="$bundle_etc"

#Set $PYTHON to point inside the bundle
export PYTHON="$bundle_macos/python"
export PYTHONHOME="$bundle_res"
#Add the bundle's python modules
PYTHONPATH="$bundle_lib:$PYTHONPATH"
PYTHONPATH="$bundle_lib/python/lib-dynload/:$PYTHONPATH"
PYTHONPATH="$bundle_lib/python/:$PYTHONPATH"
PYTHONPATH="$bundle_lib/pygtk/2.0:$PYTHONPATH"
export PYTHONPATH

# We need a UTF-8 locale.
lang=`defaults read .GlobalPreferences AppleLocale 2>/dev/null`
if test "$?" != "0"; then
lang=`defaults read .GlobalPreferences AppleCollationOrder 2>/dev/null | sed 's/_.*//'`
fi
LANG=""
if test "$lang" != ""; then
LANG="`grep \"\`echo $lang\`_\" /usr/share/locale/locale.alias | \
tail -n1 | sed 's/\./ /' | awk '{print $2}'`"
fi
if test "$LANG" == ""; then
export LANG="C"
else
export LANG="$LANG.utf8"
fi

if test -f "$bundle_lib/charset.alias"; then
export CHARSETALIASDIR="$bundle_lib"
fi

# Extra arguments can be added in environment.sh.
EXTRA_ARGS=
if test -f "$bundle_res/environment.sh"; then
source "$bundle_res/environment.sh"
fi

# Strip out the argument added by the OS.
if [ "x`echo "x$1" | sed -e "s/^x-psn_.*//"`" == "x" ]; then
shift 1
fi


$EXEC "$bundle_contents/MacOS/Meld-bin" "$@"
9 changes: 9 additions & 0 deletions osx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
curl -O https://raw.github.com/jralls/gtk-osx-build/master/gtk-osx-build-setup.sh

sh gtk-osx-build-setup.sh

ln -sf $PWD/jhbuildrc-custom ~/.jhbuildrc-custom
jhbuild bootstrap && jhbuild

curl --continue-at - -L http://ftp.cc.uoc.gr/mirrors/linux/lfs/LFS/conglomeration/cups/cups-1.2.12-source.tar.bz2 -o /Users/yousseb/gtk/source/pkgs/cups-1.2.12-source.tar.bz2

62 changes: 62 additions & 0 deletions osx/build_app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/sh

#jhbuild bootstrap ; jhbuild; jhbuild build gtk-mac-integration; jhbuild
#jhbuild -m osx/meld.modules build meld-python-deps
#jhbuild shell
#easy_install pip
#pip install pygtksourceview


python setup_py2app.py build
python setup_py2app.py py2app

APP="dist/Meld.app"
MAIN="$APP/"
RES="$MAIN/Contents/Resources/"

mkdir -p $RES/share/icons
cp -R ~/gtk/inst/share/icons/Tango $RES/share/icons
#cp -R ~/gtk/inst/share/icons/hicolor $RES/share/icons
cp -R data/icons/* $RES/share/icons

mkdir -p $RES/share/themes
cp -R ~/gtk/inst/share/themes/Clearlooks/ $RES/share/themes/Clearlooks
cp -R ~/gtk/inst/share/themes/Mac/ $RES/share/themes/Mac

cp -R ~/gtk/inst/share/gtksourceview-2.0 $RES/share

mkdir -p $RES/etc/gtk-2.0
mkdir -p $RES/etc/pango
mkdir -p $RES/etc/xdg
cp -R osx/gtkrc $RES/etc/gtk-2.0
cp -R osx/pangorc $RES/etc/pango

mkdir -p $RES/lib

cp -R ~/gtk/inst/lib/girepository-1.0 $RES/lib
cp -R ~/gtk/inst/lib/gtk-2.0 $RES/lib

mv $MAIN/Contents/MacOS/Meld $MAIN/Contents/MacOS/Meld-bin
cp -R osx/Meld $MAIN/Contents/MacOS
chmod +x $MAIN/Contents/MacOS/Meld
#cp -R ~/gtk/inst/lib/pango $RES/lib

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
cp osx/DS_Store /Volumes/Meld\ Merge/.DS_Store
hdiutil detach $DEV
hdiutil convert myimg.dmg -format UDZO -o meldmerge.dmg





#http://mirror.pnl.gov/macports/release/ports/net/deluge/files/patch-remove-osx-native-menus.diff
#and gtk.gdk.WINDOWING == "quartz":
43 changes: 43 additions & 0 deletions osx/gtkrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

gtk-icon-theme-name = "Tango"
#gtk-font-name = "DejaVa Sans 9"
gtk-theme-name = "ClearLooks"
gtk-enable-mnemonics = 0
gtk-toolbar-style = GTK_TOOLBAR_ICONS


style "meld-color-scheme"
{
color["insert-bg"] = "DarkSeaGreen1"
color["insert-outline"] = shade(0.8, @insert-bg)
color["insert-text"] = "#008800"

color["delete-bg"] = "White"
color["delete-outline"] = shade(0.8, @delete-bg)
color["delete-text"] = "#880000"

color["replace-bg"] = "#ddeeff"
color["replace-outline"] = shade(0.8, @replace-bg)
color["replace-text"] = "#0044dd"

color["conflict-bg"] = "Pink"
color["conflict-outline"] = shade(0.8, @conflict-bg)
color["conflict-text"] = "#ff0000"

color["error-bg"] = "#fce94f"
color["error-outline"] = shade(0.8, @error-bg)
color["error-text"] = "#faad3d"

color["inline-bg"] = "LightSteelBlue2"
color["inline-fg"] = "Red"

color["unknown-text"] = "#888888"

color["current-line-highlight"] = "#ffff00"

color["syncpoint-outline"] = "#555555"

color["current-chunk-highlight"] = "#ffffff"
}
widget "meldapp.*" style : lowest "meld-color-scheme"

49 changes: 49 additions & 0 deletions osx/jhbuildrc-custom
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# -*- mode: python -*-

#prefix = "/opt/gtk"
checkoutroot = os.path.expanduser("~/Source/gtk")

setup_sdk(target="10.7", sdk_version="10.10", architectures=["x86_64"])
#setup_sdk(target="10.6", sdk_version="10.6", architectures=["i386"])

_gtk_osx_use_jhbuild_python = True

skip.append("libiconv") # Lion issues
skip.append("cups")

modules = [
"python",
"meta-gtk-osx-bootstrap",
"meta-gtk-osx-core",
"gtk-mac-integration",
"librsvg", "libglade",
"meta-gtk-osx-python",
"meta-gtk-osx-themes",
"gtksourceview"
]

autogenargs='--disable-static --disable-gtk-doc --disable-documentation ' + \
'--disable-docs --enable-introspection'

module_autogenargs['cmake'] = ''# + autogenargs
module_autogenargs['zlib'] = ''# + autogenargs
module_autogenargs['gdk-pixbuf'] = '--with-included-loaders ' + autogenargs
module_autogenargs['pygobject'] = '--disable-introspection --disable-docs --enable-cairo '
module_autogenargs['gtk-quartz-engine'] = 'CFLAGS=-Wuninitialized ' + autogenargs
module_autogenargs['openssl'] = ''# + autogenargs
module_autogenargs['pango'] = "--with-included-modules " + autogenargs
#module_autogenargs['gtk+'] = '--with-included-immodules ' + autogenargs
module_autogenargs['gtk+'] = ' --disable-papi --disable-cups ' + autogenargs
module_autogenargs['gtk-engines'] = "--disable-all --enable-clearlooks --enable-animation " + autogenargs
module_autogenargs['gtksourceview'] = '' #--disable-nls ' + autogenargs
module_autogenargs['gtk-mac-integration'] = '' #'CFLAGS="$CFLAGS -mmacosx-version-min=10.7" ' + autogenargs


#`pkg-config gtk+-quartz-2.0 --libs` -L"../Frameworks"

#module_autogenargs['gtk+-3.0'] = '--with-included-immodules ' + autogenargs


# Can be usefull when tweaking modulesets to avoid jhbuild overwriting:
#nonetwork=True

Binary file added osx/meld.icns
Binary file not shown.
Loading

4 comments on commit 90a8ae5

@mechiris
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No comments, just wanted to say thank you to @yousseb for adding this build for Mac. Much easier than the alternative install methods.

@babycaseny
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible for the installation process to check if git is installed, so that it will add itself to the difftool and mergetool list?

@yousseb
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mechiris Thank you for the nice words. :)

@yousseb
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@babycaseny I don't have much experience on that part. Do you have any pointers that I can use to do so?

Please sign in to comment.