~zeitgeist/zeitgeist-explorer/git-import

« back to all changes in this revision

Viewing changes to zgexplorer/datasourceviewer.py

  • Committer: Manish Sinha
  • Date: 2013-07-13 00:26:19 UTC
  • Revision ID: git-v1:c6b68dc0d485832e8f15bd41f69de3b45f12cb2c
Have a working example of DataSourceRegistry

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
from gi.repository import Zeitgeist, Gtk, Gdk, Pango, Gio, GdkPixbuf, GLib
22
22
 
23
 
from zgexplorer.remote import get_zeitgeist
 
23
from zgexplorer.remote import get_datasource
24
24
 
25
25
class DatasourceViewer(Gtk.VBox):
26
26
 
30
30
        super(DatasourceViewer, self).__init__()
31
31
 
32
32
        self.main_window = window
33
 
        self._client = get_zeitgeist()
 
33
        self._ds = get_datasource()
34
34
 
35
35
        self.spacing = 3
36
36
        self.margin = 3
43
43
 
44
44
        ds_vbox = Gtk.VBox()
45
45
        list_vbox.pack_start(ds_vbox, True, True, 0)
46
 
        self.ds = Gtk.ListStore(str, str, GdkPixbuf.Pixbuf)
 
46
        self.ds = Gtk.ListStore(str, str)
47
47
        self.ds_tree = Gtk.TreeView(model=self.ds)
48
48
        #self.ds_tree.connect("cursor-changed", self.on_treeview_selected)
49
49
        #self.ds_tree.connect("key-release-event", self.on_key_pressed)
64
64
        column_pix_name.set_resizable(True)
65
65
        self.ds_tree.append_column(column_pix_name)
66
66
 
67
 
        pixbuf_rend = Gtk.CellRendererPixbuf()
68
 
        column_pix_name.pack_start(pixbuf_rend, False)
69
 
        column_pix_name.add_attribute(pixbuf_rend, "pixbuf", 2)
70
67
        name_rend = Gtk.CellRendererText(ellipsize=Pango.EllipsizeMode.END)
71
68
        column_pix_name.pack_start(name_rend, False)
72
69
        column_pix_name.add_attribute(name_rend, "markup", 1)
79
76
 
80
77
        list_refresh = Gtk.ToolButton.new(None, _("Refresh"))
81
78
        list_refresh.set_icon_name("view-refresh-symbolic")
82
 
        #list_refresh.connect("clicked", self.on_list_refresh)
 
79
        list_refresh.connect("clicked", self.on_list_refresh)
83
80
        self.toolbar.insert(list_refresh, 0)
84
81
        list_remove = Gtk.ToolButton.new(None, _("Delete all events for selected Application"))
85
82
        list_remove.set_icon_name("list-remove-symbolic")
86
83
        #list_remove.connect("clicked", self.on_list_remove)
87
84
        self.toolbar.insert(list_remove, 1)
88
85
        
 
86
        self.populate_ds()
 
87
        
89
88
        self.show_all()
 
89
 
 
90
    def on_list_refresh(self, button):
 
91
        self.populate_ds()
 
92
 
 
93
    def populate_ds(self):
 
94
        self.ds.clear()
 
95
        ds_list = self._ds.get_data_sources()[0]
 
96
        for ds in ds_list:
 
97
            self.ds.append([ds[0], ds[1]])