[anjuta/git-shell] git: Initial implementation of the Remotes pane



commit 2779e092d167ccbf61dd9c020dca71cbea55e3ca
Author: James Liggett <jrliggett cox net>
Date:   Fri Jun 25 22:42:58 2010 -0700

    git: Initial implementation of the Remotes pane
    
    Still need to handle selections

 plugins/git/Makefile.am        |    8 ++-
 plugins/git/anjuta-git.ui      |   62 ++++++++++++++++++
 plugins/git/git-remotes-pane.c |  134 ++++++++++++++++++++++++++++++++++++++++
 plugins/git/git-remotes-pane.h |   57 +++++++++++++++++
 plugins/git/plugin.c           |   15 +++++
 plugins/git/plugin.h           |    3 +
 6 files changed, 277 insertions(+), 2 deletions(-)
---
diff --git a/plugins/git/Makefile.am b/plugins/git/Makefile.am
index 2be9e78..d890baf 100644
--- a/plugins/git/Makefile.am
+++ b/plugins/git/Makefile.am
@@ -22,7 +22,9 @@ git_plugin_DATA = $(plugin_in_files:.plugin.in=.plugin) \
 	git-merge-pane.c        \
 	git-merge-pane.h        \
 	git-add-files-pane.h        \
-	git-add-files-pane.c
+	git-add-files-pane.c        \
+	git-remotes-pane.h        \
+	git-remotes-pane.c
 
 # NOTE :
 # The naming convention is very intentional
@@ -181,7 +183,9 @@ libanjuta_git_la_SOURCES = \
 	git-add-files-pane.c \
 	git-add-files-pane.h \
 	git-remove-files-pane.c \
-	git-remove-files-pane.h
+	git-remove-files-pane.h \
+	git-remotes-pane.c \
+	git-remotes-pane.h
 
 libanjuta_git_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
 
diff --git a/plugins/git/anjuta-git.ui b/plugins/git/anjuta-git.ui
index 8e84dde..4b58752 100644
--- a/plugins/git/anjuta-git.ui
+++ b/plugins/git/anjuta-git.ui
@@ -389,6 +389,12 @@
       <column type="gchararray"/>
     </columns>
   </object>
+  <object class="GtkListStore" id="remotes_list_model">
+    <columns>
+      <!-- column-name name -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkVBox" id="status_pane">
     <property name="visible">True</property>
     <child>
@@ -1630,4 +1636,60 @@
       </packing>
     </child>
   </object>
+  <object class="GtkVBox" id="remotes_pane">
+    <property name="visible">True</property>
+    <property name="orientation">vertical</property>
+    <child>
+      <object class="GtkFrame" id="frame1">
+        <property name="visible">True</property>
+        <property name="label_xalign">0</property>
+        <property name="shadow_type">none</property>
+        <child>
+          <object class="GtkAlignment" id="alignment1">
+            <property name="visible">True</property>
+            <property name="left_padding">12</property>
+            <child>
+              <object class="GtkScrolledWindow" id="scrolledwindow1">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="hscrollbar_policy">automatic</property>
+                <property name="vscrollbar_policy">automatic</property>
+                <property name="shadow_type">in</property>
+                <child>
+                  <object class="GtkTreeView" id="remotes_view">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="model">remotes_list_model</property>
+                    <property name="headers_visible">False</property>
+                    <property name="headers_clickable">False</property>
+                    <child>
+                      <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+                        <property name="title">column</property>
+                        <child>
+                          <object class="GtkCellRendererText" id="name_renderer"/>
+                          <attributes>
+                            <attribute name="text">0</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child type="label">
+          <object class="GtkLabel" id="label1">
+            <property name="visible">True</property>
+            <property name="label" translatable="yes">&lt;b&gt;Remote Repositories:&lt;/b&gt;</property>
+            <property name="use_markup">True</property>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="position">0</property>
+      </packing>
+    </child>
+  </object>
 </interface>
diff --git a/plugins/git/git-remotes-pane.c b/plugins/git/git-remotes-pane.c
new file mode 100644
index 0000000..639fa60
--- /dev/null
+++ b/plugins/git/git-remotes-pane.c
@@ -0,0 +1,134 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2010 <jrliggett cox net>
+ * 
+ * anjuta is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "git-remotes-pane.h"
+
+struct _GitRemotesPanePriv
+{
+	GtkBuilder *builder;
+};
+
+G_DEFINE_TYPE (GitRemotesPane, git_remotes_pane, GIT_TYPE_PANE);
+
+static void
+git_remotes_pane_init (GitRemotesPane *self)
+{
+	gchar *objects[] = {"remotes_pane",
+						"remotes_list_model",
+						NULL};
+	GError *error = NULL;
+
+	self->priv = g_new0 (GitRemotesPanePriv, 1);
+	self->priv->builder = gtk_builder_new ();
+
+	if (!gtk_builder_add_objects_from_file (self->priv->builder, BUILDER_FILE, 
+	                                        objects, 
+	                                        &error))
+	{
+		g_warning ("Couldn't load builder file: %s", error->message);
+		g_error_free (error);
+	}
+}
+
+static void
+git_remotes_pane_finalize (GObject *object)
+{
+	GitRemotesPane *self;
+
+	self = GIT_REMOTES_PANE (object);
+
+	g_object_unref (self->priv->builder);
+	g_free (self->priv);
+
+	G_OBJECT_CLASS (git_remotes_pane_parent_class)->finalize (object);
+}
+
+static GtkWidget *
+git_remotes_pane_get_widget (AnjutaDockPane *pane)
+{
+	GitRemotesPane *self;
+
+	self = GIT_REMOTES_PANE (pane);
+
+	return GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
+	                                           "remotes_pane"));
+}
+
+static void
+git_remotes_pane_class_init (GitRemotesPaneClass *klass)
+{
+	GObjectClass* object_class = G_OBJECT_CLASS (klass);
+	AnjutaDockPaneClass* pane_class = ANJUTA_DOCK_PANE_CLASS (klass);
+
+	object_class->finalize = git_remotes_pane_finalize;
+	pane_class->get_widget = git_remotes_pane_get_widget;
+	pane_class->refresh = NULL;
+}
+
+static void
+on_remote_list_command_data_arrived (AnjutaCommand *command, 
+                                     GitRemotesPane *self)
+{
+	GtkListStore *remotes_list_model;
+	GQueue *output;
+	gchar *remote;
+	GtkTreeIter iter;
+
+	remotes_list_model = GTK_LIST_STORE (gtk_builder_get_object (self->priv->builder,
+	                                                             "remotes_list_model"));
+	output = git_raw_output_command_get_output (GIT_RAW_OUTPUT_COMMAND (command));
+
+	while (g_queue_peek_head (output))
+	{
+		remote = g_queue_pop_head (output);
+
+		gtk_list_store_append (remotes_list_model, &iter);
+		gtk_list_store_set (remotes_list_model, &iter, 0, remote, -1);
+
+		g_free (remote);
+	}
+}
+
+AnjutaDockPane *
+git_remotes_pane_new (Git *plugin)
+{
+	GitRemotesPane *self;
+	GtkListStore *remotes_list_model;
+
+	self = g_object_new (GIT_TYPE_REMOTES_PANE, "plugin", plugin, NULL);
+	remotes_list_model = GTK_LIST_STORE (gtk_builder_get_object (self->priv->builder,
+	                                                             "remotes_list_model"));
+
+	g_signal_connect_swapped (G_OBJECT (plugin->remote_list_command), 
+	                          "command-started",
+	                          G_CALLBACK (gtk_list_store_clear),
+	                          remotes_list_model);
+
+	g_signal_connect (G_OBJECT (plugin->remote_list_command), "data-arrived",
+	                  G_CALLBACK (on_remote_list_command_data_arrived),
+	                  self);
+
+	return ANJUTA_DOCK_PANE (self);
+}
+
+gchar *
+git_remotes_pane_get_selected_remote (GitRemotesPane *self)
+{
+	return NULL;
+}
diff --git a/plugins/git/git-remotes-pane.h b/plugins/git/git-remotes-pane.h
new file mode 100644
index 0000000..6509e7a
--- /dev/null
+++ b/plugins/git/git-remotes-pane.h
@@ -0,0 +1,57 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2010 <jrliggett cox net>
+ * 
+ * anjuta is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _GIT_REMOTES_PANE_H_
+#define _GIT_REMOTES_PANE_H_
+
+#include <glib-object.h>
+#include "git-pane.h"
+
+G_BEGIN_DECLS
+
+#define GIT_TYPE_REMOTES_PANE             (git_remotes_pane_get_type ())
+#define GIT_REMOTES_PANE(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIT_TYPE_REMOTES_PANE, GitRemotesPane))
+#define GIT_REMOTES_PANE_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GIT_TYPE_REMOTES_PANE, GitRemotesPaneClass))
+#define GIT_IS_REMOTES_PANE(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIT_TYPE_REMOTES_PANE))
+#define GIT_IS_REMOTES_PANE_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GIT_TYPE_REMOTES_PANE))
+#define GIT_REMOTES_PANE_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GIT_TYPE_REMOTES_PANE, GitRemotesPaneClass))
+
+typedef struct _GitRemotesPaneClass GitRemotesPaneClass;
+typedef struct _GitRemotesPane GitRemotesPane;
+typedef struct _GitRemotesPanePriv GitRemotesPanePriv;
+
+struct _GitRemotesPaneClass
+{
+	GitPaneClass parent_class;
+};
+
+struct _GitRemotesPane
+{
+	GitPane parent_instance;
+
+	GitRemotesPanePriv *priv;
+};
+
+GType git_remotes_pane_get_type (void) G_GNUC_CONST;
+AnjutaDockPane *git_remotes_pane_new (Git *plugin);
+gchar *git_remotes_pane_get_selected_remote (GitRemotesPane *self);
+
+G_END_DECLS
+
+#endif /* _GIT_REMOTES_PANE_H_ */
diff --git a/plugins/git/plugin.c b/plugins/git/plugin.c
index fe839b5..5c04780 100644
--- a/plugins/git/plugin.c
+++ b/plugins/git/plugin.c
@@ -30,6 +30,7 @@
 #include "git-commit-pane.h"
 #include "git-add-files-pane.h"
 #include "git-remove-files-pane.h"
+#include "git-remotes-pane.h"
 
 AnjutaCommandBarEntry branch_entries[] =
 {
@@ -150,11 +151,16 @@ on_project_root_added (AnjutaPlugin *plugin, const gchar *name,
 	g_object_set (G_OBJECT (git_plugin->not_updated_status_command),
 	              "working-directory", git_plugin->project_root_directory,
 	              NULL);
+	g_object_set (G_OBJECT (git_plugin->remote_list_command),
+	              "working-directory", git_plugin->project_root_directory,
+	              NULL);
 
 	anjuta_command_start_automatic_monitor (ANJUTA_COMMAND (git_plugin->local_branch_list_command));
 	anjuta_command_start_automatic_monitor (ANJUTA_COMMAND (git_plugin->commit_status_command));
+	anjuta_command_start_automatic_monitor (ANJUTA_COMMAND (git_plugin->remote_list_command));
 	anjuta_command_start (ANJUTA_COMMAND (git_plugin->local_branch_list_command));
 	anjuta_command_start (ANJUTA_COMMAND (git_plugin->commit_status_command));
+	anjuta_command_start (ANJUTA_COMMAND (git_plugin->remote_list_command));
 	
 	gtk_widget_set_sensitive (git_plugin->dock, TRUE);
 	gtk_widget_set_sensitive (git_plugin->command_bar, TRUE);
@@ -344,6 +350,9 @@ git_activate_plugin (AnjutaPlugin *plugin)
 	git_plugin->not_updated_status_command = git_status_command_new (NULL,
 	                                                                 GIT_STATUS_SECTION_NOT_UPDATED);
 
+	/* Remote list command */
+	git_plugin->remote_list_command = git_remote_list_command_new (NULL);
+
 	/* Always run the not updated commmand after the commmit command. */
 	g_signal_connect (G_OBJECT (git_plugin->commit_status_command), 
 	                  "command-finished",
@@ -362,6 +371,11 @@ git_activate_plugin (AnjutaPlugin *plugin)
 	                      _("Branches"), NULL, git_plugin->branches_pane,   
 	                      GDL_DOCK_CENTER, branch_entries, 
 	                      G_N_ELEMENTS (branch_entries), git_plugin);
+
+	git_plugin->remotes_pane = git_remotes_pane_new (git_plugin);
+	anjuta_dock_add_pane (ANJUTA_DOCK (git_plugin->dock), "Remotes", 
+	                      _("Remotes"), NULL, git_plugin->remotes_pane,
+	                      GDL_DOCK_CENTER, NULL, 0, NULL);
 	
 	/* Add watches */
 	git_plugin->project_root_watch_id = anjuta_plugin_add_watch (plugin,
@@ -411,6 +425,7 @@ git_deactivate_plugin (AnjutaPlugin *plugin)
 	g_object_unref (git_plugin->remote_branch_list_command);
 	g_object_unref (git_plugin->commit_status_command);
 	g_object_unref (git_plugin->not_updated_status_command);
+	g_object_unref (git_plugin->remote_list_command);
 	
 	g_free (git_plugin->project_root_directory);
 	g_free (git_plugin->current_editor_filename);
diff --git a/plugins/git/plugin.h b/plugins/git/plugin.h
index 42c98ac..89d29e7 100644
--- a/plugins/git/plugin.h
+++ b/plugins/git/plugin.h
@@ -37,6 +37,7 @@
 #include <libanjuta/anjuta-command-queue.h>
 #include "git-branch-list-command.h"
 #include "git-status-command.h"
+#include "git-remote-list-command.h"
 
 extern GType git_get_type (GTypeModule *module);
 #define ANJUTA_TYPE_PLUGIN_GIT         (git_get_type (NULL))
@@ -67,6 +68,7 @@ struct _Git
 	/* Dock panes */
 	AnjutaDockPane *status_pane;
 	AnjutaDockPane *branches_pane;
+	AnjutaDockPane *remotes_pane;
 
 	/* List commands for various panes. 
 	 * Keep them in the plugin so that the commands have the most direct
@@ -75,6 +77,7 @@ struct _Git
 	GitBranchListCommand *remote_branch_list_command;
 	GitStatusCommand *commit_status_command;
 	GitStatusCommand *not_updated_status_command;
+	GitRemoteListCommand *remote_list_command;
 	
 	IAnjutaMessageView *message_view;
 	AnjutaCommandQueue *command_queue;



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