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

Jesper Karlsson zarper at xfce.org
Sat Oct 18 21:57:06 CEST 2008


Author: zarper
Date: 2008-10-18 19:57:06 +0000 (Sat, 18 Oct 2008)
New Revision: 5691

Modified:
   xfbib/branches/gobject/src/xfbib-bibtex-string.c
   xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c
   xfbib/branches/gobject/src/xfbib-multiple-input.c
   xfbib/branches/gobject/src/xfbib-multiple-input.h
Log:
Already existing compound strings are now shown when opening the edit dialog.


Modified: xfbib/branches/gobject/src/xfbib-bibtex-string.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-bibtex-string.c	2008-10-18 19:10:23 UTC (rev 5690)
+++ xfbib/branches/gobject/src/xfbib-bibtex-string.c	2008-10-18 19:57:06 UTC (rev 5691)
@@ -88,6 +88,12 @@
 	string->variable = g_strdup(variable);
 }
 
+XfbibBibtexValue *
+xfbib_bibtex_string_get_value(XfbibBibtexString *string)
+{
+	return string->value;
+}
+
 void
 xfbib_bibtex_string_set_value(XfbibBibtexString *string, XfbibBibtexValue *value)
 {

Modified: xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c	2008-10-18 19:10:23 UTC (rev 5690)
+++ xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c	2008-10-18 19:57:06 UTC (rev 5691)
@@ -126,7 +126,10 @@
 	gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
 	gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
 	
-	multiple_input = xfbib_multiple_input_new("TODO", "TODO");
+	multiple_input = xfbib_multiple_input_new("Text/String key", "TODO");
+	if(gtk_entry_get_visibility(entry) == TRUE) {
+		xfbib_multiple_input_set_text(XFBIB_MULTIPLE_INPUT(multiple_input), gtk_entry_get_text(entry));
+	}
 	gtk_box_pack_start(GTK_BOX (GTK_DIALOG(dialog)->vbox), multiple_input, TRUE, TRUE, 6); 
 	
 	gtk_widget_show_all(GTK_WIDGET(dialog));
@@ -134,6 +137,8 @@
 	if(gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
 		str = xfbib_multiple_input_get_str(XFBIB_MULTIPLE_INPUT (multiple_input));
 		if(str != NULL) {
+			gtk_widget_set_sensitive(GTK_WIDGET(entry), TRUE);
+			gtk_entry_set_visibility(entry, TRUE);
 			gtk_entry_set_text(entry, str);
 		} else {
 			gtk_widget_set_sensitive(GTK_WIDGET(entry), FALSE);
@@ -161,7 +166,8 @@
 	g_string_append(path, filename);
 
 	/* TODO: Fix the error handling */
-	pixbuf = gdk_pixbuf_new_from_file(g_string_free(path, FALSE), NULL);
+	pixbuf = gdk_pixbuf_new_from_file(path->str, NULL);
+	g_string_free(path, TRUE);
 
 	if(pixbuf == NULL){
 		g_warning("Button icon missing: %s", filename);
@@ -391,13 +397,16 @@
 							xfbib_bibtex_value_get_str(value));
 				}
 			} else {
-				/* TODO: Compund string: Set sensitivity to false
-				 * and make the compund button workable
-				 */
+				gtk_widget_set_sensitive(entry_edit_dialog->inputs[n], FALSE);
+				gtk_entry_set_invisible_char(entry, ' ');
+				gtk_entry_set_visibility(entry, FALSE);
 				if (n == XFBIB_FIELD_AUTHOR || n == XFBIB_FIELD_EDITOR) {
-					gtk_widget_set_sensitive(entry_edit_dialog->inputs[n], FALSE);
+					xfbib_multiple_input_set(XFBIB_MULTIPLE_INPUT(entry_edit_dialog->inputs[n]),
+							xfbib_bibtex_value_get(value));
 				} else {
-					gtk_widget_set_sensitive(entry_edit_dialog->inputs[n], FALSE);
+					/* For details on the below line see function 'cb_edit_compound_string_clicked' */
+					gtk_entry_set_text(GTK_ENTRY (entry_edit_dialog->inputs[n]),
+							xfbib_bibtex_value_get(value));
 				}
 			}
 		}

Modified: xfbib/branches/gobject/src/xfbib-multiple-input.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-multiple-input.c	2008-10-18 19:10:23 UTC (rev 5690)
+++ xfbib/branches/gobject/src/xfbib-multiple-input.c	2008-10-18 19:57:06 UTC (rev 5691)
@@ -27,6 +27,7 @@
 #include "xfbib-input-dialog.h"
 #include "xfbib-bibtex-string.h"
 #include "xfbib-bibtex-value.h"
+#include "xfbib-string.h"
 
 struct _XfbibMultipleInput
 {
@@ -233,6 +234,31 @@
 	}
 }
 
+void
+xfbib_multiple_input_set(XfbibMultipleInput *multiple_input, GList *gl)
+{
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+	gint n, len;
+	GObject *obj;
+
+	model = gtk_tree_view_get_model(GTK_TREE_VIEW (multiple_input->tree_view));
+	
+	len = g_list_length(gl);
+	for (n = 0; n < len; n++) {
+		gtk_list_store_append(GTK_LIST_STORE (model), &iter);
+		obj = g_list_nth_data(gl, n);
+		if(XFBIB_IS_STRING(obj)) {
+			gtk_list_store_set(GTK_LIST_STORE (model), &iter, 0, xfbib_string_get(XFBIB_STRING(obj)), -1);
+		} else if(XFBIB_IS_BIBTEX_STRING(obj)){
+			gtk_list_store_set(GTK_LIST_STORE (model), &iter, 0, xfbib_bibtex_string_get_variable(XFBIB_BIBTEX_STRING(obj)),
+					1, xfbib_bibtex_value_get_str(xfbib_bibtex_string_get_value(XFBIB_BIBTEX_STRING(obj))), -1);
+		} else if(XFBIB_IS_BIBTEX_INTEGER(obj)) {
+			gtk_list_store_set(GTK_LIST_STORE (model), &iter, 0, xfbib_integer_get(XFBIB_INTEGER(obj)), -1);
+		}
+	}
+}
+
 const gchar *
 xfbib_multiple_input_get_nth_row_ith_column(XfbibMultipleInput *multiple_input, gint row, gint column)
 {

Modified: xfbib/branches/gobject/src/xfbib-multiple-input.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-multiple-input.h	2008-10-18 19:10:23 UTC (rev 5690)
+++ xfbib/branches/gobject/src/xfbib-multiple-input.h	2008-10-18 19:57:06 UTC (rev 5691)
@@ -37,6 +37,7 @@
 
 GtkWidget *xfbib_multiple_input_new(gchar *, gchar *);
 void xfbib_multiple_input_set_text(XfbibMultipleInput *, const gchar *);
+void xfbib_multiple_input_set(XfbibMultipleInput *, GList *);
 const gchar *xfbib_multiple_input_get_nth_row_ith_column(XfbibMultipleInput *, gint, gint);
 const gchar *xfbib_multiple_input_get_str(XfbibMultipleInput *);
 GList *xfbib_multiple_input_get(XfbibMultipleInput *);




More information about the Goodies-commits mailing list