[anjuta/git-shell: 28/34] git: Implement the status pane



commit 26bc98d5c4dc37b9be260e72bb56b69b3ab69f30
Author: James Liggett <jrliggett cox net>
Date:   Mon Jun 7 16:48:54 2010 -0700

    git: Implement the status pane
    
    Basic implementation of the status view. For now there is no select all
    option. I'm working on an elegant and user friendly way to to this...
    
    There's also no automatic refreshing for now. This is an even trickier
    problem, because there's no fully automated way to get all status changes
    in every case, at lest that I know of.

 plugins/git/Makefile.am       |    4 +-
 plugins/git/anjuta-git.ui     |  100 +++++++
 plugins/git/git-status-pane.c |  567 +++++++++++++++++++++++++++++++++++++++++
 plugins/git/git-status-pane.h |   60 +++++
 plugins/git/plugin.c          |    8 +
 plugins/git/plugin.h          |    1 +
 6 files changed, 739 insertions(+), 1 deletions(-)
---
diff --git a/plugins/git/Makefile.am b/plugins/git/Makefile.am
index 7e70cc4..4adaa52 100644
--- a/plugins/git/Makefile.am
+++ b/plugins/git/Makefile.am
@@ -171,7 +171,9 @@ libanjuta_git_la_SOURCES = \
 	git-switch-branch-pane.c \
 	git-switch-branch-pane.h \
 	git-merge-pane.c \
-	git-merge-pane.h
+	git-merge-pane.h \
+	git-status-pane.h \
+	git-status-pane.c
 
 libanjuta_git_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
 
diff --git a/plugins/git/anjuta-git.ui b/plugins/git/anjuta-git.ui
index a5630e6..861677b 100644
--- a/plugins/git/anjuta-git.ui
+++ b/plugins/git/anjuta-git.ui
@@ -23,6 +23,18 @@
       <column type="gchararray"/>
     </columns>
   </object>
+  <object class="GtkTreeStore" id="status_model">
+    <columns>
+      <!-- column-name selected -->
+      <column type="gboolean"/>
+      <!-- column-name status -->
+      <column type="gint"/>
+      <!-- column-name path -->
+      <column type="gchararray"/>
+      <!-- column-name type -->
+      <column type="gint"/>
+    </columns>
+  </object>
   <object class="GtkVBox" id="log_pane">
     <property name="visible">True</property>
     <property name="orientation">vertical</property>
@@ -1082,4 +1094,92 @@
       </packing>
     </child>
   </object>
+  <object class="GtkVBox" id="status_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="status_view">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="model">status_model</property>
+                    <property name="headers_visible">False</property>
+                    <property name="headers_clickable">False</property>
+                    <property name="search_column">0</property>
+                    <child>
+                      <object class="GtkTreeViewColumn" id="status_column">
+                        <property name="title">column</property>
+                        <child>
+                          <object class="GtkCellRendererToggle" id="selected_renderer"/>
+                        </child>
+                        <child>
+                          <object class="GtkCellRendererPixbuf" id="status_icon_renderer"/>
+                        </child>
+                        <child>
+                          <object class="GtkCellRendererText" id="status_name_renderer"/>
+                        </child>
+                        <child>
+                          <object class="GtkCellRendererText" id="path_renderer"/>
+                        </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;Repository Status:&lt;/b&gt;</property>
+            <property name="use_markup">True</property>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="position">0</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkHButtonBox" id="hbuttonbox1">
+        <property name="visible">True</property>
+        <property name="layout_style">end</property>
+        <child>
+          <object class="GtkButton" id="refresh_button">
+            <property name="label">gtk-refresh</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="use_stock">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">False</property>
+        <property name="position">1</property>
+      </packing>
+    </child>
+  </object>
 </interface>
diff --git a/plugins/git/git-status-pane.c b/plugins/git/git-status-pane.c
new file mode 100644
index 0000000..8a29339
--- /dev/null
+++ b/plugins/git/git-status-pane.c
@@ -0,0 +1,567 @@
+/* -*- 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-status-pane.h"
+
+enum
+{
+	COL_SELECTED,
+	COL_STATUS,
+	COL_PATH,
+	COL_TYPE
+};
+
+/* Status item type flags. These help reliably determine which section a status
+ * item belongs to */
+enum
+{
+	STATUS_TYPE_NONE,
+	STATUS_TYPE_COMMIT,
+	STATUS_TYPE_NOT_UPDATED
+};
+
+struct _GitStatusPanePriv
+{
+	GtkBuilder *builder;
+
+	/* Iters for the two sections: Changes to be committed and Changed but not
+	 * updated. Status items will be children of these two iters. */
+	GtkTreeIter commit_iter;
+	GtkTreeIter not_updated_iter;
+
+	/* Hash tables that show which items are selected in each section */
+	GHashTable *selected_commit_items;
+	GHashTable *selected_not_updated_items;
+};
+
+G_DEFINE_TYPE (GitStatusPane, git_status_pane, GIT_TYPE_PANE);
+
+static void
+selected_renderer_data_func (GtkTreeViewColumn *tree_column,
+                             GtkCellRenderer *renderer,
+                             GtkTreeModel *model,
+                             GtkTreeIter *iter,
+                             gpointer user_data)
+{
+	gboolean selected;
+
+	/* Don't show the checkbox on the toplevel items--these are supposed to 
+	 * be placeholders to show the two sections, Changes to be committed and
+	 * Changeed but not updated. */
+	gtk_cell_renderer_set_visible (renderer, 
+	                               gtk_tree_store_iter_depth (GTK_TREE_STORE (model), 
+	                                                          iter) > 0);
+
+	gtk_tree_model_get (model, iter, COL_SELECTED, &selected, -1);
+
+	gtk_cell_renderer_toggle_set_active (GTK_CELL_RENDERER_TOGGLE (renderer),
+	                                     selected);
+}
+
+static void
+status_icon_renderer_data_func (GtkTreeViewColumn *tree_column,
+                                GtkCellRenderer *renderer,
+                                GtkTreeModel *model,
+                                GtkTreeIter *iter,
+                                gpointer user_data)
+{
+	
+	AnjutaVcsStatus status;
+
+	/* Don't show this renderer on placeholders */
+	gtk_cell_renderer_set_visible (renderer, 
+	                               gtk_tree_store_iter_depth (GTK_TREE_STORE (model), 
+	                                                          iter) > 0);
+
+	gtk_tree_model_get (model, iter, COL_STATUS, &status, -1);
+
+	switch (status)
+	{
+		case ANJUTA_VCS_STATUS_MODIFIED:
+			g_object_set (G_OBJECT (renderer), "stock-id", GTK_STOCK_EDIT, 
+						  NULL);
+			break;
+		case ANJUTA_VCS_STATUS_ADDED:
+			g_object_set (G_OBJECT (renderer), "stock-id", GTK_STOCK_ADD, 
+						  NULL);
+			break;
+		case ANJUTA_VCS_STATUS_DELETED:
+			g_object_set (G_OBJECT (renderer), "stock-id", GTK_STOCK_REMOVE, 
+						  NULL);
+			break;
+		case ANJUTA_VCS_STATUS_CONFLICTED:
+			g_object_set (G_OBJECT (renderer), "stock-id",  
+						  GTK_STOCK_DIALOG_WARNING, NULL);
+			break;
+		case ANJUTA_VCS_STATUS_UPTODATE:
+			g_object_set (G_OBJECT (renderer), "stock-id", GTK_STOCK_APPLY, 
+						  NULL);
+			break;
+		case ANJUTA_VCS_STATUS_LOCKED:
+			g_object_set (G_OBJECT (renderer), "stock-id",  
+						  GTK_STOCK_DIALOG_AUTHENTICATION, NULL);
+			break;	
+		case ANJUTA_VCS_STATUS_MISSING:
+			g_object_set (G_OBJECT (renderer), "stock-id",  
+						  GTK_STOCK_MISSING_IMAGE, NULL);
+			break;
+		case ANJUTA_VCS_STATUS_UNVERSIONED:
+			g_object_set (G_OBJECT (renderer), "stock-id",  
+						  GTK_STOCK_DIALOG_QUESTION, NULL);
+			break;
+		case ANJUTA_VCS_STATUS_IGNORED:
+			g_object_set (G_OBJECT (renderer), "stock-id", GTK_STOCK_STOP, 
+						  NULL);
+			break;
+		case ANJUTA_VCS_STATUS_NONE:
+		default:
+			break;
+	}
+}
+
+static void
+status_name_renderer_data_func (GtkTreeViewColumn *tree_column,
+                                GtkCellRenderer *renderer,
+                                GtkTreeModel *model,
+                                GtkTreeIter *iter,
+                                gpointer user_data)
+{
+	AnjutaVcsStatus status;
+
+	gtk_tree_model_get (model, iter, COL_STATUS, &status, -1);
+
+	/* Don't show this renderer on placeholders */
+	gtk_cell_renderer_set_visible (renderer, 
+	                               gtk_tree_store_iter_depth (GTK_TREE_STORE (model), 
+	                                                          iter) > 0);
+
+	switch (status)
+	{
+		case ANJUTA_VCS_STATUS_MODIFIED:
+			g_object_set (G_OBJECT (renderer), "text", _("Modified"), NULL);
+			break;
+		case ANJUTA_VCS_STATUS_ADDED:
+			g_object_set (G_OBJECT (renderer), "text", _("Added"), NULL);
+			break;
+		case ANJUTA_VCS_STATUS_DELETED:
+			g_object_set (G_OBJECT (renderer), "text", _("Deleted"), NULL);
+			break;
+		case ANJUTA_VCS_STATUS_CONFLICTED:
+			g_object_set (G_OBJECT (renderer), "text", _("Conflicted"), 
+									NULL);
+			break;
+		case ANJUTA_VCS_STATUS_UPTODATE:
+			g_object_set (G_OBJECT (renderer), "text", _("Up-to-date"), 
+						  NULL);
+			break;
+		case ANJUTA_VCS_STATUS_LOCKED:
+			g_object_set (G_OBJECT (renderer), "text", _("Locked"), NULL);
+			break;	
+		case ANJUTA_VCS_STATUS_MISSING:
+			g_object_set (G_OBJECT (renderer), "text", _("Missing"), NULL);
+			break;
+		case ANJUTA_VCS_STATUS_UNVERSIONED:
+			g_object_set (G_OBJECT (renderer), "text", _("Unversioned"), 
+									NULL);
+			break;
+		case ANJUTA_VCS_STATUS_IGNORED:
+			g_object_set (G_OBJECT (renderer), "text", _("Ignored"),
+						  NULL);
+			break;
+		case ANJUTA_VCS_STATUS_NONE:
+		default:
+			break;
+	}
+}
+
+static void
+path_renderer_data_func (GtkTreeViewColumn *tree_column,
+                         GtkCellRenderer *renderer,
+                         GtkTreeModel *model,
+                         GtkTreeIter *iter,
+                         gpointer user_data)
+{
+	gchar *path;
+	gchar *placeholder;
+
+	gtk_tree_model_get (model, iter, COL_PATH, &path, -1);
+
+	/* Use the path column to show placeholders as well */
+	if (gtk_tree_store_iter_depth (GTK_TREE_STORE (model), iter) == 0)
+	{
+		placeholder = g_strdup_printf ("<b>%s</b>", path); 
+		
+		g_object_set (G_OBJECT (renderer), "markup", placeholder, NULL);
+
+		g_free (placeholder);
+	}
+	else
+		g_object_set (G_OBJECT (renderer), "text", path, NULL);
+
+	g_free (path);
+	
+}
+
+static void
+on_selected_renderer_toggled (GtkCellRendererToggle *renderer, gchar *tree_path,
+                              GitStatusPane *self)
+{
+	GtkTreeModel *status_model;
+	GtkTreeIter iter;
+	gboolean selected;
+	gchar *path;
+	gint type;
+	
+	status_model = GTK_TREE_MODEL (gtk_builder_get_object (self->priv->builder,
+	                                                       "status_model"));
+
+	gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (status_model), &iter,
+	                                     tree_path);
+	gtk_tree_model_get (status_model, &iter, 
+	                    COL_SELECTED, &selected, 
+	                    COL_PATH, &path,
+	                    COL_TYPE, &type,
+	                    -1);
+
+	selected = !selected;
+
+	gtk_tree_store_set (GTK_TREE_STORE (status_model), &iter,
+	                    COL_SELECTED, selected,
+	                    -1);
+
+	switch (type)
+	{
+		case STATUS_TYPE_COMMIT:
+			g_hash_table_insert (self->priv->selected_commit_items, 
+		                 		 g_strdup (path), NULL);
+			break;
+		case STATUS_TYPE_NOT_UPDATED:
+			g_hash_table_insert (self->priv->selected_not_updated_items,
+			                     g_strdup (path), NULL);
+			break;
+		default:
+			break;
+	}
+}
+
+static void
+git_status_pane_init (GitStatusPane *self)
+{
+	gchar *objects[] = {"status_pane",
+						"status_model",
+						NULL};
+	GError *error = NULL;
+	GtkTreeViewColumn *status_column;
+	GtkCellRenderer *selected_renderer;
+	GtkCellRenderer *status_icon_renderer;
+	GtkCellRenderer *status_name_renderer;
+	GtkCellRenderer *path_renderer;
+	GtkWidget *refresh_button;
+
+	self->priv = g_new0 (GitStatusPanePriv, 1);
+	self->priv->builder = gtk_builder_new ();
+	self->priv->selected_commit_items = g_hash_table_new_full (g_str_hash, 
+	                                                           g_str_equal,
+	                                                           g_free, 
+	                                                           NULL);
+	self->priv->selected_not_updated_items = g_hash_table_new_full (g_str_hash,
+	                                                                g_str_equal,
+	                                                                g_free,
+	                                                                NULL);
+	
+	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);
+	}
+
+	status_column = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (self->priv->builder,
+	                                                              "status_column"));
+	selected_renderer = GTK_CELL_RENDERER (gtk_builder_get_object (self->priv->builder,
+	                                   							   "selected_renderer"));
+	status_icon_renderer = GTK_CELL_RENDERER (gtk_builder_get_object (self->priv->builder,
+	                                                                  "status_icon_renderer"));
+	status_name_renderer = GTK_CELL_RENDERER (gtk_builder_get_object (self->priv->builder,
+	                                                                  "status_name_renderer"));
+	path_renderer = GTK_CELL_RENDERER (gtk_builder_get_object (self->priv->builder,
+	                                                           "path_renderer"));
+	refresh_button = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
+	                                                     "refresh_button"));
+										   
+	gtk_tree_view_column_set_cell_data_func (status_column, selected_renderer,
+	                                         (GtkTreeCellDataFunc) selected_renderer_data_func,
+	                                         NULL, NULL);
+
+	gtk_tree_view_column_set_cell_data_func (status_column, status_icon_renderer,
+	                                         (GtkTreeCellDataFunc) status_icon_renderer_data_func,
+	                                         NULL, NULL);
+
+	gtk_tree_view_column_set_cell_data_func (status_column, status_name_renderer,
+	                                         (GtkTreeCellDataFunc) status_name_renderer_data_func,
+	                                         NULL, NULL);
+
+	gtk_tree_view_column_set_cell_data_func (status_column, path_renderer,
+	                                         (GtkTreeCellDataFunc) path_renderer_data_func,
+	                                         NULL, NULL);
+
+	g_signal_connect (G_OBJECT (selected_renderer), "toggled",
+	                  G_CALLBACK (on_selected_renderer_toggled),
+	                  self);
+
+	g_signal_connect_swapped (G_OBJECT (refresh_button), "clicked",
+	                          G_CALLBACK (anjuta_dock_pane_refresh),
+	                          self);
+}
+
+static void
+git_status_pane_finalize (GObject *object)
+{
+	GitStatusPane *self;
+
+	self = GIT_STATUS_PANE (object);
+
+	g_object_unref (self->priv->builder);
+	g_hash_table_destroy (self->priv->selected_commit_items);
+	g_hash_table_destroy (self->priv->selected_not_updated_items);
+	g_free (self->priv);
+
+	G_OBJECT_CLASS (git_status_pane_parent_class)->finalize (object);
+}
+
+static void
+add_status_items (GQueue *output, GtkTreeStore *status_model, 
+                  GtkTreeIter *parent_iter, gint type)
+{
+	GitStatus *status_object;
+	AnjutaVcsStatus status;
+	gchar *path;
+	GtkTreeIter iter;
+
+	while (g_queue_peek_head (output))
+	{
+		status_object = g_queue_pop_head (output);
+		status = git_status_get_vcs_status (status_object);
+		path = git_status_get_path (status_object);
+
+		gtk_tree_store_append (status_model, &iter, parent_iter);
+		gtk_tree_store_set (status_model, &iter,
+		                    COL_SELECTED, FALSE,
+		                    COL_STATUS, status,
+		                    COL_PATH, path,
+		                    COL_TYPE, type,
+		                    -1);
+
+		g_free (path);
+		g_object_unref (status_object);
+	}
+}
+
+static void
+on_commit_status_data_arrived (AnjutaCommand *command, 
+                               GitStatusPane *self)
+{
+	GtkTreeStore *status_model;
+	GQueue *output;
+
+	status_model = GTK_TREE_STORE (gtk_builder_get_object (self->priv->builder,
+	                                                       "status_model"));
+	output = git_status_command_get_status_queue (GIT_STATUS_COMMAND (command));
+
+	add_status_items (output, status_model, &(self->priv->commit_iter),
+	                  STATUS_TYPE_COMMIT);
+
+}
+
+static void
+on_not_updated_status_data_arrived (AnjutaCommand *command,
+                                    GitStatusPane *self)
+{
+	GtkTreeStore *status_model;
+	GQueue *output;
+
+	status_model = GTK_TREE_STORE (gtk_builder_get_object (self->priv->builder,
+	                                                       "status_model"));
+	output = git_status_command_get_status_queue (GIT_STATUS_COMMAND (command));
+
+	add_status_items (output, status_model, &(self->priv->not_updated_iter),
+	                  STATUS_TYPE_NOT_UPDATED);
+}
+
+static void
+git_status_pane_refresh (AnjutaDockPane *pane)
+{
+	GitStatusPane *self;
+	Git *plugin;
+	GitStatusCommand *commit_status_command;
+	GitStatusCommand *not_updated_status_command;
+	AnjutaCommandQueue *command_queue;
+	GtkTreeStore *status_model;
+	GtkTreeView *status_view;
+
+	self = GIT_STATUS_PANE (pane);
+	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (pane));
+	commit_status_command = git_status_command_new (plugin->project_root_directory,
+	                                                GIT_STATUS_SECTION_COMMIT);
+	not_updated_status_command = git_status_command_new (plugin->project_root_directory,
+	                                                     GIT_STATUS_SECTION_NOT_UPDATED);
+	command_queue = anjuta_command_queue_new (ANJUTA_COMMAND_QUEUE_EXECUTE_MANUAL);
+	status_model = GTK_TREE_STORE (gtk_builder_get_object (self->priv->builder,
+	                                                       "status_model"));
+	status_view = GTK_TREE_VIEW (gtk_builder_get_object (self->priv->builder,
+	                                                     "status_view"));
+
+	/* Clear any existing model data and create the placeholders */
+	gtk_tree_store_clear (status_model);
+	
+	gtk_tree_store_append (status_model, &(self->priv->commit_iter), NULL);
+	gtk_tree_store_set (status_model, &(self->priv->commit_iter), 
+	                    COL_PATH, _("Changes to be committed"), 
+	                    COL_SELECTED, FALSE,
+	                    COL_STATUS, ANJUTA_VCS_STATUS_NONE,
+	                    COL_TYPE, STATUS_TYPE_NONE,
+	                    -1);
+
+	g_hash_table_remove_all (self->priv->selected_commit_items);
+	g_hash_table_remove_all (self->priv->selected_not_updated_items);
+
+	gtk_tree_store_append (status_model, &(self->priv->not_updated_iter), 
+	                       NULL);
+	gtk_tree_store_set (status_model, &(self->priv->not_updated_iter), 
+	                    COL_PATH, _("Changed but not updated"), 
+	                    COL_SELECTED, FALSE, 
+	                    COL_STATUS, ANJUTA_VCS_STATUS_NONE,
+	                    COL_TYPE, STATUS_TYPE_NONE,
+	                    -1);
+
+	g_signal_connect (G_OBJECT (commit_status_command), "data-arrived",
+	                  G_CALLBACK (on_commit_status_data_arrived),
+	                  self);
+
+	g_signal_connect (G_OBJECT (not_updated_status_command), "data-arrived",
+	                  G_CALLBACK (on_not_updated_status_data_arrived),
+	                  self);
+
+	g_signal_connect (G_OBJECT (commit_status_command), "command-finished",
+	                  G_CALLBACK (g_object_unref),
+	                  NULL);
+
+	g_signal_connect (G_OBJECT (not_updated_status_command), "command-finished",
+	                  G_CALLBACK (g_object_unref),
+	                  NULL);
+
+	/* Expand all of the rows so everything is visible */
+	g_signal_connect_swapped (G_OBJECT (command_queue), "finished",
+	                          G_CALLBACK (gtk_tree_view_expand_all),
+	                          status_view);
+
+	g_signal_connect (G_OBJECT (command_queue), "finished",
+	                  G_CALLBACK (g_object_unref),
+	                  NULL);
+
+	anjuta_command_queue_push (command_queue, 
+	                           ANJUTA_COMMAND (commit_status_command));
+	anjuta_command_queue_push (command_queue, 
+	                           ANJUTA_COMMAND (not_updated_status_command));
+
+	anjuta_command_queue_start (command_queue);
+}
+
+static GtkWidget *
+git_status_pane_get_widget (AnjutaDockPane *pane)
+{
+	GitStatusPane *self;
+
+	self = GIT_STATUS_PANE (pane);
+
+	return GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
+	                                           "status_pane"));
+}
+
+static void
+git_status_pane_class_init (GitStatusPaneClass *klass)
+{
+	GObjectClass* object_class = G_OBJECT_CLASS (klass);
+	AnjutaDockPaneClass* pane_class = ANJUTA_DOCK_PANE_CLASS (klass);
+
+	object_class->finalize = git_status_pane_finalize;
+	pane_class->refresh = git_status_pane_refresh;
+	pane_class->get_widget = git_status_pane_get_widget;
+}
+
+
+AnjutaDockPane *
+git_status_pane_new (Git *plugin)
+{
+	return g_object_new (GIT_TYPE_STATUS_PANE, "plugin", plugin, NULL);
+}
+
+static void
+selected_items_table_foreach (GHashTable *hash_table, gchar *path, gchar value,
+                              GList **list)
+{
+	*list = g_list_append (*list, g_strdup (path));
+}
+
+GList *
+git_status_pane_get_selected_commit_items (GitStatusPane *self)
+{
+	GList *list;
+
+	list = NULL;
+
+	g_hash_table_foreach (self->priv->selected_commit_items, 
+	                      (GHFunc) selected_items_table_foreach,
+	                      &list);
+
+	return list;
+}
+
+GList *
+git_status_pane_get_selected_not_updated_items (GitStatusPane *self)
+{
+	GList *list;
+
+	list = NULL;
+
+	g_hash_table_foreach (self->priv->selected_not_updated_items, 
+	                      (GHFunc) selected_items_table_foreach,
+	                      &list);
+
+	return list;
+}
+
+GList *
+git_status_pane_get_all_selected_items (GitStatusPane *self)
+{
+	GList *list;
+
+	list = NULL;
+
+	g_hash_table_foreach (self->priv->selected_commit_items, 
+	                      (GHFunc) selected_items_table_foreach,
+	                      &list);
+
+	g_hash_table_foreach (self->priv->selected_not_updated_items, 
+	                      (GHFunc) selected_items_table_foreach,
+	                      &list);
+
+	return list;
+}
\ No newline at end of file
diff --git a/plugins/git/git-status-pane.h b/plugins/git/git-status-pane.h
new file mode 100644
index 0000000..a66feaf
--- /dev/null
+++ b/plugins/git/git-status-pane.h
@@ -0,0 +1,60 @@
+/* -*- 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_STATUS_PANE_H_
+#define _GIT_STATUS_PANE_H_
+
+#include <glib-object.h>
+#include "git-pane.h"
+#include "git-status-command.h"
+
+G_BEGIN_DECLS
+
+#define GIT_TYPE_STATUS_PANE             (git_status_pane_get_type ())
+#define GIT_STATUS_PANE(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIT_TYPE_STATUS_PANE, GitStatusPane))
+#define GIT_STATUS_PANE_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GIT_TYPE_STATUS_PANE, GitStatusPaneClass))
+#define GIT_IS_STATUS_PANE(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIT_TYPE_STATUS_PANE))
+#define GIT_IS_STATUS_PANE_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GIT_TYPE_STATUS_PANE))
+#define GIT_STATUS_PANE_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GIT_TYPE_STATUS_PANE, GitStatusPaneClass))
+
+typedef struct _GitStatusPaneClass GitStatusPaneClass;
+typedef struct _GitStatusPane GitStatusPane;
+typedef struct _GitStatusPanePriv GitStatusPanePriv;
+
+struct _GitStatusPaneClass
+{
+	GitPaneClass parent_class;
+};
+
+struct _GitStatusPane
+{
+	GitPane parent_instance;
+
+	GitStatusPanePriv *priv;
+};
+
+GType git_status_pane_get_type (void) G_GNUC_CONST;
+AnjutaDockPane *git_status_pane_new (Git *plugin);
+GList *git_status_pane_get_selected_commit_items (GitStatusPane *self);
+GList *git_status_pane_get_selected_not_updated_items (GitStatusPane *self);
+GList *git_status_pane_get_all_selected_items (GitStatusPane *self);
+
+G_END_DECLS
+
+#endif /* _GIT_STATUS_PANE_H_ */
diff --git a/plugins/git/plugin.c b/plugins/git/plugin.c
index 4f505e6..46d410c 100644
--- a/plugins/git/plugin.c
+++ b/plugins/git/plugin.c
@@ -26,6 +26,7 @@
 #include "git-delete-branches-pane.h"
 #include "git-switch-branch-pane.h"
 #include "git-merge-pane.h"
+#include "git-status-pane.h"
 
 AnjutaCommandBarEntry branch_entries[] =
 {
@@ -100,6 +101,8 @@ on_project_root_added (AnjutaPlugin *plugin, const gchar *name,
 
 	anjuta_command_start_automatic_monitor (ANJUTA_COMMAND (git_plugin->local_branch_list_command));
 	anjuta_command_start (ANJUTA_COMMAND (git_plugin->local_branch_list_command));
+
+	anjuta_dock_pane_refresh (git_plugin->status_pane);
 	
 
 	gtk_widget_set_sensitive (git_plugin->dock, TRUE);
@@ -279,6 +282,11 @@ git_activate_plugin (AnjutaPlugin *plugin)
 	                  plugin);
 
 	/* Add the panes to the dock */
+	git_plugin->status_pane = git_status_pane_new (git_plugin);
+	anjuta_dock_add_pane (ANJUTA_DOCK (git_plugin->dock), "Status",
+	                      _("Status"), NULL, git_plugin->status_pane,
+	                      GDL_DOCK_CENTER, NULL, 0, NULL);
+	
 	git_plugin->branches_pane = git_branches_pane_new (git_plugin);
 	anjuta_dock_add_pane (ANJUTA_DOCK (git_plugin->dock), "Branches", 
 	                      _("Branches"), NULL, git_plugin->branches_pane,   
diff --git a/plugins/git/plugin.h b/plugins/git/plugin.h
index 03a6ce6..a30e493 100644
--- a/plugins/git/plugin.h
+++ b/plugins/git/plugin.h
@@ -64,6 +64,7 @@ struct _Git
 	GtkWidget *dock_window;
 
 	/* Dock panes */
+	AnjutaDockPane *status_pane;
 	AnjutaDockPane *branches_pane;
 
 	/* Branch list commands */



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