Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Add Caja Meld compare example #70

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
48 changes: 48 additions & 0 deletions examples/meld.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Examples: https://github.com/mate-desktop/python-caja/tree/master/examples

import os

from gi.repository import Caja, GObject


class MeldMenuProvider(GObject.GObject, Caja.MenuProvider):
MELD_EXECUTABLE = 'meld'
MELD_ICON = '/usr/share/icons/hicolor/scalable/apps/org.gnome.Meld.svg'

def __init__(self):
pass

def menu_activate_cb(self, menu, files=None):
args = ''

if files and len(files):
# Set working directory
os.chdir(os.path.dirname(files[0].get_location().get_path()))

# Start Meld with 1..3 files or directories
for i in range(0, 3):
if i >= len(files):
break
args += '"{}" '.format(files[i].get_location().get_path())

# Start Meld
cmd = '{} {} &'.format(self.MELD_EXECUTABLE, args)
os.system(cmd)

def get_file_items(self, window, files):
top_menuitem = Caja.MenuItem(name='MeldMenuProvider::Meld',
label='Meld compare',
tip='',
Copy link
Member

Choose a reason for hiding this comment

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

Add a tip/description

icon=self.MELD_ICON)
top_menuitem.connect('activate', self.menu_activate_cb, files)

return top_menuitem,

def get_background_items(self, window, file):
bg_menuitem_meld = Caja.MenuItem(name='MeldMenuProvider::MeldBg',
label='Meld',
tip='',
Copy link
Member

Choose a reason for hiding this comment

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

Add a tip/description

icon=self.MELD_ICON)
bg_menuitem_meld.connect('activate', self.menu_activate_cb)

return bg_menuitem_meld,