Revision: 214 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=214&view=rev Author: yurand Date: 2008-10-20 10:20:44 +0000 (Mon, 20 Oct 2008)
Log Message: ----------- VC: Added update command
Modified Paths: -------------- trunk/geanyvc/geanyvc.c trunk/geanyvc/geanyvc.h trunk/geanyvc/vc_bzr.c trunk/geanyvc/vc_cvs.c trunk/geanyvc/vc_git.c trunk/geanyvc/vc_hg.c trunk/geanyvc/vc_svk.c trunk/geanyvc/vc_svn.c
Modified: trunk/geanyvc/geanyvc.c =================================================================== --- trunk/geanyvc/geanyvc.c 2008-10-17 15:39:57 UTC (rev 213) +++ trunk/geanyvc/geanyvc.c 2008-10-20 10:20:44 UTC (rev 214) @@ -838,10 +838,8 @@ }
static gboolean -command_with_question_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer gdata, - gint cmd, const gchar * question, gboolean ask) +command_with_question_activated(gchar ** text, gint cmd, const gchar * question, gboolean ask) { - gchar *text; GtkWidget *dialog; gint result; gchar *dir; @@ -876,18 +874,14 @@ vc = find_vc(dir); g_return_val_if_fail(vc, FALSE);
- execute_command(vc, &text, NULL, doc->file_name, cmd, NULL, NULL); - if (text) - { - g_free(text); - } + execute_command(vc, text, NULL, doc->file_name, cmd, NULL, NULL); g_free(dir); } return (result == GTK_RESPONSE_YES) ? TRUE : FALSE; }
static void -vcrevert_activated(GtkMenuItem * menuitem, gpointer gdata) +vcrevert_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer gdata) { gboolean ret; GeanyDocument *doc; @@ -895,8 +889,8 @@ doc = p_document->get_current(); g_return_if_fail(doc != NULL && doc->file_name != NULL);
- ret = command_with_question_activated(menuitem, gdata, VC_COMMAND_REVERT_FILE, - _("Do you really want to revert: %s"), TRUE); + ret = command_with_question_activated(NULL, VC_COMMAND_REVERT_FILE, + _("Do you really want to revert: %s?"), TRUE); if (ret) { p_document->reload_file(doc, NULL); @@ -905,19 +899,19 @@
static void -vcadd_activated(GtkMenuItem * menuitem, gpointer gdata) +vcadd_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer gdata) { - command_with_question_activated(menuitem, gdata, VC_COMMAND_ADD, - _("Do you really want to add: %s"), set_add_confirmation); + command_with_question_activated(NULL, VC_COMMAND_ADD, + _("Do you really want to add: %s?"), set_add_confirmation); }
static void -vcremove_activated(GtkMenuItem * menuitem, gpointer gdata) +vcremove_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer gdata) { gboolean ret;
- ret = command_with_question_activated(menuitem, gdata, VC_COMMAND_REMOVE, - _("Do you really want to remove: %s"), TRUE); + ret = command_with_question_activated(NULL, VC_COMMAND_REMOVE, + _("Do you really want to remove: %s?"), TRUE); if (ret) { p_document-> @@ -926,6 +920,33 @@ } }
+static void +vcupdate_activated(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer gdata) +{ + gchar *text = NULL; + GeanyDocument *doc; + gboolean ret; + + doc = p_document->get_current(); + g_return_if_fail(doc != NULL && doc->file_name != NULL); + + if (doc->changed) + { + p_document->save_file(doc, FALSE); + } + + ret = command_with_question_activated(&text, VC_COMMAND_UPDATE, + _("Do you really want to update?"), + set_add_confirmation); + if (ret) + { + if (NZV(text)) + show_output(text, "*VC-UPDATE*", NULL); + if (text) + g_free(text); + } +} + enum { COLUMN_COMMIT, @@ -1452,6 +1473,7 @@ static GtkWidget *menu_vc_revert_file = NULL; static GtkWidget *menu_vc_add_file = NULL; static GtkWidget *menu_vc_remove_file = NULL; +static GtkWidget *menu_vc_update = NULL; static GtkWidget *menu_vc_commit = NULL;
static void @@ -1496,6 +1518,7 @@ gtk_widget_set_sensitive(menu_vc_remove_file, f_have_vc); gtk_widget_set_sensitive(menu_vc_add_file, d_have_vc && !f_have_vc);
+ gtk_widget_set_sensitive(menu_vc_update, d_have_vc); gtk_widget_set_sensitive(menu_vc_commit, d_have_vc); }
@@ -1976,6 +1999,14 @@
gtk_container_add(GTK_CONTAINER(menu_vc_menu), gtk_separator_menu_item_new());
+ // Update + menu_vc_update = gtk_menu_item_new_with_mnemonic(_("Update")); + gtk_container_add(GTK_CONTAINER(menu_vc_menu), menu_vc_update); + gtk_tooltips_set_tip(tooltips, menu_vc_update, _("Update from remote repositary."), NULL); + + g_signal_connect((gpointer) menu_vc_update, "activate", + G_CALLBACK(vcupdate_activated), NULL); + // Commit menu_vc_commit = gtk_menu_item_new_with_mnemonic(_("_Commit")); gtk_container_add(GTK_CONTAINER(menu_vc_menu), menu_vc_commit);
Modified: trunk/geanyvc/geanyvc.h =================================================================== --- trunk/geanyvc/geanyvc.h 2008-10-17 15:39:57 UTC (rev 213) +++ trunk/geanyvc/geanyvc.h 2008-10-20 10:20:44 UTC (rev 214) @@ -35,6 +35,7 @@ VC_COMMAND_COMMIT, VC_COMMAND_BLAME, VC_COMMAND_SHOW, + VC_COMMAND_UPDATE, VC_COMMAND_COUNT };
Modified: trunk/geanyvc/vc_bzr.c =================================================================== --- trunk/geanyvc/vc_bzr.c 2008-10-17 15:39:57 UTC (rev 213) +++ trunk/geanyvc/vc_bzr.c 2008-10-20 10:20:44 UTC (rev 214) @@ -45,6 +45,7 @@ static const gchar *BZR_CMD_COMMIT[] = { "bzr", "commit", "-m", MESSAGE, FILE_LIST, NULL }; static const gchar *BZR_CMD_BLAME[] = { "bzr", "blame", "--all", "--long", BASENAME, NULL }; static const gchar *BZR_CMD_SHOW[] = { "bzr", "cat", BASENAME, NULL }; +static const gchar *BZR_CMD_UPDATE[] = { "bzr", "pull", NULL };
static const VC_COMMAND commands[] = { { @@ -101,6 +102,11 @@ .startdir = VC_COMMAND_STARTDIR_FILE, .command = BZR_CMD_SHOW, .env = NULL, + .function = NULL}, + { + .startdir = VC_COMMAND_STARTDIR_BASE, + .command = BZR_CMD_UPDATE, + .env = NULL, .function = NULL} };
Modified: trunk/geanyvc/vc_cvs.c =================================================================== --- trunk/geanyvc/vc_cvs.c 2008-10-17 15:39:57 UTC (rev 213) +++ trunk/geanyvc/vc_cvs.c 2008-10-20 10:20:44 UTC (rev 214) @@ -42,6 +42,7 @@ static const gchar *CVS_CMD_COMMIT[] = { "cvs", NULL }; static const gchar *CVS_CMD_BLAME[] = { "cvs", "annotate", BASE_FILENAME, NULL }; static const gchar *CVS_CMD_SHOW[] = { "cvs", NULL }; +static const gchar *CVS_CMD_UPDATE[] = { "cvs", "up", "-d", NULL };
static const VC_COMMAND commands[] = { { @@ -98,6 +99,11 @@ .startdir = VC_COMMAND_STARTDIR_FILE, .command = CVS_CMD_SHOW, .env = NULL, + .function = NULL}, + { + .startdir = VC_COMMAND_STARTDIR_BASE, + .command = CVS_CMD_UPDATE, + .env = NULL, .function = NULL} };
Modified: trunk/geanyvc/vc_git.c =================================================================== --- trunk/geanyvc/vc_git.c 2008-10-17 15:39:57 UTC (rev 213) +++ trunk/geanyvc/vc_git.c 2008-10-20 10:20:44 UTC (rev 214) @@ -98,6 +98,7 @@ static const gchar *GIT_CMD_LOG_FILE[] = { "git", "log", "--", BASENAME, NULL }; static const gchar *GIT_CMD_LOG_DIR[] = { "git", "log", NULL }; static const gchar *GIT_CMD_BLAME[] = { "git", "blame", "--", BASENAME, NULL }; +static const gchar *GIT_CMD_UPDATE[] = { "git", "pull", NULL };
static const gchar *GIT_ENV_DIFF_FILE[] = { "PAGER=cat", NULL }; static const gchar *GIT_ENV_DIFF_DIR[] = { "PAGER=cat", NULL }; @@ -108,6 +109,7 @@ static const gchar *GIT_ENV_LOG_FILE[] = { "PAGER=cat", NULL }; static const gchar *GIT_ENV_LOG_DIR[] = { "PAGER=cat", NULL }; static const gchar *GIT_ENV_BLAME[] = { "PAGER=cat", NULL }; +static const gchar *GIT_ENV_UPDATE[] = { "PAGER=cat", NULL };
static const VC_COMMAND commands[] = { { @@ -164,7 +166,12 @@ .startdir = VC_COMMAND_STARTDIR_FILE, .command = NULL, .env = GIT_ENV_SHOW, - .function = git_show} + .function = git_show}, + { + .startdir = VC_COMMAND_STARTDIR_BASE, + .command = GIT_CMD_UPDATE, + .env = GIT_ENV_UPDATE, + .function = NULL} };
static gboolean
Modified: trunk/geanyvc/vc_hg.c =================================================================== --- trunk/geanyvc/vc_hg.c 2008-10-17 15:39:57 UTC (rev 213) +++ trunk/geanyvc/vc_hg.c 2008-10-20 10:20:44 UTC (rev 214) @@ -45,6 +45,7 @@ static const gchar *HG_CMD_COMMIT[] = { "hg", "commit", "-m", MESSAGE, FILE_LIST, NULL }; static const gchar *HG_CMD_BLAME[] = { "hg", "annotate", BASENAME, NULL }; static const gchar *HG_CMD_SHOW[] = { "hg", "cat", BASENAME, NULL }; +static const gchar *HG_CMD_UPDATE[] = { "hg", "pull", CMD_SEPARATOR, "hg", "update", NULL };
static const VC_COMMAND commands[] = { { @@ -101,6 +102,11 @@ .startdir = VC_COMMAND_STARTDIR_FILE, .command = HG_CMD_SHOW, .env = NULL, + .function = NULL}, + { + .startdir = VC_COMMAND_STARTDIR_BASE, + .command = HG_CMD_UPDATE, + .env = NULL, .function = NULL} };
Modified: trunk/geanyvc/vc_svk.c =================================================================== --- trunk/geanyvc/vc_svk.c 2008-10-17 15:39:57 UTC (rev 213) +++ trunk/geanyvc/vc_svk.c 2008-10-20 10:20:44 UTC (rev 214) @@ -45,8 +45,8 @@ static const gchar *SVK_CMD_COMMIT[] = { "svk", "commit", "-m", MESSAGE, FILE_LIST, NULL }; static const gchar *SVK_CMD_BLAME[] = { "svk", "blame", BASENAME, NULL }; static const gchar *SVK_CMD_SHOW[] = { "svk", "cat", BASENAME, NULL }; +static const gchar *SVK_CMD_UPDATE[] = { "svk", "up", NULL };
- static const VC_COMMAND commands[] = { { .startdir = VC_COMMAND_STARTDIR_FILE, @@ -102,6 +102,11 @@ .startdir = VC_COMMAND_STARTDIR_FILE, .command = SVK_CMD_SHOW, .env = NULL, + .function = NULL}, + { + .startdir = VC_COMMAND_STARTDIR_BASE, + .command = SVK_CMD_UPDATE, + .env = NULL, .function = NULL} };
Modified: trunk/geanyvc/vc_svn.c =================================================================== --- trunk/geanyvc/vc_svn.c 2008-10-17 15:39:57 UTC (rev 213) +++ trunk/geanyvc/vc_svn.c 2008-10-20 10:20:44 UTC (rev 214) @@ -47,6 +47,7 @@ { "svn", "commit", "--non-interactive", "-m", MESSAGE, FILE_LIST, NULL }; static const gchar *SVN_CMD_BLAME[] = { "svn", "blame", BASENAME, NULL }; static const gchar *SVN_CMD_SHOW[] = { "svn", "cat", BASENAME, NULL }; +static const gchar *SVN_CMD_UPDATE[] = { "svn", "up", NULL };
static const VC_COMMAND commands[] = { { @@ -103,6 +104,11 @@ .startdir = VC_COMMAND_STARTDIR_FILE, .command = SVN_CMD_SHOW, .env = NULL, + .function = NULL}, + { + .startdir = VC_COMMAND_STARTDIR_BASE, + .command = SVN_CMD_UPDATE, + .env = NULL, .function = NULL} };
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.