~zeitgeist/zeitgeist-explorer/git-import

« back to all changes in this revision

Viewing changes to zgexplorer/datasourceviewer.py

  • Committer: Manish Sinha
  • Date: 2013-07-12 07:39:18 UTC
  • Revision ID: git-v1:8167509ae1167e2cda5ae78f319b8a5829cddadf
Created basic structure of Datasourceviewer

Signed-off-by: Manish Sinha <manishsinha@ubuntu.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
 
2
# -.- coding: utf-8 -.-
 
3
#
 
4
# Zeitgeist Explorer
 
5
#
 
6
# Copyright © 2013 Manish Sinha <manishsinha@ubuntu.com>
 
7
#
 
8
# This program is free software: you can redistribute it and/or modify it
 
9
# under the terms of the GNU Lesser General Public License as published
 
10
# by the Free Software Foundation, either version 2 of the License, or
 
11
# (at your option) any later version.
 
12
#
 
13
# This program is distributed in the hope that it will be useful,
 
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
# GNU Lesser General Public License for more details.
 
17
#
 
18
# You should have received a copy of the GNU General Public License
 
19
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
 
 
21
from gi.repository import Zeitgeist, Gtk, Gdk, Pango, Gio, GdkPixbuf, GLib
 
22
 
 
23
from zgexplorer.remote import get_zeitgeist
 
24
 
 
25
class DatasourceViewer(Gtk.VBox):
 
26
 
 
27
    _client = None
 
28
 
 
29
    def __init__(self, window):
 
30
        super(DatasourceViewer, self).__init__()
 
31
 
 
32
        self.main_window = window
 
33
        self._client = get_zeitgeist()
 
34
 
 
35
        self.spacing = 3
 
36
        self.margin = 3
 
37
 
 
38
        self.hbox = Gtk.HBox()
 
39
        self.pack_start(self.hbox, True, True, 3)
 
40
 
 
41
        list_vbox = Gtk.VBox()
 
42
        self.hbox.pack_start(list_vbox, False, False, 0)
 
43
 
 
44
        ds_vbox = Gtk.VBox()
 
45
        list_vbox.pack_start(ds_vbox, True, True, 0)
 
46
        self.ds = Gtk.ListStore(str, str, GdkPixbuf.Pixbuf)
 
47
        self.ds_tree = Gtk.TreeView(model=self.ds)
 
48
        #self.ds_tree.connect("cursor-changed", self.on_treeview_selected)
 
49
        #self.ds_tree.connect("key-release-event", self.on_key_pressed)
 
50
        self.ds_tree.set_size_request(200, 600)
 
51
        self.ds_tree.set_properties('border_width',1,
 
52
                                    'visible',True,
 
53
                                    'rules_hint',True,
 
54
                                    'headers_visible',False)
 
55
 
 
56
        scroll = Gtk.ScrolledWindow(None, None)
 
57
        scroll.add(self.ds_tree)
 
58
        scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
 
59
        scroll.set_shadow_type(Gtk.ShadowType.IN)
 
60
        scroll.set_border_width(1)
 
61
        ds_vbox.pack_start(scroll, True, True, 0)
 
62
 
 
63
        column_pix_name = Gtk.TreeViewColumn(_('Datasources'))
 
64
        column_pix_name.set_resizable(True)
 
65
        self.ds_tree.append_column(column_pix_name)
 
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
        name_rend = Gtk.CellRendererText(ellipsize=Pango.EllipsizeMode.END)
 
71
        column_pix_name.pack_start(name_rend, False)
 
72
        column_pix_name.add_attribute(name_rend, "markup", 1)
 
73
 
 
74
        self.toolbar = Gtk.Toolbar(icon_size=1)
 
75
        self.toolbar.set_style(Gtk.ToolbarStyle.ICONS)
 
76
        self.toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_INLINE_TOOLBAR)
 
77
        self.toolbar.get_style_context().set_junction_sides(Gtk.JunctionSides.TOP)
 
78
        list_vbox.pack_start(self.toolbar, False, False, 3)
 
79
 
 
80
        list_refresh = Gtk.ToolButton.new(None, _("Refresh"))
 
81
        list_refresh.set_icon_name("view-refresh-symbolic")
 
82
        #list_refresh.connect("clicked", self.on_list_refresh)
 
83
        self.toolbar.insert(list_refresh, 0)
 
84
        list_remove = Gtk.ToolButton.new(None, _("Delete all events for selected Application"))
 
85
        list_remove.set_icon_name("list-remove-symbolic")
 
86
        #list_remove.connect("clicked", self.on_list_remove)
 
87
        self.toolbar.insert(list_remove, 1)
 
88
        
 
89
        self.show_all()