Subversion Repositories basico

Rev

Rev 176 | Rev 179 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 t00mlabs 1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
3
# File: window.py
4
# Author: Tomás Vírseda
5
# License: GPL v3
6
# Description: Gtk.ApplicationWindow implementation
7
 
8
import os
9
import stat
10
import time
11
import platform
12
 
13
import gi
14
gi.require_version('Gtk', '3.0')
138 t00mlabs 15
#~ gi.require_version('WebKit', '3.0')
4 t00mlabs 16
 
17
from gi.repository import GLib
18
from gi.repository import GObject
19
from gi.repository import Gtk
20
from gi.repository import Gdk
21
from gi.repository import Gio
22
from gi.repository import Pango
138 t00mlabs 23
#~ from gi.repository import WebKit
4 t00mlabs 24
from gi.repository.GdkPixbuf import Pixbuf
25
 
142 t00mlabs 26
from .widgets import Statusbar
133 t00mlabs 27
from .service import Service
4 t00mlabs 28
 
29
 
30
MONOSPACE_FONT = 'Lucida Console' if platform.system() == 'Windows' else 'monospace'
31
 
133 t00mlabs 32
class GtkAppWindow(Gtk.ApplicationWindow, Service):
4 t00mlabs 33
    def __init__(self, uiapp):
34
        self.setup_controller(uiapp)
35
        self.get_services()
142 t00mlabs 36
        self.log = self.controller.log
4 t00mlabs 37
        self.gui.add_widget('uiapp', uiapp)
38
        self.gui.set_key('cmbvalue', 'search')
39
        self.settings = {}
40
        self.settings['fullscreen'] = False
41
        self.current_notes = {}
42
 
43
        self.setup_window()
141 t00mlabs 44
        self.controller.debug("Window setup correctly")
4 t00mlabs 45
        self.setup_widgets()
141 t00mlabs 46
        self.controller.debug("Widgets setup correctly")
137 t00mlabs 47
        #~ self.setup_app()
4 t00mlabs 48
 
106 t00mlabs 49
 
4 t00mlabs 50
 
141 t00mlabs 51
 
4 t00mlabs 52
    def setup_controller(self, uiapp):
53
        self.uiapp = uiapp
54
        self.controller = uiapp.get_controller()
55
 
56
 
57
    def setup_window(self):
58
        app_title = self.controller.get_app_info('name')
59
        Gtk.Window.__init__(self, title=app_title, application=self.uiapp)
60
        self.gui.add_widget('mainwindow', self)
153 t00m 61
        icon = self.im.get_icon('basico', 48, 48)
4 t00mlabs 62
        self.set_icon(icon)
63
        # FIXME
64
        # From docs: Don’t use this function. It sets the X xlib.Window
65
        # System “class” and “name” hints for a window.
66
        # But I have to do it or it doesn't shows the right title. ???
67
        self.set_wmclass (app_title, app_title)
68
        self.set_role(app_title)
69
        self.set_default_size(1024, 728)
70
        self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
93 t00mlabs 71
 
72
        # HEADERBAR WIDGETS
73
        self.setup_headerbar()
4 t00mlabs 74
        self.show_all()
75
 
76
 
77 t00mlabs 77
    def setup_headerbar(self):
78
        #~# Header Bar
79
        hb = self.gui.add_widget("HeaderBar", Gtk.HeaderBar())
80
        hb.set_show_close_button(True)
81
        hb.props.title = "Basico"
79 t00mlabs 82
        hb.props.subtitle = "SAP Notes Manager for SAP Consultants"
77 t00mlabs 83
 
79 t00mlabs 84
        lhbox = Gtk.HBox() # Left side of title bar
85
        mhbox = Gtk.HBox() # Mid side of title bar
86
        rhbox = Gtk.HBox() # Right side of title bar
77 t00mlabs 87
 
79 t00mlabs 88
        # Left side titlebar
131 t00mlabs 89
        button = self.gui.add_widget('tgbShowMenuView', Gtk.ToggleButton())
141 t00mlabs 90
        #~ button.connect('toggled', self.workplace.show_menu_view)
91
        button.set_active(False)
131 t00mlabs 92
        icon = self.im.get_image_icon('gtk-select-color')
93
        button.add(icon)
94
        lhbox.pack_start(button, False, False, 3)
95
 
157 t00m 96
        menuviews = self.gui.add_widget('mnuBtnViews', Gtk.Button())
130 t00mlabs 97
        hbox = Gtk.HBox()
98
        label = self.gui.add_widget('lblViewCurrent', Gtk.Label())
141 t00mlabs 99
        label.set_xalign(0.0)
130 t00mlabs 100
        image = self.gui.add_widget('imgViewCurrent', Gtk.Image())
101
        hbox.pack_start(image, False, False, 3)
102
        hbox.pack_start(label, False, False, 3)
103
        menuviews.add(hbox)
104
        lhbox.pack_start(menuviews, False, False, 3)
105
 
81 t00mlabs 106
        imgtitlebar = self.gui.add_widget('imgtitlebar', Gtk.Image())
101 t00mlabs 107
        imgtitlebar.set_visible(False)
108
        imgtitlebar.set_no_show_all(True)
79 t00mlabs 109
        lbltitlebar = self.gui.add_widget("lbltitlebar", Gtk.Label())
141 t00mlabs 110
        lbltitlebar.set_xalign(0.0)
111
        lbltitlebar.set_justify(Gtk.Justification.LEFT)
130 t00mlabs 112
        lbltitlebar.set_visible(False)
113
        lbltitlebar.set_no_show_all(True)
81 t00mlabs 114
        lhbox.pack_start(imgtitlebar, False, False, 3)
115
        lhbox.pack_start(lbltitlebar, False, False, 3)
116
        lhbox.show_all()
79 t00mlabs 117
        hb.pack_start(lhbox)
77 t00mlabs 118
 
79 t00mlabs 119
        # Middle side titlebar
130 t00mlabs 120
        label = self.gui.add_widget('lblSelectedNotes', Gtk.Label())
121
        #~ label.set_markup('<b><small>0</small>/0 of <big>%d</big></b>' % self.db.get_total())
122
        button = self.gui.add_widget('mnuBtnActions', Gtk.MenuButton())
123
        button.set_relief(Gtk.ReliefStyle.NONE)
124
        button.set_no_show_all(False)
125
        button.set_visible(False)
126
        button.add(label)
127
        mhbox.pack_start(button, False, False, 0)
128
 
78 t00mlabs 129
        # Right side titlebar
153 t00m 130
        ## Import menu
130 t00mlabs 131
        btnactions = self.gui.add_widget('mnuBtnImport', Gtk.MenuButton())
132
        btnactions.set_always_show_image(True)
133
        btnactions.set_property("use-popover", True)
134
        btnactions.set_relief(Gtk.ReliefStyle.NONE)
135
        imgwpimport = Gtk.Image()
150 t00m 136
        icon = self.im.get_pixbuf_icon('menu-add-new', 24, 24)
130 t00mlabs 137
        imgwpimport.set_from_pixbuf(icon)
138
        btnactions.add(imgwpimport)
139
        #~ actions_menu = self.gui.get_widget('actions_menu')
140
        #~ btnactions.set_menu_model(actions_menu)
141
        rhbox.pack_start(btnactions, False, False, 0)
142
 
153 t00m 143
        ## System Menu
77 t00mlabs 144
        button = Gtk.Button()
122 t00mlabs 145
        #~ button.set_tooltip_markup('<big><b>About</b></big>')
155 t00m 146
        icon = self.im.get_pixbuf_icon('menu-system', 24, 24)
81 t00mlabs 147
        image = Gtk.Image()
148
        image.set_from_pixbuf(icon)
149
        button.set_image(image)
77 t00mlabs 150
        button.set_relief(Gtk.ReliefStyle.NONE)
122 t00mlabs 151
        popover = Gtk.Popover.new(button)
150 t00m 152
        self.gui.add_widget('popover-right-menu', popover)
122 t00mlabs 153
        button.connect('clicked', self.cb.show_popover_menu, popover)
154
        #~ button.connect('clicked', self.uiapp.cb_show_about)
77 t00mlabs 155
        rhbox.pack_end(button, False, False, 0)
79 t00mlabs 156
 
122 t00mlabs 157
        # Popover body
158
        box = Gtk.Box(spacing = 0, orientation="vertical")
159
 
153 t00m 160
        ### About
122 t00mlabs 161
        hbox = Gtk.Box(spacing = 0, orientation="horizontal")
162
        icon = self.im.get_pixbuf_icon('about', 24, 24)
163
        image = Gtk.Image()
164
        image.set_from_pixbuf(icon)
165
        label = Gtk.Label("About")
166
        hbox.pack_start(image, False, False, 3)
167
        hbox.pack_start(label, False, False, 3)
168
        button = Gtk.Button()
169
        button.add(hbox)
170
        button.set_relief(Gtk.ReliefStyle.NONE)
136 t00mlabs 171
        button.connect('clicked', self.cb.show_about)
122 t00mlabs 172
        box.pack_end(button, False, False, 0)
173
 
153 t00m 174
        ### Help
122 t00mlabs 175
        hbox = Gtk.Box(spacing = 0, orientation="horizontal")
153 t00m 176
        icon = self.im.get_pixbuf_icon('basico-help', 24, 24)
93 t00mlabs 177
        image = Gtk.Image()
178
        image.set_from_pixbuf(icon)
122 t00mlabs 179
        label = Gtk.Label("Help")
180
        hbox.pack_start(image, False, False, 3)
181
        hbox.pack_start(label, False, False, 3)
182
        button = Gtk.Button()
183
        button.add(hbox)
93 t00mlabs 184
        button.set_relief(Gtk.ReliefStyle.NONE)
185
        button.connect('clicked', self.cb.show_help)
122 t00mlabs 186
        box.pack_end(button, False, False, 0)
93 t00mlabs 187
 
153 t00m 188
        ### Log viewer
122 t00mlabs 189
        hbox = Gtk.Box(spacing = 0, orientation="horizontal")
153 t00m 190
        icon = self.im.get_pixbuf_icon('basico-logviewer', 24, 24)
191
        image = Gtk.Image()
192
        image.set_from_pixbuf(icon)
193
        label = Gtk.Label("Log viewer")
194
        hbox.pack_start(image, False, False, 3)
195
        hbox.pack_start(label, False, False, 3)
196
        button = Gtk.Button()
197
        button.add(hbox)
198
        button.set_relief(Gtk.ReliefStyle.NONE)
199
        button.connect('clicked', self.cb.show_log)
200
        box.pack_end(button, False, False, 0)
201
 
202
        ### Settings
203
        hbox = Gtk.Box(spacing = 0, orientation="horizontal")
155 t00m 204
        icon = self.im.get_pixbuf_icon('basico-settings', 24, 24)
81 t00mlabs 205
        image = Gtk.Image()
206
        image.set_from_pixbuf(icon)
122 t00mlabs 207
        label = Gtk.Label("Settings")
208
        hbox.pack_start(image, False, False, 3)
209
        hbox.pack_start(label, False, False, 3)
210
        button = Gtk.Button()
211
        button.add(hbox)
79 t00mlabs 212
        button.set_relief(Gtk.ReliefStyle.NONE)
122 t00mlabs 213
        button.connect('clicked', self.cb.show_settings)
130 t00mlabs 214
        box.pack_start(button, False, False, 0)
122 t00mlabs 215
        popover.add(box)
77 t00mlabs 216
        hb.pack_end(rhbox)
79 t00mlabs 217
        hb.set_custom_title(mhbox)
77 t00mlabs 218
        self.set_titlebar(hb)
219
        hb.show_all()
220
 
221
 
84 t00mlabs 222
 
110 t00mlabs 223
    def setup_popover_settings(self, widget):
224
        #Creating a popover
225
        popover = Gtk.Popover.new(widget)
226
        #~ popover.set_size_request(50,100)
227
 
228
        box = Gtk.Box(spacing = 10, orientation="vertical")
112 t00mlabs 229
        hboxfs = Gtk.Box(spacing = 10, orientation="horizontal")
230
        lblfs = Gtk.Label('Fullscreen')
231
        swFullScreen = self.gui.add_widget('fullscreen', Gtk.Switch())
232
        swFullScreen.connect('state-set', self.uif.fullscreen)
233
        hboxfs.pack_start(lblfs, True, True, 6)
234
        hboxfs.pack_start(swFullScreen, True, True, 6)
235
        hboxfs.set_homogeneous(True)
236
        box.add(hboxfs)
110 t00mlabs 237
        popover.add(box)
238
 
239
        return popover
240
 
241
 
4 t00mlabs 242
    def setup_menus(self):
106 t00mlabs 243
        pass
4 t00mlabs 244
 
74 t00mlabs 245
 
4 t00mlabs 246
    def show_home_page(self, *args):
247
        notebook = self.gui.get_widget('notebook')
248
        notebook.set_current_page(0)
249
 
74 t00mlabs 250
 
4 t00mlabs 251
    def show_settings_page(self, *args):
101 t00mlabs 252
        sapnoteview = self.gui.get_widget('viewmenu')
4 t00mlabs 253
        sapnoteview.set_view('settings')
83 t00mlabs 254
        notebook = self.gui.get_widget('mainbox')
255
        notebook.set_current_page(5)
4 t00mlabs 256
 
74 t00mlabs 257
 
258
    def show_stats_page(self, *args):
101 t00mlabs 259
        sapnoteview = self.gui.get_widget('viewmenu')
74 t00mlabs 260
        sapnoteview.set_view('stats')
261
        notebook = self.gui.get_widget('notebook')
262
        notebook.set_current_page(4)
263
 
264
 
4 t00mlabs 265
    def show_browser_page(self, *args):
266
        notebook = self.gui.get_widget('notebook')
267
        notebook.set_current_page(1)
268
 
269
 
74 t00mlabs 270
    def hide_props_window(self):
271
        hpnnotes = self.gui.get_widget('hpnNotesManager')
272
        boxprops = self.gui.get_widget('boxPropsWidget')
273
        size = hpnnotes.get_allocation()
4 t00mlabs 274
 
74 t00mlabs 275
        boxprops.set_no_show_all(True)
276
        boxprops.hide()
277
        hpnnotes.set_position(size.width)
4 t00mlabs 278
 
74 t00mlabs 279
 
280
    def show_props_window(self):
281
        hpnnotes = self.gui.get_widget('hpnNotesManager')
282
        boxprops = self.gui.get_widget('boxPropsWidget')
283
        size = hpnnotes.get_allocation()
284
 
285
        boxprops.set_no_show_all(False)
286
        boxprops.show_all()
287
        hpnnotes.show_all()
288
        hpnnotes.set_position(size.width/5*3)
289
 
290
 
291
    def switch_props_window(self, *args):
292
        tgbprops = self.gui.get_widget('tgbShowManage')
293
 
294
        if tgbprops.get_active():
295
            self.show_props_window()
296
        else:
297
            self.hide_props_window()
298
 
299
 
4 t00mlabs 300
    def setup_widgets(self):
137 t00mlabs 301
        # Mainbox
142 t00mlabs 302
        mainbox = self.gui.add_widget('mainbox', Gtk.VBox())
137 t00mlabs 303
        mainbox.set_hexpand(True)
304
        paned = self.gui.add_widget('paned', Gtk.HPaned())
178 t00m 305
        paned.set_property('margin-bottom', 6)
306
        paned.set_wide_handle(False)
164 t00m 307
        paned.set_position(300)
82 t00mlabs 308
 
137 t00mlabs 309
        # Paned
310
        ## Left view
166 t00m 311
        box = self.gui.add_widget('boxMenuView', Gtk.VBox())
312
        box.set_property('margin-left', 6)
313
        box.set_property('margin-right', 6)
176 t00m 314
        box.set_property('margin-bottom', 0)
137 t00mlabs 315
        box.set_hexpand(True)
166 t00m 316
 
317
        ### Toolbar
318
        toolbar = Gtk.Toolbar()
319
        toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
175 t00m 320
        # ~ toolbar.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("Gray"))
321
        toolbar.set_property('margin-bottom', 3)
166 t00m 322
        toolbar.set_hexpand(True)
175 t00m 323
        # ~ toolbar.set_property('margin-bottom', 6)
166 t00m 324
 
325
        #### Filter entry tool
326
        tool = Gtk.ToolItem.new()
327
 
328
        hbox = Gtk.HBox()
329
        viewfilter = self.gui.add_widget('viewfilter', Gtk.Entry())
178 t00m 330
        viewfilter.connect('activate', self.cb.filter_viewmenu)
175 t00m 331
 
332
        icon = self.im.get_pixbuf_icon('basico-refresh')
333
        viewfilter.set_icon_from_pixbuf(Gtk.EntryIconPosition.PRIMARY, icon)
334
        viewfilter.set_icon_sensitive(Gtk.EntryIconPosition.PRIMARY, True)
335
        viewfilter.set_icon_tooltip_markup (Gtk.EntryIconPosition.PRIMARY, "Refresh and collapse")
336
 
337
        icon = self.im.get_pixbuf_icon('basico-filter')
338
        viewfilter.set_icon_from_pixbuf(Gtk.EntryIconPosition.SECONDARY, icon)
339
        viewfilter.set_icon_sensitive(Gtk.EntryIconPosition.SECONDARY, True)
340
        viewfilter.set_icon_tooltip_markup (Gtk.EntryIconPosition.SECONDARY, "Click here to expand the tree")
341
        viewfilter.set_placeholder_text("Filter this view...")
342
 
343
        def on_icon_pressed(entry, icon_pos, event):
344
            if icon_pos == Gtk.EntryIconPosition.PRIMARY:
345
                viewmenu = self.gui.get_widget('viewmenu')
346
                viewmenu.refresh()
347
            elif icon_pos == Gtk.EntryIconPosition.SECONDARY:
348
                self.cb.expand_menuview()
349
 
350
        viewfilter.connect("icon-press", on_icon_pressed)
351
 
166 t00m 352
        hbox.pack_start(viewfilter, True, True, 0)
353
        tool.add(hbox)
354
        tool.set_expand(True)
355
        toolbar.insert(tool, -1)
356
 
357
        box.pack_start(toolbar, False, False, 0)
358
 
359
        #### View treeview
137 t00mlabs 360
        scr = Gtk.ScrolledWindow()
361
        scr.set_hexpand(True)
362
        scr.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
164 t00m 363
        scr.set_shadow_type(Gtk.ShadowType.IN)
137 t00mlabs 364
        vwp = Gtk.Viewport()
365
        vwp.set_hexpand(True)
366
        viewsbox = self.gui.add_widget('viewsbox', Gtk.Box())
367
        viewsbox.set_hexpand(True)
368
        vwp.add(viewsbox)
369
        scr.add(vwp)
166 t00m 370
        box.pack_start(scr, True, True, 0)
137 t00mlabs 371
        paned.add1(box)
82 t00mlabs 372
 
137 t00mlabs 373
        ## Right view
168 t00m 374
        box = self.gui.add_widget('boxVisor', Gtk.VBox())
137 t00mlabs 375
        box.set_hexpand(True)
168 t00m 376
 
377
        boxtoolbar = self.gui.add_widget('boxtoolbar', Gtk.HBox())
378
        box.pack_start(boxtoolbar, False, False, 0)
379
 
137 t00mlabs 380
        scr = self.gui.add_widget('scrVisor', Gtk.ScrolledWindow())
178 t00m 381
        # ~ scr.set_shadow_type(Gtk.ShadowType.IN)
137 t00mlabs 382
        scr.set_hexpand(True)
383
        scr.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
384
        vwp = Gtk.Viewport()
385
        vwp.set_hexpand(True)
386
        notesbox = self.gui.add_widget('notesbox', Gtk.Box())
387
        notesbox.set_hexpand(True)
168 t00m 388
        notesbox.set_vexpand(True)
137 t00mlabs 389
        vwp.add(notesbox)
390
        scr.add(vwp)
168 t00m 391
        box.pack_start(scr, True, True, 0)
137 t00mlabs 392
        paned.add2(box)
142 t00mlabs 393
        mainbox.pack_start(paned, True, True, 0)
82 t00mlabs 394
 
162 t00m 395
        # Statusbar
142 t00mlabs 396
        statusbar = self.gui.add_widget('statusbar', Statusbar(self.controller))
397
        mainbox.pack_start(statusbar, False, False, 0)
398
 
137 t00mlabs 399
        self.add(mainbox)
400
        self.show_all()
82 t00mlabs 401
 
141 t00mlabs 402
        # Finally, activate Workplace
403
        self.controller.get_service('Workplace')
82 t00mlabs 404
 
137 t00mlabs 405
 
406
 
74 t00mlabs 407
    def setup_props_window(self):
408
        imgtitle = self.gui.get_widget('imgPropsTitle')
409
        icon = self.im.get_icon('fingerprint', 48, 48)
410
        imgtitle.set_from_pixbuf (icon)
411
        model = Gtk.TreeStore(str, str)
412
        trvprops = self.gui.add_widget('trvprops', Gtk.TreeView())
413
        trvprops.set_model(model)
414
 
415
        # Property
416
        renderer = Gtk.CellRendererText()
417
        renderer.set_alignment(1.0, 0.5)
418
        column = Gtk.TreeViewColumn('Property', renderer, markup=0)
419
        column.set_visible(True)
420
        column.set_expand(False)
421
        column.set_clickable(True)
422
        column.set_sort_indicator(True)
423
        trvprops.append_column(column)
424
 
425
        # Value
426
        renderer = Gtk.CellRendererText()
427
        renderer.set_alignment(0.0, 0.5)
428
        column = Gtk.TreeViewColumn('Value', renderer, markup=1)
429
        column.set_visible(True)
430
        column.set_expand(True)
431
        column.set_clickable(True)
432
        column.set_sort_indicator(True)
433
        trvprops.append_column(column)
434
        trvprops.show_all()
435
 
436
        trvprops.set_headers_visible(True)
437
        trvprops.set_enable_search(True)
438
        trvprops.set_grid_lines(Gtk.TreeViewGridLines.NONE)
439
        trvprops.set_search_column(1)
440
        #~ trvprops.connect('row-activated', self.double_click)
441
        selection = trvprops.get_selection()
442
        selection.set_mode(Gtk.SelectionMode.SINGLE)
443
        #~ trvprops.set_search_entry(self.pname)
444
 
445
        container = self.gui.get_widget('boxProps')
446
        self.gui.swap_widget(container, trvprops)
447
 
448
    def set_notes_manager_pane_position(self, pane, rectangle):
133 t00mlabs 449
        #~ self.controller.debug(type(pane.get_allocation()))
74 t00mlabs 450
        position = rectangle.width/5*3
451
        pane.set_position(position)
133 t00mlabs 452
        self.debug("Pane position: %s" % position)
74 t00mlabs 453
 
454
 
4 t00mlabs 455
    def __completion_func(self, completion, key, iter):
456
        model = completion.get_model()
457
        text = model.get_value(iter, 0)
458
        if key.upper() in text.upper():
459
            return True
460
        return False
461
 
462
 
463
    def setup_combobox_completions(self, key):
464
        model = Gtk.ListStore(str)
465
        search = self.gui.get_widget("stySearchInfo")
466
        completion = Gtk.EntryCompletion()
467
        completion.set_model(model)
468
        completion.set_text_column(0)
469
        completion.set_match_func(self.__completion_func)
470
        search.set_completion(completion)
471
 
74 t00mlabs 472
        stats = self.db.get_stats()
4 t00mlabs 473
 
474
        try:
475
            items = list(stats[key])
476
            items.sort()
477
            for item in items:
478
                model.append([item])
479
        except:
480
            pass
481
 
482
 
483
    def cb_combobox_changed(self, combobox):
484
        model = combobox.get_model()
485
        treeiter = combobox.get_active_iter()
486
        key = model[treeiter][0]
487
        self.gui.set_key('cmbvalue', key)
488
        self.setup_combobox_completions(key)
489
 
490
 
74 t00mlabs 491
    def setup_combobox_search(self):
492
        combobox = self.gui.get_widget('cmbSearchInfo')
4 t00mlabs 493
        model = Gtk.TreeStore(str, str)
494
        combobox.set_model(model)
495
 
496
        ## key
497
        cell = Gtk.CellRendererText()
498
        cell.set_visible(False)
499
        combobox.pack_start(cell, True)
500
        combobox.add_attribute(cell, 'text', 0)
501
 
502
        ## value
503
        cell = Gtk.CellRendererText()
504
        cell.set_alignment(0.0, 0.5)
505
        combobox.pack_start(cell, expand=False)
506
        combobox.add_attribute(cell, 'markup', 1)
507
        combobox.connect('changed', self.cb_combobox_changed)
508
 
101 t00mlabs 509
        model.append(None, ['search', 'Search in all database'])
510
        model.append(None, ['project', 'Filter by project name'])
511
        model.append(None, ['task', 'Filter by task name'])
512
        model.append(None, ['component', 'Filter by component'])
513
        model.append(None, ['category', 'Filter by category'])
514
        model.append(None, ['type', 'Filter by type'])
515
        model.append(None, ['id', 'Filter by Id'])
516
        model.append(None, ['title', 'Filter by title'])
517
        model.append(None, ['priority', 'Filter by priority'])
518
        model.append(None, ['version', 'Filter by version'])
4 t00mlabs 519
        #~ model.append(None, ['released', 'Filter by release date'])
520
 
521
        combobox.set_active(0)
522
 
523
 
524
    def get_services(self):
525
        """Load services to be used in this class
526
        """
527
        self.gui = self.controller.get_service("GUI")
528
        self.app = self.gui.get_app()
74 t00mlabs 529
        self.db = self.controller.get_service("DB")
4 t00mlabs 530
        self.uif = self.controller.get_service("UIF")
531
        self.prefs = self.controller.get_service("Settings")
532
        self.im = self.controller.get_service('IM')
533
        self.cb = self.controller.get_service('Callbacks')
141 t00mlabs 534
        #~ self.workplace = self.controller.get_service('Workplace')
4 t00mlabs 535
 
536
 
537
    def swap_widget(self, container, combobox):
538
        """Shortcut to GUI.swap_widget method
539
        """
540
        self.gui.swap_widget(container, combobox)