anjuta r4586 - in trunk: . plugins/cvs-plugin plugins/file-manager
- From: jhs svn gnome org
- To: svn-commits-list gnome org
- Subject: anjuta r4586 - in trunk: . plugins/cvs-plugin plugins/file-manager
- Date: Tue, 13 Jan 2009 23:28:27 +0000 (UTC)
Author: jhs
Date: Tue Jan 13 23:28:27 2009
New Revision: 4586
URL: http://svn.gnome.org/viewvc/anjuta?rev=4586&view=rev
Log:
2009-01-14 Johannes Schmid <jhs gnome org>
* plugins/cvs-plugin/anjuta-cvs.plugin.in:
Don't claim to implement IAnjutaVCS
* plugins/file-manager/file-model.c
(file_model_vcs_status_callback), (file_model_free_vcs_data),
(file_model_get_vcs_status), (file_model_update_file),
(file_model_new):
* plugins/file-manager/file-model.h:
* plugins/file-manager/file-view.c (file_view_show_extended_data),
(file_view_init):
* plugins/file-manager/plugin.c (file_manager_activate):
Show VCS status in file-manager
Modified:
trunk/ChangeLog
trunk/plugins/cvs-plugin/anjuta-cvs.plugin.in
trunk/plugins/file-manager/file-model.c
trunk/plugins/file-manager/file-model.h
trunk/plugins/file-manager/file-view.c
trunk/plugins/file-manager/plugin.c
Modified: trunk/plugins/cvs-plugin/anjuta-cvs.plugin.in
==============================================================================
--- trunk/plugins/cvs-plugin/anjuta-cvs.plugin.in (original)
+++ trunk/plugins/cvs-plugin/anjuta-cvs.plugin.in Tue Jan 13 23:28:27 2009
@@ -3,7 +3,6 @@
_Description=A version control system plugin
Location=anjuta-cvs-plugin:CVSPlugin
Icon=anjuta-cvs-plugin-48.png
-Interfaces=IAnjutaVcs
[Version Control]
Supported-Vcs-Types=cvs
Modified: trunk/plugins/file-manager/file-model.c
==============================================================================
--- trunk/plugins/file-manager/file-model.c (original)
+++ trunk/plugins/file-manager/file-model.c Tue Jan 13 23:28:27 2009
@@ -26,6 +26,9 @@
#include <glib/gi18n.h>
#include <string.h>
#include <libanjuta/anjuta-debug.h>
+#include <libanjuta/anjuta-plugin.h>
+#include <libanjuta/anjuta-async-notify.h>
+#include <libanjuta/interfaces/ianjuta-vcs.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
@@ -60,6 +63,8 @@
gboolean filter_binary;
gboolean filter_hidden;
gboolean filter_backup;
+
+ GtkTreeView* view;
};
struct _FileModelAsyncData
@@ -102,7 +107,7 @@
static void
file_model_add_dummy (FileModel* model,
- GtkTreeIter* iter)
+ GtkTreeIter* iter)
{
GtkTreeStore* store = GTK_TREE_STORE (model);
GtkTreeIter dummy;
@@ -114,6 +119,99 @@
-1);
}
+typedef struct
+{
+ FileModel* model;
+ GtkTreeRowReference* ref;
+} VcsData;
+
+static void
+file_model_vcs_status_callback(GFile *file,
+ AnjutaVcsStatus status,
+ gpointer user_data)
+{
+ VcsData* data = user_data;
+ gchar* path = g_file_get_path (file);
+
+ GtkTreePath* tree_path = gtk_tree_row_reference_get_path (data->ref);
+ if (tree_path)
+ {
+ const gchar* color = NULL;
+ GtkTreeIter iter;
+ GtkTreeModel* model = gtk_tree_row_reference_get_model (data->ref);
+ switch (status)
+ {
+ case ANJUTA_VCS_STATUS_MODIFIED:
+ color = "yellow";
+ break;
+ case ANJUTA_VCS_STATUS_ADDED:
+ color = "green";
+ break;
+ case ANJUTA_VCS_STATUS_CONFLICTED:
+ color = "red";
+ break;
+ default:
+ color = "white";
+ }
+ gtk_tree_model_get_iter (model,
+ &iter,
+ tree_path);
+ gtk_tree_store_set (GTK_TREE_STORE (model),
+ &iter,
+ COLUMN_BACKGROUND,
+ color,
+ COLUMN_STATUS,
+ status,
+ -1);
+ gtk_tree_path_free (tree_path);
+ }
+ g_free(path);
+}
+
+static void
+file_model_free_vcs_data (VcsData *data)
+{
+ gtk_tree_row_reference_free (data->ref);
+ g_free (data);
+}
+
+static void
+file_model_get_vcs_status (FileModel* model,
+ GtkTreeIter* iter,
+ GFile* file)
+{
+ GtkTreePath* path = gtk_tree_model_get_path (GTK_TREE_MODEL(model),
+ iter);
+ FileModelPrivate* priv = FILE_MODEL_GET_PRIVATE(model);
+ AnjutaPlugin* plugin = ANJUTA_PLUGIN(g_object_get_data (G_OBJECT(priv->view), "__plugin"));
+
+ g_return_if_fail (plugin != NULL);
+
+ IAnjutaVcs* ivcs = anjuta_shell_get_interface (plugin->shell,
+ IAnjutaVcs,
+ NULL);
+ if (ivcs)
+ {
+ VcsData* data = g_new0(VcsData, 1);
+ AnjutaAsyncNotify* notify = anjuta_async_notify_new();
+ data->ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (model),
+ path);
+ data->model = model;
+
+ g_signal_connect_swapped (G_OBJECT (notify), "finished",
+ G_CALLBACK (file_model_free_vcs_data), data);
+
+ ianjuta_vcs_query_status(ivcs,
+ file,
+ file_model_vcs_status_callback,
+ data,
+ NULL,
+ notify,
+ NULL);
+ }
+ gtk_tree_path_free (path);
+}
+
static void
file_model_update_file (FileModel* model,
GtkTreeIter* iter,
@@ -155,12 +253,17 @@
COLUMN_FILENAME, display_name,
COLUMN_FILE, file,
COLUMN_PIXBUF, pixbuf,
+ COLUMN_STATUS, ANJUTA_VCS_STATUS_NONE,
+ COLUMN_BACKGROUND, "white",
COLUMN_IS_DIR, is_dir,
COLUMN_SORT, g_file_info_get_sort_order(file_info),
-1);
+
if (is_dir)
file_model_add_dummy(model, iter);
+ file_model_get_vcs_status (model, iter, file);
+
if (pixbuf)
g_object_unref (pixbuf);
g_free(display_name);
@@ -532,8 +635,9 @@
GObject* model =
g_object_new (FILE_TYPE_MODEL, "base_uri", base_uri, NULL);
GType types[N_COLUMNS] = {GDK_TYPE_PIXBUF, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_OBJECT,
+ G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_OBJECT,
G_TYPE_BOOLEAN, G_TYPE_INT};
+ FileModelPrivate* priv = FILE_MODEL_GET_PRIVATE(model);
g_signal_connect (G_OBJECT (tree_view), "row-collapsed",
G_CALLBACK (file_model_row_collapsed), model);
@@ -543,6 +647,8 @@
gtk_tree_store_set_column_types (GTK_TREE_STORE (model), N_COLUMNS,
types);
+ priv->view = tree_view;
+
return FILE_MODEL(model);
}
Modified: trunk/plugins/file-manager/file-model.h
==============================================================================
--- trunk/plugins/file-manager/file-model.h (original)
+++ trunk/plugins/file-manager/file-model.h Tue Jan 13 23:28:27 2009
@@ -48,6 +48,8 @@
COLUMN_PIXBUF,
COLUMN_FILENAME,
COLUMN_DISPLAY,
+ COLUMN_STATUS,
+ COLUMN_BACKGROUND,
COLUMN_FILE,
COLUMN_IS_DIR,
COLUMN_SORT,
Modified: trunk/plugins/file-manager/file-view.c
==============================================================================
--- trunk/plugins/file-manager/file-view.c (original)
+++ trunk/plugins/file-manager/file-view.c Tue Jan 13 23:28:27 2009
@@ -37,6 +37,7 @@
#include <glib/gi18n.h>
#include <libanjuta/anjuta-debug.h>
+#include <libanjuta/anjuta-vcs-status.h>
typedef struct _AnjutaFileViewPrivate AnjutaFileViewPrivate;
@@ -53,6 +54,19 @@
G_DEFINE_TYPE (AnjutaFileView, file_view, GTK_TYPE_TREE_VIEW);
+const gchar* anjuta_vcs_status_strings[] = {
+ NULL,
+ N_("Modified"),
+ N_("Added"),
+ N_("Removed"),
+ N_("Deleted"),
+ N_("Conflicted"),
+ N_("Outdated"),
+ N_("Locked"),
+ N_("Missing"),
+ N_("Unversioned")
+};
+
enum
{
PROP_BASE_URI = 1,
@@ -260,7 +274,9 @@
{
gchar* display;
gchar time_str[128];
- gtk_tree_model_get (file_model, iter, COLUMN_FILE, &file, -1);
+ AnjutaVcsStatus status;
+ gtk_tree_model_get (file_model, iter, COLUMN_FILE, &file,
+ COLUMN_STATUS, &status, -1);
time_t time;
file_info = g_file_query_info (file,
@@ -269,11 +285,22 @@
NULL, NULL);
time = g_file_info_get_attribute_uint64(file_info, "time::changed");
strftime(time_str, 127, "%x %X", localtime(&time));
- display = g_markup_printf_escaped("%s\n"
- "<small><tt>%s</tt></small>",
- g_file_info_get_display_name(file_info),
- time_str);
-
+ if (anjuta_vcs_status_strings[status])
+ {
+ display = g_markup_printf_escaped("%s\n"
+ "<small><tt>%s</tt></small>\n"
+ "<small>%s</small>",
+ g_file_info_get_display_name(file_info),
+ time_str,
+ anjuta_vcs_status_strings[status]);
+ }
+ else
+ {
+ display = g_markup_printf_escaped("%s\n"
+ "<small><tt>%s</tt></small>",
+ g_file_info_get_display_name(file_info),
+ time_str);
+ }
gtk_tree_store_set (GTK_TREE_STORE(file_model), iter,
COLUMN_DISPLAY, display,
-1);
@@ -431,16 +458,21 @@
NULL);
renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
+ g_object_set (G_OBJECT (renderer_pixbuf), "cell-background-set", TRUE, NULL);
renderer_display = gtk_cell_renderer_text_new ();
-
+ g_object_set (G_OBJECT (renderer_pixbuf), "cell-background-set", TRUE, NULL);
column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_title (column, _("Filename"));
gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
gtk_tree_view_column_pack_start (column, renderer_display, FALSE);
gtk_tree_view_column_set_attributes (column, renderer_pixbuf,
- "pixbuf", COLUMN_PIXBUF, NULL);
+ "pixbuf", COLUMN_PIXBUF,
+ "cell-background", COLUMN_BACKGROUND,
+ NULL);
gtk_tree_view_column_set_attributes (column, renderer_display,
- "markup", COLUMN_DISPLAY, NULL);
+ "markup", COLUMN_DISPLAY,
+ "cell-background", COLUMN_BACKGROUND,
+ NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (object), column);
selection =
Modified: trunk/plugins/file-manager/plugin.c
==============================================================================
--- trunk/plugins/file-manager/plugin.c (original)
+++ trunk/plugins/file-manager/plugin.c Tue Jan 13 23:28:27 2009
@@ -231,6 +231,7 @@
GTK_SHADOW_IN);
file_manager->fv = ANJUTA_FILE_VIEW (file_view_new ());
+ g_object_set_data (G_OBJECT(file_manager->fv), "__plugin", ANJUTA_PLUGIN(file_manager));
g_signal_connect (G_OBJECT (file_manager->fv), "file-open",
G_CALLBACK (on_file_view_open_file), file_manager);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]