[Goodies-commits] r4059 - in xfbib/trunk: . po src

Jesper Karlsson zarper at xfce.org
Sat Mar 15 21:55:26 CET 2008


Author: zarper
Date: 2008-03-15 20:55:26 +0000 (Sat, 15 Mar 2008)
New Revision: 4059

Modified:
   xfbib/trunk/TODO
   xfbib/trunk/po/POTFILES.in
   xfbib/trunk/src/about_dialog.c
   xfbib/trunk/src/entry_edit_dialog.c
   xfbib/trunk/src/entry_edit_dialog.h
   xfbib/trunk/src/menubar.c
   xfbib/trunk/src/node.c
   xfbib/trunk/src/node.h
   xfbib/trunk/src/open.c
   xfbib/trunk/src/parser.y
   xfbib/trunk/src/tag.c
   xfbib/trunk/src/tag.h
   xfbib/trunk/src/window.c
Log:
Xfbib: Added ability to make entries case sensitive.
The parser also sees if the entriy should be case sensitive or not.

Modified: xfbib/trunk/TODO
===================================================================
--- xfbib/trunk/TODO	2008-03-15 12:12:58 UTC (rev 4058)
+++ xfbib/trunk/TODO	2008-03-15 20:55:26 UTC (rev 4059)
@@ -1,9 +1,9 @@
-- Added information to the statusbar when the mouse is over buttons, e.g. print "Open file" when the mouse is over the open button. (0.0.2)
-
 - Autogenerate a bibtexkey for a new entry (should of course be modifiable). (0.0.2)
 
 - Right click menu. (0.0.2)
 
+- Create a better input method for author and editor, now if the user does not add \and between the authors, and there are to many of them, the file will fail on compilation in bibtex.
+
 - Save before exiting dialog.
 
 - Test suite for the parser.

Modified: xfbib/trunk/po/POTFILES.in
===================================================================
--- xfbib/trunk/po/POTFILES.in	2008-03-15 12:12:58 UTC (rev 4058)
+++ xfbib/trunk/po/POTFILES.in	2008-03-15 20:55:26 UTC (rev 4059)
@@ -1,6 +1,7 @@
 src/about_dialog.c
 src/entry_edit_dialog.c
 src/menubar.c
+src/open.c
 src/open_dialog.c
 src/save_dialog.c
 src/string_edit_dialog.c

Modified: xfbib/trunk/src/about_dialog.c
===================================================================
--- xfbib/trunk/src/about_dialog.c	2008-03-15 12:12:58 UTC (rev 4058)
+++ xfbib/trunk/src/about_dialog.c	2008-03-15 20:55:26 UTC (rev 4059)
@@ -41,10 +41,9 @@
 	gtk_about_dialog_set_authors((GtkAboutDialog *)dialog, authors);
 	gtk_about_dialog_set_license((GtkAboutDialog *)dialog, xfce_get_license_text(XFCE_LICENSE_TEXT_GPL));
 
-	/* Add this later */
 	gtk_about_dialog_set_copyright((GtkAboutDialog *)dialog, N_("Copyright \302\251 2008 Jesper Karlsson & David Gustafsson"));
 
 	gtk_dialog_run(GTK_DIALOG(dialog));
-
+	// Wait for user to click the OK button.
 	gtk_widget_destroy(dialog);
 }

Modified: xfbib/trunk/src/entry_edit_dialog.c
===================================================================
--- xfbib/trunk/src/entry_edit_dialog.c	2008-03-15 12:12:58 UTC (rev 4058)
+++ xfbib/trunk/src/entry_edit_dialog.c	2008-03-15 20:55:26 UTC (rev 4059)
@@ -187,7 +187,7 @@
 {
 	_DEBUG(("entry_sensitivity"));
 	
-	/* These entries are not used by any of the standard types in bibtex */
+	/* These entries are not used by any of the standard types in BibTeX */
 	//gtk_widget_set_sensitive(GTK_WIDGET(entries[get_entry_pos("url")].entry), FALSE);
 	//gtk_widget_set_sensitive(GTK_WIDGET(entries[get_entry_pos("e-print")].entry), FALSE);
 	//gtk_widget_set_sensitive(GTK_WIDGET(entries[get_entry_pos("crossref")].entry), FALSE);
@@ -337,7 +337,10 @@
 		gtk_entry_set_width_chars(GTK_ENTRY (edit_entry[i].entry), 30);
 		gtk_widget_set_tooltip_text (edit_entry[i].entry, tooltips[i]);
 		edit_entry[i].hbox = gtk_hbox_new(FALSE, 10);
+		edit_entry[i].toggle = gtk_toggle_button_new_with_label ("aA");
+		gtk_widget_set_tooltip_text (edit_entry[i].toggle, _("Toggle case sensitivity."));
 		gtk_box_pack_start(GTK_BOX(edit_entry[i].hbox), edit_entry[i].label, FALSE, FALSE, 10);
+		gtk_box_pack_end(GTK_BOX(edit_entry[i].hbox), edit_entry[i].toggle, FALSE, TRUE, 10);
 		gtk_box_pack_end(GTK_BOX(edit_entry[i].hbox), edit_entry[i].entry, FALSE, TRUE, 10);
 		g_signal_connect (G_OBJECT (GTK_ENTRY(edit_entry[i].entry)), "changed",
                       G_CALLBACK (entry_changed_event), combobox);
@@ -366,14 +369,20 @@
 	gtk_widget_show_all(dialog);
 
 	if (selected != NULL) {
+		_DEBUG(("Entry selected"));
 		if ((pos = get_type_pos(selected->type)) != -1) {
 			/* Adding predefined values */
 			gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), pos);
 			set_entry_text(GTK_ENTRY(key_entry), selected->key);
 			for (tags = selected->tags; tags != NULL; tags = tags->next) {
 				pos = get_entry_pos(tags->name);
-				if (pos != -1)
+				if (pos != -1) {
 					set_entry_text(GTK_ENTRY(edit_entry[pos].entry), tags->value);
+					if (tags->sense)
+						gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (edit_entry[pos].toggle), TRUE);
+					else
+						gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (edit_entry[pos].toggle), FALSE);
+				}
 				else
 					_DEBUG(("Tag equals -1: Name: %s Value: %s", tags->name, tags->value));
 			}
@@ -410,7 +419,8 @@
 						fprintf(stderr, "label = %s\tvalue = %s\n",
 								gtk_label_get_text(GTK_LABEL(edit_entry[i].label)), value);
 						/* Field was not empty and sensitive, so add value to a new entry */
-						add_tag(selected,(char*) gtk_label_get_text(GTK_LABEL(edit_entry[i].label)),(char*) value);
+						add_tag(selected,(char*) gtk_label_get_text(GTK_LABEL(edit_entry[i].label)),(char*) value,
+								gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (edit_entry[i].toggle)));
 					}
 				}
 				update_treeview(xfbib);

Modified: xfbib/trunk/src/entry_edit_dialog.h
===================================================================
--- xfbib/trunk/src/entry_edit_dialog.h	2008-03-15 12:12:58 UTC (rev 4058)
+++ xfbib/trunk/src/entry_edit_dialog.h	2008-03-15 20:55:26 UTC (rev 4059)
@@ -70,8 +70,7 @@
 	GtkWidget *label;
 	GtkWidget *entry;
 	GtkWidget *hbox;
+	GtkWidget *toggle;
 };
 
-
-
 void show_entry_edit_dialog(struct xfbib*, struct entry*);

Modified: xfbib/trunk/src/menubar.c
===================================================================
--- xfbib/trunk/src/menubar.c	2008-03-15 12:12:58 UTC (rev 4058)
+++ xfbib/trunk/src/menubar.c	2008-03-15 20:55:26 UTC (rev 4059)
@@ -30,6 +30,7 @@
 #include "entry_edit_dialog.h"
 #include "treeview.h"
 #include "string_edit_dialog.h"
+#include "statusbar.h"
 
 static void file_new_event_handler(struct xfbib *xfbib)
 {
@@ -39,6 +40,7 @@
 	xfbib->list = NULL;
 	update_treeview(xfbib);
 	gtk_window_set_title(GTK_WINDOW(xfbib->window.window), create_title(xfbib));
+	statusbar_push((GtkStatusbar *) xfbib->window.statusbar, 0, "New file.");
 }
 
 static void file_open_event_handler (struct xfbib *xfbib)
@@ -46,6 +48,7 @@
 	_DEBUG(("file_open_event_handler"));
 	show_open_dialog(xfbib);
 }
+
 static void file_save_event_handler (struct xfbib *xfbib)
 {
 	_DEBUG(("file_save_event_handler"));

Modified: xfbib/trunk/src/node.c
===================================================================
--- xfbib/trunk/src/node.c	2008-03-15 12:12:58 UTC (rev 4058)
+++ xfbib/trunk/src/node.c	2008-03-15 20:55:26 UTC (rev 4059)
@@ -84,10 +84,10 @@
 	}
 }
 
-void add_tag(struct entry *entry, char *name, char *value)
+void add_tag(struct entry *entry, char *name, char *value, int sense)
 {
 	_DEBUG(("add_tag"));
-	new_tag(&(entry->tags), name, value);
+	new_tag(&(entry->tags), name, value, sense);
 }
 
 void print_list(struct node *node)

Modified: xfbib/trunk/src/node.h
===================================================================
--- xfbib/trunk/src/node.h	2008-03-15 12:12:58 UTC (rev 4058)
+++ xfbib/trunk/src/node.h	2008-03-15 20:55:26 UTC (rev 4059)
@@ -33,7 +33,7 @@
 void add_preamble(struct node**, char*);
 void add_comment(struct node**, char*);
 void add_string(struct node**, char*, char*);
-void add_tag(struct entry*, char*, char*);
+void add_tag(struct entry*, char*, char*, int);
 void print_list(struct node*);
 void write_list(struct node*, FILE*);
 void free_list(struct node*);

Modified: xfbib/trunk/src/open.c
===================================================================
--- xfbib/trunk/src/open.c	2008-03-15 12:12:58 UTC (rev 4058)
+++ xfbib/trunk/src/open.c	2008-03-15 20:55:26 UTC (rev 4059)
@@ -32,6 +32,6 @@
 	update_treeview(xfbib);
 	_DEBUG(("Opening: %s", xfbib->filename));
 	gtk_window_set_title(GTK_WINDOW(xfbib->window.window), create_title(xfbib));
-	statusbar_push((GtkStatusbar *) xfbib->window.statusbar, 0, "File loaded.");
+	statusbar_push((GtkStatusbar *) xfbib->window.statusbar, 0, strcat(filename, _(" loaded...")));
 	return 0;
 }

Modified: xfbib/trunk/src/parser.y
===================================================================
--- xfbib/trunk/src/parser.y	2008-03-15 12:12:58 UTC (rev 4058)
+++ xfbib/trunk/src/parser.y	2008-03-15 20:55:26 UTC (rev 4059)
@@ -36,6 +36,7 @@
 void yysetnodelist(struct node **n) {yynodelist = n;}
 int yywrap(void){ return 1;}
 int yyerror(const char *s) { fprintf(stderr, "%d : %s\n",yylineno, s); return 1;}
+int sense;
 %}
 
 %token DEFINESTRING
@@ -103,7 +104,7 @@
 	|	field fields
 	;
 
-field	:	STRING w EQUAL w body optcomma {add_tag(entry, $1, $5); }
+field	:	STRING w EQUAL w body optcomma { add_tag(entry, $1, $5, sense); }
 	;
 
 optcomma:	COMMA w optcomma
@@ -116,9 +117,9 @@
 
 string 	:	STRING w 			{ $$ = lookup($1) ; }
 	|	ATSTRING w 			{ $$ = $1 ; }
-	|	QUOTE noquote QUOTE w 		{ $$ = $2 ; }
+	|	QUOTE noquote QUOTE w 		{ sense = 0; $$ = $2 ; }
 	|	LATEXCOMMAND w			{ $$ = $1 ; }
-	|	LCBRACKET whatever RCBRACKET w 	{ $$ = $2 ; }
+	|	LCBRACKET whatever RCBRACKET w 	{ sense = 1; $$ = $2 ; }
 	;
 
 noquote	:	/* Empty */			{ $$ = strdup("") ; }

Modified: xfbib/trunk/src/tag.c
===================================================================
--- xfbib/trunk/src/tag.c	2008-03-15 12:12:58 UTC (rev 4058)
+++ xfbib/trunk/src/tag.c	2008-03-15 20:55:26 UTC (rev 4059)
@@ -22,7 +22,7 @@
 #include "debug.h"
 
 
-void new_tag(struct tag **tags, char *name, char *value)
+void new_tag(struct tag **tags, char *name, char *value, int sense)
 {
 	_DEBUG(("new_tag"));
 	if (*tags == NULL) {
@@ -32,9 +32,10 @@
 		if ((new->value = strdup(value)) == NULL)
 			fprintf(stderr, "Insufficient amount of memory available\n");
 		new->next = NULL;
+		new->sense = sense;
 		*tags = new;
 	} else {
-		new_tag(&((*tags)->next), name, value);
+		new_tag(&((*tags)->next), name, value, sense);
 	}
 }
 
@@ -49,11 +50,13 @@
 	_DEBUG(("write_tags"));
 	struct tag *t;
 	for (t = tags; t != NULL; t = t->next) {
-		fprintf(file, "\t%s = \"%s\",\n", t->name, t->value);
+		if (t->sense)
+			fprintf(file, "\t%s = {%s},\n", t->name, t->value);
+		else
+			fprintf(file, "\t%s = \"%s\",\n", t->name, t->value);
 	}
 }
 
-
 void free_tags(struct tag* t)
 {
 	_DEBUG(("free_tags"));

Modified: xfbib/trunk/src/tag.h
===================================================================
--- xfbib/trunk/src/tag.h	2008-03-15 12:12:58 UTC (rev 4058)
+++ xfbib/trunk/src/tag.h	2008-03-15 20:55:26 UTC (rev 4059)
@@ -20,9 +20,10 @@
 	char *name;
 	char *value;
 	struct tag *next;
+	int sense;
 };
 
-void new_tag(struct tag**, char*, char*);
+void new_tag(struct tag**, char*, char*, int);
 void print_tags(struct tag*);
 void write_tags(struct tag*, FILE*);
 void free_tags(struct tag*);

Modified: xfbib/trunk/src/window.c
===================================================================
--- xfbib/trunk/src/window.c	2008-03-15 12:12:58 UTC (rev 4058)
+++ xfbib/trunk/src/window.c	2008-03-15 20:55:26 UTC (rev 4059)
@@ -104,7 +104,7 @@
 
 	return title;*/
 	if (xfbib->filename == NULL)
-		return "Xfbib";
+		return PACKAGE_NAME;
 	else
 		return xfbib->filename;
 }




More information about the Goodies-commits mailing list