SF.net SVN: geany: [944] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sun Oct 29 13:03:24 UTC 2006


Revision: 944
          http://svn.sourceforge.net/geany/?rev=944&view=rev
Author:   eht16
Date:     2006-10-29 05:03:13 -0800 (Sun, 29 Oct 2006)

Log Message:
-----------
Colour also the open files list items according to their changed state.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/document.c
    trunk/src/treeviews.c
    trunk/src/treeviews.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-10-29 01:28:58 UTC (rev 943)
+++ trunk/ChangeLog	2006-10-29 13:03:13 UTC (rev 944)
@@ -5,6 +5,9 @@
    Added an Apply button to preferences dialog.
    New setting to show/hide the Quit toolbar item.
    New setting to show/hide notebook tabs.
+ * src/document.c, src/treeviews.c, src/treeviews.h:
+   Colour also the open files list items according to their changed
+   state.
 
 
 2006-10-28  Nick Treleaven  <nick.treleaven at btinternet.com>

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2006-10-29 01:28:58 UTC (rev 943)
+++ trunk/src/document.c	2006-10-29 13:03:13 UTC (rev 944)
@@ -165,8 +165,9 @@
 	if (idx >= 0 && doc_list[idx].is_valid && ! app->quitting)
 	{
 		// changes the color of the tab text according to the status
-		GdkColor colorred = {0, 65535, 0, 0};
-		GdkColor colorblack = {0, 0, 0, 0};
+		static GdkColor colorred = {0, 65535, 0, 0};
+		static GdkColor colorblack = {0, 0, 0, 0};
+		gchar *basename = g_path_get_basename(doc_list[idx].file_name);
 
 		gtk_widget_modify_fg(doc_list[idx].tab_label, GTK_STATE_NORMAL,
 					(doc_list[idx].changed) ? &colorred : &colorblack);
@@ -180,6 +181,8 @@
 		ui_save_buttons_toggle(doc_list[idx].changed);
 		ui_set_window_title(idx);
 		ui_update_statusbar(idx, -1);
+		treeviews_openfiles_update(doc_list[idx].iter, basename, doc_list[idx].changed);
+		g_free(basename);
 	}
 }
 
@@ -301,7 +304,7 @@
 	tabnum = notebook_new_tab(new_idx, title, GTK_WIDGET(sci));
 	gtk_notebook_set_current_page(GTK_NOTEBOOK(app->notebook), tabnum);
 
-	iter = treeviews_openfiles_add(new_idx, title);
+	iter = treeviews_openfiles_add(new_idx, title, FALSE);
 	g_free(title);
 
 	this->tag_store = NULL;
@@ -893,10 +896,8 @@
 		tm_workspace_update(TM_WORK_OBJECT(app->tm_workspace), TRUE, TRUE, FALSE);
 		gtk_label_set_text(GTK_LABEL(doc_list[idx].tab_label), basename);
 		gtk_label_set_text(GTK_LABEL(doc_list[idx].tabmenu_label), basename);
-		treeviews_openfiles_update(doc_list[idx].iter, doc_list[idx].file_name);
 		msgwin_status_add(_("File %s saved."), doc_list[idx].file_name);
 		ui_update_statusbar(idx, -1);
-		treeviews_openfiles_update(doc_list[idx].iter, basename);
 		g_free(basename);
 #ifdef HAVE_VTE
 		vte_cwd(doc_list[idx].file_name);

Modified: trunk/src/treeviews.c
===================================================================
--- trunk/src/treeviews.c	2006-10-29 01:28:58 UTC (rev 943)
+++ trunk/src/treeviews.c	2006-10-29 13:03:13 UTC (rev 944)
@@ -29,7 +29,7 @@
 #include "document.h"
 
 
-/* the following two functions are document-related, but I think they fit better here than in document.c*/
+/* the following two functions are document-related, but I think they fit better here than in document.c */
 void treeviews_prepare_taglist(GtkWidget *tree, GtkTreeStore *store)
 {
 	GtkCellRenderer *renderer;
@@ -236,7 +236,7 @@
 	tv.tree_openfiles = lookup_widget(app->window, "treeview6");
 
 	// store the short filename to show, and the index as reference
-	tv.store_openfiles = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
+	tv.store_openfiles = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_INT, GDK_TYPE_COLOR);
 	gtk_tree_view_set_model(GTK_TREE_VIEW(tv.tree_openfiles), GTK_TREE_MODEL(tv.store_openfiles));
 
 	// set policy settings for the scolledwindow around the treeview again, because glade
@@ -246,7 +246,8 @@
 			GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
 
 	renderer = gtk_cell_renderer_text_new();
-	column = gtk_tree_view_column_new_with_attributes(_("Open files"), renderer, "text", 0, NULL);
+	column = gtk_tree_view_column_new_with_attributes(_("Open files"), renderer,
+															"text", 0, "foreground-gdk", 2, NULL);
 	gtk_tree_view_append_column(GTK_TREE_VIEW(tv.tree_openfiles), column);
 	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tv.tree_openfiles), FALSE);
 
@@ -263,12 +264,21 @@
 }
 
 
-GtkTreeIter treeviews_openfiles_add(gint idx, const gchar *string)
+GtkTreeIter treeviews_openfiles_add(gint idx, const gchar *string, gboolean changed)
 {
 	GtkTreeIter iter;
+	static GdkColor black = {0, 0, 0, 0};
+	static GdkColor red = {0, 65535, 0, 0};
+	GdkColor *colour;
+	
+	if (changed)
+		colour = &red;
+	else
+		colour = &black;
+	
 
 	gtk_list_store_append(tv.store_openfiles, &iter);
-	gtk_list_store_set(tv.store_openfiles, &iter, 0, string, 1, idx, -1);
+	gtk_list_store_set(tv.store_openfiles, &iter, 0, string, 1, idx, 2, colour, -1);
 
 	return iter;
 }
@@ -281,9 +291,18 @@
 }
 
 
-void treeviews_openfiles_update(GtkTreeIter iter, const gchar *string)
+void treeviews_openfiles_update(GtkTreeIter iter, const gchar *string, gboolean changed)
 {
-	gtk_list_store_set(tv.store_openfiles, &iter, 0, string, -1);
+	static GdkColor black = {0, 0, 0, 0};
+	static GdkColor red = {0, 65535, 0, 0};
+	GdkColor *colour;
+	
+	if (changed)
+		colour = &red;
+	else
+		colour = &black;
+	
+	gtk_list_store_set(tv.store_openfiles, &iter, 0, string, 2, colour, -1);
 }
 
 
@@ -304,10 +323,9 @@
 		else
 			shortname = g_path_get_basename(doc_list[idx].file_name);
 
-		doc_list[idx].iter = treeviews_openfiles_add(idx, shortname);
+		doc_list[idx].iter = treeviews_openfiles_add(idx, shortname, doc_list[idx].changed);
 		g_free(shortname);
 	}
-
 }
 
 

Modified: trunk/src/treeviews.h
===================================================================
--- trunk/src/treeviews.h	2006-10-29 01:28:58 UTC (rev 943)
+++ trunk/src/treeviews.h	2006-10-29 13:03:13 UTC (rev 944)
@@ -54,9 +54,9 @@
 
 void treeviews_prepare_openfiles(void);
 
-GtkTreeIter treeviews_openfiles_add(gint idx, const gchar *string);
+GtkTreeIter treeviews_openfiles_add(gint idx, const gchar *string, gboolean changed);
 
-void treeviews_openfiles_update(GtkTreeIter iter, const gchar *string);
+void treeviews_openfiles_update(GtkTreeIter iter, const gchar *string, gboolean changed);
 
 void treeviews_openfiles_update_all(void);
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list