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

David Gustafsson tssj at xfce.org
Fri Oct 17 00:50:24 CEST 2008


Author: tssj
Date: 2008-10-16 22:50:24 +0000 (Thu, 16 Oct 2008)
New Revision: 5652

Modified:
   xfbib/branches/gobject/src/xfbib-bibtex-entry.c
   xfbib/branches/gobject/src/xfbib-bibtex-entry.h
   xfbib/branches/gobject/src/xfbib-bibtex-field.c
   xfbib/branches/gobject/src/xfbib-bibtex-field.h
   xfbib/branches/gobject/src/xfbib-bibtex-value.c
   xfbib/branches/gobject/src/xfbib-bibtex-value.h
   xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c
   xfbib/branches/gobject/src/xfbib-file-io.c
   xfbib/branches/gobject/src/xfbib-tree-view.c
Log:
Bug squashing :)
Fixed one Segfault and opening the edit dialog from the treeview


Modified: xfbib/branches/gobject/src/xfbib-bibtex-entry.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-bibtex-entry.c	2008-10-16 19:47:32 UTC (rev 5651)
+++ xfbib/branches/gobject/src/xfbib-bibtex-entry.c	2008-10-16 22:50:24 UTC (rev 5652)
@@ -146,7 +146,7 @@
 	return TRUE;
 }
 
-const GList *
+GList *
 xfbib_bibtex_entry_get_fields(XfbibBibtexEntry *entry)
 {
 	g_return_val_if_fail(XFBIB_IS_BIBTEX_ENTRY(entry), NULL);

Modified: xfbib/branches/gobject/src/xfbib-bibtex-entry.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-bibtex-entry.h	2008-10-16 19:47:32 UTC (rev 5651)
+++ xfbib/branches/gobject/src/xfbib-bibtex-entry.h	2008-10-16 22:50:24 UTC (rev 5652)
@@ -39,7 +39,7 @@
 
 XfbibBibtexEntry *xfbib_bibtex_entry_new();
 gboolean xfbib_bibtex_entry_parse(XfbibBibtexEntry *, const gchar *);
-const GList *xfbib_bibtex_entry_get_fields(XfbibBibtexEntry *);
+GList *xfbib_bibtex_entry_get_fields(XfbibBibtexEntry *);
 void xfbib_bibtex_entry_set_fields(XfbibBibtexEntry *, GList *);
 const gchar *xfbib_bibtex_entry_get_key(XfbibBibtexEntry *);
 void xfbib_bibtex_entry_set_key(XfbibBibtexEntry *, const gchar *);

Modified: xfbib/branches/gobject/src/xfbib-bibtex-field.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-bibtex-field.c	2008-10-16 19:47:32 UTC (rev 5651)
+++ xfbib/branches/gobject/src/xfbib-bibtex-field.c	2008-10-16 22:50:24 UTC (rev 5652)
@@ -119,7 +119,7 @@
 	xfbib_strbuf_append(field->variable, str);
 }
 
-const XfbibBibtexValue *
+XfbibBibtexValue *
 xfbib_bibtex_field_get_value(XfbibBibtexField *field)
 {
 	g_return_val_if_fail(XFBIB_IS_BIBTEX_FIELD(field), NULL);

Modified: xfbib/branches/gobject/src/xfbib-bibtex-field.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-bibtex-field.h	2008-10-16 19:47:32 UTC (rev 5651)
+++ xfbib/branches/gobject/src/xfbib-bibtex-field.h	2008-10-16 22:50:24 UTC (rev 5652)
@@ -102,7 +102,7 @@
 gboolean xfbib_bibtex_field_parse(XfbibBibtexField *, const gchar *);
 const gchar *xfbib_bibtex_field_get_variable(XfbibBibtexField *);
 void xfbib_bibtex_field_set_variable(XfbibBibtexField *, const gchar *);
-const XfbibBibtexValue *xfbib_bibtex_field_get_value(XfbibBibtexField *);
+XfbibBibtexValue *xfbib_bibtex_field_get_value(XfbibBibtexField *);
 void xfbib_bibtex_field_set_value(XfbibBibtexField *, XfbibBibtexValue *);
 #if 0
 const gchar *xfbib_bibtex_field_get_value_str(XfbibBibtexField *);

Modified: xfbib/branches/gobject/src/xfbib-bibtex-value.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-bibtex-value.c	2008-10-16 19:47:32 UTC (rev 5651)
+++ xfbib/branches/gobject/src/xfbib-bibtex-value.c	2008-10-16 22:50:24 UTC (rev 5652)
@@ -159,7 +159,8 @@
 	return TRUE;
 }
 
-const GList *xfbib_bibtex_value_get(XfbibBibtexValue *value)
+GList *
+xfbib_bibtex_value_get(XfbibBibtexValue *value)
 {
 	g_return_val_if_fail(XFBIB_IS_BIBTEX_VALUE(value), NULL);
 	
@@ -167,7 +168,8 @@
 }
 
 
-void xfbib_bibtex_value_set(XfbibBibtexValue *value, GList *list)
+void 
+xfbib_bibtex_value_set(XfbibBibtexValue *value, GList *list)
 {
 	g_return_if_fail(XFBIB_IS_BIBTEX_VALUE(value));
 
@@ -178,7 +180,7 @@
 	value->list = list;
 }
 
-const gchar *
+gchar *
 xfbib_bibtex_value_get_str(XfbibBibtexValue *value)
 {
 	GObject *obj;

Modified: xfbib/branches/gobject/src/xfbib-bibtex-value.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-bibtex-value.h	2008-10-16 19:47:32 UTC (rev 5651)
+++ xfbib/branches/gobject/src/xfbib-bibtex-value.h	2008-10-16 22:50:24 UTC (rev 5652)
@@ -18,9 +18,9 @@
 
 XfbibBibtexValue *xfbib_bibtex_value_new();
 gboolean xfbib_bibtex_value_parse(XfbibBibtexValue *, const gchar *);
-const GList *xfbib_bibtex_value_get(XfbibBibtexValue *);
+GList *xfbib_bibtex_value_get(XfbibBibtexValue *);
 void xfbib_bibtex_value_set(XfbibBibtexValue *, GList *);
-const gchar *xfbib_bibtex_value_get_str(XfbibBibtexValue *);
+gchar *xfbib_bibtex_value_get_str(XfbibBibtexValue *);
 void xfbib_bibtex_value_set_str(XfbibBibtexValue *, const gchar *);
 
 G_END_DECLS

Modified: xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c	2008-10-16 19:47:32 UTC (rev 5651)
+++ xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c	2008-10-16 22:50:24 UTC (rev 5652)
@@ -355,7 +355,7 @@
 			NULL);
 
 	if (entry != NULL) {
-		bibtype = xfbib_strbuf_get_str(xfbib_bibtex_entry_get_bibtype(entry));
+		bibtype = xfbib_bibtex_entry_get_bibtype(entry);
 		for (n = 0; xfbib_type_constants[n].text != NULL; n++) {
 			if (xfbib_type_constants[n].text == bibtype) {
 				gtk_combo_box_set_active(GTK_COMBO_BOX (entry_edit_dialog->type_combo_box), n);
@@ -363,21 +363,22 @@
 			}
 		}
 
-		gtk_entry_set_text(GTK_ENTRY (entry_edit_dialog->key_entry), xfbib_strbuf_get_str(xfbib_bibtex_entry_get_key(entry)));
+		gtk_entry_set_text(GTK_ENTRY (entry_edit_dialog->key_entry), xfbib_bibtex_entry_get_key(entry));
 
 		for (n = 0; n < XFBIB_FIELD_N_FIELDS; n++) {
 
 			list = xfbib_bibtex_entry_get_fields(entry);
 
-			for (i = 0; i < g_list_length(list); i++) {
+			for (i = 0, value = NULL; i < g_list_length(list); i++) {
 				field = g_list_nth_data(list, i);
 				if (strcasecmp(xfbib_bibtex_field_get_variable(field),
 							xfbib_bibtex_field_constants[n].label) == 0) {
+					value = xfbib_bibtex_field_get_value(field);
 					break;
 				}
 			}
 			
-			if (i >= g_list_length(list)) {
+			if (value == NULL) {
 				/* Did not find a matching field */
 				continue;
 			}

Modified: xfbib/branches/gobject/src/xfbib-file-io.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-file-io.c	2008-10-16 19:47:32 UTC (rev 5651)
+++ xfbib/branches/gobject/src/xfbib-file-io.c	2008-10-16 22:50:24 UTC (rev 5652)
@@ -72,7 +72,7 @@
 			name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
 		} else {
 			gtk_widget_destroy(dialog);
-			return FALSE;
+			return NULL;
 	 	}
 		gtk_widget_destroy(dialog);
 	}
@@ -90,7 +90,7 @@
 		}
 	}
 	
-	return TRUE;
+	return filename;
 }
 
 

Modified: xfbib/branches/gobject/src/xfbib-tree-view.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-tree-view.c	2008-10-16 19:47:32 UTC (rev 5651)
+++ xfbib/branches/gobject/src/xfbib-tree-view.c	2008-10-16 22:50:24 UTC (rev 5652)
@@ -81,6 +81,7 @@
 void
 cb_row_activated (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
 {
+	g_printf("cb_row_activated\n");
 	XfbibState *state;
 	XfbibBibtexEntry *entry, *new_entry;
 	GtkWidget *dialog;
@@ -105,6 +106,7 @@
 gboolean
 cb_button_press (GtkWidget *tree_view, GdkEventButton *event, gpointer data)
 {
+	g_printf("cb_button_press\n");
 	XfbibBibtexEntry *new_entry;
 	GtkTreeModel *model;
 	GtkWidget *dialog;
@@ -117,6 +119,17 @@
 
 		model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view));
 
+		/* Check if any row has been selected */
+		if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection
+					(GTK_TREE_VIEW(tree_view)), NULL, NULL)) {
+			/* 
+			 * A row is selected Let the other cb_row_activated()
+			 * function take care of the rest.
+			 */
+			/* TODO: Take care of the event here instead */
+			return FALSE;
+		}
+
 		dialog = xfbib_entry_edit_dialog_new(NULL);
 
 		if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {




More information about the Goodies-commits mailing list