[anjuta] file-manager: Render version control status icons better
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] file-manager: Render version control status icons better
- Date: Sun, 12 Feb 2012 20:23:19 +0000 (UTC)
commit d46bb8444acb5b41ce8da4255b00ee1f1cfdd0d5
Author: Johannes Schmid <jhs gnome org>
Date: Sun Feb 12 21:21:48 2012 +0100
file-manager: Render version control status icons better
Previously the emblems were created on top of each other - now only one emblem can be there at a time.
plugins/file-manager/file-model.c | 81 ----------------------------
plugins/file-manager/file-view.c | 105 ++++++++++++++++++++++++++++++++++--
2 files changed, 99 insertions(+), 87 deletions(-)
---
diff --git a/plugins/file-manager/file-model.c b/plugins/file-manager/file-model.c
index 0541040..b030ff3 100644
--- a/plugins/file-manager/file-model.c
+++ b/plugins/file-manager/file-model.c
@@ -129,53 +129,6 @@ typedef struct
GtkTreeRowReference* ref;
} VcsData;
-#define EMBLEM_ADDED "vcs-added.png"
-#define EMBLEM_CONFLICT "vcs-conflict.png"
-#define EMBLEM_DELETED "vcs-deleted.png"
-#define EMBLEM_IGNORED "vcs-ignored.png"
-#define EMBLEM_LOCKED "vcs-locked.png"
-#define EMBLEM_UNVERSIONED "vcs-unversioned.png"
-#define EMBLEM_UPTODATE "vcs-updated.png"
-#define EMBLEM_MODIFIED "vcs-modified.png"
-
-#define COMPOSITE_ALPHA 225
-
-static GdkPixbuf*
-get_vcs_emblem (AnjutaVcsStatus status)
-{
- GdkPixbuf* emblem ;
- switch (status)
- {
- case ANJUTA_VCS_STATUS_ADDED:
- emblem = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"EMBLEM_ADDED, NULL);
- break;
- case ANJUTA_VCS_STATUS_MODIFIED:
- emblem = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"EMBLEM_MODIFIED, NULL);
- break;
- case ANJUTA_VCS_STATUS_DELETED:
- emblem = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"EMBLEM_DELETED, NULL);
- break;
- case ANJUTA_VCS_STATUS_CONFLICTED:
- emblem = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"EMBLEM_CONFLICT, NULL);
- break;
- case ANJUTA_VCS_STATUS_LOCKED:
- emblem = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"EMBLEM_LOCKED, NULL);
- break;
- case ANJUTA_VCS_STATUS_UNVERSIONED:
- emblem = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"EMBLEM_UNVERSIONED, NULL);
- break;
- case ANJUTA_VCS_STATUS_UPTODATE:
- emblem = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"EMBLEM_UPTODATE, NULL);
- break;
- case ANJUTA_VCS_STATUS_IGNORED:
- emblem = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"EMBLEM_IGNORED, NULL);
- break;
- default:
- emblem = NULL;
- }
- return emblem;
-}
-
static void
file_model_vcs_status_callback(GFile *file,
AnjutaVcsStatus status,
@@ -190,8 +143,6 @@ file_model_vcs_status_callback(GFile *file,
{
GFile* dir;
GFile* parent;
- GdkPixbuf* file_icon = NULL;
- GdkPixbuf* emblem = NULL;
GtkTreeIter iter;
GtkTreeIter child;
GtkTreeModel* model = gtk_tree_row_reference_get_model (data->ref);
@@ -228,38 +179,6 @@ file_model_vcs_status_callback(GFile *file,
}
else
{
- emblem = get_vcs_emblem (status);
- if (emblem)
- {
- gtk_tree_model_get (model, &child,
- COLUMN_PIXBUF, &file_icon,
- -1);
- if (file_icon)
- {
- GdkPixbuf *new_icon;
-
- new_icon = gdk_pixbuf_copy (file_icon);
- gdk_pixbuf_composite (emblem,
- new_icon,
- 0, 0,
- gdk_pixbuf_get_width (file_icon),
- gdk_pixbuf_get_height (file_icon),
- 0, 0,
- 1, 1,
- GDK_INTERP_BILINEAR,
- COMPOSITE_ALPHA);
- gtk_tree_store_set (GTK_TREE_STORE (model),
- &child,
- COLUMN_PIXBUF,
- new_icon,
- -1);
- DEBUG_PRINT ("%s", "setting emblem");
- g_object_unref (new_icon);
- g_object_unref (file_icon);
- }
- g_object_unref (emblem);
- }
-
gtk_tree_store_set (GTK_TREE_STORE (model),
&child,
COLUMN_STATUS,
diff --git a/plugins/file-manager/file-view.c b/plugins/file-manager/file-view.c
index 18fa193..6fec1a2 100644
--- a/plugins/file-manager/file-view.c
+++ b/plugins/file-manager/file-view.c
@@ -89,10 +89,8 @@ get_status_string(AnjutaVcsStatus status)
return _("Unversioned");
case ANJUTA_VCS_STATUS_IGNORED:
return _("Ignored");
-#if 0
default:
- g_assert_not_reached();
-#endif
+ break;
}
return NULL;
@@ -542,6 +540,100 @@ file_view_sort_model(GtkTreeModel* model,
return retval;
}
+#define EMBLEM_ADDED "vcs-added.png"
+#define EMBLEM_CONFLICT "vcs-conflict.png"
+#define EMBLEM_DELETED "vcs-deleted.png"
+#define EMBLEM_IGNORED "vcs-ignored.png"
+#define EMBLEM_LOCKED "vcs-locked.png"
+#define EMBLEM_UNVERSIONED "vcs-unversioned.png"
+#define EMBLEM_UPTODATE "vcs-updated.png"
+#define EMBLEM_MODIFIED "vcs-modified.png"
+
+#define COMPOSITE_ALPHA 225
+
+static GdkPixbuf*
+get_vcs_emblem (AnjutaVcsStatus status)
+{
+ GdkPixbuf* emblem ;
+ switch (status)
+ {
+ case ANJUTA_VCS_STATUS_ADDED:
+ emblem = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"EMBLEM_ADDED, NULL);
+ break;
+ case ANJUTA_VCS_STATUS_MODIFIED:
+ emblem = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"EMBLEM_MODIFIED, NULL);
+ break;
+ case ANJUTA_VCS_STATUS_DELETED:
+ emblem = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"EMBLEM_DELETED, NULL);
+ break;
+ case ANJUTA_VCS_STATUS_CONFLICTED:
+ emblem = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"EMBLEM_CONFLICT, NULL);
+ break;
+ case ANJUTA_VCS_STATUS_LOCKED:
+ emblem = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"EMBLEM_LOCKED, NULL);
+ break;
+ case ANJUTA_VCS_STATUS_UNVERSIONED:
+ emblem = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"EMBLEM_UNVERSIONED, NULL);
+ break;
+ case ANJUTA_VCS_STATUS_UPTODATE:
+ emblem = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"EMBLEM_UPTODATE, NULL);
+ break;
+ case ANJUTA_VCS_STATUS_IGNORED:
+ emblem = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"EMBLEM_IGNORED, NULL);
+ break;
+ default:
+ emblem = NULL;
+ }
+ return emblem;
+}
+
+static void
+file_view_render_pixbuf_with_emblem (GtkTreeViewColumn* tree_column,
+ GtkCellRenderer* cell,
+ GtkTreeModel* tree_model,
+ GtkTreeIter* iter,
+ gpointer data)
+{
+ GdkPixbuf* file_icon = NULL;
+ GdkPixbuf* emblem = NULL;
+
+ AnjutaVcsStatus status;
+
+ gtk_tree_model_get (tree_model, iter,
+ COLUMN_STATUS, &status,
+ COLUMN_PIXBUF, &file_icon, -1);
+
+ if (file_icon)
+ {
+ emblem = get_vcs_emblem (status);
+ if (emblem)
+ {
+ GdkPixbuf *new_icon;
+
+ new_icon = gdk_pixbuf_copy (file_icon);
+ gdk_pixbuf_composite (emblem,
+ new_icon,
+ 0, 0,
+ gdk_pixbuf_get_width (file_icon),
+ gdk_pixbuf_get_height (file_icon),
+ 0, 0,
+ 1, 1,
+ GDK_INTERP_BILINEAR,
+ COMPOSITE_ALPHA);
+
+ g_object_set (cell, "pixbuf", new_icon, NULL);
+
+ g_object_unref (new_icon);
+ g_object_unref (emblem);
+ }
+ else
+ {
+ g_object_set (cell, "pixbuf", file_icon, NULL);
+ }
+ g_object_unref (file_icon);
+ }
+}
+
static void
file_view_init (AnjutaFileView *object)
{
@@ -570,9 +662,10 @@ file_view_init (AnjutaFileView *object)
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);
+ gtk_tree_view_column_set_cell_data_func(column,
+ renderer_pixbuf,
+ file_view_render_pixbuf_with_emblem,
+ object, NULL);
gtk_tree_view_column_set_attributes (column, renderer_display,
"markup", COLUMN_DISPLAY,
NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]