[anjuta/libgit2-glib] git: Initialize repository and thread pool on project load



commit 6c8b6973eeb7f5a341fd1b073ceeabcee8d36d23
Author: James Liggett <jrliggett cox net>
Date:   Sat Jul 13 00:06:54 2013 -0700

    git: Initialize repository and thread pool on project load

 plugins/git/plugin.c |   29 +++++++++++++++++++++++++++++
 plugins/git/plugin.h |    5 +++++
 2 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/plugins/git/plugin.c b/plugins/git/plugin.c
index 23f5416..4d2daae 100644
--- a/plugins/git/plugin.c
+++ b/plugins/git/plugin.c
@@ -642,14 +642,27 @@ on_project_root_added (AnjutaPlugin *plugin, const gchar *name,
        Git *git_plugin;
        gchar *project_root_uri;
        GFile *file;
+       GFile *repository_file;
        
        git_plugin = ANJUTA_PLUGIN_GIT (plugin);
        
        g_free (git_plugin->project_root_directory);
        project_root_uri = g_value_dup_string (value);
        file = g_file_new_for_uri (project_root_uri);
+       repository_file = g_file_get_child (file, ".git");
+       
        git_plugin->project_root_directory = g_file_get_path (file);
+       git_plugin->repository = ggit_repository_open (repository_file, NULL);
+
+       if (git_plugin->repository)
+       {
+               git_plugin->thread_pool = git_thread_pool_new (git_plugin->repository);
+               gtk_widget_set_sensitive (git_plugin->dock, TRUE);
+               gtk_widget_set_sensitive (git_plugin->command_bar, TRUE);
+       }
+       
        g_object_unref (file);
+       g_object_unref (repository_file);
        
        g_free (project_root_uri);
 
@@ -704,6 +717,18 @@ on_project_root_removed (AnjutaPlugin *plugin, const gchar *name,
        
        git_plugin = ANJUTA_PLUGIN_GIT (plugin);
        status = anjuta_shell_get_status (plugin->shell, NULL);
+
+       gtk_widget_set_sensitive (git_plugin->dock, FALSE);
+       gtk_widget_set_sensitive (git_plugin->command_bar, FALSE);
+
+       if (git_plugin->repository)
+       {
+               g_object_unref (git_plugin->thread_pool);
+               g_object_unref (git_plugin->repository);
+
+               git_plugin->thread_pool = NULL;
+               git_plugin->repository = NULL;
+       }
        
        anjuta_command_stop_automatic_monitor (ANJUTA_COMMAND (git_plugin->local_branch_list_command));
        anjuta_command_stop_automatic_monitor (ANJUTA_COMMAND (git_plugin->commit_status_command));
@@ -1036,8 +1061,12 @@ git_deactivate_plugin (AnjutaPlugin *plugin)
        anjuta_plugin_remove_watch (plugin, git_plugin->editor_watch_id,
                                                                TRUE);
 
+
        anjuta_shell_remove_widget (plugin->shell, git_plugin->box, NULL);
 
+       g_clear_object (&git_plugin->thread_pool);
+       g_clear_object (&git_plugin->repository);
+
        ui = anjuta_shell_get_ui (plugin->shell, NULL);
        anjuta_ui_remove_action_group (ui, git_plugin->status_menu_group);
        anjuta_ui_remove_action_group (ui, git_plugin->log_menu_group);
diff --git a/plugins/git/plugin.h b/plugins/git/plugin.h
index 41325cf..cbf0a1d 100644
--- a/plugins/git/plugin.h
+++ b/plugins/git/plugin.h
@@ -35,6 +35,7 @@
 #include <libanjuta/anjuta-dock.h>
 #include <libanjuta/anjuta-debug.h>
 #include <libanjuta/anjuta-command-queue.h>
+#include "git-thread-pool.h"
 #include "git-branch-list-command.h"
 #include "git-status-command.h"
 #include "git-remote-list-command.h"
@@ -85,6 +86,10 @@ struct _Git
        GtkActionGroup *remote_menu_group;
        GtkActionGroup *stash_menu_group;
 
+       /* Current git repository */
+       GgitRepository *repository;
+       GitThreadPool *thread_pool;
+
        /* List commands for various panes. 
         * Keep them in the plugin so that the commands have the most direct
         * way of handling project (working directory) changes */


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