[geany/geany-plugins] 87e1f9: geanyvc: search external diff tools in 'program files' locations for Windows
Yury Siamashka
git-noreply at xxxxx
Mon Jun 29 13:02:08 UTC 2015
Branch: refs/heads/master
Author: Yury Siamashka <yurand2 at gmail.com>
Committer: Yury Siamashka <yurand2 at gmail.com>
Date: Mon, 29 Jun 2015 13:02:08 UTC
Commit: 87e1f9fb8ae77cbd1ff3fe5c9769d15272ef1171
https://github.com/geany/geany-plugins/commit/87e1f9fb8ae77cbd1ff3fe5c9769d15272ef1171
Log Message:
-----------
geanyvc: search external diff tools in 'program files' locations for Windows
Modified Paths:
--------------
geanyvc/src/externdiff.c
geanyvc/src/geanyvc.c
geanyvc/src/geanyvc.h
Modified: geanyvc/src/externdiff.c
69 lines changed, 57 insertions(+), 12 deletions(-)
===================================================================
@@ -19,10 +19,13 @@
*/
#include <string.h>
-
#include <geanyplugin.h>
#include "geanyvc.h"
+#ifdef G_OS_WIN32
+#include <Shlobj.h>
+#endif
+
extern GeanyFunctions *geany_functions;
@@ -38,27 +41,70 @@ enum
};
-static const gchar *viewers[EXTERNAL_DIFF_COUNT] = { "meld", "kompare", "kdiff3", "diffuse", "tkdiff", "WinMergeU" };
+static const gchar *viewers[EXTERNAL_DIFF_COUNT] = { "Meld/meld", "kompare", "kdiff3", "diffuse", "tkdiff", "WinMerge/WinMergeU" };
static gchar *extern_diff_viewer = NULL;
-const gchar *
-get_external_diff_viewer(void)
+
+void external_diff_viewer_init(void)
{
gint i;
- if (extern_diff_viewer)
- return extern_diff_viewer;
+ for (i = 0; i < EXTERNAL_DIFF_COUNT; i++)
+ {
+ gchar *filename = g_path_get_basename(viewers[i]);
+ gchar *path = g_find_program_in_path(filename);
+ g_free(filename);
+ if (path)
+ {
+ extern_diff_viewer = path;
+ return;
+ }
+ }
+#ifdef G_OS_WIN32
+ TCHAR szPathProgramFiles[MAX_PATH];
+ TCHAR szPathProgramFiles86[MAX_PATH];
+ SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL, 0, szPathProgramFiles);
+ SHGetFolderPath(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, szPathProgramFiles86);
for (i = 0; i < EXTERNAL_DIFF_COUNT; i++)
{
- gchar *path = g_find_program_in_path(viewers[i]);
+ gchar *filename = g_build_filename(szPathProgramFiles, viewers[i], NULL);
+ gchar *path = g_find_program_in_path(filename);
+ g_free(filename);
if (path)
{
- g_free(path);
- extern_diff_viewer = (gchar *) viewers[i];
- return viewers[i];
+ extern_diff_viewer = path;
+ return;
}
}
+ for (i = 0; i < EXTERNAL_DIFF_COUNT; i++)
+ {
+ gchar *filename = g_build_filename(szPathProgramFiles86, viewers[i], NULL);
+ gchar *path = g_find_program_in_path(filename);
+ g_free(filename);
+ if (path)
+ {
+ extern_diff_viewer = path;
+ return;
+ }
+ }
+#endif
+}
+
+void external_diff_viewer_deinit(void)
+{
+ if (extern_diff_viewer)
+ {
+ g_free(extern_diff_viewer);
+ extern_diff_viewer = NULL;
+ }
+}
+
+const gchar *
+get_external_diff_viewer(void)
+{
+ if (extern_diff_viewer)
+ return extern_diff_viewer;
return NULL;
}
@@ -67,7 +113,6 @@ void
vc_external_diff(const gchar * src, const gchar * dest)
{
gchar *argv[4] = { NULL, NULL, NULL, NULL };
-
const gchar *diff = get_external_diff_viewer();
if (!diff)
return;
@@ -76,7 +121,7 @@ vc_external_diff(const gchar * src, const gchar * dest)
argv[1] = (gchar *) src;
argv[2] = (gchar *) dest;
- utils_spawn_sync(NULL, argv, NULL,
+ g_spawn_sync(NULL, argv, NULL,
G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL |
G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
Modified: geanyvc/src/geanyvc.c
2 lines changed, 2 insertions(+), 0 deletions(-)
===================================================================
@@ -2305,6 +2305,7 @@ plugin_init(G_GNUC_UNUSED GeanyData * data)
load_config();
registrate();
+ external_diff_viewer_init();
if (set_menubar_entry == TRUE)
{
@@ -2378,6 +2379,7 @@ plugin_init(G_GNUC_UNUSED GeanyData * data)
void
plugin_cleanup(void)
{
+ external_diff_viewer_deinit();
remove_menuitems_from_editor_menu();
gtk_widget_destroy(menu_entry);
g_slist_free(VC);
Modified: geanyvc/src/geanyvc.h
2 lines changed, 2 insertions(+), 0 deletions(-)
===================================================================
@@ -135,6 +135,8 @@ GSList *get_commit_files_null(const gchar * dir);
extern const gchar *NO_ENV[];
/* External diff viewer */
+void external_diff_viewer_init(void);
+void external_diff_viewer_deinit(void);
const gchar *get_external_diff_viewer(void);
void vc_external_diff(const gchar * src, const gchar * dest);
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Plugins-Commits
mailing list