[Goodies-commits] r5670 - xfbib/branches/gobject/src

Jesper Karlsson zarper at xfce.org
Fri Oct 17 16:29:20 CEST 2008


Author: zarper
Date: 2008-10-17 14:29:20 +0000 (Fri, 17 Oct 2008)
New Revision: 5670

Modified:
   xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c
   xfbib/branches/gobject/src/xfbib-multiple-input.c
Log:
Switched from XfbibStrbuf to GString.


Modified: xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c	2008-10-17 13:43:45 UTC (rev 5669)
+++ xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c	2008-10-17 14:29:20 UTC (rev 5670)
@@ -23,11 +23,11 @@
 #include <gtk/gtk.h>
 #include <libxfcegui4/libxfcegui4.h>
 #include <string.h>
+#include <glib.h>
 
 #include "xfbib-entry-edit-dialog.h"
 #include "xfbib-multiple-input.h"
 #include "xfbib-bibtex-field.h"
-#include "xfbib-strbuf.h"
 #include "xfbib-bibtex-entry.h"
 
 static struct {
@@ -115,26 +115,26 @@
 	g_printf("cb_generate_clicked\n");
 	/* Generate BibTeX key */
 	/* Suggested format: Last name of first author, year of publication, first word in title appended together */
-	XfbibStrbuf *strbuf;
+	GString *str;
 	const gchar *lastname, *title;
 	gchar **split;
 	char *tmp;
-	strbuf = xfbib_strbuf_new();
+	str = g_string_new("");
 
 	lastname = xfbib_multiple_input_get_nth_row_ith_column(XFBIB_MULTIPLE_INPUT (XFBIB_ENTRY_EDIT_DIALOG (user_data)->inputs[XFBIB_FIELD_AUTHOR]),0,0);
 	if(lastname != NULL) {
 		tmp = strrchr(lastname, ' ') + 1;
-		xfbib_strbuf_append(strbuf, tmp);
+		g_string_append(str, tmp);
 	}
 
-	xfbib_strbuf_append(strbuf, (gtk_entry_get_text(GTK_ENTRY (XFBIB_ENTRY_EDIT_DIALOG (user_data)->inputs[XFBIB_FIELD_YEAR])) + 2));
+	g_string_append(str, (gtk_entry_get_text(GTK_ENTRY (XFBIB_ENTRY_EDIT_DIALOG (user_data)->inputs[XFBIB_FIELD_YEAR])) + 2));
 
 	title = gtk_entry_get_text(GTK_ENTRY (XFBIB_ENTRY_EDIT_DIALOG (user_data)->inputs[XFBIB_FIELD_TITLE]));
 	split = g_strsplit(title, " ", 2);
 	title = split[0];
-	xfbib_strbuf_append(strbuf, title);
+	g_string_append(str, title);
 
-	gtk_entry_set_text(GTK_ENTRY (XFBIB_ENTRY_EDIT_DIALOG (user_data)->key_entry), xfbib_strbuf_get_str(strbuf));
+	gtk_entry_set_text(GTK_ENTRY (XFBIB_ENTRY_EDIT_DIALOG (user_data)->key_entry), g_string_free(str, FALSE));
 }
 
 static void
@@ -147,16 +147,16 @@
 xfbib_get_image (gchar *filename)
 {
 	GtkWidget *image;
-	XfbibStrbuf *path;
+	GString *path;
 	GdkPixbuf *pixbuf = NULL;
 
-	path = xfbib_strbuf_new();
-	xfbib_strbuf_append(path, DATADIR);
-	xfbib_strbuf_append(path, "/pixmaps/xfbib/");
-	xfbib_strbuf_append(path, filename);
+	path = g_string_new("");
+	g_string_append(path, DATADIR);
+	g_string_append(path, "/pixmaps/xfbib/");
+	g_string_append(path, filename);
 
 	/* TODO: Fix the error handling */
-	pixbuf = gdk_pixbuf_new_from_file(xfbib_strbuf_get_str(path),NULL);
+	pixbuf = gdk_pixbuf_new_from_file(g_string_free(path, FALSE), NULL);
 
 	if(pixbuf == NULL){
 		g_warning("Button icon missing: %s", filename);

Modified: xfbib/branches/gobject/src/xfbib-multiple-input.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-multiple-input.c	2008-10-17 13:43:45 UTC (rev 5669)
+++ xfbib/branches/gobject/src/xfbib-multiple-input.c	2008-10-17 14:29:20 UTC (rev 5670)
@@ -21,10 +21,10 @@
 #include <config.h>
 #endif
 #include <gtk/gtk.h>
+#include <glib.h>
 
 #include "xfbib-multiple-input.h"
 #include "xfbib-input-dialog.h"
-#include "xfbib-strbuf.h"
 #include "xfbib-bibtex-string.h"
 #include "xfbib-bibtex-value.h"
 
@@ -34,7 +34,6 @@
 	GtkWidget *tree_view;
 	GtkWidget *add_button;
 	GtkWidget *remove_button;
-	//GtkWidget *toggle_button;
 };
 
 typedef struct _XfbibMultipleInputClass
@@ -258,7 +257,7 @@
 const gchar *
 xfbib_multiple_input_get_str(XfbibMultipleInput *multiple_input)
 {
-	XfbibStrbuf *strbuf;
+	GString *strbuf;
 	const gchar *str;
 	int n;
 
@@ -268,21 +267,21 @@
 			return NULL;
 		}
 	}
-	strbuf = xfbib_strbuf_new();
+	strbuf = g_string_new("");
 	for(n = 0; (str = xfbib_multiple_input_get_nth_row_ith_column(multiple_input, n, 0)) != NULL; n++) {
 		if(n != 0) {
-			xfbib_strbuf_append(strbuf, " and ");
+			g_string_append(strbuf, " and ");
 		}
-		xfbib_strbuf_append(strbuf, str);
+		g_string_append(strbuf, str);
 	}
-	return xfbib_strbuf_get_str(strbuf);
+	return g_string_free(strbuf, FALSE);
 }
 
 GList *
 xfbib_multiple_input_get(XfbibMultipleInput *multiple_input)
 { 
 	GList *list = NULL;
-	XfbibStrbuf *strbuf;
+	GString *strbuf;
 	XfbibBibtexString *string;
 	XfbibBibtexValue *value;
 	const gchar *str, *text;
@@ -300,8 +299,8 @@
 
 			list = g_list_append(list, G_OBJECT(string));
 		} else {
-			strbuf = xfbib_strbuf_new();
-			xfbib_strbuf_append(strbuf, str);
+			strbuf = g_string_new("");
+			g_string_append(strbuf, str);
 			list = g_list_append(list, G_OBJECT(strbuf));
 		}
 	}




More information about the Goodies-commits mailing list