~ubuntu-branches/debian/experimental/backintime/experimental

« back to all changes in this revision

Viewing changes to gnome/logviewdialog.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Wiltshire
  • Date: 2010-12-03 21:56:53 UTC
  • mfrom: (1.2.1 upstream) (3.1.8 sid)
  • Revision ID: james.westby@ubuntu.com-20101203215653-scx9roloq4m0dqns
Tags: 1.0.4-1
* New upstream release
    Closes: #555293
    LP: #409130 #507246 #528518 #534829 #522618
* Update debian/copyright
* The following patches are either integrated or fixed properly
  upstream: no-chmod-777.patch allow-root-backup.patch
* Refactor remaining patches and make the headers DEP-3 compliant
* Convert to source format 3.0 (quilt) and drop quilt dependency and
  logic
* Don't depend on a specific version of Python; let dh_python choose
  the best option
* Remove the "earlier-than" restriction for the Conflicts on
  backintime-kde4
* Standards version 3.9.1 (no changes required)
* Update my email address

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#    Back In Time
 
2
#    Copyright (C) 2008-2009 Oprea Dan
 
3
#
 
4
#    This program is free software; you can redistribute it and/or modify
 
5
#    it under the terms of the GNU General Public License as published by
 
6
#    the Free Software Foundation; either version 2 of the License, or
 
7
#    (at your option) any later version.
 
8
#
 
9
#    This program is distributed in the hope that it will be useful,
 
10
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
#    GNU General Public License for more details.
 
13
#
 
14
#    You should have received a copy of the GNU General Public License along
 
15
#    with this program; if not, write to the Free Software Foundation, Inc.,
 
16
#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
17
 
 
18
 
 
19
import os
 
20
import os.path
 
21
import sys
 
22
import copy
 
23
import pygtk
 
24
pygtk.require("2.0")
 
25
import gtk
 
26
import gobject
 
27
import datetime
 
28
import gettext
 
29
 
 
30
import config
 
31
import snapshots
 
32
import tools
 
33
 
 
34
 
 
35
_=gettext.gettext
 
36
 
 
37
 
 
38
class LogViewDialog(object):
 
39
        
 
40
        def __init__( self, parent, snapshot_id = None ):
 
41
                self.parent = parent
 
42
                self.config = parent.config
 
43
                self.snapshots = parent.snapshots
 
44
                self.profile_id = self.config.get_current_profile()
 
45
                self.snapshot_id = snapshot_id
 
46
                
 
47
                builder = gtk.Builder()
 
48
                self.builder = builder
 
49
                
 
50
                glade_file = os.path.join(self.config.get_app_path(), 'gnome', 'logviewdialog.glade')
 
51
                
 
52
                builder.add_from_file(glade_file)
 
53
                
 
54
                get = builder.get_object
 
55
                
 
56
                self.dialog = get('LogViewDialog')
 
57
                self.dialog.set_transient_for( parent.window )
 
58
 
 
59
                signals = { 
 
60
                                'on_combo_profiles_changed': self.on_combo_profiles_changed,
 
61
                                'on_combo_filter_changed': self.on_combo_filter_changed
 
62
                        }
 
63
                
 
64
                builder.connect_signals(signals)
 
65
 
 
66
                #log view
 
67
                self.txt_log_view = get( 'txt_log_view' )
 
68
                
 
69
                #profiles
 
70
                self.hbox_profiles = get( 'hbox_profiles' )
 
71
 
 
72
                self.store_profiles = gtk.ListStore( str, str )
 
73
                self.combo_profiles = get( 'combo_profiles' )
 
74
                
 
75
                text_renderer = gtk.CellRendererText()
 
76
                self.combo_profiles.pack_start( text_renderer, True )
 
77
                self.combo_profiles.add_attribute( text_renderer, 'text', 0 )
 
78
                
 
79
                self.combo_profiles.set_model( self.store_profiles )
 
80
        
 
81
                #filter
 
82
                self.store_filter = gtk.ListStore( str, int )
 
83
                self.combo_filter = get( 'combo_filter' )
 
84
                
 
85
                text_renderer = gtk.CellRendererText()
 
86
                self.combo_filter.pack_start( text_renderer, True )
 
87
                self.combo_filter.add_attribute( text_renderer, 'text', 0 )
 
88
                
 
89
                self.combo_filter.set_model( self.store_filter )
 
90
        
 
91
                self.store_filter.append( [ _('All'), 0 ] )
 
92
                select_iter = self.store_filter.append( [ _('Errors'), 1 ] )
 
93
                set_active = True
 
94
                if self.snapshot_id is None or self.snapshots.is_snapshot_failed( self.snapshot_id ):
 
95
                        self.combo_filter.set_active_iter( select_iter )
 
96
                        set_active = False
 
97
                select_iter = self.store_filter.append( [ _('Changes'), 2 ] )
 
98
                if not self.snapshot_id is None and set_active:
 
99
                        self.combo_filter.set_active_iter( select_iter )
 
100
                self.store_filter.append( [ _('Informations'), 3 ] )
 
101
                
 
102
                #update title
 
103
                if not snapshot_id is None:
 
104
                        self.hbox_profiles.hide()
 
105
                        self.dialog.set_title( "%s (%s)" % ( self.dialog.get_title(), self.snapshots.get_snapshot_display_name( self.snapshot_id ) ) )
 
106
                
 
107
                self.update_profiles()
 
108
        
 
109
        def on_combo_profiles_changed( self, *params ):
 
110
                iter = self.combo_profiles.get_active_iter()
 
111
                if iter is None:
 
112
                        return
 
113
                
 
114
                profile_id = self.store_profiles.get_value( iter, 1 )
 
115
                if profile_id != self.profile_id:
 
116
                        self.profile_id = profile_id
 
117
                
 
118
                self.update_log_view()
 
119
        
 
120
        def on_combo_filter_changed( self, *params ):
 
121
                self.update_log_view()
 
122
        
 
123
        def update_profiles( self ):
 
124
                profiles = self.config.get_profiles_sorted_by_name()
 
125
                
 
126
                select_iter = None
 
127
                self.store_profiles.clear()
 
128
 
 
129
                counter = 0
 
130
                for profile_id in profiles:
 
131
                        counter = counter + 1
 
132
                        iter = self.store_profiles.append( [ self.config.get_profile_name( profile_id ), profile_id ] )
 
133
                        if profile_id == self.profile_id:
 
134
                                select_iter = iter
 
135
                
 
136
                if not select_iter is None:
 
137
                        self.combo_profiles.set_active_iter( select_iter )
 
138
 
 
139
                if counter <= 1:
 
140
                        self.hbox_profiles.hide()
 
141
 
 
142
                self.update_log_view()
 
143
        
 
144
        def update_log_view( self ):
 
145
                mode = 0
 
146
                iter = self.combo_filter.get_active_iter()
 
147
                if not iter is None:
 
148
                        mode = self.store_filter.get_value( iter, 1 )
 
149
 
 
150
                if self.snapshot_id is None:
 
151
                        self.txt_log_view.get_buffer().set_text( self.snapshots.get_take_snapshot_log( mode, self.profile_id ) )
 
152
                else:
 
153
                        self.txt_log_view.get_buffer().set_text( self.snapshots.get_snapshot_log( self.snapshot_id, mode ) )
 
154
                
 
155
        def run( self ):
 
156
                self.dialog.run()
 
157
                self.dialog.destroy()
 
158
 
 
159