[gnome-documents] all: use GtkListStore new/set methods directly from JS
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] all: use GtkListStore new/set methods directly from JS
- Date: Tue, 5 Jun 2012 16:54:27 +0000 (UTC)
commit 40684634108e95eb0ad988624a5c4234310de2ff
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Jun 5 12:52:48 2012 -0400
all: use GtkListStore new/set methods directly from JS
Now that GJS supports this, we can avoid using C wrappers to set values
on the list store.
src/documents.js | 25 ++++++++++++++++---------
src/manager.js | 16 +++++++++++-----
src/selections.js | 16 +++++++++++-----
3 files changed, 38 insertions(+), 19 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index 99c95f2..2b14d37 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -1012,7 +1012,14 @@ const DocumentModel = new Lang.Class({
Name: 'DocumentModel',
_init: function() {
- this.model = Gd.create_list_store();
+ this.model = Gtk.ListStore.new(
+ [ GObject.TYPE_STRING,
+ GObject.TYPE_STRING,
+ GObject.TYPE_STRING,
+ GObject.TYPE_STRING,
+ GdkPixbuf.Pixbuf,
+ GObject.TYPE_INT,
+ GObject.TYPE_BOOLEAN ]);
this.model.set_sort_column_id(Gd.MainColumns.MTIME,
Gtk.SortType.DESCENDING);
},
@@ -1024,10 +1031,10 @@ const DocumentModel = new Lang.Class({
documentAdded: function(doc) {
let iter = this.model.append();
- Gd.store_set(this.model, iter,
- doc.id, doc.uri,
- doc.name, doc.author,
- doc.pixbuf, doc.mtime);
+ this.model.set(iter,
+ [ 0, 1, 2, 3, 4, 5 ],
+ [ doc.id, doc.uri, doc.name,
+ doc.author, doc.pixbuf, doc.mtime ]);
let treePath = this.model.get_path(iter);
let treeRowRef = Gtk.TreeRowReference.new(this.model, treePath);
@@ -1040,10 +1047,10 @@ const DocumentModel = new Lang.Class({
let objectIter = this.model.get_iter(objectPath)[1];
if (objectIter)
- Gd.store_set(this.model, iter,
- doc.id, doc.uri,
- doc.name, doc.author,
- doc.pixbuf, doc.mtime);
+ this.model.set(objectIter,
+ [ 0, 1, 2, 3, 4, 5 ],
+ [ doc.id, doc.uri, doc.name,
+ doc.author, doc.pixbuf, doc.mtime ]);
}));
},
diff --git a/src/manager.js b/src/manager.js
index 5e8574a..5ecffe8 100644
--- a/src/manager.js
+++ b/src/manager.js
@@ -21,6 +21,7 @@
const Gd = imports.gi.Gd;
const Gdk = imports.gi.Gdk;
+const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Pango = imports.gi.Pango;
@@ -177,7 +178,10 @@ const BaseModel = new Lang.Class({
Name: 'BaseModel',
_init: function(manager) {
- this.model = Gd.create_item_store();
+ this.model = Gtk.ListStore.new(
+ [ GObject.TYPE_STRING, // ID
+ GObject.TYPE_STRING, // NAME
+ GObject.TYPE_STRING ]); // HEADING_TEXT
this._manager = manager;
this._manager.connect('item-added', Lang.bind(this, this._refreshModel));
this._manager.connect('item-removed', Lang.bind(this, this._refreshModel));
@@ -193,16 +197,18 @@ const BaseModel = new Lang.Class({
if (title) {
iter = this.model.append();
- Gd.item_store_set(this.model, iter,
- 'heading', '', title);
+ this.model.set(iter,
+ [ 0, 1, 2 ],
+ [ 'heading', '', title ]);
}
let items = this._manager.getItems();
for (idx in items) {
let item = items[idx];
iter = this.model.append();
- Gd.item_store_set(this.model, iter,
- item.id, item.name, '');
+ this.model.set(iter,
+ [ 0, 1, 2 ],
+ [ item.id, item.name, '' ]);
}
}
});
diff --git a/src/selections.js b/src/selections.js
index 387d98f..4c38b27 100644
--- a/src/selections.js
+++ b/src/selections.js
@@ -23,6 +23,7 @@ const EvView = imports.gi.EvinceView;
const Gd = imports.gi.Gd;
const Gdk = imports.gi.Gdk;
const GLib = imports.gi.GLib;
+const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const GtkClutter = imports.gi.GtkClutter;
const Pango = imports.gi.Pango;
@@ -317,7 +318,10 @@ const OrganizeCollectionModel = new Lang.Class({
Name: 'OrganizeCollectionModel',
_init: function() {
- this.model = Gd.create_organize_store();
+ this.model = Gtk.ListStore.new(
+ [ GObject.TYPE_STRING,
+ GObject.TYPE_STRING,
+ GObject.TYPE_INT ]);
this._placeholderRef = null;
this._collAddedId =
@@ -367,8 +371,9 @@ const OrganizeCollectionModel = new Lang.Class({
if (!iter)
iter = this.model.append();
- Gd.organize_store_set(this.model, iter,
- item.id, item.name, collectionState[item.id]);
+ this.model.set(iter,
+ [ 0, 1, 2 ],
+ [ item.id, item.name, collectionState[item.id] ]);
}
},
@@ -396,8 +401,9 @@ const OrganizeCollectionModel = new Lang.Class({
this.removePlaceholder();
let iter = this.model.append();
- Gd.organize_store_set(this.model, iter,
- _COLLECTION_PLACEHOLDER_ID, '', OrganizeCollectionState.ACTIVE);
+ this.model.set(iter,
+ [ 0, 1, 2 ],
+ [ _COLLECTION_PLACEHOLDER_ID, '', OrganizeCollectionState.ACTIVE ]);
let placeholderPath = this.model.get_path(iter);
if (placeholderPath != null)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]