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

David Gustafsson tssj at xfce.org
Wed Oct 1 20:22:01 CEST 2008


Author: tssj
Date: 2008-10-01 18:22:01 +0000 (Wed, 01 Oct 2008)
New Revision: 5499

Modified:
   xfbib/branches/gobject/src/xfbib-list-store.c
   xfbib/branches/gobject/src/xfbib-list-store.h
   xfbib/branches/gobject/src/xfbib-menu-bar.c
   xfbib/branches/gobject/src/xfbib-tree-view.c
Log:
Updated the edit functionality


Modified: xfbib/branches/gobject/src/xfbib-list-store.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-list-store.c	2008-10-01 16:02:29 UTC (rev 5498)
+++ xfbib/branches/gobject/src/xfbib-list-store.c	2008-10-01 18:22:01 UTC (rev 5499)
@@ -557,3 +557,12 @@
 	gtk_tree_path_free(path);
 }
 
+XfbibEntry *
+xfbib_list_store_get_entry(XfbibListStore *list_store, GtkTreeIter *iter)
+{
+	g_return_val_if_fail(XFBIB_IS_LIST_STORE (list_store), NULL);
+	g_return_val_if_fail(list_store->stamp == iter->stamp, NULL);
+	g_return_val_if_fail(iter->user_data != NULL, NULL);
+	
+	return XFBIB_ENTRY(iter->user_data);
+}

Modified: xfbib/branches/gobject/src/xfbib-list-store.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-list-store.h	2008-10-01 16:02:29 UTC (rev 5498)
+++ xfbib/branches/gobject/src/xfbib-list-store.h	2008-10-01 18:22:01 UTC (rev 5499)
@@ -21,6 +21,7 @@
 #define __XFBIB_LIST_STORE_H
 
 #include <gtk/gtk.h>
+#include "xfbib-entry.h"
 
 #define XFBIB_TYPE_LIST_STORE             (xfbib_list_store_get_type())
 #define XFBIB_LIST_STORE(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), XFBIB_TYPE_LIST_STORE, XfbibListStore))
@@ -39,6 +40,7 @@
 gboolean xfbib_list_store_remove(XfbibListStore *, GtkTreeIter  *);
 void xfbib_list_store_clear(XfbibListStore *);
 void xfbib_list_store_row_inserted(XfbibListStore *, gint);
+XfbibEntry *xfbib_list_store_get_entry(XfbibListStore *, GtkTreeIter *);
 
 
 G_END_DECLS

Modified: xfbib/branches/gobject/src/xfbib-menu-bar.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-menu-bar.c	2008-10-01 16:02:29 UTC (rev 5498)
+++ xfbib/branches/gobject/src/xfbib-menu-bar.c	2008-10-01 18:22:01 UTC (rev 5499)
@@ -129,8 +129,6 @@
 	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
 	if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
 		xfbib_list_store_remove(XFBIB_LIST_STORE(model), &iter);
-//		gtk_tree_model_get (model, &iter, COLUMN_ENTRY, &node, -1);
-//		remove_node(&(xfbib->list), node);
 	} else {
 		xfce_err("No row has been selected for removal");
 	}
@@ -158,15 +156,9 @@
 		 * Get the XfbibEntry pointer and pass it to the 
 		 * entry edit dialog
 		 */
-		path = gtk_tree_model_get_path(model, &iter);
-			
-		if ((entry = xfbib_elements_get_nth_entry(xfbib_state_get_bibtex_elements(state),
-				gtk_tree_path_get_indices(path)[0])) == NULL) {
-			xfce_err("Could not find the selected entry to edit");
-			return;
-		}
+		entry = xfbib_list_store_get_entry(model, &iter);
+
 		dialog = xfbib_entry_edit_dialog_new(entry);
-	
 		if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
 			/* TODO: Save the entry */
 		}

Modified: xfbib/branches/gobject/src/xfbib-tree-view.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-tree-view.c	2008-10-01 16:02:29 UTC (rev 5498)
+++ xfbib/branches/gobject/src/xfbib-tree-view.c	2008-10-01 18:22:01 UTC (rev 5499)
@@ -77,6 +77,28 @@
 
 static GObjectClass *xfbib_tree_view_parent_class = NULL;
 
+void 
+cb_row_activated (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
+{
+	XfbibEntry *entry;
+	GtkWidget *dialog;
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+
+	model = gtk_tree_view_get_model(tree_view);
+
+	if (gtk_tree_model_get_iter(model, &iter, path)) {
+		entry = xfbib_list_store_get_entry(model, &iter);
+		dialog = xfbib_entry_edit_dialog_new(entry);
+		if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
+			/* TODO: Save the entry */
+		}
+		gtk_widget_destroy(dialog);
+		g_print ("Double-clicked on a row with stuff");
+	}
+}
+
+	
 GType
 xfbib_tree_view_get_type (void)
 {
@@ -118,6 +140,10 @@
 	GtkTreeModel *model;
 	gint i;
 
+	/* Connect the double-click to a callback function */
+	g_signal_connect(GTK_TREE_VIEW(instance), "row-activated", (GCallback) cb_row_activated, NULL);
+
+	
 	for (i = 0; i < XFBIB_FIELD_N_FIELDS; i++) {
 		switch (i) {
 			case XFBIB_FIELD_ANNOTE:




More information about the Goodies-commits mailing list