From 12d3b636937889ce7383061b31051f9627e11372 Mon Sep 17 00:00:00 2001 From: James Liggett Date: Tue, 22 Apr 2008 18:09:08 -0700 Subject: [PATCH] Add a function for getting relative paths from full paths. Any command whose user interface uses a GtkFileChooser (add, remove, etc) will probably need this, as file choosers only give full paths. --- plugins/git/git-ui-utils.c | 10 ++++++++++ plugins/git/git-ui-utils.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/plugins/git/git-ui-utils.c b/plugins/git/git-ui-utils.c index 475ff51b..c793dcf8 100644 --- a/plugins/git/git-ui-utils.c +++ b/plugins/git/git-ui-utils.c @@ -222,6 +222,16 @@ get_filename_from_full_path (gchar *path) return g_strdup (""); } +const gchar * +get_relative_path (const gchar *path, const gchar *working_directory) +{ + /* Path could already be a relative path */ + if (strstr (path, working_directory)) + return path + strlen (working_directory) + 1; + else + return path; +} + void on_status_command_finished (AnjutaCommand *command, guint return_code, gpointer user_data) diff --git a/plugins/git/git-ui-utils.h b/plugins/git/git-ui-utils.h index 85ed5156..3611f6a8 100644 --- a/plugins/git/git-ui-utils.h +++ b/plugins/git/git-ui-utils.h @@ -50,6 +50,8 @@ void clear_status_bar_progress_pulse (guint timer_id); void pulse_progress_bar (GtkProgressBar *progress_bar); void report_errors (AnjutaCommand *command, guint return_code); gchar *get_filename_from_full_path (gchar *path); +const gchar *get_relative_path (const gchar *path, + const gchar *working_directory); /* Stock signal handlers */ void on_status_command_finished (AnjutaCommand *command, guint return_code, -- 2.11.4.GIT