#!/usr/bin/python2
# -*- coding: utf-8 -*-
# [Pluma Tool]
# Name=Switch onto a file .c and .h
# Name[am]=መቀየሪያ ወደ ፋይል .c እና .h
# Name[ar]=حوّل إلى ملفات .c و .h
# Name[ast]=Cambiar a un ficheru .c y .h
# Name[be]=Пераключыць на файлы .c і .h
# Name[bg]=Превключване между файл .c и .h
# Name[br]=Trec'haoliñ betek ur restr mod .c ha .h
# Name[ca]=Passa a un fitxer .c i .h
# Name[ca@valencia]=Passa a un fitxer .c i .h
# Name[cmn]=切換到檔案 .c 與 .h
# Name[cs]=Přepnout na soubor .c a .h
# Name[da]=Skift over på en fil .c og .h
# Name[de]=Zu einer .c- und .h-Datei wechseln
# Name[el]=Αλλαγή σε ένα αρχείο .c και .h
# Name[en_AU]=Switch onto a file .c and .h
# Name[en_GB]=Switch onto a file .c and .h
# Name[es]=Cambiar a un archivo .c y .h
# Name[eu]=Aldatu .c edo .h fitxategi batera
# Name[fi]=Vaihda tiedostoon .c ja .h
# Name[fr]=Basculer vers un fichier .c et .h
# Name[gl]=Cambiar entre os ficheiros .c e .h
# Name[hu]=Kapcsoljon rá egy .c és egy .h fájlt
# Name[hy]=Անցնել  .c և .h Ֆայլի վրա
# Name[id]=Beralih ke berkas c dan H
# Name[ie]=Alterar inter files .c e .h
# Name[it]=Passa tra file .c e .h
# Name[ja]=.cと.hファイルの切り替え
# Name[ko]=.c 파일과 .h 파일로 전환
# Name[lt]=Perjungti į failą .c ir .h
# Name[ms]=Tukar ke fail .c dan .h
# Name[nb]=Bytt til en fil .c og .h
# Name[nl]=Wisselen naar een .c- en .h-bestand
# Name[pl]=Przełącz na plik .c i .h
# Name[pt]=Mudar para um ficheiro .c e .h
# Name[pt_BR]=Mudar para um arquivo .c e .h
# Name[ro]=Schimbă într-un fișier de tip .c sau .h
# Name[ru]=Переключить на файлы .c и .h
# Name[sk]=Prepnúť na súbor .c a .h
# Name[sl]=Preklopi na datoteko .c in .h
# Name[sr]=Пребаците се на датотеку „.c“ и „.h“
# Name[sv]=Växla till en fil .c och .h
# Name[th]=สลับไปยังแฟ้ม .c และ .h
# Name[tr]=.c ve .h dosyasına geç
# Name[uk]=Перемикнути на файли .c і .h
# Name[zh_CN]=切换到一个 .c 或 .h 文件
# Name[zh_HK]=在檔案 .c 和 .h 間切換
# Name[zh_TW]=在檔案 .c 和 .h 間切換
# Shortcut=<Shift><Alt>s
# Applicability=all
# Output=nothing
# Input=nothing
# Save-files=nothing

# Copyright © 2011 Perberos
# Copyright © 2012-2017 MATE developers
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation; either version 2.1 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

import os
import subprocess

try:
    name = os.environ["PLUMA_CURRENT_DOCUMENT_NAME"]
except KeyError:
    exit(1)

f, ext = os.path.splitext(name)
nxt = ''

if ext == '.c':
    nxt = '.h'

if ext == '.h':
    nxt = '.c'

if nxt:
    subprocess.call(['/usr/bin/pluma', f+nxt])
