[anjuta/libgit2-glib: 14/14] git: Refresh the index before getting status information
- From: James Liggett <jrliggett src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/libgit2-glib: 14/14] git: Refresh the index before getting status information
- Date: Tue, 6 Aug 2013 04:42:45 +0000 (UTC)
commit 7ad49fc0967ab09a1aff4154d4a547612b4a6e5c
Author: James Liggett <jrliggett cox net>
Date: Mon Aug 5 21:37:32 2013 -0700
git: Refresh the index before getting status information
libanjuta/interfaces/libanjuta.idl | 12 ++-
plugins/git/Makefile.am | 6 +-
plugins/git/git-index-refreshable.c | 176 +++++++++++++++++++++++++++++++
plugins/git/git-index-refreshable.h | 61 +++++++++++
plugins/git/git-refresh-index-command.c | 64 +++++++++++
plugins/git/git-refresh-index-command.h | 55 ++++++++++
plugins/git/git-status-pane.c | 113 +--------------------
plugins/git/plugin.c | 20 +++-
plugins/git/plugin.h | 1 +
9 files changed, 391 insertions(+), 117 deletions(-)
---
diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl
index 413b5ae..866de39 100644
--- a/libanjuta/interfaces/libanjuta.idl
+++ b/libanjuta/interfaces/libanjuta.idl
@@ -6870,7 +6870,7 @@ interface IAnjutaRefreshable
* would cause the data contained by this object to become outdated. The
* object will refresh itself once these changes are detected.
*/
- void start_monitor();
+ void start_monitor ();
/**
* ianjuta_refreshable_stop_monitor:
@@ -6880,5 +6880,13 @@ interface IAnjutaRefreshable
* Stop monitoring for changes. This method cleans up any resources created
* by ianjuta_refreshable_start_monitor.
*/
- void stop_monitor();
+ void stop_monitor ();
+
+ /**
+ * IAnjutaRefreshable::refreshed
+ * @obj: self
+ *
+ * Emitted when a refreshable refreshes its data
+ */
+ void ::refreshed ();
}
diff --git a/plugins/git/Makefile.am b/plugins/git/Makefile.am
index 2f63ecf..bd670bb 100644
--- a/plugins/git/Makefile.am
+++ b/plugins/git/Makefile.am
@@ -235,7 +235,11 @@ libanjuta_git_la_SOURCES = \
git-command.c \
git-command.h \
git-thread-pool.c \
- git_thread-pool.h
+ git_thread-pool.h \
+ git-index-refreshable.c \
+ git-index-refreshable.h \
+ git-refresh-index-command.c \
+ git-refresh-index-command.h
libanjuta_git_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
diff --git a/plugins/git/git-index-refreshable.c b/plugins/git/git-index-refreshable.c
new file mode 100644
index 0000000..c8d0924
--- /dev/null
+++ b/plugins/git/git-index-refreshable.c
@@ -0,0 +1,176 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * git-index-refreshable.c
+ * Copyright (C) 2013 James Liggett <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-index-refreshable.h"
+
+struct _GitIndexRefreshablePrivate
+{
+ Git *plugin;
+ GFileMonitor *index_monitor;
+ GFileMonitor *head_monitor;
+ GitCommand *refresh_command;
+};
+
+static void
+on_refresh_command_finished (AnjutaTask *task, GitIndexRefreshable *self)
+{
+ g_clear_object (&self->priv->refresh_command);
+ g_signal_emit_by_name (self, "refreshed", NULL);
+}
+
+static void
+on_file_monitor_changed (GFileMonitor *monitor, GFile *file, GFile *other_file,
+ GFileMonitorEvent event, GitIndexRefreshable *self)
+{
+ /* Handle created and modified events just to cover all possible cases.
+ * Sometimes git does some odd things... */
+ if (event == G_FILE_MONITOR_EVENT_CHANGED ||
+ event == G_FILE_MONITOR_EVENT_CREATED)
+ {
+ if (!self->priv->refresh_command)
+ {
+ self->priv->refresh_command = git_refresh_index_command_new ();
+
+ g_signal_connect (G_OBJECT (self->priv->refresh_command), "finished",
+ G_CALLBACK (on_refresh_command_finished),
+ self);
+
+ git_thread_pool_push (self->priv->plugin->thread_pool,
+ self->priv->refresh_command);
+ }
+ }
+}
+
+static void
+git_index_refreshable_start_monitor (IAnjutaRefreshable *obj, GError **err)
+{
+ GitIndexRefreshable *self;
+ const gchar *working_directory;
+ gchar *git_index_path;
+ gchar *git_head_path;
+ GFile *git_index_file;
+ GFile *git_head_file;
+
+ self = GIT_INDEX_REFRESHABLE (obj);
+ working_directory = self->priv->plugin->project_root_directory;
+
+ /* Watch for changes to the HEAD file and the index file, so that we can
+ * at least detect commits and index changes. */
+ git_index_path = g_strjoin (G_DIR_SEPARATOR_S,
+ working_directory,
+ ".git",
+ "index",
+ NULL);
+ git_head_path = g_strjoin (G_DIR_SEPARATOR_S,
+ working_directory,
+ ".git",
+ "HEAD",
+ NULL);
+ git_index_file = g_file_new_for_path (git_index_path);
+ git_head_file = g_file_new_for_path (git_head_path);
+
+ self->priv->index_monitor = g_file_monitor_file (git_index_file, 0, NULL,
+ err);
+
+ if (self->priv->index_monitor)
+ {
+ self->priv->head_monitor = g_file_monitor_file (git_head_file, 0, NULL,
+ err);
+
+ if (self->priv->head_monitor)
+ {
+ g_signal_connect (G_OBJECT (self->priv->index_monitor), "changed",
+ G_CALLBACK (on_file_monitor_changed),
+ obj);
+
+ g_signal_connect (G_OBJECT (self->priv->head_monitor), "changed",
+ G_CALLBACK (on_file_monitor_changed),
+ obj);
+
+ }
+ }
+
+ g_free (git_index_path);
+ g_free (git_head_path);
+ g_object_unref (git_index_file);
+ g_object_unref (git_head_file);
+}
+
+static void
+git_index_refreshable_stop_monitor (IAnjutaRefreshable *obj, GError **err)
+{
+ GitIndexRefreshable *self;
+
+ self = GIT_INDEX_REFRESHABLE (obj);
+
+ g_clear_object (&self->priv->index_monitor);
+ g_clear_object (&self->priv->head_monitor);
+}
+
+static void
+ianjuta_refreshable_init (IAnjutaRefreshableIface *iface)
+{
+ iface->start_monitor = git_index_refreshable_start_monitor;
+ iface->stop_monitor = git_index_refreshable_stop_monitor;
+}
+
+G_DEFINE_TYPE_WITH_CODE (GitIndexRefreshable, git_index_refreshable, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (IANJUTA_TYPE_REFRESHABLE,
+ ianjuta_refreshable_init));
+
+static void
+git_index_refreshable_init (GitIndexRefreshable *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GIT_TYPE_INDEX_REFRESHABLE,
GitIndexRefreshablePrivate);
+
+}
+
+static void
+git_index_refreshable_finalize (GObject *object)
+{
+ GitIndexRefreshable *self;
+
+ self = GIT_INDEX_REFRESHABLE (object);
+
+ g_clear_object (&self->priv->index_monitor);
+ g_clear_object (&self->priv->head_monitor);
+
+ G_OBJECT_CLASS (git_index_refreshable_parent_class)->finalize (object);
+}
+
+static void
+git_index_refreshable_class_init (GitIndexRefreshableClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GitIndexRefreshablePrivate));
+
+ object_class->finalize = git_index_refreshable_finalize;
+}
+
+IAnjutaRefreshable *
+git_index_refreshable_new (Git *plugin)
+{
+ GitIndexRefreshable *self;
+
+ self = g_object_new (GIT_TYPE_INDEX_REFRESHABLE, NULL);
+ self->priv->plugin = plugin;
+
+ return IANJUTA_REFRESHABLE (self);
+}
diff --git a/plugins/git/git-index-refreshable.h b/plugins/git/git-index-refreshable.h
new file mode 100644
index 0000000..d259338
--- /dev/null
+++ b/plugins/git/git-index-refreshable.h
@@ -0,0 +1,61 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * git-index-refreshable.h
+ * Copyright (C) 2013 James Liggett <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_INDEX_REFRESHABLE_H_
+#define _GIT_INDEX_REFRESHABLE_H_
+
+#include <glib-object.h>
+#include <gio/gio.h>
+#include <libanjuta/interfaces/ianjuta-refreshable.h>
+#include "plugin.h"
+#include "git-refresh-index-command.h"
+
+G_BEGIN_DECLS
+
+#define GIT_TYPE_INDEX_REFRESHABLE (git_index_refreshable_get_type ())
+#define GIT_INDEX_REFRESHABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GIT_TYPE_INDEX_REFRESHABLE, GitIndexRefreshable))
+#define GIT_INDEX_REFRESHABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GIT_TYPE_INDEX_REFRESHABLE, GitIndexRefreshableClass))
+#define GIT_IS_INDEX_REFRESHABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GIT_TYPE_INDEX_REFRESHABLE))
+#define GIT_IS_INDEX_REFRESHABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GIT_TYPE_INDEX_REFRESHABLE))
+#define GIT_INDEX_REFRESHABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GIT_TYPE_INDEX_REFRESHABLE, GitIndexRefreshableClass))
+
+typedef struct _GitIndexRefreshableClass GitIndexRefreshableClass;
+typedef struct _GitIndexRefreshable GitIndexRefreshable;
+typedef struct _GitIndexRefreshablePrivate GitIndexRefreshablePrivate;
+
+
+struct _GitIndexRefreshableClass
+{
+ GObjectClass parent_class;
+};
+
+struct _GitIndexRefreshable
+{
+ GObject parent_instance;
+
+ GitIndexRefreshablePrivate *priv;
+};
+
+GType git_index_refreshable_get_type (void) G_GNUC_CONST;
+IAnjutaRefreshable *git_index_refreshable_new (Git *plugin);
+
+G_END_DECLS
+
+#endif /* _GIT_INDEX_REFRESHABLE_H_ */
+
diff --git a/plugins/git/git-refresh-index-command.c b/plugins/git/git-refresh-index-command.c
new file mode 100644
index 0000000..48da649
--- /dev/null
+++ b/plugins/git/git-refresh-index-command.c
@@ -0,0 +1,64 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * git-refresh-index-command.c
+ * Copyright (C) 2013 James Liggett <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-refresh-index-command.h"
+
+G_DEFINE_TYPE (GitRefreshIndexCommand, git_refresh_index_command, GIT_TYPE_COMMAND);
+
+static void
+git_refresh_index_command_init (GitRefreshIndexCommand *self)
+{
+
+}
+
+static void
+git_refresh_index_command_finalize (GObject *object)
+{
+
+ G_OBJECT_CLASS (git_refresh_index_command_parent_class)->finalize (object);
+}
+
+static void
+git_refresh_index_command_run (AnjutaTask *task)
+{
+ GgitRepository *repository;
+
+ repository = git_command_get_repository (GIT_COMMAND (task));
+
+ g_return_if_fail (repository);
+ ggit_index_read (ggit_repository_get_index (repository, NULL), NULL);
+}
+
+static void
+git_refresh_index_command_class_init (GitRefreshIndexCommandClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ AnjutaTaskClass *task_class = ANJUTA_TASK_CLASS (klass);
+
+ object_class->finalize = git_refresh_index_command_finalize;
+ task_class->run = git_refresh_index_command_run;
+}
+
+
+GitCommand *
+git_refresh_index_command_new (void)
+{
+ return g_object_new (GIT_TYPE_REFRESH_INDEX_COMMAND, NULL);
+}
+
diff --git a/plugins/git/git-refresh-index-command.h b/plugins/git/git-refresh-index-command.h
new file mode 100644
index 0000000..7462c18
--- /dev/null
+++ b/plugins/git/git-refresh-index-command.h
@@ -0,0 +1,55 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * git-refresh-index-command.h
+ * Copyright (C) 2013 James Liggett <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_REFRESH_INDEX_COMMAND_H_
+#define _GIT_REFRESH_INDEX_COMMAND_H_
+
+#include <glib-object.h>
+#include "git-command.h"
+
+G_BEGIN_DECLS
+
+#define GIT_TYPE_REFRESH_INDEX_COMMAND (git_refresh_index_command_get_type ())
+#define GIT_REFRESH_INDEX_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GIT_TYPE_REFRESH_INDEX_COMMAND, GitRefreshIndexCommand))
+#define GIT_REFRESH_INDEX_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GIT_TYPE_REFRESH_INDEX_COMMAND, GitRefreshIndexCommandClass))
+#define GIT_IS_REFRESH_INDEX_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GIT_TYPE_REFRESH_INDEX_COMMAND))
+#define GIT_IS_REFRESH_INDEX_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GIT_TYPE_REFRESH_INDEX_COMMAND))
+#define GIT_REFRESH_INDEX_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GIT_TYPE_REFRESH_INDEX_COMMAND, GitRefreshIndexCommandClass))
+
+typedef struct _GitRefreshIndexCommandClass GitRefreshIndexCommandClass;
+typedef struct _GitRefreshIndexCommand GitRefreshIndexCommand;
+
+
+struct _GitRefreshIndexCommandClass
+{
+ GitCommandClass parent_class;
+};
+
+struct _GitRefreshIndexCommand
+{
+ GitCommand parent_instance;
+};
+
+GType git_refresh_index_command_get_type (void) G_GNUC_CONST;
+GitCommand *git_refresh_index_command_new (void);
+
+G_END_DECLS
+
+#endif /* _GIT_REFRESH_INDEX_COMMAND_H_ */
+
diff --git a/plugins/git/git-status-pane.c b/plugins/git/git-status-pane.c
index b2490cd..e99f546 100644
--- a/plugins/git/git-status-pane.c
+++ b/plugins/git/git-status-pane.c
@@ -71,119 +71,10 @@ struct _GitStatusPanePriv
/* Hash tables that show which items are selected in each section */
GHashTable *selected_commit_items;
GHashTable *selected_not_updated_items;
-
- /* File monitors */
- GFileMonitor *head_monitor;
- GFileMonitor *index_monitor;
};
-static void
-on_file_monitor_changed (GFileMonitor *monitor, GFile *file, GFile *other_file,
- GFileMonitorEvent event, AnjutaDockPane *pane)
-{
- /* Handle created and modified events just to cover all possible cases.
- * Sometimes git does some odd things... */
- if (event == G_FILE_MONITOR_EVENT_CHANGED ||
- event == G_FILE_MONITOR_EVENT_CREATED)
- {
- anjuta_dock_pane_refresh (pane);
- }
-}
-
-static void
-git_status_pane_start_monitor (IAnjutaRefreshable *obj, GError **error)
-{
- GitStatusPane *self;
- Git *plugin;
- const gchar *working_directory;
- gchar *git_head_path;
- gchar *git_index_path;
- GFile *git_head_file;
- GFile *git_index_file;
- GError *file_error;
-
- self = GIT_STATUS_PANE (obj);
- plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (obj)));
- working_directory = plugin->project_root_directory;
-
- /* Watch for changes to the HEAD file and the index file, so that we can
- * at least detect commits and index changes. */
- git_head_path = g_strjoin (G_DIR_SEPARATOR_S,
- working_directory,
- ".git",
- "HEAD",
- NULL);
- git_index_path = g_strjoin (G_DIR_SEPARATOR_S,
- working_directory,
- ".git",
- "index",
- NULL);
- git_head_file = g_file_new_for_path (git_head_path);
- git_index_file = g_file_new_for_path (git_index_path);
-
- self->priv->head_monitor = g_file_monitor_file (git_head_file, 0, NULL,
- &file_error);
-
- if (self->priv->head_monitor)
- {
- self->priv->index_monitor = g_file_monitor_file (git_index_file, 0, NULL,
- &file_error);
-
- if (self->priv->index_monitor)
- {
- g_signal_connect (G_OBJECT (self->priv->head_monitor), "changed",
- G_CALLBACK (on_file_monitor_changed),
- ANJUTA_DOCK_PANE (obj));
-
- g_signal_connect (G_OBJECT (self->priv->index_monitor), "changed",
- G_CALLBACK (on_file_monitor_changed),
- ANJUTA_DOCK_PANE (obj));
- }
- }
-
-
-
- if (error)
- *error = g_error_copy (file_error);
-
- g_error_free (file_error);
-
- g_free (git_head_path);
- g_free (git_index_path);
- g_object_unref (git_head_file);
- g_object_unref (git_index_file);
-}
-
-static void
-git_status_pane_stop_monitor (IAnjutaRefreshable *obj, GError **error)
-{
- GitStatusPane *self;
-
- self = GIT_STATUS_PANE (obj);
-
- if (self->priv->head_monitor)
- {
- g_file_monitor_cancel (self->priv->head_monitor);
- g_clear_object (&self->priv->head_monitor);
- }
-
- if (self->priv->index_monitor)
- {
- g_file_monitor_cancel (self->priv->index_monitor);
- g_clear_object (&self->priv->head_monitor);
- }
-}
-
-static void
-ianjuta_refreshable_init (IAnjutaRefreshableIface *iface)
-{
- iface->start_monitor = git_status_pane_start_monitor;
- iface->stop_monitor = git_status_pane_stop_monitor;
-}
-G_DEFINE_TYPE_WITH_CODE (GitStatusPane, git_status_pane, GIT_TYPE_PANE,
- G_IMPLEMENT_INTERFACE (IANJUTA_TYPE_REFRESHABLE,
- ianjuta_refreshable_init));
+G_DEFINE_TYPE (GitStatusPane, git_status_pane, GIT_TYPE_PANE);
static void
selected_renderer_data_func (GtkTreeViewColumn *tree_column,
@@ -816,8 +707,6 @@ git_status_pane_finalize (GObject *object)
g_hash_table_destroy (self->priv->selected_commit_items);
g_hash_table_destroy (self->priv->selected_not_updated_items);
- g_clear_object (&self->priv->index_monitor);
- g_clear_object (&self->priv->head_monitor);
g_free (self->priv);
G_OBJECT_CLASS (git_status_pane_parent_class)->finalize (object);
diff --git a/plugins/git/plugin.c b/plugins/git/plugin.c
index 656a195..09a4c6d 100644
--- a/plugins/git/plugin.c
+++ b/plugins/git/plugin.c
@@ -56,6 +56,7 @@
#include "git-cherry-pick-pane.h"
#include "git-patch-series-pane.h"
#include "git-apply-mailbox-pane.h"
+#include "git-index-refreshable.h"
#define SETTINGS_SCHEMA "org.gnome.anjuta.plugins.git"
#define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-git.xml"
@@ -683,7 +684,7 @@ on_project_root_added (AnjutaPlugin *plugin, const gchar *name,
"working-directory", git_plugin->project_root_directory,
NULL);
- ianjuta_refreshable_start_monitor (IANJUTA_REFRESHABLE (git_plugin->status_pane), NULL);
+ ianjuta_refreshable_start_monitor (IANJUTA_REFRESHABLE (git_plugin->index_refreshable), NULL);
anjuta_dock_pane_refresh (git_plugin->status_pane);
anjuta_command_start_automatic_monitor (ANJUTA_COMMAND (git_plugin->local_branch_list_command));
@@ -723,7 +724,7 @@ on_project_root_removed (AnjutaPlugin *plugin, const gchar *name,
git_plugin->repository = NULL;
}
- ianjuta_refreshable_stop_monitor (IANJUTA_REFRESHABLE (git_plugin->status_pane), NULL);
+ ianjuta_refreshable_stop_monitor (git_plugin->index_refreshable, NULL);
anjuta_command_stop_automatic_monitor (ANJUTA_COMMAND (git_plugin->local_branch_list_command));
anjuta_command_stop_automatic_monitor (ANJUTA_COMMAND (git_plugin->remote_list_command));
@@ -820,6 +821,13 @@ on_branch_list_command_data_arrived (AnjutaCommand *command, Git *plugin)
}
static void
+on_index_refreshable_refreshed (IAnjutaRefreshable *obj, Git *plugin)
+{
+ anjuta_dock_pane_refresh (plugin->status_pane);
+ g_signal_emit_by_name (plugin, "status-changed", NULL);
+}
+
+static void
git_register_stock_icons (AnjutaPlugin *plugin)
{
static gboolean registered = FALSE;
@@ -954,6 +962,13 @@ git_activate_plugin (AnjutaPlugin *plugin)
G_CALLBACK (on_branch_list_command_data_arrived),
plugin);
+ /* Index refreshable object that watches for changes to the git index and
+ * keeps it up to date */
+ git_plugin->index_refreshable = git_index_refreshable_new (git_plugin);
+
+ g_signal_connect (G_OBJECT (git_plugin->index_refreshable), "refreshed",
+ G_CALLBACK (on_index_refreshable_refreshed),
+ git_plugin);
/* Remote list command */
git_plugin->remote_list_command = git_remote_list_command_new (NULL);
@@ -1053,6 +1068,7 @@ git_deactivate_plugin (AnjutaPlugin *plugin)
g_clear_object (&git_plugin->thread_pool);
g_clear_object (&git_plugin->repository);
+ g_clear_object (&git_plugin->index_refreshable);
ui = anjuta_shell_get_ui (plugin->shell, NULL);
anjuta_ui_remove_action_group (ui, git_plugin->status_menu_group);
diff --git a/plugins/git/plugin.h b/plugins/git/plugin.h
index dafc588..bc0f170 100644
--- a/plugins/git/plugin.h
+++ b/plugins/git/plugin.h
@@ -91,6 +91,7 @@ struct _Git
/* Current git repository */
GgitRepository *repository;
GitThreadPool *thread_pool;
+ IAnjutaRefreshable *index_refreshable;
/* List commands for various panes.
* Keep them in the plugin so that the commands have the most direct
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]