From 373f5f994063db8007cddadbe2c6097f3eaf43a9 Mon Sep 17 00:00:00 2001 From: James Liggett Date: Sat, 31 May 2008 17:10:26 -0700 Subject: [PATCH] Implement fetching --- TODO.tasks | 10 ++--- plugins/git/Makefile.am | 6 ++- plugins/git/anjuta-git.ui | 1 + plugins/git/git-fetch-command.c | 69 +++++++++++++++++++++++++++++++++ plugins/git/git-fetch-command.h | 58 ++++++++++++++++++++++++++++ plugins/git/git-fetch-dialog.c | 84 +++++++++++++++++++++++++++++++++++++++++ plugins/git/git-fetch-dialog.h | 33 ++++++++++++++++ plugins/git/plugin.c | 9 +++++ 8 files changed, 264 insertions(+), 6 deletions(-) create mode 100644 plugins/git/git-fetch-command.c create mode 100644 plugins/git/git-fetch-command.h create mode 100644 plugins/git/git-fetch-dialog.c create mode 100644 plugins/git/git-fetch-dialog.h diff --git a/TODO.tasks b/TODO.tasks index 6c21384c..46eead4e 100644 --- a/TODO.tasks +++ b/TODO.tasks @@ -643,11 +643,6 @@ Fix c++/gobject class generator to allow adding members, methods, signals, prope - - Fetching - - - Rebasing @@ -740,6 +735,11 @@ Fix c++/gobject class generator to allow adding members, methods, signals, prope Reverting commits + + + + + Fetching diff --git a/plugins/git/Makefile.am b/plugins/git/Makefile.am index 4f82aa37..b2835b6c 100644 --- a/plugins/git/Makefile.am +++ b/plugins/git/Makefile.am @@ -129,7 +129,11 @@ libanjuta_git_la_SOURCES = \ git-revert-command.c \ git-revert-command.h \ git-revert-dialog.c \ - git-revert-dialog.h + git-revert-dialog.h \ + git-fetch-command.c \ + git-fetch-command.h \ + git-fetch-dialog.c \ + git-fetch-dialog.h libanjuta_git_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS) diff --git a/plugins/git/anjuta-git.ui b/plugins/git/anjuta-git.ui index 95f97d43..658e8d8d 100644 --- a/plugins/git/anjuta-git.ui +++ b/plugins/git/anjuta-git.ui @@ -5,6 +5,7 @@ + diff --git a/plugins/git/git-fetch-command.c b/plugins/git/git-fetch-command.c new file mode 100644 index 00000000..a3c081e1 --- /dev/null +++ b/plugins/git/git-fetch-command.c @@ -0,0 +1,69 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * anjuta-git + * Copyright (C) James Liggett 2008 + * + * anjuta-git is free software. + * + * You may redistribute it and/or modify it under the terms of the + * GNU General Public License, as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * anjuta-git 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with anjuta-git. If not, write to: + * The Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301, USA. + */ + +#include "git-fetch-command.h" + +G_DEFINE_TYPE (GitFetchCommand, git_fetch_command, GIT_TYPE_COMMAND); + +static void +git_fetch_command_init (GitFetchCommand *self) +{ +} + +static void +git_fetch_command_finalize (GObject *object) +{ + G_OBJECT_CLASS (git_fetch_command_parent_class)->finalize (object); +} + +static guint +git_fetch_command_run (AnjutaCommand *command) +{ + git_command_add_arg (GIT_COMMAND (command), "fetch"); + git_command_add_arg (GIT_COMMAND (command), "-q"); + + return 0; +} + +static void +git_fetch_command_class_init (GitFetchCommandClass *klass) +{ + GObjectClass* object_class = G_OBJECT_CLASS (klass); + GitCommandClass *parent_class = GIT_COMMAND_CLASS (klass); + AnjutaCommandClass* command_class = ANJUTA_COMMAND_CLASS (klass); + + object_class->finalize = git_fetch_command_finalize; + parent_class->output_handler = git_command_send_output_to_info; + command_class->run = git_fetch_command_run; +} + + +GitFetchCommand * +git_fetch_command_new (const gchar *working_directory) +{ + return g_object_new (GIT_TYPE_FETCH_COMMAND, + "working-directory", working_directory, + "single-line-output", TRUE, + NULL); +} diff --git a/plugins/git/git-fetch-command.h b/plugins/git/git-fetch-command.h new file mode 100644 index 00000000..9b15728a --- /dev/null +++ b/plugins/git/git-fetch-command.h @@ -0,0 +1,58 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * anjuta-git + * Copyright (C) James Liggett 2008 + * + * anjuta-git is free software. + * + * You may redistribute it and/or modify it under the terms of the + * GNU General Public License, as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * anjuta-git 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with anjuta-git. If not, write to: + * The Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301, USA. + */ + +#ifndef _GIT_FETCH_COMMAND_H_ +#define _GIT_FETCH_COMMAND_H_ + +#include +#include "git-command.h" + +G_BEGIN_DECLS + +#define GIT_TYPE_FETCH_COMMAND (git_fetch_command_get_type ()) +#define GIT_FETCH_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIT_TYPE_FETCH_COMMAND, GitFetchCommand)) +#define GIT_FETCH_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIT_TYPE_FETCH_COMMAND, GitFetchCommandClass)) +#define GIT_IS_FETCH_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIT_TYPE_FETCH_COMMAND)) +#define GIT_IS_FETCH_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIT_TYPE_FETCH_COMMAND)) +#define GIT_FETCH_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIT_TYPE_FETCH_COMMAND, GitFetchCommandClass)) + +typedef struct _GitFetchCommandClass GitFetchCommandClass; +typedef struct _GitFetchCommand GitFetchCommand; + +struct _GitFetchCommandClass +{ + GitCommandClass parent_class; +}; + +struct _GitFetchCommand +{ + GitCommand parent_instance; +}; + +GType git_fetch_command_get_type (void) G_GNUC_CONST; +GitFetchCommand *git_fetch_command_new (const gchar *working_directory); + +G_END_DECLS + +#endif /* _GIT_FETCH_COMMAND_H_ */ diff --git a/plugins/git/git-fetch-dialog.c b/plugins/git/git-fetch-dialog.c new file mode 100644 index 00000000..682c3989 --- /dev/null +++ b/plugins/git/git-fetch-dialog.c @@ -0,0 +1,84 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * anjuta + * Copyright (C) James Liggett 2008 + * + * anjuta is free software. + * + * You may redistribute it and/or modify it under the terms of the + * GNU General Public License, as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * anjuta 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with anjuta. If not, write to: + * The Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301, USA. + */ + +#include "git-fetch-dialog.h" + +/* FIXME: We don't really have a dialog yet. We would probably need one to + * support some advanced options of fetch, though. Make the dialog when we + * implment those. */ + +static void +on_fetch_command_finished (AnjutaCommand *command, guint return_code, + Git *plugin) +{ + AnjutaStatus *status; + + status = anjuta_shell_get_status (ANJUTA_PLUGIN (plugin)->shell, + NULL); + + anjuta_status (status, _("Git: Fetch complete."), 5); + + report_errors (command, return_code); + + g_object_unref (command); + +} + +static void +git_fetch (Git *plugin) +{ + GitProgressData *data; + GitFetchCommand *fetch_command; + + data = git_progress_data_new (plugin, _("Git: Fetching...")); + fetch_command = git_fetch_command_new (plugin->project_root_directory); + + g_signal_connect (G_OBJECT (fetch_command), "data-arrived", + G_CALLBACK (on_command_info_arrived), + plugin); + + g_signal_connect (G_OBJECT (fetch_command), "command-finished", + G_CALLBACK (on_fetch_command_finished), + plugin); + + g_signal_connect_swapped (G_OBJECT (fetch_command), "command-finished", + G_CALLBACK (git_progress_data_free), + data); + + g_signal_connect (G_OBJECT (fetch_command), "progress", + G_CALLBACK (on_command_progress), + data); + + create_message_view (plugin); + + anjuta_command_start (ANJUTA_COMMAND (fetch_command)); + +} + +void +on_menu_git_fetch (GtkAction *action, Git *plugin) +{ + git_fetch (plugin); +} + diff --git a/plugins/git/git-fetch-dialog.h b/plugins/git/git-fetch-dialog.h new file mode 100644 index 00000000..52f40804 --- /dev/null +++ b/plugins/git/git-fetch-dialog.h @@ -0,0 +1,33 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * anjuta + * Copyright (C) James Liggett 2008 + * + * anjuta is free software. + * + * You may redistribute it and/or modify it under the terms of the + * GNU General Public License, as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * anjuta 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with anjuta. If not, write to: + * The Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301, USA. + */ + +#ifndef _GIT_FETCH_DIALOG_H +#define _GIT_FETCH_DIALOG_H + +#include "git-fetch-command.h" +#include "git-ui-utils.h" + +void on_menu_git_fetch (GtkAction *action, Git *plugin); + +#endif diff --git a/plugins/git/plugin.c b/plugins/git/plugin.c index 9a1d1e25..5c9a23cd 100644 --- a/plugins/git/plugin.c +++ b/plugins/git/plugin.c @@ -35,6 +35,7 @@ #include "git-create-tag-dialog.h" #include "git-reset-dialog.h" #include "git-revert-dialog.h" +#include "git-fetch-dialog.h" #define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-git.ui" @@ -59,6 +60,14 @@ static GtkActionEntry actions_git[] = G_CALLBACK (on_menu_git_commit) /* action callback */ }, { + "ActionGitFetch", /* Action name */ + GTK_STOCK_CONNECT, /* Stock icon, if any */ + N_("_Fetch..."), /* Display label */ + NULL, /* short-cut */ + NULL, /* Tooltip */ + G_CALLBACK (on_menu_git_fetch) /* action callback */ + }, + { "ActionGitUnstageFiles", /* Action name */ GTK_STOCK_CANCEL, /* Stock icon, if any */ N_("_Unstage files..."), /* Display label */ -- 2.11.4.GIT