On Tuesday 29 January 2013 22:47:57 Rudra Banerjee wrote: > I tried a lot(trying to understand the huge GLib as suggested by > Andrew), but most of the discussion here went way beyond my capability. > So, lets try from fresh. > > My code for treeview and editing the treeview column (column Id #1). So, > once the column is edited, its updated by the cell_edited. Now, I need > to put this new_text in the file as well. > The file that is read is a bibtex file (http://www.bibtex.org/Format/) > > GtkWidget *create_view_and_model(void) { > GtkCellRenderer *cell; > void > cell_edited(GtkCellRendererText *renderer, > gchar *path, > gchar *new_text, > GtkTreeView *treeview); > > store = gtk_list_store_new (NUM_COLS, G_TYPE_STRING, G_TYPE_STRING, > G_TYPE_STRING, > G_TYPE_STRING, > G_TYPE_STRING); > > tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); > gtk_tree_view_set_rules_hint (GTK_TREE_VIEW(tree), TRUE); > > > /* #1: KEY COLUMN */ > cell = gtk_cell_renderer_text_new (); > g_object_set (cell, > "editable", TRUE, > NULL); > g_signal_connect (cell, > "edited",G_CALLBACK(cell_edited), > tree); > g_object_set_data (G_OBJECT (cell), > "column", GINT_TO_POINTER (COL_BIB_KEY)); > > GtkTreeViewColumn *col_key,*col_year,*col_type,*col_auth,*col_pub; > col_key=gtk_tree_view_column_new_with_attributes ( > "Key", cell, > "text", COL_BIB_KEY, > NULL); > gtk_tree_view_column_set_sort_column_id( col_key, ID_KEY); > gtk_tree_view_append_column (GTK_TREE_VIEW (tree), col_key); > gtk_tree_view_column_set_max_width (col_key,100); > > > /* #2: TYPE COLUMN */ > cell = gtk_cell_renderer_text_new (); > > col_type=gtk_tree_view_column_new_with_attributes ( > "Type", cell, > "text", COL_BIB_TYPE, > NULL); > gtk_tree_view_column_set_sort_column_id( col_type, ID_TYPE); > gtk_tree_view_append_column (GTK_TREE_VIEW (tree), col_type); > > > /* > Three more such column of treeview > */ > > return tree; > } > > > /* Apply the changed text to the cell if it is not an empty string. */ > void cell_edited(GtkCellRendererText *renderer, > gchar *path, > gchar *new_text, > GtkTreeView *treeview) > { > guint column; > GtkTreeIter iter; > GtkTreeModel *model; > gpointer columnptr = g_object_get_data(G_OBJECT(renderer), "column"); > column = GPOINTER_TO_UINT(columnptr); > > > if (g_ascii_strcasecmp (new_text, "") != 0) > { > model = gtk_tree_view_get_model (treeview); > if (gtk_tree_model_get_iter_from_string (model, &iter, path)) > gtk_list_store_set (GTK_LIST_STORE (model), &iter, column, > new_text, -1); > } > } > Kindly Help. >
Take a look at: http://www.gerd-neugebauer.de/software/TeX/BibTool/ this bibtool seems to be able to manipulate bibtex file fields. So you maybe can call it from your program with the correct args or take a look at the source to see how things are done. Ciao, ZZ _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list