def update_snapshots(self, current_snapshot_id, snapshots_list): self.edit_path.set_text(self.path) #fill snapshots self.store_snapshots.clear() path = self.snapshots.get_snapshot_path_to(current_snapshot_id, self.path) isdir = os.path.isdir(path) counter = 0 index_combo_diff_with = 0 #add now path = self.path if os.path.exists(path): if os.path.isdir(path) == isdir: self.store_snapshots.append([ gnomesnapshotstools.get_snapshot_display_markup( self.snapshots, '/'), '/' ]) if '/' == current_snapshot_id: indexComboDiffWith = counter counter += 1 #add snapshots for snapshot in snapshots_list: path = self.snapshots.get_snapshot_path_to(snapshot, self.path) if os.path.exists(path): if os.path.isdir(path) == isdir: self.store_snapshots.append([ gnomesnapshotstools.get_snapshot_display_markup( self.snapshots, snapshot), snapshot ]) if snapshot == current_snapshot_id: index_combo_diff_with = counter counter += 1 #select first item if len(self.store_snapshots) > 0: iter = self.store_snapshots.get_iter_first() if not iter is None: self.list_snapshots.get_selection().select_iter(iter) self.combo_diff_with.set_active(index_combo_diff_with) self.glade.get_widget('btn_diff_with').set_sensitive(True) self.combo_diff_with.set_sensitive(True) else: self.glade.get_widget('btn_diff_with').set_sensitive(False) self.combo_diff_with.set_sensitive(False) self.list_snapshots.grab_focus() self.update_toolbar()
def update_snapshots( self, current_snapshot_id, snapshots_list ): self.edit_path.set_text( self.path ) #fill snapshots self.store_snapshots.clear() path = self.snapshots.get_snapshot_path_to( current_snapshot_id, self.path ) isdir = os.path.isdir( path ) counter = 0 index_combo_diff_with = 0 #add now path = self.path if os.path.exists( path ): if os.path.isdir( path ) == isdir: self.store_snapshots.append( [ gnomesnapshotstools.get_snapshot_display_markup( self.snapshots, '/' ), '/' ] ) if '/' == current_snapshot_id: indexComboDiffWith = counter counter += 1 #add snapshots for snapshot in snapshots_list: path = self.snapshots.get_snapshot_path_to( snapshot, self.path ) if os.path.exists( path ): if os.path.isdir( path ) == isdir: self.store_snapshots.append( [ gnomesnapshotstools.get_snapshot_display_markup( self.snapshots, snapshot ), snapshot ] ) if snapshot == current_snapshot_id: index_combo_diff_with = counter counter += 1 #select first item if len( self.store_snapshots ) > 0: iter = self.store_snapshots.get_iter_first() if not iter is None: self.list_snapshots.get_selection().select_iter( iter ) self.combo_diff_with.set_active( index_combo_diff_with ) self.glade.get_widget( 'btn_diff_with' ).set_sensitive( True ) self.combo_diff_with.set_sensitive( True ) else: self.glade.get_widget( 'btn_diff_with' ).set_sensitive( False ) self.combo_diff_with.set_sensitive( False ) self.list_snapshots.grab_focus() self.update_toolbar()
def on_btn_snapshot_name_clicked( self, button ): iter = self.list_time_line.get_selection().get_selected()[1] if iter is None: return snapshot_id = self.store_time_line.get_value( iter, 1 ) if len( snapshot_id ) <= 1: return old_name = self.snapshots.get_snapshot_name( snapshot_id ) new_name = gnomemessagebox.text_input_dialog( self.window, self.glade, _('Snapshot Name'), old_name ) if new_name is None: return if old_name == new_name: return self.snapshots.set_snapshot_name( snapshot_id, new_name ) self.store_time_line.set_value( iter, 0, gnomesnapshotstools.get_snapshot_display_markup( self.snapshots, snapshot_id ) )
def on_btn_snapshot_name_clicked(self, button): iter = self.list_time_line.get_selection().get_selected()[1] if iter is None: return snapshot_id = self.store_time_line.get_value(iter, 1) if len(snapshot_id) <= 1: return old_name = self.snapshots.get_snapshot_name(snapshot_id) new_name = gnomemessagebox.text_input_dialog(self.window, self.glade, _('Snapshot Name'), old_name) if new_name is None: return if old_name == new_name: return self.snapshots.set_snapshot_name(snapshot_id, new_name) self.store_time_line.set_value( iter, 0, gnomesnapshotstools.get_snapshot_display_markup( self.snapshots, snapshot_id))
def fill_time_line( self, update_folder_view = True ): current_selection = '/' iter = self.list_time_line.get_selection().get_selected()[1] if not iter is None: current_selection = self.store_time_line.get_value( iter, 1 ) self.store_time_line.clear() self.store_time_line.append( [ gnomesnapshotstools.get_snapshot_display_markup( self.snapshots, '/' ), '/' ] ) self.snapshots_list = self.snapshots.get_snapshots_list() groups = [] now = datetime.date.today() #today date = now groups.append( (_('Today'), self.snapshots.get_snapshot_id( date ), []) ) #yesterday date = now - datetime.timedelta( days = 1 ) groups.append( (_('Yesterday'), self.snapshots.get_snapshot_id( date ), []) ) #this week date = now - datetime.timedelta( days = now.weekday() ) groups.append( (_('This week'), self.snapshots.get_snapshot_id( date ), []) ) #last week date = now - datetime.timedelta( days = now.weekday() + 7 ) groups.append( (_('Last week'), self.snapshots.get_snapshot_id( date ), []) ) #fill groups for snapshot_id in self.snapshots_list: found = False for group in groups: if snapshot_id >= group[1]: group[2].append( snapshot_id ) found = True break if not found: year = int( snapshot_id[ 0 : 4 ] ) month = int( snapshot_id[ 4 : 6 ] ) date = datetime.date( year, month, 1 ) group_name = '' if year == now.year: group_name = date.strftime( '%B' ).capitalize() else: group_name = date.strftime( '%B, %Y' ).capitalize() groups.append( ( group_name, self.snapshots.get_snapshot_id( date ), [ snapshot_id ]) ) #fill time_line list for group in groups: if len( group[2] ) > 0: self.store_time_line.append( [ "<b>%s</b>" % group[0], '' ] ); for snapshot_id in group[2]: self.store_time_line.append( [ gnomesnapshotstools.get_snapshot_display_markup( self.snapshots, snapshot_id ), snapshot_id ] ) #select previous item iter = self.store_time_line.get_iter_first() while not iter is None: if current_selection == self.store_time_line.get_value( iter, 1 ): break iter = self.store_time_line.iter_next( iter ) changed = False if iter is None: changed = True iter = self.store_time_line.get_iter_first() self.list_time_line.get_selection().select_iter( iter ) if changed and update_folder_view: self.update_folder_view( 2 )
def fill_time_line(self, update_folder_view=True): current_selection = '/' iter = self.list_time_line.get_selection().get_selected()[1] if not iter is None: current_selection = self.store_time_line.get_value(iter, 1) self.store_time_line.clear() self.store_time_line.append([ gnomesnapshotstools.get_snapshot_display_markup( self.snapshots, '/'), '/' ]) self.snapshots_list = self.snapshots.get_snapshots_list() groups = [] now = datetime.date.today() #today date = now groups.append((_('Today'), self.snapshots.get_snapshot_id(date), [])) #yesterday date = now - datetime.timedelta(days=1) groups.append( (_('Yesterday'), self.snapshots.get_snapshot_id(date), [])) #this week date = now - datetime.timedelta(days=now.weekday()) groups.append( (_('This week'), self.snapshots.get_snapshot_id(date), [])) #last week date = now - datetime.timedelta(days=now.weekday() + 7) groups.append( (_('Last week'), self.snapshots.get_snapshot_id(date), [])) #fill groups for snapshot_id in self.snapshots_list: found = False for group in groups: if snapshot_id >= group[1]: group[2].append(snapshot_id) found = True break if not found: year = int(snapshot_id[0:4]) month = int(snapshot_id[4:6]) date = datetime.date(year, month, 1) group_name = '' if year == now.year: group_name = date.strftime('%B').capitalize() else: group_name = date.strftime('%B, %Y').capitalize() groups.append( (group_name, self.snapshots.get_snapshot_id(date), [snapshot_id])) #fill time_line list for group in groups: if len(group[2]) > 0: self.store_time_line.append(["<b>%s</b>" % group[0], '']) for snapshot_id in group[2]: self.store_time_line.append([ gnomesnapshotstools.get_snapshot_display_markup( self.snapshots, snapshot_id), snapshot_id ]) #select previous item iter = self.store_time_line.get_iter_first() while not iter is None: if current_selection == self.store_time_line.get_value(iter, 1): break iter = self.store_time_line.iter_next(iter) changed = False if iter is None: changed = True iter = self.store_time_line.get_iter_first() self.list_time_line.get_selection().select_iter(iter) if changed and update_folder_view: self.update_folder_view(2)