~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 03:32:54 UTC
  • Revision ID: git-v1:639a4c33f43442c488848cc4297dfb2e5c334406
Implemented showing the basic structure of a DataSource and the left list

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
        self.main_window = window
33
33
        self._ds = get_datasource()
 
34
        
 
35
        self.ds_map = {}
34
36
 
35
37
        self.spacing = 3
36
38
        self.margin = 3
45
47
        list_vbox.pack_start(ds_vbox, True, True, 0)
46
48
        self.ds = Gtk.ListStore(str, str)
47
49
        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.connect("cursor-changed", self.on_treeview_selected)
50
51
        self.ds_tree.set_size_request(200, 600)
51
52
        self.ds_tree.set_properties('border_width',1,
52
53
                                    'visible',True,
78
79
        list_refresh.set_icon_name("view-refresh-symbolic")
79
80
        list_refresh.connect("clicked", self.on_list_refresh)
80
81
        self.toolbar.insert(list_refresh, 0)
81
 
        list_remove = Gtk.ToolButton.new(None, _("Delete all events for selected Application"))
82
 
        list_remove.set_icon_name("list-remove-symbolic")
83
 
        #list_remove.connect("clicked", self.on_list_remove)
84
 
        self.toolbar.insert(list_remove, 1)
 
82
        
 
83
        self.viewer = SingleDataSourceViewer(self.main_window)
85
84
        
86
85
        self.populate_ds()
87
86
        
95
94
        ds_list = self._ds.get_data_sources()[0]
96
95
        for ds in ds_list:
97
96
            self.ds.append([ds[0], ds[1]])
 
97
            self.ds_map[ds[0]] = ds
 
98
 
 
99
    def on_treeview_selected(self, treeview):
 
100
        selection = self.ds_tree.get_selection()
 
101
        if selection is not None:
 
102
            model, _iter = selection.get_selected()
 
103
            if _iter is not None:
 
104
                index = model.get(_iter, 0)[0]
 
105
                self.viewer.set_values(self.ds_map[index])
 
106
                self.show_viewer()
 
107
 
 
108
    def show_viewer(self):
 
109
        if self.viewer not in self.hbox.get_children():
 
110
            self.hbox.pack_start(self.viewer, False, False, 12)
 
111
            self.show_all()
 
112
 
 
113
class SingleDataSourceViewer(Gtk.VBox):
 
114
    def __init__(self, window):
 
115
    
 
116
        super(SingleDataSourceViewer, self).__init__()
 
117
 
 
118
        self.main_window = window
 
119
 
 
120
        self.spacing = 12
 
121
        self.margin = 12
 
122
        
 
123
        list_vbox = Gtk.VBox()
 
124
        self.pack_start(list_vbox, True, True, 12)
 
125
        
 
126
        self.grid = Gtk.Grid()
 
127
        self.grid.set_column_spacing (12)
 
128
        self.grid.set_row_spacing (12)
 
129
        self.grid.set_column_homogeneous(True)
 
130
        self.grid.set_row_homogeneous(False)
 
131
        list_vbox.pack_start(self.grid, False, False, 12)
 
132
        
 
133
        id_label = Gtk.Label(xalign=1,yalign=0.5)
 
134
        id_label.set_markup("<b>%s</b>" %("ID"))
 
135
        self.grid.attach(id_label,0, 0, 1, 1)
 
136
        self.id_value_label = Gtk.Label(xalign=0,yalign=0.5)
 
137
        self.grid.attach(self.id_value_label,1, 0, 6, 1)
 
138
        
 
139
        desc_label = Gtk.Label(xalign=1,yalign=0.5)
 
140
        desc_label.set_markup("<b>%s</b>" %("Description"))
 
141
        self.grid.attach(desc_label,0, 1, 1, 1)
 
142
        self.desc_value_label = Gtk.Label(xalign=0,yalign=0.5)
 
143
        self.grid.attach(self.desc_value_label,1, 1, 6, 1)
 
144
        
 
145
        enabled_label = Gtk.Label(xalign=1,yalign=0.5)
 
146
        enabled_label.set_markup("<b>%s</b>" %("Enabled"))
 
147
        self.grid.attach(enabled_label,0, 2, 1, 1)
 
148
        self.enabled_value_switch = Gtk.Switch()
 
149
        self.grid.attach(self.enabled_value_switch,1, 2, 1, 1)
 
150
 
 
151
    def set_values(self, single_ds):
 
152
        self.id_value_label.set_markup(single_ds[0])
 
153
        self.desc_value_label.set_markup(single_ds[2])
 
154
        self.enabled_value_switch.set_active(single_ds[-3])
 
155
 
 
156