~ubuntu-branches/debian/squeeze/geany-plugins/squeeze

« back to all changes in this revision

Viewing changes to geanyvc/src/externdiff.c

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-07-10 22:56:41 UTC
  • Revision ID: james.westby@ubuntu.com-20090710225641-xc1126t7pq0jmpos
Tags: upstream-0.17.1
ImportĀ upstreamĀ versionĀ 0.17.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *      externdiff.h - Plugin to geany light IDE to work with vc
 
3
 *
 
4
 *      Copyright 2008 Yura Siamashka <yurand2@gmail.com>
 
5
 *
 
6
 *      This program is free software; you can redistribute it and/or modify
 
7
 *      it under the terms of the GNU General Public License as published by
 
8
 *      the Free Software Foundation; either version 2 of the License, or
 
9
 *      (at your option) any later version.
 
10
 *
 
11
 *      This program is distributed in the hope that it will be useful,
 
12
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *      GNU General Public License for more details.
 
15
 *
 
16
 *      You should have received a copy of the GNU General Public License
 
17
 *      along with this program; if not, write to the Free Software
 
18
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
19
 */
 
20
 
 
21
#include <string.h>
 
22
 
 
23
#include "geany.h"
 
24
#include "support.h"
 
25
#include "plugindata.h"
 
26
#include "document.h"
 
27
#include "filetypes.h"
 
28
#include "utils.h"
 
29
#include "ui_utils.h"
 
30
#include "project.h"
 
31
#include "prefs.h"
 
32
#include "geanyfunctions.h"
 
33
 
 
34
 
 
35
#include "geanyvc.h"
 
36
 
 
37
extern GeanyFunctions *geany_functions;
 
38
 
 
39
enum
 
40
{
 
41
        EXTERNAL_DIFF_MELD,
 
42
        EXTERNAL_DIFF_KOMPARE,
 
43
        EXTERNAL_DIFF_KDIFF3,
 
44
        EXTERNAL_DIFF_DIFFUSE,
 
45
        EXTERNAL_DIFF_TKDIFF,
 
46
        EXTERNAL_DIFF_COUNT
 
47
};
 
48
 
 
49
static gchar *viewers[EXTERNAL_DIFF_COUNT] = { "meld", "kompare", "kdiff3", "diffuse", "tkdiff" };
 
50
 
 
51
static gchar *extern_diff_viewer = NULL;
 
52
const gchar *
 
53
get_external_diff_viewer()
 
54
{
 
55
        gint i;
 
56
 
 
57
        if (extern_diff_viewer)
 
58
                return extern_diff_viewer;
 
59
 
 
60
        for (i = 0; i < EXTERNAL_DIFF_COUNT; i++)
 
61
        {
 
62
                if (g_find_program_in_path(viewers[i]))
 
63
                {
 
64
                        extern_diff_viewer = viewers[i];
 
65
                        return extern_diff_viewer;
 
66
                }
 
67
        }
 
68
        return NULL;
 
69
}
 
70
 
 
71
void
 
72
vc_external_diff(const gchar * src, const gchar * dest)
 
73
{
 
74
        gchar *argv[4] = { NULL, NULL, NULL, NULL };
 
75
 
 
76
        const gchar *diff = get_external_diff_viewer();
 
77
        if (!diff)
 
78
                return;
 
79
 
 
80
        argv[0] = (gchar *) diff;
 
81
        argv[1] = (gchar *) src;
 
82
        argv[2] = (gchar *) dest;
 
83
 
 
84
        utils_spawn_sync(NULL, argv, NULL,
 
85
                         G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL |
 
86
                         G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
87
}