[anjuta/gnome-3-0] git/file-manager: bgo#578511 - after vcs update the files' icons don't get updated



commit 831e158a7c54137942b725deb5f5f06da1ce383f
Author: Tamara Atanasoska <tamarce_s hotmail com>
Date:   Tue May 31 05:01:34 2011 +0200

    git/file-manager: bgo#578511 - after vcs update the files' icons don't get updated

 libanjuta/interfaces/libanjuta.idl |    9 +++++++
 plugins/file-manager/file-model.c  |   42 ++++++++++++++++++++++++++++++++++-
 plugins/file-manager/file-model.h  |    3 ++
 plugins/file-manager/file-view.c   |    8 ++++++
 plugins/file-manager/file-view.h   |    3 ++
 plugins/file-manager/plugin.c      |   14 +++++++++++-
 plugins/file-manager/plugin.h      |   11 +++++++-
 plugins/git/git-commit-pane.c      |    5 +++-
 plugins/git/git-pull-pane.c        |    5 +++-
 plugins/git/git-push-pane.c        |    4 +++
 plugins/git/plugin.c               |    6 +++++
 plugins/git/plugin.h               |    2 +
 12 files changed, 105 insertions(+), 7 deletions(-)
---
diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl
index 279ee78..7a07af6 100644
--- a/libanjuta/interfaces/libanjuta.idl
+++ b/libanjuta/interfaces/libanjuta.idl
@@ -5448,6 +5448,15 @@ interface IAnjutaVcs
 	{
 	  UNKOWN_ERROR
 	}
+	
+	/**
+	 * IAnjutaVcsStatus
+	 * @obj: Self
+ 	 *
+ 	 * This signal is emited when the git pull command is finished, and refreshes the tree of files with the new pulled files without the need to 
+ 	 * fold- unfold the tree.
+	 */
+	void	::status_changed();
 
 	/**
 	 * ianjuta_vcs_add:
diff --git a/plugins/file-manager/file-model.c b/plugins/file-manager/file-model.c
index 0ed25f5..006e8b3 100644
--- a/plugins/file-manager/file-model.c
+++ b/plugins/file-manager/file-model.c
@@ -218,7 +218,7 @@ file_model_vcs_status_callback(GFile *file,
 				                    &dummy, -1);
 				if (dummy)
 					break;
-				if (g_file_equal (file, child_file))
+				if (file && child_file && g_file_equal (file, child_file))
 				{
 					if (priv->filter_unversioned &&
 					    (status == ANJUTA_VCS_STATUS_UNVERSIONED ||
@@ -385,6 +385,38 @@ file_model_update_file (FileModel* model,
 	g_free(display_name);
 }
 
+static gboolean
+file_model_update_file_foreach_func (GtkTreeModel* model,
+                                     GtkTreePath* path,
+                                     GtkTreeIter* iter,
+                                     gpointer user_data)
+{
+	GFile* file;
+	GFileInfo* info;
+	
+	gtk_tree_model_get (model, iter,
+	                    COLUMN_FILE, &file, -1);
+
+	if (!file)
+		return FALSE;
+	
+	info = g_file_query_info (file,
+	                          "standard::*",
+	                          G_FILE_QUERY_INFO_NONE,
+	                          NULL, NULL);
+	
+	file_model_update_file (FILE_MODEL (model), 
+	                        iter,
+	                        file,
+	                        info,
+	                        FALSE);
+	g_object_unref (info);
+	g_object_unref (file);
+	
+	/* Continue iterating */
+	return FALSE;
+}
+
 static void
 file_model_add_file (FileModel* model,
 					 GtkTreeIter* parent,
@@ -401,6 +433,12 @@ file_model_add_file (FileModel* model,
 	}
 }
 
+void file_model_update_vcs_status (FileModel* model)
+{
+    gtk_tree_model_foreach (GTK_TREE_MODEL(model), 
+                            file_model_update_file_foreach_func, NULL);
+}
+
 static void
 on_file_model_changed (GFileMonitor* monitor,
 					   GFile* file,
@@ -432,7 +470,7 @@ on_file_model_changed (GFileMonitor* monitor,
 			GFile* model_file;
 			gtk_tree_model_get (GTK_TREE_MODEL(model), &file_iter,
 								COLUMN_FILE, &model_file, -1);
-			if (g_file_equal (model_file, file))
+			if (model_file && file && g_file_equal (model_file, file))
 			{
 				g_object_unref (model_file);
 				found = TRUE;
diff --git a/plugins/file-manager/file-model.h b/plugins/file-manager/file-model.h
index 9cf67c8..46c74ef 100644
--- a/plugins/file-manager/file-model.h
+++ b/plugins/file-manager/file-model.h
@@ -85,6 +85,9 @@ file_model_get_filename (FileModel* model, GtkTreeIter* iter);
 void
 file_model_set_ivcs (FileModel* model, IAnjutaVcs *ivcs);
 
+void
+file_model_update_vcs_status (FileModel* model);
+
 G_END_DECLS
 
 #endif /* _FILE_MODEL_H_ */
diff --git a/plugins/file-manager/file-view.c b/plugins/file-manager/file-view.c
index c83b37a..60d19d0 100644
--- a/plugins/file-manager/file-view.c
+++ b/plugins/file-manager/file-view.c
@@ -703,6 +703,14 @@ file_view_class_init (AnjutaFileViewClass *klass)
 	widget_class->drag_data_get = file_view_drag_data_get;
 }
 
+void 
+file_view_refresh_vcs (AnjutaFileView* view)
+{
+	AnjutaFileViewPrivate* priv = ANJUTA_FILE_VIEW_GET_PRIVATE (view);
+    file_model_update_vcs_status(priv->model);
+}
+
+
 GtkWidget*
 file_view_new (void)
 {
diff --git a/plugins/file-manager/file-view.h b/plugins/file-manager/file-view.h
index 28e9a5e..1940bc7 100644
--- a/plugins/file-manager/file-view.h
+++ b/plugins/file-manager/file-view.h
@@ -76,6 +76,9 @@ file_view_get_selected (AnjutaFileView* view);
 void
 file_view_refresh (AnjutaFileView* view);
 
+void 
+file_view_refresh_vcs (AnjutaFileView* view);
+
 G_END_DECLS
 
 #endif /* _FILE_VIEW_H_ */
diff --git a/plugins/file-manager/plugin.c b/plugins/file-manager/plugin.c
index 5424054..66ddb78 100644
--- a/plugins/file-manager/plugin.c
+++ b/plugins/file-manager/plugin.c
@@ -96,6 +96,13 @@ file_manager_set_default_uri (AnjutaFileManager* file_manager)
 	g_free(path);
 }
 
+static void 
+refresh_signal_cb(IAnjutaVcs* ivcs, gpointer data) 
+{
+    AnjutaFileManager* file_manager = ANJUTA_FILE_MANAGER(data);
+	file_view_refresh_vcs (file_manager->fv);
+}
+
 static IAnjutaVcs*
 get_vcs_plugin(AnjutaFileManager* file_manager, const gchar* root_uri)
 {
@@ -126,7 +133,7 @@ get_vcs_plugin(AnjutaFileManager* file_manager, const gchar* root_uri)
 		if (vcs_system)
 			break;
 	}
-	
+	       
 	if (vcs_system)
 	{
 		/* Load current language editor support plugins */
@@ -145,6 +152,11 @@ get_vcs_plugin(AnjutaFileManager* file_manager, const gchar* root_uri)
 													  &plugin_id);
 			ivcs = IANJUTA_VCS(anjuta_plugin_manager_get_plugin_by_id (plugin_manager,
 																	   plugin_id));
+
+			g_signal_connect (G_OBJECT (ivcs), "status_changed",
+			                  G_CALLBACK (refresh_signal_cb),
+			                  file_manager);
+			
 			g_list_free (plugin_descs);
 		}
 	}
diff --git a/plugins/file-manager/plugin.h b/plugins/file-manager/plugin.h
index 5337012..7f9e4fa 100644
--- a/plugins/file-manager/plugin.h
+++ b/plugins/file-manager/plugin.h
@@ -31,11 +31,16 @@
 #include "file-view.h"
 #include "file-model.h"
 
+#define ANJUTA_TYPE_FILE_MANAGER             (file_manager_get_type (NULL))
+#define ANJUTA_FILE_MANAGER(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_FILE_MANAGER, AnjutaFileManager))
+#define ANJUTA_FILE_MANAGER_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), ANJUTA_TYPE_FILE_MANAGER, AnjutaFileManagerClass))
+#define ANJUTA_IS_FILE_MANAGER(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANJUTA_TYPE_FILE_MANAGER))
+#define ANJUTA_IS_FILE_MANAGER_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), ANJUTA_TYPE_FILE_MANAGER))
+#define ANJUTA_FILE_MANAGER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), ANJUTA_TYPE_FILE_MANAGER, AnjutaFileManagerClass))
+
 typedef struct _AnjutaFileManager AnjutaFileManager;
 typedef struct _AnjutaFileManagerClass AnjutaFileManagerClass;
 
-extern GType file_manager_get_type (GTypeModule *module);
-
 struct _AnjutaFileManager {
 	AnjutaPlugin parent;
 	AnjutaFileView* fv;
@@ -52,4 +57,6 @@ struct _AnjutaFileManagerClass {
 	AnjutaPluginClass parent_class;
 };
 
+GType file_manager_get_type (GTypeModule *module);
+
 #endif
diff --git a/plugins/git/git-commit-pane.c b/plugins/git/git-commit-pane.c
index bc23774..807a184 100644
--- a/plugins/git/git-commit-pane.c
+++ b/plugins/git/git-commit-pane.c
@@ -181,7 +181,10 @@ on_ok_button_clicked (GtkButton *button, GitCommitPane *self)
 	g_signal_connect (G_OBJECT (commit_command), "command-finished",
 	                  G_CALLBACK (git_pane_report_errors),
 	                  plugin);
-
+	                  
+    g_signal_connect (G_OBJECT (commit_command), "command-finished",
+                      G_CALLBACK (git_plugin_status_changed_emit),
+                      plugin);
 
 	g_signal_connect (G_OBJECT (commit_command), "command-finished",
 	                  G_CALLBACK (g_object_unref),
diff --git a/plugins/git/git-pull-pane.c b/plugins/git/git-pull-pane.c
index 9886624..2b0c080 100644
--- a/plugins/git/git-pull-pane.c
+++ b/plugins/git/git-pull-pane.c
@@ -90,7 +90,10 @@ on_ok_button_clicked (GtkButton *button, GitPullPane *self)
 	g_signal_connect (G_OBJECT (pull_command), "command-finished",
 	                  G_CALLBACK (git_pane_report_errors),
 	                  plugin);
-
+	                  
+	g_signal_connect (G_OBJECT (pull_command), "command-finished",
+                      G_CALLBACK (git_plugin_status_changed_emit),
+                      plugin);
 
 	g_signal_connect (G_OBJECT (pull_command), "command-finished",
 	                  G_CALLBACK (g_object_unref),
diff --git a/plugins/git/git-push-pane.c b/plugins/git/git-push-pane.c
index ec5318c..9fb01c0 100644
--- a/plugins/git/git-push-pane.c
+++ b/plugins/git/git-push-pane.c
@@ -132,6 +132,10 @@ on_ok_button_clicked (GtkButton *button, GitPushPane *self)
 	g_signal_connect (G_OBJECT (push_command), "command-finished",
 	                  G_CALLBACK (git_pane_report_errors),
 	                  plugin);
+	
+	g_signal_connect (G_OBJECT (push_command), "command-finished",
+                      G_CALLBACK (git_plugin_status_changed_emit),
+                      plugin);
 
 	g_signal_connect (G_OBJECT (push_command), "command-finished",
 	                  G_CALLBACK (g_object_unref),
diff --git a/plugins/git/plugin.c b/plugins/git/plugin.c
index 609942c..fe9080d 100644
--- a/plugins/git/plugin.c
+++ b/plugins/git/plugin.c
@@ -888,6 +888,12 @@ git_class_init (GObjectClass *klass)
 	klass->dispose = git_dispose;
 }
 
+
+void git_plugin_status_changed_emit(AnjutaCommand *command, guint return_code, Git *plugin)
+{
+        g_signal_emit_by_name(plugin, "status-changed");
+}
+
 ANJUTA_PLUGIN_BEGIN (Git, git);
 ANJUTA_PLUGIN_ADD_INTERFACE (git_ivcs, IANJUTA_TYPE_VCS);
 ANJUTA_PLUGIN_END;
diff --git a/plugins/git/plugin.h b/plugins/git/plugin.h
index 13110c2..81d3843 100644
--- a/plugins/git/plugin.h
+++ b/plugins/git/plugin.h
@@ -101,4 +101,6 @@ struct _GitClass
 	AnjutaPluginClass parent_class;
 };
 
+void git_plugin_status_changed_emit(AnjutaCommand *command, guint return_code, Git *plugin);
+
 #endif



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