Revision: 5330 http://geany.svn.sourceforge.net/geany/?rev=5330&view=rev Author: ntrel Date: 2010-10-26 17:20:48 +0000 (Tue, 26 Oct 2010)
Log Message: ----------- Show mimetype icon in sidebar Documents list (patch by Colomban Wendling, thanks).
Modified Paths: -------------- trunk/ChangeLog trunk/src/document.c trunk/src/sidebar.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-10-26 16:02:30 UTC (rev 5329) +++ trunk/ChangeLog 2010-10-26 17:20:48 UTC (rev 5330) @@ -11,6 +11,9 @@ exponential time. * src/ui_utils.h, src/filetypes.c, src/filetypes.h, src/ui_utils.c: Add filetype mimetype field (patch by Colomban Wendling, thanks). + * src/sidebar.c, src/document.c: + Show mimetype icon in sidebar Documents list (patch by Colomban + Wendling, thanks).
2010-10-25 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/src/document.c =================================================================== --- trunk/src/document.c 2010-10-26 16:02:30 UTC (rev 5329) +++ trunk/src/document.c 2010-10-26 17:20:48 UTC (rev 5330) @@ -2512,7 +2512,10 @@ document_load_config(doc, type, ft_changed);
if (ft_changed) + { + sidebar_openfiles_update(doc); /* to update the icon */ g_signal_emit_by_name(geany_object, "document-filetype-set", doc, old_ft); + } }
Modified: trunk/src/sidebar.c =================================================================== --- trunk/src/sidebar.c 2010-10-26 16:02:30 UTC (rev 5329) +++ trunk/src/sidebar.c 2010-10-26 17:20:48 UTC (rev 5330) @@ -272,7 +272,7 @@
/* store the icon and the short filename to show, and the index as reference, * the colour (black/red/green) and the full name for the tooltip */ - store_openfiles = gtk_tree_store_new(5, G_TYPE_STRING, G_TYPE_STRING, + store_openfiles = gtk_tree_store_new(5, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_POINTER, GDK_TYPE_COLOR, G_TYPE_STRING); gtk_tree_view_set_model(GTK_TREE_VIEW(tv.tree_openfiles), GTK_TREE_MODEL(store_openfiles));
@@ -287,7 +287,7 @@ g_object_set(text_renderer, "ellipsize", PANGO_ELLIPSIZE_MIDDLE, NULL); column = gtk_tree_view_column_new(); gtk_tree_view_column_pack_start(column, icon_renderer, FALSE); - gtk_tree_view_column_set_attributes(column, icon_renderer, "stock-id", DOCUMENTS_ICON, NULL); + gtk_tree_view_column_set_attributes(column, icon_renderer, "pixbuf", DOCUMENTS_ICON, NULL); gtk_tree_view_column_pack_start(column, text_renderer, TRUE); gtk_tree_view_column_set_attributes(column, text_renderer, "text", DOCUMENTS_SHORTNAME, "foreground-gdk", DOCUMENTS_COLOR, NULL); @@ -399,6 +399,7 @@ gchar *dirname = NULL; static GtkTreeIter parent; GtkTreeModel *model = GTK_TREE_MODEL(store_openfiles); + static GdkPixbuf *dir_icon = NULL;
if (!documents_show_paths) return NULL; @@ -420,8 +421,11 @@ while (gtk_tree_model_iter_next(model, &parent)); } /* no match, add dir parent */ + if (!dir_icon) + dir_icon = ui_get_mime_icon("inode/directory", GTK_ICON_SIZE_MENU); + gtk_tree_store_append(store_openfiles, &parent, NULL); - gtk_tree_store_set(store_openfiles, &parent, DOCUMENTS_ICON, GTK_STOCK_DIRECTORY, + gtk_tree_store_set(store_openfiles, &parent, DOCUMENTS_ICON, dir_icon, DOCUMENTS_FILENAME, path, DOCUMENTS_SHORTNAME, doc->file_name ? dirname : GEANY_STRING_UNTITLED, -1);
@@ -439,6 +443,7 @@ GtkTreeIter *parent = get_doc_parent(doc); gchar *basename; const GdkColor *color = document_get_status_color(doc); + static GdkPixbuf *file_icon = NULL;
gtk_tree_store_append(store_openfiles, iter, parent);
@@ -452,8 +457,12 @@ gtk_tree_view_expand_row(GTK_TREE_VIEW(tv.tree_openfiles), path, TRUE); gtk_tree_path_free(path); } + if (!file_icon) + file_icon = ui_get_mime_icon("text/plain", GTK_ICON_SIZE_MENU); + basename = g_path_get_basename(DOC_FILENAME(doc)); - gtk_tree_store_set(store_openfiles, iter, DOCUMENTS_ICON, GTK_STOCK_FILE, + gtk_tree_store_set(store_openfiles, iter, + DOCUMENTS_ICON, (doc->file_type && doc->file_type->icon) ? doc->file_type->icon : file_icon, DOCUMENTS_SHORTNAME, basename, DOCUMENTS_DOCUMENT, doc, DOCUMENTS_COLOR, color, DOCUMENTS_FILENAME, DOC_FILENAME(doc), -1); g_free(basename); @@ -482,10 +491,13 @@
if (utils_str_equal(fname, DOC_FILENAME(doc))) { - /* just update color */ + /* just update color and the icon */ const GdkColor *color = document_get_status_color(doc); + GdkPixbuf *icon = doc->file_type->icon;
gtk_tree_store_set(store_openfiles, iter, DOCUMENTS_COLOR, color, -1); + if (icon) + gtk_tree_store_set(store_openfiles, iter, DOCUMENTS_ICON, icon, -1); } else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.