[anjuta] git: Add init support (bgo 566698)



commit 5c57ade9b8c2cb423f5f1a4ba3e84df9e8ae1bea
Author: James Liggett <jrliggett cox net>
Date:   Thu Jul 30 02:00:00 2009 -0700

    git: Add init support (bgo 566698)

 plugins/git/Makefile.am        |    6 +++-
 plugins/git/anjuta-git.xml     |    2 +
 plugins/git/git-init-command.c |   78 ++++++++++++++++++++++++++++++++++++++++
 plugins/git/git-init-command.h |   58 +++++++++++++++++++++++++++++
 plugins/git/git-init-dialog.c  |   54 +++++++++++++++++++++++++++
 plugins/git/git-init-dialog.h  |   33 +++++++++++++++++
 plugins/git/plugin.c           |   11 +++++-
 7 files changed, 240 insertions(+), 2 deletions(-)
---
diff --git a/plugins/git/Makefile.am b/plugins/git/Makefile.am
index ca680cc..5f2c7ae 100644
--- a/plugins/git/Makefile.am
+++ b/plugins/git/Makefile.am
@@ -219,7 +219,11 @@ libanjuta_git_la_SOURCES = \
 	git-stash-drop-command.c \
 	git-stash-drop-command.h \
 	git-stash-clear-command.c \
-	git-stash-clear-command.h
+	git-stash-clear-command.h \
+	git-init-command.c \
+	git-init-command.h \
+	git-init-dialog.c \
+	git-init-dialog.h
 
 libanjuta_git_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
 
diff --git a/plugins/git/anjuta-git.xml b/plugins/git/anjuta-git.xml
index e3c423c..497bc04 100644
--- a/plugins/git/anjuta-git.xml
+++ b/plugins/git/anjuta-git.xml
@@ -85,6 +85,8 @@
 				</placeholder>
 				<separator />
 				<menuitem name="View log..." action="ActionGitLog" />
+				<separator />
+				<menuitem name="Initialize repository" action="ActionGitInit" />
 			</placeholder>
 		</menu>
 		</placeholder>
diff --git a/plugins/git/git-init-command.c b/plugins/git/git-init-command.c
new file mode 100644
index 0000000..8af3398
--- /dev/null
+++ b/plugins/git/git-init-command.c
@@ -0,0 +1,78 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2008 <jrliggett cox net>
+ * 
+ * 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-init-command.h"
+
+G_DEFINE_TYPE (GitInitCommand, git_init_command, 
+			   GIT_TYPE_COMMAND);
+
+static void
+git_init_command_init (GitInitCommand *self)
+{
+
+}
+
+static void
+git_init_command_finalize (GObject *object)
+{
+	GitInitCommand *self;
+	
+	self = GIT_INIT_COMMAND (object);
+	
+	G_OBJECT_CLASS (git_init_command_parent_class)->finalize (object);
+}
+
+static guint
+git_init_command_run (AnjutaCommand *command)
+{	
+	GitInitCommand *self;
+	
+	self = GIT_INIT_COMMAND (command);
+	
+	git_command_add_arg (GIT_COMMAND (command), "init");
+	
+	return 0;
+}
+
+static void
+git_init_command_class_init (GitInitCommandClass *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_init_command_finalize;
+	parent_class->output_handler = git_command_send_output_to_info;
+	command_class->run = git_init_command_run;
+}
+
+
+GitInitCommand *
+git_init_command_new (const gchar *working_directory)
+{
+	return g_object_new (GIT_TYPE_INIT_COMMAND, 
+						 "working-directory", working_directory,
+						 NULL);
+}
+
diff --git a/plugins/git/git-init-command.h b/plugins/git/git-init-command.h
new file mode 100644
index 0000000..aa4a2d3
--- /dev/null
+++ b/plugins/git/git-init-command.h
@@ -0,0 +1,58 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2008 <jrliggett cox net>
+ * 
+ * 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_INIT_COMMAND_H_
+#define _GIT_INIT_COMMAND_H_
+
+#include <glib-object.h>
+#include "git-command.h"
+
+G_BEGIN_DECLS
+
+#define GIT_TYPE_INIT_COMMAND             (git_init_command_get_type ())
+#define GIT_INIT_COMMAND(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIT_TYPE_INIT_COMMAND, GitInitCommand))
+#define GIT_INIT_COMMAND_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GIT_TYPE_INIT_COMMAND, GitInitCommandClass))
+#define GIT_IS_INIT_COMMAND(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIT_TYPE_INIT_COMMAND))
+#define GIT_IS_INIT_COMMAND_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GIT_TYPE_INIT_COMMAND))
+#define GIT_INIT_COMMAND_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GIT_TYPE_INIT_COMMAND, GitInitCommandClass))
+
+typedef struct _GitInitCommandClass GitInitCommandClass;
+typedef struct _GitInitCommand GitInitCommand;
+
+struct _GitInitCommandClass
+{
+	GitCommandClass parent_class;
+};
+
+struct _GitInitCommand
+{
+	GitCommand parent_instance;
+};
+
+GType git_init_command_get_type (void) G_GNUC_CONST;
+GitInitCommand *git_init_command_new (const gchar *working_directory);
+
+G_END_DECLS
+
+#endif /* _GIT_INIT_COMMAND_H_ */
diff --git a/plugins/git/git-init-dialog.c b/plugins/git/git-init-dialog.c
new file mode 100644
index 0000000..e505e2d
--- /dev/null
+++ b/plugins/git/git-init-dialog.c
@@ -0,0 +1,54 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2008 <jrliggett cox net>
+ * 
+ * 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-init-dialog.h"
+
+/* TODO: Implement a working dialog when the need arises. */
+
+static void
+git_init (Git *plugin)
+{
+	GitInitCommand *init_command;
+	
+	init_command = git_init_command_new (plugin->project_root_directory);
+
+	git_create_message_view (plugin);
+	
+	g_signal_connect (G_OBJECT (init_command), "data-arrived",
+					  G_CALLBACK (on_git_command_info_arrived),
+					  plugin);
+	
+	g_signal_connect (G_OBJECT (init_command), "command_finished",
+					  G_CALLBACK (on_git_command_finished),
+					  NULL);
+	
+	anjuta_command_start (ANJUTA_COMMAND (init_command));
+	
+}
+
+void
+on_menu_git_init (GtkAction *action, Git *plugin)
+{
+	git_init (plugin);
+}
diff --git a/plugins/git/git-init-dialog.h b/plugins/git/git-init-dialog.h
new file mode 100644
index 0000000..19d4b7e
--- /dev/null
+++ b/plugins/git/git-init-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 <jrliggett cox net>
+ * 
+ * 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_INIT_DIALOG_H
+#define _GIT_INIT_DIALOG_H
+
+#include "git-init-command.h"
+#include "git-ui-utils.h"
+
+void on_menu_git_init (GtkAction *action, Git *plugin);
+
+#endif
diff --git a/plugins/git/plugin.c b/plugins/git/plugin.c
index abff26a..9130449 100644
--- a/plugins/git/plugin.c
+++ b/plugins/git/plugin.c
@@ -52,6 +52,7 @@
 #include "git-stash-changes-dialog.h"
 #include "git-stash-widget.h"
 #include "git-apply-stash-dialog.h"
+#include "git-init-dialog.h"
 
 #define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-git.xml"
 
@@ -439,7 +440,15 @@ static GtkActionEntry actions_git[] =
 		NULL,                                     /* short-cut */
 		N_("View change history"),                      /* Tooltip */
 		G_CALLBACK (on_menu_git_log)    /* action callback */
-	}
+	},
+	{
+		"ActionGitInit",                       /* Action name */
+		NULL,                            /* Stock icon, if any */
+		N_("_Initialize repository"),                     /* Display label */
+		NULL,                                     /* short-cut */
+		N_("Create a new git repository or reinitialize an existing one"),                      /* Tooltip */
+		G_CALLBACK (on_menu_git_init)    /* action callback */
+	},
 };
 
 static GtkActionEntry actions_log[] =



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]