[Pkg-wmaker-commits] [wmstickynotes] 21/81: Save color names instead of indexes in the schemes array.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Tue Aug 25 02:33:44 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmstickynotes.

commit 968562cc8c612b996a85ea4f02095d71f3ce52e6
Author: hnc <hnc at 7fc852e4-12a7-4f5b-bad7-374d67da4d19>
Date:   Sat Feb 21 04:11:47 2009 +0000

    Save color names instead of indexes in the schemes array.
---
 wmstickynotes.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/wmstickynotes.c b/wmstickynotes.c
index 128f220..3ff57e4 100644
--- a/wmstickynotes.c
+++ b/wmstickynotes.c
@@ -203,7 +203,6 @@ void save_note(GtkWidget *widget, Note *note)
 	GtkTextIter start;
 	GtkTextIter end;
 	gchar *text;
-	int scheme_number;
 
 	text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(note->text_widget));
 	gtk_text_buffer_get_start_iter(text_buffer, &start);
@@ -215,14 +214,9 @@ void save_note(GtkWidget *widget, Note *note)
 	file = fopen(filename, "w");
 	free(filename);
 
-	/* Get the scheme number.  This should probably be revisited. */
-	for(scheme_number = num_color_schemes-1; scheme_number > 0; scheme_number--) {
-		if(!strcmp(color_schemes[scheme_number].name, note->scheme->name)) break;
-	}
-
 	fprintf(
-		file, "%d,%d,%d,%d,%d\n%s",
-		note->x, note->y, note->width, note->height, scheme_number, text);
+		file, "%d,%d,%d,%d,%d,%d,%s\n%s",
+		note->x, note->y, note->width, note->height, 0, 0, note->scheme->name, text);
 	fclose(file);
 
 	g_free(text);
@@ -363,7 +357,8 @@ void read_old_notes()
 	DIR *dir = opendir(".");
 	FILE *file;
 	struct dirent *entry;
-	int scheme_number;
+	int reserved1;
+	int reserved2;
 	int i;
 	char buffer[256];
 
@@ -381,9 +376,19 @@ void read_old_notes()
 		note->id = atoi(entry->d_name);
 		if(note->id > highest_note_id) highest_note_id = note->id;
 
-		fscanf(file, "%d,%d,%d,%d,%d\n", &(note->x), &(note->y), &(note->width), &(note->height), &scheme_number);
-		if(scheme_number >= num_color_schemes || scheme_number < 0) scheme_number = 0;
-		note->scheme = &color_schemes[scheme_number];
+		fscanf(file, "%d,%d,%d,%d,%d,%d,",
+			&(note->x), &(note->y), &(note->width), &(note->height),
+			&reserved1, &reserved2);
+
+		/* Get color name */
+		fgets(buffer, 256, file);
+		/* Replace the newline with a null char */
+		buffer[strlen(buffer) - 1] = '\0';
+
+		for(i=num_color_schemes; i > 0; i--) {
+			if(!strcmp(color_schemes[i].name, buffer)) break;
+		}
+		note->scheme = &color_schemes[i];
 
 		text_buffer = gtk_text_buffer_new(NULL);
 		while(fgets(buffer, 256, file)) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmstickynotes.git



More information about the Pkg-wmaker-commits mailing list